Some more UI updates and fixes.
* Added UICreatureButton class for handling/replacing "battle buttons" (can now be used in other modules). * Added the ability to use items on creatures via the battle window. * Some minor cosmetics.
This commit is contained in:
parent
f93d79649f
commit
0763b266d5
|
@ -12,6 +12,7 @@ local skin = {
|
||||||
|
|
||||||
styles = {
|
styles = {
|
||||||
'buttons.otui',
|
'buttons.otui',
|
||||||
|
'creaturebuttons.otui',
|
||||||
'labels.otui',
|
'labels.otui',
|
||||||
'panels.otui',
|
'panels.otui',
|
||||||
'separators.otui',
|
'separators.otui',
|
||||||
|
|
|
@ -58,4 +58,4 @@ NextButton < BrowseButton
|
||||||
icon-source: /images/arrow_right.png
|
icon-source: /images/arrow_right.png
|
||||||
|
|
||||||
PreviousButton < BrowseButton
|
PreviousButton < BrowseButton
|
||||||
icon-source: /images/arrow_left.png
|
icon-source: /images/arrow_left.png
|
|
@ -0,0 +1,48 @@
|
||||||
|
CreatureButton < UICreatureButton
|
||||||
|
height: 20
|
||||||
|
margin-bottom: 5
|
||||||
|
|
||||||
|
UICreature
|
||||||
|
id: creature
|
||||||
|
size: 20 20
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.top: parent.top
|
||||||
|
phantom: true
|
||||||
|
|
||||||
|
UIWidget
|
||||||
|
id: spacer
|
||||||
|
width: 5
|
||||||
|
anchors.left: creature.right
|
||||||
|
anchors.top: creature.top
|
||||||
|
phantom: true
|
||||||
|
|
||||||
|
UIWidget
|
||||||
|
id: skull
|
||||||
|
height: 11
|
||||||
|
anchors.left: spacer.right
|
||||||
|
anchors.top: spacer.top
|
||||||
|
phantom: true
|
||||||
|
|
||||||
|
UIWidget
|
||||||
|
id: emblem
|
||||||
|
height: 11
|
||||||
|
anchors.left: skull.right
|
||||||
|
anchors.top: creature.top
|
||||||
|
phantom: true
|
||||||
|
|
||||||
|
Label
|
||||||
|
id: label
|
||||||
|
anchors.left: emblem.right
|
||||||
|
anchors.top: creature.top
|
||||||
|
color: #888888
|
||||||
|
margin-left: 2
|
||||||
|
phantom: true
|
||||||
|
|
||||||
|
ProgressBar
|
||||||
|
id: lifeBar
|
||||||
|
height: 5
|
||||||
|
anchors.left: spacer.right
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: label.bottom
|
||||||
|
margin-top: 2
|
||||||
|
phantom: true
|
|
@ -0,0 +1,140 @@
|
||||||
|
-- @docclass
|
||||||
|
UICreatureButton = extends(UIWidget)
|
||||||
|
|
||||||
|
local CreatureButtonColors = {
|
||||||
|
onIdle = {notHovered = '#888888', hovered = '#FFFFFF' },
|
||||||
|
onTargeted = {notHovered = '#FF0000', hovered = '#FF8888' },
|
||||||
|
onFollowed = {notHovered = '#00FF00', hovered = '#88FF88' }
|
||||||
|
}
|
||||||
|
|
||||||
|
local LifeBarColors = {} -- Must be sorted by percentAbove
|
||||||
|
table.insert(LifeBarColors, {percentAbove = 92, color = '#00BC00' } )
|
||||||
|
table.insert(LifeBarColors, {percentAbove = 60, color = '#50A150' } )
|
||||||
|
table.insert(LifeBarColors, {percentAbove = 30, color = '#A1A100' } )
|
||||||
|
table.insert(LifeBarColors, {percentAbove = 8, color = '#3C2727' } )
|
||||||
|
table.insert(LifeBarColors, {percentAbove = 3, color = '#3C0000' } )
|
||||||
|
table.insert(LifeBarColors, {percentAbove = -1, color = '#4F0000' } )
|
||||||
|
|
||||||
|
function UICreatureButton.create()
|
||||||
|
local button = UICreatureButton.internalCreate()
|
||||||
|
button:setFocusable(false)
|
||||||
|
button.creature = nil
|
||||||
|
button.isHovered = false
|
||||||
|
button.isTarget = false
|
||||||
|
button.isFollowed = false
|
||||||
|
return button
|
||||||
|
end
|
||||||
|
|
||||||
|
function UICreatureButton:getClassName()
|
||||||
|
return 'UICreatureButton'
|
||||||
|
end
|
||||||
|
|
||||||
|
function UICreatureButton:setCreature(creature)
|
||||||
|
self.creature = creature
|
||||||
|
end
|
||||||
|
|
||||||
|
function UICreatureButton:getCreature()
|
||||||
|
return self.creature
|
||||||
|
end
|
||||||
|
|
||||||
|
function UICreatureButton:getCreatureId()
|
||||||
|
return self.creature:getId()
|
||||||
|
end
|
||||||
|
|
||||||
|
function UICreatureButton:setup(creature)
|
||||||
|
self.creature = creature
|
||||||
|
|
||||||
|
local creatureWidget = self:getChildById('creature')
|
||||||
|
local labelWidget = self:getChildById('label')
|
||||||
|
local lifeBarWidget = self:getChildById('lifeBar')
|
||||||
|
|
||||||
|
labelWidget:setText(creature:getName())
|
||||||
|
creatureWidget:setCreature(creature)
|
||||||
|
|
||||||
|
self:setId('CreatureButton_' .. creature:getName():gsub('%s','_'))
|
||||||
|
self:setLifeBarPercent(creature:getHealthPercent())
|
||||||
|
|
||||||
|
self:updateSkull(creature:getSkull())
|
||||||
|
self:updateEmblem(creature:getEmblem())
|
||||||
|
end
|
||||||
|
|
||||||
|
function UICreatureButton:update()
|
||||||
|
local color = CreatureButtonColors.onIdle
|
||||||
|
if self.isTarget then
|
||||||
|
color = CreatureButtonColors.onTargeted
|
||||||
|
elseif self.isFollowed then
|
||||||
|
color = CreatureButtonColors.onFollowed
|
||||||
|
end
|
||||||
|
color = self.isHovered and color.hovered or color.notHovered
|
||||||
|
|
||||||
|
if self.isHovered or self.isTarget or self.isFollowed then
|
||||||
|
self.creature:showStaticSquare(color)
|
||||||
|
self:getChildById('creature'):setBorderWidth(1)
|
||||||
|
self:getChildById('creature'):setBorderColor(color)
|
||||||
|
self:getChildById('label'):setColor(color)
|
||||||
|
else
|
||||||
|
self.creature:hideStaticSquare()
|
||||||
|
self:getChildById('creature'):setBorderWidth(0)
|
||||||
|
self:getChildById('label'):setColor(color)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function UICreatureButton:updateSkull(skullId)
|
||||||
|
if not self.creature then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local skullId = skullId or self.creature:getSkull()
|
||||||
|
local skullWidget = self:getChildById('skull')
|
||||||
|
local labelWidget = self:getChildById('label')
|
||||||
|
|
||||||
|
if skullId ~= SkullNone then
|
||||||
|
skullWidget:setWidth(skullWidget:getHeight())
|
||||||
|
print(skullId)
|
||||||
|
local imagePath = getSkullImagePath(skullId)
|
||||||
|
skullWidget:setImageSource(imagePath)
|
||||||
|
labelWidget:setMarginLeft(5)
|
||||||
|
else
|
||||||
|
skullWidget:setWidth(0)
|
||||||
|
if self.creature:getEmblem() == EmblemNone then
|
||||||
|
labelWidget:setMarginLeft(2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function UICreatureButton:updateEmblem(emblemId)
|
||||||
|
if not self.creature then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local emblemId = emblemId or self.creature:getEmblem()
|
||||||
|
local emblemWidget = self:getChildById('emblem')
|
||||||
|
local labelWidget = self:getChildById('label')
|
||||||
|
|
||||||
|
if emblemId ~= EmblemNone then
|
||||||
|
emblemWidget:setWidth(emblemWidget:getHeight())
|
||||||
|
local imagePath = getEmblemImagePath(emblemId)
|
||||||
|
emblemWidget:setImageSource(imagePath)
|
||||||
|
emblemWidget:setMarginLeft(5)
|
||||||
|
labelWidget:setMarginLeft(5)
|
||||||
|
else
|
||||||
|
emblemWidget:setWidth(0)
|
||||||
|
emblemWidget:setMarginLeft(0)
|
||||||
|
if self.creature:getSkull() == SkullNone then
|
||||||
|
labelWidget:setMarginLeft(2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function UICreatureButton:setLifeBarPercent(percent)
|
||||||
|
local lifeBarWidget = self:getChildById('lifeBar')
|
||||||
|
lifeBarWidget:setPercent(percent)
|
||||||
|
|
||||||
|
local color
|
||||||
|
for i, v in pairs(LifeBarColors) do
|
||||||
|
if percent > v.percentAbove then
|
||||||
|
color = v.color
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
lifeBarWidget:setBackgroundColor(color)
|
||||||
|
end
|
|
@ -12,20 +12,6 @@ hideMonstersButton = nil
|
||||||
hideSkullsButton = nil
|
hideSkullsButton = nil
|
||||||
hidePartyButton = nil
|
hidePartyButton = nil
|
||||||
|
|
||||||
BattleButtonColors = {
|
|
||||||
onIdle = {notHovered = '#888888', hovered = '#FFFFFF' },
|
|
||||||
onTargeted = {notHovered = '#FF0000', hovered = '#FF8888' },
|
|
||||||
onFollowed = {notHovered = '#00FF00', hovered = '#88FF88' }
|
|
||||||
}
|
|
||||||
|
|
||||||
LifeBarColors = {} --Must be sorted by percentAbove
|
|
||||||
table.insert(LifeBarColors, {percentAbove = 92, color = '#00BC00' } )
|
|
||||||
table.insert(LifeBarColors, {percentAbove = 60, color = '#50A150' } )
|
|
||||||
table.insert(LifeBarColors, {percentAbove = 30, color = '#A1A100' } )
|
|
||||||
table.insert(LifeBarColors, {percentAbove = 8, color = '#3C2727' } )
|
|
||||||
table.insert(LifeBarColors, {percentAbove = 3, color = '#3C0000' } )
|
|
||||||
table.insert(LifeBarColors, {percentAbove = -1, color = '#4F0000' } )
|
|
||||||
|
|
||||||
function init()
|
function init()
|
||||||
g_ui.importStyle('battlebutton.otui')
|
g_ui.importStyle('battlebutton.otui')
|
||||||
battleButton = TopMenu.addRightGameToggleButton('battleButton', tr('Battle') .. ' (Ctrl+B)', 'battle.png', toggle)
|
battleButton = TopMenu.addRightGameToggleButton('battleButton', tr('Battle') .. ' (Ctrl+B)', 'battle.png', toggle)
|
||||||
|
@ -52,17 +38,20 @@ function init()
|
||||||
battleWindow:setContentMinimumHeight(80)
|
battleWindow:setContentMinimumHeight(80)
|
||||||
--battleWindow:setContentMaximumHeight(384)
|
--battleWindow:setContentMaximumHeight(384)
|
||||||
|
|
||||||
connect(Creature, { onSkullChange = checkCreatureSkull,
|
connect(Creature, {
|
||||||
onEmblemChange = checkCreatureEmblem,
|
onSkullChange = updateCreatureSkull,
|
||||||
onHealthPercentChange = onCreatureHealthPercentChange,
|
onEmblemChange = updateCreatureEmblem,
|
||||||
onPositionChange = onCreaturePositionChange,
|
onHealthPercentChange = onCreatureHealthPercentChange,
|
||||||
onAppear = onCreatureAppear,
|
onPositionChange = onCreaturePositionChange,
|
||||||
onDisappear = onCreatureDisappear
|
onAppear = onCreatureAppear,
|
||||||
} )
|
onDisappear = onCreatureDisappear
|
||||||
|
})
|
||||||
|
|
||||||
connect(g_game, { onAttackingCreatureChange = onAttack,
|
connect(g_game, {
|
||||||
onFollowingCreatureChange = onFollow,
|
onAttackingCreatureChange = onAttack,
|
||||||
onGameEnd = removeAllCreatures } )
|
onFollowingCreatureChange = onFollow,
|
||||||
|
onGameEnd = removeAllCreatures
|
||||||
|
})
|
||||||
|
|
||||||
checkCreatures()
|
checkCreatures()
|
||||||
battleWindow:setup()
|
battleWindow:setup()
|
||||||
|
@ -75,17 +64,20 @@ function terminate()
|
||||||
battleWindow:destroy()
|
battleWindow:destroy()
|
||||||
mouseWidget:destroy()
|
mouseWidget:destroy()
|
||||||
|
|
||||||
disconnect(Creature, { onSkullChange = checkCreatureSkull,
|
disconnect(Creature, {
|
||||||
onEmblemChange = checkCreatureEmblem,
|
onSkullChange = updateCreatureSkull,
|
||||||
onHealthPercentChange = onCreatureHealthPercentChange,
|
onEmblemChange = updateCreatureEmblem,
|
||||||
onPositionChange = onCreaturePositionChange,
|
onHealthPercentChange = onCreatureHealthPercentChange,
|
||||||
onAppear = onCreatureAppear,
|
onPositionChange = onCreaturePositionChange,
|
||||||
onDisappear = onCreatureDisappear
|
onAppear = onCreatureAppear,
|
||||||
} )
|
onDisappear = onCreatureDisappear
|
||||||
|
})
|
||||||
|
|
||||||
disconnect(g_game, { onAttackingCreatureChange = onAttack,
|
disconnect(g_game, {
|
||||||
onFollowingCreatureChange = onFollow,
|
onAttackingCreatureChange = onAttack,
|
||||||
onGameEnd = removeAllCreatures } )
|
onFollowingCreatureChange = onFollow,
|
||||||
|
onGameEnd = removeAllCreatures
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function toggle()
|
function toggle()
|
||||||
|
@ -158,7 +150,7 @@ end
|
||||||
function onCreatureHealthPercentChange(creature, health)
|
function onCreatureHealthPercentChange(creature, health)
|
||||||
local battleButton = battleButtonsByCreaturesList[creature:getId()]
|
local battleButton = battleButtonsByCreaturesList[creature:getId()]
|
||||||
if battleButton then
|
if battleButton then
|
||||||
setLifeBarPercent(battleButton, creature:getHealthPercent())
|
battleButton:setLifeBarPercent(creature:getHealthPercent())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -193,32 +185,16 @@ end
|
||||||
|
|
||||||
function addCreature(creature)
|
function addCreature(creature)
|
||||||
local creatureId = creature:getId()
|
local creatureId = creature:getId()
|
||||||
|
local battleButton = battleButtonsByCreaturesList[creatureId]
|
||||||
local battleButton = battleButtonsByCreaturesList[creature:getId()]
|
|
||||||
if not battleButton then
|
if not battleButton then
|
||||||
battleButton = g_ui.createWidget('BattleButton', battlePanel)
|
battleButton = g_ui.createWidget('BattleButton', battlePanel)
|
||||||
local creatureWidget = battleButton:getChildById('creature')
|
battleButton:setup(creature)
|
||||||
local labelWidget = battleButton:getChildById('label')
|
|
||||||
local lifeBarWidget = battleButton:getChildById('lifeBar')
|
|
||||||
battleButton.onHoverChange = onBattleButtonHoverChange
|
battleButton.onHoverChange = onBattleButtonHoverChange
|
||||||
battleButton.onMouseRelease = onMouseRelease
|
battleButton.onMouseRelease = onMouseRelease
|
||||||
|
|
||||||
battleButton:setId('BattleButton_' .. creature:getName():gsub('%s','_'))
|
|
||||||
battleButton.creatureId = creatureId
|
|
||||||
battleButton.creature = creature
|
|
||||||
battleButton.isHovered = false
|
|
||||||
battleButton.isTarget = false
|
|
||||||
battleButton.isFollowed = false
|
|
||||||
|
|
||||||
labelWidget:setText(creature:getName())
|
|
||||||
creatureWidget:setCreature(creature)
|
|
||||||
setLifeBarPercent(battleButton, creature:getHealthPercent())
|
|
||||||
|
|
||||||
battleButtonsByCreaturesList[creatureId] = battleButton
|
battleButtonsByCreaturesList[creatureId] = battleButton
|
||||||
|
|
||||||
checkCreatureSkull(battleButton.creature)
|
|
||||||
checkCreatureEmblem(battleButton.creature)
|
|
||||||
|
|
||||||
if creature == g_game.getAttackingCreature() then
|
if creature == g_game.getAttackingCreature() then
|
||||||
onAttack(creature)
|
onAttack(creature)
|
||||||
end
|
end
|
||||||
|
@ -227,52 +203,7 @@ function addCreature(creature)
|
||||||
onFollow(creature)
|
onFollow(creature)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
setLifeBarPercent(battleButton, creature:getHealthPercent())
|
battleButton:setLifeBarPercent(creature:getHealthPercent())
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function checkCreatureSkull(creature, skullId)
|
|
||||||
local battleButton = battleButtonsByCreaturesList[creature:getId()]
|
|
||||||
if battleButton then
|
|
||||||
local skullWidget = battleButton:getChildById('skull')
|
|
||||||
local labelWidget = battleButton:getChildById('label')
|
|
||||||
local creature = battleButton.creature
|
|
||||||
|
|
||||||
if creature:getSkull() ~= SkullNone then
|
|
||||||
skullWidget:setWidth(skullWidget:getHeight())
|
|
||||||
local imagePath = getSkullImagePath(creature:getSkull())
|
|
||||||
skullWidget:setImageSource(imagePath)
|
|
||||||
labelWidget:setMarginLeft(5)
|
|
||||||
else
|
|
||||||
skullWidget:setWidth(0)
|
|
||||||
if creature:getEmblem() == EmblemNone then
|
|
||||||
labelWidget:setMarginLeft(2)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function checkCreatureEmblem(creature, emblemId)
|
|
||||||
local battleButton = battleButtonsByCreaturesList[creature:getId()]
|
|
||||||
if battleButton then
|
|
||||||
local emblemId = emblemId or creature:getEmblem()
|
|
||||||
local emblemWidget = battleButton:getChildById('emblem')
|
|
||||||
local labelWidget = battleButton:getChildById('label')
|
|
||||||
local creature = battleButton.creature
|
|
||||||
|
|
||||||
if emblemId ~= EmblemNone then
|
|
||||||
emblemWidget:setWidth(emblemWidget:getHeight())
|
|
||||||
local imagePath = getEmblemImagePath(emblemId)
|
|
||||||
emblemWidget:setImageSource(imagePath)
|
|
||||||
emblemWidget:setMarginLeft(5)
|
|
||||||
labelWidget:setMarginLeft(5)
|
|
||||||
else
|
|
||||||
emblemWidget:setWidth(0)
|
|
||||||
emblemWidget:setMarginLeft(0)
|
|
||||||
if creature:getSkull() == SkullNone then
|
|
||||||
labelWidget:setMarginLeft(2)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -314,25 +245,10 @@ function removeCreature(creature)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function setLifeBarPercent(battleButton, percent)
|
|
||||||
local lifeBarWidget = battleButton:getChildById('lifeBar')
|
|
||||||
lifeBarWidget:setPercent(percent)
|
|
||||||
|
|
||||||
local color
|
|
||||||
for i, v in pairs(LifeBarColors) do
|
|
||||||
if percent > v.percentAbove then
|
|
||||||
color = v.color
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
lifeBarWidget:setBackgroundColor(color)
|
|
||||||
end
|
|
||||||
|
|
||||||
function onBattleButtonHoverChange(widget, hovered)
|
function onBattleButtonHoverChange(widget, hovered)
|
||||||
if widget.isBattleButton then
|
if widget.isBattleButton then
|
||||||
widget.isHovered = hovered
|
widget.isHovered = hovered
|
||||||
checkBattleButton(widget)
|
updateBattleButton(widget)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -340,7 +256,7 @@ function onAttack(creature)
|
||||||
local battleButton = creature and battleButtonsByCreaturesList[creature:getId()] or lastBattleButtonSwitched
|
local battleButton = creature and battleButtonsByCreaturesList[creature:getId()] or lastBattleButtonSwitched
|
||||||
if battleButton then
|
if battleButton then
|
||||||
battleButton.isTarget = creature and true or false
|
battleButton.isTarget = creature and true or false
|
||||||
checkBattleButton(battleButton)
|
updateBattleButton(battleButton)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -348,37 +264,32 @@ function onFollow(creature)
|
||||||
local battleButton = creature and battleButtonsByCreaturesList[creature:getId()] or lastBattleButtonSwitched
|
local battleButton = creature and battleButtonsByCreaturesList[creature:getId()] or lastBattleButtonSwitched
|
||||||
if battleButton then
|
if battleButton then
|
||||||
battleButton.isFollowed = creature and true or false
|
battleButton.isFollowed = creature and true or false
|
||||||
checkBattleButton(battleButton)
|
updateBattleButton(battleButton)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function checkBattleButton(battleButton)
|
function updateCreatureSkull(creature, skullId)
|
||||||
local color = BattleButtonColors.onIdle
|
local battleButton = battleButtonsByCreaturesList[creature:getId()]
|
||||||
if battleButton.isTarget then
|
if battleButton then
|
||||||
color = BattleButtonColors.onTargeted
|
battleButton:updateSkull(skullId)
|
||||||
elseif battleButton.isFollowed then
|
|
||||||
color = BattleButtonColors.onFollowed
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
color = battleButton.isHovered and color.hovered or color.notHovered
|
function updateCreatureEmblem(creature, emblemId)
|
||||||
|
local battleButton = battleButtonsByCreaturesList[creature:getId()]
|
||||||
if battleButton.isHovered or battleButton.isTarget or battleButton.isFollowed then
|
if battleButton then
|
||||||
battleButton.creature:showStaticSquare(color)
|
battleButton:updateSkull(emblemId)
|
||||||
battleButton:getChildById('creature'):setBorderWidth(1)
|
|
||||||
battleButton:getChildById('creature'):setBorderColor(color)
|
|
||||||
battleButton:getChildById('label'):setColor(color)
|
|
||||||
else
|
|
||||||
battleButton.creature:hideStaticSquare()
|
|
||||||
battleButton:getChildById('creature'):setBorderWidth(0)
|
|
||||||
battleButton:getChildById('label'):setColor(color)
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function updateBattleButton(battleButton)
|
||||||
|
battleButton:update()
|
||||||
if battleButton.isTarget or battleButton.isFollowed then
|
if battleButton.isTarget or battleButton.isFollowed then
|
||||||
-- set new last battle button switched
|
-- set new last battle button switched
|
||||||
if lastBattleButtonSwitched and lastBattleButtonSwitched ~= battleButton then
|
if lastBattleButtonSwitched and lastBattleButtonSwitched ~= battleButton then
|
||||||
lastBattleButtonSwitched.isTarget = false
|
lastBattleButtonSwitched.isTarget = false
|
||||||
lastBattleButtonSwitched.isFollowed = false
|
lastBattleButtonSwitched.isFollowed = false
|
||||||
checkBattleButton(lastBattleButtonSwitched)
|
updateBattleButton(lastBattleButtonSwitched)
|
||||||
end
|
end
|
||||||
lastBattleButtonSwitched = battleButton
|
lastBattleButtonSwitched = battleButton
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,49 +1,2 @@
|
||||||
BattleButton < UIButton
|
BattleButton < CreatureButton
|
||||||
height: 20
|
&isBattleButton: true
|
||||||
margin-bottom: 5
|
|
||||||
&isBattleButton: true
|
|
||||||
|
|
||||||
UICreature
|
|
||||||
id: creature
|
|
||||||
size: 20 20
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.top: parent.top
|
|
||||||
phantom: true
|
|
||||||
|
|
||||||
UIWidget
|
|
||||||
id: spacer
|
|
||||||
width: 5
|
|
||||||
anchors.left: creature.right
|
|
||||||
anchors.top: creature.top
|
|
||||||
phantom: true
|
|
||||||
|
|
||||||
UIWidget
|
|
||||||
id: skull
|
|
||||||
height: 11
|
|
||||||
anchors.left: spacer.right
|
|
||||||
anchors.top: spacer.top
|
|
||||||
phantom: true
|
|
||||||
|
|
||||||
UIWidget
|
|
||||||
id: emblem
|
|
||||||
height: 11
|
|
||||||
anchors.left: skull.right
|
|
||||||
anchors.top: creature.top
|
|
||||||
phantom: true
|
|
||||||
|
|
||||||
Label
|
|
||||||
id: label
|
|
||||||
anchors.left: emblem.right
|
|
||||||
anchors.top: creature.top
|
|
||||||
color: #888888
|
|
||||||
margin-left: 2
|
|
||||||
phantom: true
|
|
||||||
|
|
||||||
ProgressBar
|
|
||||||
id: lifeBar
|
|
||||||
height: 5
|
|
||||||
anchors.left: spacer.right
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.top: label.bottom
|
|
||||||
margin-top: 2
|
|
||||||
phantom: true
|
|
|
@ -182,6 +182,11 @@ function onUseWith(clickedWidget, mousePosition)
|
||||||
end
|
end
|
||||||
elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
|
elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
|
||||||
g_game.useWith(selectedThing, clickedWidget:getItem())
|
g_game.useWith(selectedThing, clickedWidget:getItem())
|
||||||
|
elseif clickedWidget:getClassName() == 'UICreatureButton' then
|
||||||
|
local creature = clickedWidget:getCreature()
|
||||||
|
if creature then
|
||||||
|
g_game.useWith(selectedThing, creature)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -154,6 +154,11 @@ local function clearFilters()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function clearFee()
|
||||||
|
feeLabel:setText('')
|
||||||
|
fee = 0
|
||||||
|
end
|
||||||
|
|
||||||
local function refreshTypeList()
|
local function refreshTypeList()
|
||||||
offerTypeList:clearOptions()
|
offerTypeList:clearOptions()
|
||||||
offerTypeList:addOption('Buy')
|
offerTypeList:addOption('Buy')
|
||||||
|
@ -165,11 +170,6 @@ local function refreshTypeList()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function refreshFee()
|
|
||||||
feeLabel:setText('')
|
|
||||||
fee = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
local function addOffer(offer, type)
|
local function addOffer(offer, type)
|
||||||
if not offer then
|
if not offer then
|
||||||
return false
|
return false
|
||||||
|
@ -841,7 +841,7 @@ function Market.resetCreateOffer()
|
||||||
totalPriceEdit:setValue(1)
|
totalPriceEdit:setValue(1)
|
||||||
amountEdit:setValue(1)
|
amountEdit:setValue(1)
|
||||||
refreshTypeList()
|
refreshTypeList()
|
||||||
refreshFee()
|
clearFee()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Market.refreshItemsWidget(selectItem)
|
function Market.refreshItemsWidget(selectItem)
|
||||||
|
|
|
@ -64,14 +64,14 @@ TexturePtr TextureManager::getTexture(const std::string& fileName)
|
||||||
try {
|
try {
|
||||||
// currently only png textures are supported
|
// currently only png textures are supported
|
||||||
if(!stdext::ends_with(filePath, ".png"))
|
if(!stdext::ends_with(filePath, ".png"))
|
||||||
stdext::throw_exception("texture file format no supported");
|
stdext::throw_exception("texture file format not supported");
|
||||||
|
|
||||||
// load texture file data
|
// load texture file data
|
||||||
std::stringstream fin;
|
std::stringstream fin;
|
||||||
g_resources.loadFile(filePath, fin);
|
g_resources.loadFile(filePath, fin);
|
||||||
texture = loadPNG(fin);
|
texture = loadPNG(fin);
|
||||||
} catch(stdext::exception& e) {
|
} catch(stdext::exception& e) {
|
||||||
g_logger.error(stdext::format("unable to load texture '%s': %s", fileName, e.what()));
|
g_logger.error(stdext::format("Unable to load texture '%s': %s", fileName, e.what()));
|
||||||
texture = g_textures.getEmptyTexture();
|
texture = g_textures.getEmptyTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue