improving battle window and fixes

master
AndreFaramir 12 years ago
parent c707f990bf
commit d0a5f27fcf

@ -27,12 +27,8 @@ local function onUseWithMouseRelease(self, mousePosition, mouseButton)
end
elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
g_game.useWith(g_game.selectedThing, clickedWidget:getItem())
elseif clickedWidget.isBattleButton or clickedWidget.battleButtonChild then
local battleButton = clickedWidget
if clickedWidget.battleButtonChild then
battleButton = clickedWidget:getParent()
end
g_game.useWith(g_game.selectedThing, battleButton.creature)
elseif clickedWidget.isBattleButton then
g_game.useWith(g_game.selectedThing, clickedWidget.creature)
end
end
end

@ -52,9 +52,6 @@ function Battle.create()
mouseWidget = createWidget('UIButton')
mouseWidget:setVisible(false)
mouseWidget:setFocusable(false)
connect(UIWidget, { onHoverChange = Battle.onbattlePannelHoverChange,
onMouseRelease = Battle.onMouseRelease } )
connect(Creature, { onSkullChange = Battle.checkCreatureSkull,
onEmblemChange = Battle.checkCreatureEmblem } )
@ -83,9 +80,6 @@ function Battle.destroy()
battleButton = nil
battleWindow:destroy()
battleWindow = nil
disconnect(UIWidget, { onHoverChange = Battle.onbattlePannelHoverChange,
onMouseRelease = Battle.onMouseRelease } )
disconnect(Creature, { onSkullChange = Battle.checkCreatureSkull,
onEmblemChange = Battle.checkCreatureEmblem } )
@ -252,13 +246,20 @@ end
function Battle.onMouseRelease(self, mousePosition, mouseButton)
if mouseButton == MouseRightButton then
local clickedWidget = g_game.gameUi:recursiveGetChildByPos(mousePosition)
if clickedWidget then
if clickedWidget:getStyleName() == 'BattleButton' then
g_game.createThingMenu(mousePosition, nil, nil, clickedWidget.creature)
return true
g_game.createThingMenu(mousePosition, nil, nil, self.creature)
return true
elseif mouseButton == MouseLeftButton then
local modifiers = g_window.getKeyboardModifiers()
if modifiers == KeyboardShiftModifier then
g_game.look(self.creature)
else
if self.isTarget then
g_game.cancelAttack()
else
g_game.attack(self.creature)
end
end
return true
end
end
@ -270,6 +271,7 @@ function Battle.removeCreature(creature)
lastBattleButtonSwitched = nil
end
battleButtonsByCreaturesList[creatureId].creature:hideStaticSquare()
battleButtonsByCreaturesList[creatureId]:destroy()
battleButtonsByCreaturesList[creatureId] = nil
end
@ -290,27 +292,10 @@ function Battle.setLifeBarPercent(battleButton, percent)
lifeBarWidget:setBackgroundColor(color)
end
function Battle.onButtonClick(battleButton)
if battleButton then
if battleButton.isTarget then
g_game.cancelAttack()
else
g_game.attack(battleButton.creature)
end
end
end
function Battle.onbattlePannelHoverChange(widget, hovered)
if widget.isBattleButton or widget.battleButtonChild then
local battleButton = widget
if widget.battleButtonChild then
battleButton = widget:getParent()
end
if battleButton then
battleButton.isHovered = hovered
Battle.checkBattleButton(battleButton)
end
if widget.isBattleButton then
widget.isHovered = hovered
Battle.checkBattleButton(widget)
end
end

@ -4,7 +4,8 @@ BattleButton
height: 20
margin-top: 5
fixed-size: true
@onClick: Battle.onButtonClick(self)
&onHoverChange: Battle.onbattlePannelHoverChange
&onMouseRelease: Battle.onMouseRelease
&isBattleButton: true
UICreature
@ -12,29 +13,28 @@ BattleButton
size: 20 20
anchors.left: parent.left
anchors.top: parent.top
@onClick: Battle.onButtonClick(parent)
&battleButtonChild: true
phantom: true
UIWidget
id: spacer
width: 5
anchors.left: creature.right
anchors.top: creature.top
&battleButtonChild: true
phantom: true
UIWidget
id: skull
height: 11
anchors.left: spacer.right
anchors.top: spacer.top
&battleButtonChild: true
phantom: true
UIWidget
id: emblem
height: 11
anchors.left: skull.right
anchors.top: creature.top
&battleButtonChild: true
phantom: true
LargerLabel
id: label
@ -42,8 +42,7 @@ BattleButton
anchors.top: creature.top
color: #888888
margin-left: 2
@onClick: Battle.onButtonClick(parent)
&battleButtonChild: true
phantom: true
ProgressBar
id: lifeBar
@ -52,5 +51,4 @@ BattleButton
anchors.right: parent.right
anchors.top: label.bottom
margin-top: 2
@onClick: Battle.onButtonClick(parent)
&battleButtonChild: true
phantom: true
Loading…
Cancel
Save