mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
restore old modules
* partially restore vip, battle, healthbar, skills and inventory modules * more fixes on UIWidgets * implement UIMiniWindow close/minimize functionality * allow drag and drop miniwindows beteween game panels
This commit is contained in:
@@ -35,19 +35,19 @@ table.insert(lifeBarColors, {percentAbove = 3, color = '#3C0000' } )
|
||||
table.insert(lifeBarColors, {percentAbove = -1, color = '#4F0000' } )
|
||||
|
||||
-- public functions
|
||||
function Battle.create()
|
||||
function Battle.init()
|
||||
battleWindow = displayUI('battle.otui', GameInterface.getRightPanel())
|
||||
battleWindow:hide()
|
||||
battleButton = TopMenu.addGameButton('battleButton', 'Battle (Ctrl+B)', '/game_battle/battle.png', Battle.toggle)
|
||||
battleButton = TopMenu.addGameToggleButton('battleButton', 'Battle (Ctrl+B)', 'battle.png', Battle.toggle)
|
||||
battleButton:setOn(true)
|
||||
Keyboard.bindKeyDown('Ctrl+B', Battle.toggle)
|
||||
|
||||
battlePannel = battleWindow:getChildById('battlePanel')
|
||||
battlePanel = battleWindow:recursiveGetChildById('battlePanel')
|
||||
|
||||
hidePlayersButton = battleWindow:getChildById('hidePlayers')
|
||||
hideNPCsButton = battleWindow:getChildById('hideNPCs')
|
||||
hideMonstersButton = battleWindow:getChildById('hideMonsters')
|
||||
hideSkullsButton = battleWindow:getChildById('hideSkulls')
|
||||
hidePartyButton = battleWindow:getChildById('hideParty')
|
||||
hidePlayersButton = battleWindow:recursiveGetChildById('hidePlayers')
|
||||
hideNPCsButton = battleWindow:recursiveGetChildById('hideNPCs')
|
||||
hideMonstersButton = battleWindow:recursiveGetChildById('hideMonsters')
|
||||
hideSkullsButton = battleWindow:recursiveGetChildById('hideSkulls')
|
||||
hidePartyButton = battleWindow:recursiveGetChildById('hideParty')
|
||||
|
||||
mouseWidget = createWidget('UIButton')
|
||||
mouseWidget:setVisible(false)
|
||||
@@ -63,9 +63,9 @@ function Battle.create()
|
||||
checkCreaturesEvent = scheduleEvent(Battle.checkCreatures, 200)
|
||||
end
|
||||
|
||||
function Battle.destroy()
|
||||
function Battle.terminate()
|
||||
Keyboard.unbindKeyDown('Ctrl+B')
|
||||
battlePannel = nil
|
||||
battlePanel = nil
|
||||
lastBattleButtonTargeted = nil
|
||||
lastBattleButtonFollowed = nil
|
||||
battleButtonsByCreaturesList = {}
|
||||
@@ -95,15 +95,15 @@ end
|
||||
|
||||
function Battle.addAllCreatures()
|
||||
local spectators = {}
|
||||
local player = g_game.getLocalPlayer()
|
||||
if player then
|
||||
creatures = g_map.getSpectators(player:getPosition(), false)
|
||||
for i, creature in ipairs(creatures) do
|
||||
if creature ~= player and Battle.doCreatureFitFilters(creature) then
|
||||
table.insert(spectators, creature)
|
||||
end
|
||||
end
|
||||
end
|
||||
local player = g_game.getLocalPlayer()
|
||||
if player then
|
||||
creatures = g_map.getSpectators(player:getPosition(), false)
|
||||
for i, creature in ipairs(creatures) do
|
||||
if creature ~= player and Battle.doCreatureFitFilters(creature) then
|
||||
table.insert(spectators, creature)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for i, v in pairs(spectators) do
|
||||
Battle.addCreature(v)
|
||||
@@ -176,7 +176,7 @@ function Battle.addCreature(creature)
|
||||
local creatureId = creature:getId()
|
||||
|
||||
if battleButtonsByCreaturesList[creatureId] == nil then
|
||||
local battleButton = displayUI('battleButton.otui', battlePanne)
|
||||
local battleButton = displayUI('battleButton.otui', battlePanel)
|
||||
local creatureWidget = battleButton:getChildById('creature')
|
||||
local labelWidget = battleButton:getChildById('label')
|
||||
local lifeBarWidget = battleButton:getChildById('lifeBar')
|
||||
@@ -292,7 +292,7 @@ function Battle.setLifeBarPercent(battleButton, percent)
|
||||
lifeBarWidget:setBackgroundColor(color)
|
||||
end
|
||||
|
||||
function Battle.onbattlePannelHoverChange(widget, hovered)
|
||||
function Battle.onbattleButtonHoverChange(widget, hovered)
|
||||
if widget.isBattleButton then
|
||||
widget.isHovered = hovered
|
||||
Battle.checkBattleButton(widget)
|
||||
@@ -345,6 +345,3 @@ function Battle.checkBattleButton(battleButton)
|
||||
lastBattleButtonSwitched = battleButton
|
||||
end
|
||||
end
|
||||
|
||||
connect(g_game, { onGameStart = Battle.create,
|
||||
onGameEnd = Battle.destroy } )
|
@@ -3,6 +3,12 @@ Module
|
||||
description: Manage battle window
|
||||
author: OTClient team
|
||||
website: https://github.com/edubart/otclient
|
||||
icon: battle.png
|
||||
|
||||
@onLoad: |
|
||||
dofile 'battle'
|
||||
Battle.init()
|
||||
|
||||
@onUnload:
|
||||
Battle.terminate()
|
||||
|
||||
|
@@ -26,66 +26,72 @@ BattlePlayers < BattleIcon
|
||||
|
||||
BattleNPCs < BattleIcon
|
||||
image-source: /game_battle/battle_npcs.png
|
||||
|
||||
|
||||
BattleMonsters < BattleIcon
|
||||
image-source: /game_battle/battle_monsters.png
|
||||
|
||||
BattleSkulls < BattleIcon
|
||||
image-source: /game_battle/battle_skulls.png
|
||||
|
||||
|
||||
BattleParty < BattleIcon
|
||||
image-source: /game_battle/battle_party.png
|
||||
|
||||
image-source: /game_battle/battle_party.png
|
||||
|
||||
MiniWindow
|
||||
id: battleWindow
|
||||
text: Battle
|
||||
height: 250
|
||||
|
||||
BattlePlayers
|
||||
id: hidePlayers
|
||||
tooltip: Hide players
|
||||
anchors.top: parent.top
|
||||
anchors.right: next.left
|
||||
margin-right: 5
|
||||
|
||||
BattleNPCs
|
||||
id: hideNPCs
|
||||
tooltip: Hide Npc's
|
||||
anchors.top: parent.top
|
||||
anchors.right: next.left
|
||||
margin-right: 5
|
||||
|
||||
BattleMonsters
|
||||
id: hideMonsters
|
||||
tooltip: Hide monsters
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
BattleSkulls
|
||||
id: hideSkulls
|
||||
tooltip: Hide non-skull players
|
||||
anchors.top: prev.top
|
||||
anchors.left: prev.right
|
||||
margin-left: 5
|
||||
|
||||
BattleParty
|
||||
id: hideParty
|
||||
tooltip: Hide party members
|
||||
anchors.top: prev.top
|
||||
anchors.left: prev.right
|
||||
margin-left: 5
|
||||
|
||||
HorizontalSeparator
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
margin-top: 5
|
||||
|
||||
Panel
|
||||
id: battlePanel
|
||||
anchors.fill: parent
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 5
|
||||
layout: verticalBox
|
||||
|
||||
|
||||
height: 100
|
||||
icon: battle.png
|
||||
@onClose: Battle.toggle()
|
||||
|
||||
MiniWindowContents
|
||||
BattlePlayers
|
||||
id: hidePlayers
|
||||
tooltip: Hide players
|
||||
anchors.top: parent.top
|
||||
anchors.right: next.left
|
||||
margin-right: 5
|
||||
|
||||
BattleNPCs
|
||||
id: hideNPCs
|
||||
tooltip: Hide Npc's
|
||||
anchors.top: parent.top
|
||||
anchors.right: next.left
|
||||
margin-right: 5
|
||||
|
||||
BattleMonsters
|
||||
id: hideMonsters
|
||||
tooltip: Hide monsters
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
BattleSkulls
|
||||
id: hideSkulls
|
||||
tooltip: Hide non-skull players
|
||||
anchors.top: prev.top
|
||||
anchors.left: prev.right
|
||||
margin-left: 5
|
||||
|
||||
BattleParty
|
||||
id: hideParty
|
||||
tooltip: Hide party members
|
||||
anchors.top: prev.top
|
||||
anchors.left: prev.right
|
||||
margin-left: 5
|
||||
|
||||
HorizontalSeparator
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
margin-top: 5
|
||||
|
||||
Panel
|
||||
id: battlePanel
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 5
|
||||
layout:
|
||||
type: verticalBox
|
||||
fit-children: true
|
||||
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -4,7 +4,7 @@ BattleButton
|
||||
height: 20
|
||||
margin-top: 5
|
||||
fixed-size: true
|
||||
&onHoverChange: Battle.onbattlePannelHoverChange
|
||||
&onHoverChange: Battle.onbattleButtonHoverChange
|
||||
&onMouseRelease: Battle.onMouseRelease
|
||||
&isBattleButton: true
|
||||
|
||||
@@ -51,4 +51,4 @@ BattleButton
|
||||
anchors.right: parent.right
|
||||
anchors.top: label.bottom
|
||||
margin-top: 2
|
||||
phantom: true
|
||||
phantom: true
|
||||
|
Reference in New Issue
Block a user