2012-07-24 07:30:08 +02:00
|
|
|
battleWindow = nil
|
|
|
|
battleButton = nil
|
|
|
|
battlePanel = nil
|
|
|
|
lastBattleButtonSwitched = nil
|
|
|
|
battleButtonsByCreaturesList = {}
|
2012-02-09 06:27:29 +01:00
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
mouseWidget = nil
|
2012-02-09 06:27:29 +01:00
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
hidePlayersButton = nil
|
|
|
|
hideNPCsButton = nil
|
|
|
|
hideMonstersButton = nil
|
|
|
|
hideSkullsButton = nil
|
|
|
|
hidePartyButton = nil
|
2012-02-09 06:27:29 +01:00
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
BattleButtonColors = {
|
2012-02-09 06:27:29 +01:00
|
|
|
onIdle = {notHovered = '#888888', hovered = '#FFFFFF' },
|
|
|
|
onTargeted = {notHovered = '#FF0000', hovered = '#FF8888' },
|
|
|
|
onFollowed = {notHovered = '#00FF00', hovered = '#88FF88' }
|
|
|
|
}
|
|
|
|
|
2012-08-06 22:19:32 +02:00
|
|
|
LifeBarColors = {} --Must be sorted by percentAbove
|
2012-07-24 07:30:08 +02:00
|
|
|
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()
|
2012-07-26 11:12:20 +02:00
|
|
|
g_ui.importStyle('battlebutton.otui')
|
2012-07-24 07:30:08 +02:00
|
|
|
battleWindow = g_ui.loadUI('battle.otui', modules.game_interface.getRightPanel())
|
|
|
|
battleButton = TopMenu.addRightGameToggleButton('battleButton', tr('Battle') .. ' (Ctrl+B)', 'battle.png', toggle)
|
2012-03-28 16:10:21 +02:00
|
|
|
battleButton:setOn(true)
|
2012-07-24 07:30:08 +02:00
|
|
|
g_keyboard.bindKeyDown('Ctrl+B', toggle)
|
2012-02-20 03:27:08 +01:00
|
|
|
|
2012-08-18 07:04:01 +02:00
|
|
|
-- this disables scrollbar auto hiding
|
|
|
|
local scrollbar = battleWindow:getChildById('miniwindowScrollBar')
|
|
|
|
scrollbar:mergeStyle({ ['$!on'] = { }})
|
|
|
|
|
2012-03-28 16:10:21 +02:00
|
|
|
battlePanel = battleWindow:recursiveGetChildById('battlePanel')
|
2012-02-20 03:27:08 +01:00
|
|
|
|
2012-03-28 16:10:21 +02:00
|
|
|
hidePlayersButton = battleWindow:recursiveGetChildById('hidePlayers')
|
|
|
|
hideNPCsButton = battleWindow:recursiveGetChildById('hideNPCs')
|
|
|
|
hideMonstersButton = battleWindow:recursiveGetChildById('hideMonsters')
|
|
|
|
hideSkullsButton = battleWindow:recursiveGetChildById('hideSkulls')
|
|
|
|
hidePartyButton = battleWindow:recursiveGetChildById('hideParty')
|
2012-02-20 03:27:08 +01:00
|
|
|
|
2012-06-26 00:13:30 +02:00
|
|
|
mouseWidget = g_ui.createWidget('UIButton')
|
2012-02-09 06:27:29 +01:00
|
|
|
mouseWidget:setVisible(false)
|
2012-02-20 03:27:08 +01:00
|
|
|
mouseWidget:setFocusable(false)
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
connect(Creature, { onSkullChange = checkCreatureSkull,
|
2012-08-03 07:05:09 +02:00
|
|
|
onEmblemChange = checkCreatureEmblem,
|
2012-08-08 21:17:16 +02:00
|
|
|
onHealthPercentChange = onCreatureHealthPercentChange,
|
|
|
|
onPositionChange = onCreaturePositionChange,
|
|
|
|
onAppear = onCreatureAppear,
|
|
|
|
onDisappear = onCreatureDisappear
|
2012-08-03 07:05:09 +02:00
|
|
|
} )
|
2012-02-20 03:27:08 +01:00
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
connect(g_game, { onAttackingCreatureChange = onAttack,
|
|
|
|
onFollowingCreatureChange = onFollow,
|
|
|
|
onGameEnd = removeAllCreatures } )
|
2012-02-20 03:27:08 +01:00
|
|
|
|
2012-08-08 21:17:16 +02:00
|
|
|
checkCreatures()
|
2012-02-09 06:27:29 +01:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function terminate()
|
2012-06-26 00:13:30 +02:00
|
|
|
g_keyboard.unbindKeyDown('Ctrl+B')
|
2012-02-09 06:27:29 +01:00
|
|
|
battleButtonsByCreaturesList = {}
|
|
|
|
battleButton:destroy()
|
|
|
|
battleWindow:destroy()
|
2012-04-27 06:54:14 +02:00
|
|
|
mouseWidget:destroy()
|
2012-02-20 03:27:08 +01:00
|
|
|
|
2012-08-03 07:05:09 +02:00
|
|
|
disconnect(Creature, { onSkullChange = checkCreatureSkull,
|
|
|
|
onEmblemChange = checkCreatureEmblem,
|
2012-08-08 21:17:16 +02:00
|
|
|
onHealthPercentChange = onCreatureHealthPercentChange,
|
|
|
|
onPositionChange = onCreaturePositionChange,
|
|
|
|
onAppear = onCreatureAppear,
|
|
|
|
onDisappear = onCreatureDisappear
|
|
|
|
} )
|
2012-04-27 06:54:14 +02:00
|
|
|
|
2012-08-03 07:05:09 +02:00
|
|
|
disconnect(g_game, { onAttackingCreatureChange = onAttack,
|
|
|
|
onFollowingCreatureChange = onFollow,
|
|
|
|
onGameEnd = removeAllCreatures } )
|
2012-02-09 06:27:29 +01:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function toggle()
|
2012-06-21 21:31:22 +02:00
|
|
|
if battleButton:isOn() then
|
|
|
|
battleWindow:close()
|
|
|
|
battleButton:setOn(false)
|
|
|
|
else
|
|
|
|
battleWindow:open()
|
|
|
|
battleButton:setOn(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function onMiniWindowClose()
|
2012-06-21 21:31:22 +02:00
|
|
|
battleButton:setOn(false)
|
2012-02-09 06:27:29 +01:00
|
|
|
end
|
|
|
|
|
2012-08-03 07:05:09 +02:00
|
|
|
function checkCreatures()
|
|
|
|
removeAllCreatures()
|
|
|
|
|
2012-02-20 03:27:08 +01:00
|
|
|
local spectators = {}
|
2012-08-03 07:05:09 +02:00
|
|
|
local player = g_game.getLocalPlayer()
|
|
|
|
if g_game.isOnline() then
|
|
|
|
creatures = g_map.getSpectators(player:getPosition(), false)
|
|
|
|
for i, creature in ipairs(creatures) do
|
|
|
|
if creature ~= player and doCreatureFitFilters(creature) then
|
|
|
|
table.insert(spectators, creature)
|
|
|
|
end
|
2012-03-28 16:10:21 +02:00
|
|
|
end
|
2012-08-03 07:05:09 +02:00
|
|
|
end
|
2012-02-20 03:27:08 +01:00
|
|
|
|
2012-02-09 06:27:29 +01:00
|
|
|
for i, v in pairs(spectators) do
|
2012-07-24 07:30:08 +02:00
|
|
|
addCreature(v)
|
2012-02-09 06:27:29 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function doCreatureFitFilters(creature)
|
2012-08-03 07:05:09 +02:00
|
|
|
local localPlayer = g_game.getLocalPlayer()
|
|
|
|
if creature == localPlayer then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
local pos = creature:getPosition()
|
|
|
|
if not pos then return false end
|
|
|
|
|
|
|
|
if pos.z ~= localPlayer:getPosition().z or not localPlayer:hasSight(pos) then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2012-02-09 06:27:29 +01:00
|
|
|
local hidePlayers = hidePlayersButton:isChecked()
|
|
|
|
local hideNPCs = hideNPCsButton:isChecked()
|
|
|
|
local hideMonsters = hideMonstersButton:isChecked()
|
|
|
|
local hideSkulls = hideSkullsButton:isChecked()
|
|
|
|
local hideParty = hidePartyButton:isChecked()
|
2012-02-20 03:27:08 +01:00
|
|
|
|
2012-07-29 05:34:40 +02:00
|
|
|
if hidePlayers and creature:isPlayer() then
|
2012-02-09 06:27:29 +01:00
|
|
|
return false
|
2012-07-29 05:34:40 +02:00
|
|
|
elseif hideNPCs and creature:isNpc() then
|
2012-02-09 06:27:29 +01:00
|
|
|
return false
|
2012-07-29 05:34:40 +02:00
|
|
|
elseif hideMonsters and creature:isMonster() then
|
2012-02-09 06:27:29 +01:00
|
|
|
return false
|
2012-07-29 05:34:40 +02:00
|
|
|
elseif hideSkulls and creature:isPlayer() and creature:getSkull() == SkullNone then
|
2012-02-09 06:27:29 +01:00
|
|
|
return false
|
|
|
|
elseif hideParty and creature:getShield() > ShieldWhiteBlue then
|
|
|
|
return false
|
|
|
|
end
|
2012-02-20 03:27:08 +01:00
|
|
|
|
2012-02-09 06:27:29 +01:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2012-08-08 21:17:16 +02:00
|
|
|
function onCreatureHealthPercentChange(creature, health)
|
|
|
|
local battleButton = battleButtonsByCreaturesList[creature:getId()]
|
|
|
|
if battleButton then
|
|
|
|
setLifeBarPercent(battleButton, creature:getHealthPercent())
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-08-03 07:05:09 +02:00
|
|
|
function onCreaturePositionChange(creature, newPos, oldPos)
|
|
|
|
if creature:isLocalPlayer() then
|
|
|
|
checkCreatures()
|
|
|
|
else
|
|
|
|
local has = hasCreature(creature)
|
|
|
|
local fit = doCreatureFitFilters(creature)
|
|
|
|
if has and not fit then
|
|
|
|
removeCreature(creature)
|
|
|
|
elseif not has and fit then
|
|
|
|
addCreature(creature)
|
2012-02-09 06:27:29 +01:00
|
|
|
end
|
|
|
|
end
|
2012-08-03 07:05:09 +02:00
|
|
|
end
|
|
|
|
|
2012-08-08 21:17:16 +02:00
|
|
|
function onCreatureAppear(creature)
|
|
|
|
local player = g_game.getLocalPlayer()
|
2012-08-08 21:49:02 +02:00
|
|
|
if creature ~= player and creature:getPosition().z == player:getPosition().z and doCreatureFitFilters(creature) then
|
2012-08-08 21:17:16 +02:00
|
|
|
addCreature(creature)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function onCreatureDisappear(creature)
|
|
|
|
removeCreature(creature)
|
|
|
|
end
|
|
|
|
|
2012-08-03 07:05:09 +02:00
|
|
|
function hasCreature(creature)
|
|
|
|
return battleButtonsByCreaturesList[creature:getId()] ~= nil
|
2012-02-09 06:27:29 +01:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function addCreature(creature)
|
2012-02-09 06:27:29 +01:00
|
|
|
local creatureId = creature:getId()
|
2012-02-20 03:27:08 +01:00
|
|
|
|
2012-08-03 07:05:09 +02:00
|
|
|
local battleButton = battleButtonsByCreaturesList[creature:getId()]
|
|
|
|
if not battleButton then
|
|
|
|
battleButton = g_ui.createWidget('BattleButton', battlePanel)
|
2012-02-09 06:27:29 +01:00
|
|
|
local creatureWidget = battleButton:getChildById('creature')
|
|
|
|
local labelWidget = battleButton:getChildById('label')
|
|
|
|
local lifeBarWidget = battleButton:getChildById('lifeBar')
|
2012-07-26 11:12:20 +02:00
|
|
|
battleButton.onHoverChange = onbattleButtonHoverChange
|
|
|
|
battleButton.onMouseRelease = onMouseRelease
|
2012-02-20 03:27:08 +01:00
|
|
|
|
2012-02-09 06:27:29 +01:00
|
|
|
battleButton:setId('BattleButton_' .. creature:getName():gsub('%s','_'))
|
|
|
|
battleButton.creatureId = creatureId
|
|
|
|
battleButton.creature = creature
|
|
|
|
battleButton.isHovered = false
|
2012-08-03 07:58:48 +02:00
|
|
|
battleButton.isTarget = false
|
|
|
|
battleButton.isFollowed = false
|
2012-02-20 03:27:08 +01:00
|
|
|
|
2012-02-09 06:27:29 +01:00
|
|
|
labelWidget:setText(creature:getName())
|
2012-02-20 03:27:08 +01:00
|
|
|
creatureWidget:setCreature(creature)
|
2012-07-24 07:30:08 +02:00
|
|
|
setLifeBarPercent(battleButton, creature:getHealthPercent())
|
2012-02-09 06:27:29 +01:00
|
|
|
|
|
|
|
battleButtonsByCreaturesList[creatureId] = battleButton
|
2012-02-20 03:27:08 +01:00
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
checkCreatureSkull(battleButton.creature)
|
|
|
|
checkCreatureEmblem(battleButton.creature)
|
2012-08-03 07:58:48 +02:00
|
|
|
|
|
|
|
if creature == g_game.getAttackingCreature() then
|
|
|
|
onAttack(creature)
|
|
|
|
end
|
|
|
|
|
|
|
|
if creature == g_game.getFollowingCreature() then
|
|
|
|
onFollow(creature)
|
|
|
|
end
|
2012-08-03 07:05:09 +02:00
|
|
|
else
|
|
|
|
setLifeBarPercent(battleButton, creature:getHealthPercent())
|
2012-02-09 06:27:29 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function checkCreatureSkull(creature, skullId)
|
2012-08-08 21:17:16 +02:00
|
|
|
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)
|
2012-02-09 06:27:29 +01:00
|
|
|
end
|
|
|
|
end
|
2012-08-08 21:17:16 +02:00
|
|
|
end
|
2012-02-09 06:27:29 +01:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function checkCreatureEmblem(creature, emblemId)
|
2012-08-08 21:17:16 +02:00
|
|
|
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)
|
2012-02-09 06:27:29 +01:00
|
|
|
end
|
|
|
|
end
|
2012-08-08 21:17:16 +02:00
|
|
|
end
|
2012-02-09 06:27:29 +01:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function onMouseRelease(self, mousePosition, mouseButton)
|
2012-02-09 06:27:29 +01:00
|
|
|
if mouseButton == MouseRightButton then
|
2012-07-24 07:30:08 +02:00
|
|
|
modules.game_interface.createThingMenu(mousePosition, nil, nil, self.creature)
|
2012-02-09 08:26:52 +01:00
|
|
|
return true
|
|
|
|
elseif mouseButton == MouseLeftButton then
|
2012-06-26 00:13:30 +02:00
|
|
|
if g_keyboard.isShiftPressed() then
|
2012-02-09 08:26:52 +01:00
|
|
|
g_game.look(self.creature)
|
|
|
|
else
|
|
|
|
if self.isTarget then
|
|
|
|
g_game.cancelAttack()
|
|
|
|
else
|
|
|
|
g_game.attack(self.creature)
|
2012-02-09 06:27:29 +01:00
|
|
|
end
|
|
|
|
end
|
2012-02-09 08:26:52 +01:00
|
|
|
return true
|
2012-02-09 06:27:29 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function removeAllCreatures()
|
2012-03-30 06:10:55 +02:00
|
|
|
for i, v in pairs(battleButtonsByCreaturesList) do
|
2012-07-24 07:30:08 +02:00
|
|
|
removeCreature(v.creature)
|
2012-03-30 06:10:55 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function removeCreature(creature)
|
2012-02-09 06:27:29 +01:00
|
|
|
local creatureId = creature:getId()
|
2012-02-20 03:27:08 +01:00
|
|
|
|
2012-02-09 06:27:29 +01:00
|
|
|
if battleButtonsByCreaturesList[creatureId] ~= nil then
|
|
|
|
if lastBattleButtonSwitched == battleButtonsByCreaturesList[creatureId] then
|
|
|
|
lastBattleButtonSwitched = nil
|
|
|
|
end
|
2012-03-30 12:06:33 +02:00
|
|
|
|
2012-02-09 08:26:52 +01:00
|
|
|
battleButtonsByCreaturesList[creatureId].creature:hideStaticSquare()
|
2012-02-09 06:27:29 +01:00
|
|
|
battleButtonsByCreaturesList[creatureId]:destroy()
|
|
|
|
battleButtonsByCreaturesList[creatureId] = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function setLifeBarPercent(battleButton, percent)
|
2012-02-09 06:27:29 +01:00
|
|
|
local lifeBarWidget = battleButton:getChildById('lifeBar')
|
|
|
|
lifeBarWidget:setPercent(percent)
|
2012-02-20 03:27:08 +01:00
|
|
|
|
2012-02-09 06:27:29 +01:00
|
|
|
local color
|
2012-07-24 07:30:08 +02:00
|
|
|
for i, v in pairs(LifeBarColors) do
|
2012-02-09 06:27:29 +01:00
|
|
|
if percent > v.percentAbove then
|
|
|
|
color = v.color
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
2012-02-20 03:27:08 +01:00
|
|
|
|
2012-02-09 06:27:29 +01:00
|
|
|
lifeBarWidget:setBackgroundColor(color)
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function onbattleButtonHoverChange(widget, hovered)
|
2012-02-20 03:27:08 +01:00
|
|
|
if widget.isBattleButton then
|
2012-02-09 08:26:52 +01:00
|
|
|
widget.isHovered = hovered
|
2012-07-24 07:30:08 +02:00
|
|
|
checkBattleButton(widget)
|
2012-02-09 06:27:29 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function onAttack(creature)
|
2012-02-20 03:27:08 +01:00
|
|
|
local battleButton = creature and battleButtonsByCreaturesList[creature:getId()] or lastBattleButtonSwitched
|
2012-02-09 06:27:29 +01:00
|
|
|
if battleButton then
|
|
|
|
battleButton.isTarget = creature and true or false
|
2012-07-24 07:30:08 +02:00
|
|
|
checkBattleButton(battleButton)
|
2012-02-09 06:27:29 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function onFollow(creature)
|
2012-02-20 03:27:08 +01:00
|
|
|
local battleButton = creature and battleButtonsByCreaturesList[creature:getId()] or lastBattleButtonSwitched
|
2012-02-09 06:27:29 +01:00
|
|
|
if battleButton then
|
|
|
|
battleButton.isFollowed = creature and true or false
|
2012-07-24 07:30:08 +02:00
|
|
|
checkBattleButton(battleButton)
|
2012-02-20 03:27:08 +01:00
|
|
|
end
|
2012-02-09 06:27:29 +01:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function checkBattleButton(battleButton)
|
|
|
|
local color = BattleButtonColors.onIdle
|
2012-02-09 06:27:29 +01:00
|
|
|
if battleButton.isTarget then
|
2012-07-24 07:30:08 +02:00
|
|
|
color = BattleButtonColors.onTargeted
|
2012-02-09 06:27:29 +01:00
|
|
|
elseif battleButton.isFollowed then
|
2012-07-24 07:30:08 +02:00
|
|
|
color = BattleButtonColors.onFollowed
|
2012-02-09 06:27:29 +01:00
|
|
|
end
|
2012-02-20 03:27:08 +01:00
|
|
|
|
2012-02-09 06:27:29 +01:00
|
|
|
color = battleButton.isHovered and color.hovered or color.notHovered
|
2012-02-20 03:27:08 +01:00
|
|
|
|
2012-02-09 06:27:29 +01:00
|
|
|
if battleButton.isHovered or battleButton.isTarget or battleButton.isFollowed then
|
|
|
|
battleButton.creature:showStaticSquare(color)
|
|
|
|
battleButton:getChildById('creature'):setBorderWidth(1)
|
|
|
|
battleButton:getChildById('creature'):setBorderColor(color)
|
2012-02-20 03:27:08 +01:00
|
|
|
battleButton:getChildById('label'):setColor(color)
|
|
|
|
else
|
2012-02-09 06:27:29 +01:00
|
|
|
battleButton.creature:hideStaticSquare()
|
|
|
|
battleButton:getChildById('creature'):setBorderWidth(0)
|
2012-02-20 03:27:08 +01:00
|
|
|
battleButton:getChildById('label'):setColor(color)
|
2012-02-09 06:27:29 +01:00
|
|
|
end
|
2012-02-20 03:27:08 +01:00
|
|
|
|
2012-02-09 06:27:29 +01:00
|
|
|
if battleButton.isTarget or battleButton.isFollowed then
|
2012-07-09 13:37:47 +02:00
|
|
|
-- set new last battle button switched
|
2012-02-09 06:27:29 +01:00
|
|
|
if lastBattleButtonSwitched and lastBattleButtonSwitched ~= battleButton then
|
|
|
|
lastBattleButtonSwitched.isTarget = false
|
|
|
|
lastBattleButtonSwitched.isFollowed = false
|
2012-07-24 07:30:08 +02:00
|
|
|
checkBattleButton(lastBattleButtonSwitched)
|
2012-02-09 06:27:29 +01:00
|
|
|
end
|
|
|
|
lastBattleButtonSwitched = battleButton
|
|
|
|
end
|
|
|
|
end
|