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:
parent
e2ea267703
commit
8d14d9bc99
|
@ -2,5 +2,5 @@ ProgressBar < UIProgressBar
|
|||
height: 16
|
||||
background-color: red
|
||||
border: 1 black
|
||||
image: /core_styles/styles/images/progressbar.png
|
||||
image-source: /core_styles/styles/images/progressbar.png
|
||||
image-border: 1
|
||||
|
|
|
@ -14,10 +14,11 @@ Module
|
|||
- game_console
|
||||
- game_outfit
|
||||
- game_healthbar
|
||||
- game_skills
|
||||
- game_inventory
|
||||
//- game_combatcontrols
|
||||
//- game_skills
|
||||
//- game_viplist
|
||||
- game_combatcontrols
|
||||
- game_battle
|
||||
- game_viplist
|
||||
//- game_hotkeys
|
||||
|
||||
@onLoad: |
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
GameSidePanel < UIMiniWindowContainer
|
||||
image-source: images/sidepanel.png
|
||||
image-border: 4
|
||||
padding: 4
|
||||
|
||||
GameBottomPanel < Panel
|
||||
image-source: images/bottompanel.png
|
||||
|
@ -33,7 +34,7 @@ UIWidget
|
|||
|
||||
GameSidePanel
|
||||
id: gameLeftPanel
|
||||
width: 0
|
||||
width: 190
|
||||
layout: verticalBox
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
|
@ -66,6 +67,7 @@ UIWidget
|
|||
anchors.bottom: parent.bottom
|
||||
relative-margin: right
|
||||
margin-right: 190
|
||||
enabled: false
|
||||
@canUpdateMargin: function(self, newMargin) return math.max(math.min(newMargin, self:getParent():getWidth() - 300), 150) end
|
||||
@onGeometryChange: function(self) self:setMarginRight(math.min(math.max(self:getParent():getWidth() - 300, 150), self:getMarginRight())) end
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 551 B After Width: | Height: | Size: 626 B |
|
@ -1,23 +1,22 @@
|
|||
MiniWindow < UIMiniWindow
|
||||
font: verdana-11px-antialised
|
||||
//icon: /core_styles/icons/login.png
|
||||
icon-rect: 4 4 16 16
|
||||
width: 192
|
||||
height: 200
|
||||
text-offset: 26 5
|
||||
text-align: topLeft
|
||||
margin-top: 2
|
||||
margin-left: 6
|
||||
margin-right: 6
|
||||
margin-bottom: 2
|
||||
move-policy: free updated
|
||||
image-source: /game/images/miniwindow.png
|
||||
image-border: 4
|
||||
image-border-top: 23
|
||||
image-border-left: 23
|
||||
image-border-bottom: 4
|
||||
focusable: false
|
||||
&minimizedHeight: 24
|
||||
|
||||
$on:
|
||||
height: 24
|
||||
image-border-bottom: 1
|
||||
image-border-bottom: 2
|
||||
|
||||
UIButton
|
||||
id: closeButton
|
||||
|
@ -27,13 +26,13 @@ MiniWindow < UIMiniWindow
|
|||
margin-right: 5
|
||||
size: 14 14
|
||||
image-source: /game/images/miniwindowbuttons.png
|
||||
image-clip: 14 0 14 14
|
||||
image-clip: 28 0 14 14
|
||||
|
||||
$hover:
|
||||
image-clip: 14 14 14 14
|
||||
image-clip: 28 14 14 14
|
||||
|
||||
$pressed:
|
||||
image-clip: 14 28 14 14
|
||||
image-clip: 28 28 14 14
|
||||
|
||||
UIButton
|
||||
id: minimizeButton
|
||||
|
@ -50,6 +49,15 @@ MiniWindow < UIMiniWindow
|
|||
$pressed:
|
||||
image-clip: 0 28 14 14
|
||||
|
||||
$on:
|
||||
image-clip: 14 0 14 14
|
||||
|
||||
$on hover:
|
||||
image-clip: 14 14 14 14
|
||||
|
||||
$on pressed:
|
||||
image-clip: 14 28 14 14
|
||||
|
||||
VerticalScrollBar
|
||||
id: miniwindowScrollBar
|
||||
anchors.top: parent.top
|
||||
|
@ -67,14 +75,16 @@ MiniWindow < UIMiniWindow
|
|||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: 3
|
||||
minimum: 70
|
||||
minimum: 64
|
||||
background: #ffffff88
|
||||
|
||||
MiniWindowContents < ScrollablePanel
|
||||
id: contentsPanel
|
||||
anchors.fill: parent
|
||||
margin-right: 14
|
||||
padding: 25 8 3 8
|
||||
padding: 25 6 6 6
|
||||
vertical-scrollbar: miniwindowScrollBar
|
||||
|
||||
BorderlessGameWindow < UIWindow
|
||||
focusable: false
|
||||
margin: 2
|
||||
|
|
|
@ -27,7 +27,7 @@ end
|
|||
function UIItem:onDrop(widget, mousePos)
|
||||
if self:isVirtual() then return false end
|
||||
|
||||
if not widget or not widget.currentDragThing then return true end
|
||||
if not widget or not widget.currentDragThing then return false end
|
||||
|
||||
local pos = self.position
|
||||
local count = widget.currentDragThing:getCount()
|
||||
|
|
|
@ -2,10 +2,16 @@ UIMiniWindow = extends(UIWindow)
|
|||
|
||||
function UIMiniWindow.create()
|
||||
local miniwindow = UIMiniWindow.internalCreate()
|
||||
miniwindow:setFocusable(false)
|
||||
return miniwindow
|
||||
end
|
||||
|
||||
function UIMiniWindow:onSetup()
|
||||
addEvent(function()
|
||||
self:getChildById('closeButton').onClick = function() signalcall(self.onClose, self) end
|
||||
self:getChildById('minimizeButton').onClick = function() signalcall(self.onMinimize, self) end
|
||||
end)
|
||||
end
|
||||
|
||||
function UIMiniWindow:onDragEnter(mousePos)
|
||||
local parent = self:getParent()
|
||||
if not parent then return false end
|
||||
|
@ -19,9 +25,19 @@ function UIMiniWindow:onDragEnter(mousePos)
|
|||
local oldPos = self:getPosition()
|
||||
self.movingReference = { x = mousePos.x - oldPos.x, y = mousePos.y - oldPos.y }
|
||||
self:setPosition(oldPos)
|
||||
self.free = true
|
||||
return true
|
||||
end
|
||||
|
||||
function UIMiniWindow:onMousePress()
|
||||
local parent = self:getParent()
|
||||
if not parent then return false end
|
||||
if parent:getClassName() ~= 'UIMiniWindowContainer' then
|
||||
self:raise()
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function UIMiniWindow:onDragLeave(droppedWidget, mousePos)
|
||||
-- TODO: drop on other interfaces
|
||||
end
|
||||
|
@ -35,3 +51,25 @@ function UIMiniWindow:onFocusChange(focused)
|
|||
end
|
||||
end
|
||||
|
||||
function UIMiniWindow:onClose()
|
||||
end
|
||||
|
||||
function UIMiniWindow:onMinimize()
|
||||
if self:isOn() then
|
||||
self:setOn(false)
|
||||
self:getChildById('contentsPanel'):show()
|
||||
self:getChildById('miniwindowScrollBar'):show()
|
||||
self:getChildById('bottomResizeBorder'):show()
|
||||
self:getChildById('minimizeButton'):setOn(false)
|
||||
self:setHeight(self.savedHeight)
|
||||
else
|
||||
self.savedHeight = self:getHeight()
|
||||
self:setHeight(self.minimizedHeight)
|
||||
self:setOn(true)
|
||||
self:getChildById('contentsPanel'):hide()
|
||||
self:getChildById('miniwindowScrollBar'):hide()
|
||||
self:getChildById('bottomResizeBorder'):hide()
|
||||
self:getChildById('minimizeButton'):setOn(true)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@ function UIMiniWindowContainer.create()
|
|||
end
|
||||
|
||||
function UIMiniWindowContainer:onDrop(widget, mousePos)
|
||||
print 'drop'
|
||||
widget:setParent(self)
|
||||
return true
|
||||
end
|
||||
|
||||
function UIMiniWindowContainer:getClassName()
|
||||
|
|
|
@ -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 = {}
|
||||
|
@ -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()
|
||||
|
||||
|
|
|
@ -39,8 +39,11 @@ BattleParty < BattleIcon
|
|||
MiniWindow
|
||||
id: battleWindow
|
||||
text: Battle
|
||||
height: 250
|
||||
height: 100
|
||||
icon: battle.png
|
||||
@onClose: Battle.toggle()
|
||||
|
||||
MiniWindowContents
|
||||
BattlePlayers
|
||||
id: hidePlayers
|
||||
tooltip: Hide players
|
||||
|
@ -83,9 +86,12 @@ MiniWindow
|
|||
|
||||
Panel
|
||||
id: battlePanel
|
||||
anchors.fill: parent
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 5
|
||||
layout: verticalBox
|
||||
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
|
||||
|
||||
|
|
|
@ -48,15 +48,15 @@ end
|
|||
|
||||
-- public functions
|
||||
function CombatControls.init()
|
||||
combatControlsButton = TopMenu.addGameButton('combatControlsButton', 'Combat Controls', 'combatcontrols.png', CombatControls.toggle)
|
||||
combatControlsButton = TopMenu.addGameToggleButton('combatControlsButton', 'Combat Controls', 'combatcontrols.png', CombatControls.toggle)
|
||||
combatControlsButton:setOn(true)
|
||||
combatControlsWindow = loadUI('combatcontrols.otui', GameInterface.getRightPanel())
|
||||
|
||||
fightOffensiveBox = combatControlsWindow:getChildById('fightOffensiveBox')
|
||||
fightBalancedBox = combatControlsWindow:getChildById('fightBalancedBox')
|
||||
fightDefensiveBox = combatControlsWindow:getChildById('fightDefensiveBox')
|
||||
chaseModeButton = combatControlsWindow:getChildById('chaseModeBox')
|
||||
safeFightButton = combatControlsWindow:getChildById('safeFightBox')
|
||||
fightOffensiveBox = combatControlsWindow:recursiveGetChildById('fightOffensiveBox')
|
||||
fightBalancedBox = combatControlsWindow:recursiveGetChildById('fightBalancedBox')
|
||||
fightDefensiveBox = combatControlsWindow:recursiveGetChildById('fightDefensiveBox')
|
||||
chaseModeButton = combatControlsWindow:recursiveGetChildById('chaseModeBox')
|
||||
safeFightButton = combatControlsWindow:recursiveGetChildById('safeFightBox')
|
||||
|
||||
fightModeRadioGroup = RadioGroup.create()
|
||||
fightModeRadioGroup:addWidget(fightOffensiveBox)
|
||||
|
|
|
@ -19,25 +19,29 @@ ChaseModeBox < CombatBox
|
|||
SafeFightBox < CombatBox
|
||||
image-source: /game_combatcontrols/icons/safefight.png
|
||||
|
||||
UIWindow
|
||||
width: 130
|
||||
height: 30
|
||||
margin-top: 10
|
||||
margin-left: 6
|
||||
margin-right: 6
|
||||
MiniWindow
|
||||
text: Combat Controls
|
||||
icon: combatcontrols.png
|
||||
height: 64
|
||||
@onClose: CombatControls.toggle()
|
||||
|
||||
MiniWindowContents
|
||||
FightOffensiveBox
|
||||
id: fightOffensiveBox
|
||||
anchors.right: next.left
|
||||
anchors.top: next.top
|
||||
FightBalancedBox
|
||||
id: fightBalancedBox
|
||||
anchors.right: next.left
|
||||
anchors.top: next.top
|
||||
FightDefensiveBox
|
||||
id: fightDefensiveBox
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.centerIn: parent
|
||||
ChaseModeBox
|
||||
id: chaseModeBox
|
||||
anchors.left: prev.right
|
||||
anchors.top: prev.top
|
||||
SafeFightBox
|
||||
id: safeFightBox
|
||||
anchors.left: prev.right
|
||||
anchors.top: prev.top
|
||||
|
|
|
@ -12,13 +12,13 @@ function HealthBar.init()
|
|||
connect(LocalPlayer, { onHealthChange = HealthBar.onHealthChange,
|
||||
onManaChange = HealthBar.onManaChange })
|
||||
|
||||
healthBarWindow = displayUI('healthbar.otui', GameInterface.getRightPanel())
|
||||
healthBarWindow = displayUI('healthbar.otui', GameInterface.getLeftPanel())
|
||||
healthBarButton = TopMenu.addGameToggleButton('healthBarButton', 'Healh Bar', 'healthbar.png', HealthBar.toggle)
|
||||
healthBarButton:setOn(true)
|
||||
healthBar = healthBarWindow:getChildById('healthBar')
|
||||
manaBar = healthBarWindow:getChildById('manaBar')
|
||||
healthLabel = healthBarWindow:getChildById('healthLabel')
|
||||
manaLabel = healthBarWindow:getChildById('manaLabel')
|
||||
healthBar = healthBarWindow:recursiveGetChildById('healthBar')
|
||||
manaBar = healthBarWindow:recursiveGetChildById('manaBar')
|
||||
healthLabel = healthBarWindow:recursiveGetChildById('healthLabel')
|
||||
manaLabel = healthBarWindow:recursiveGetChildById('manaLabel')
|
||||
|
||||
if g_game.isOnline() then
|
||||
local localPlayer = g_game.getLocalPlayer()
|
||||
|
@ -32,8 +32,8 @@ function HealthBar.terminate()
|
|||
onManaChange = HealthBar.onManaChange })
|
||||
|
||||
healthBarWindow:destroy()
|
||||
healthBarWindow = nil
|
||||
healthBarButton:destroy()
|
||||
healthBarWindow = nil
|
||||
healthBarButton = nil
|
||||
healthBar = nil
|
||||
manaBar = nil
|
||||
|
|
|
@ -10,9 +10,10 @@ ManaBar < ProgressBar
|
|||
id: manaBar
|
||||
height: 15
|
||||
background-color: #4444ff
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
margin-top: 4
|
||||
|
||||
HealthLabel < GameLabel
|
||||
id: healthLabel
|
||||
|
@ -32,15 +33,14 @@ ManaLabel < GameLabel
|
|||
margin-top: 2
|
||||
text: 0 / 0
|
||||
|
||||
BorderlessGameWindow
|
||||
id: healthManaPanel
|
||||
width: 192
|
||||
height: 34
|
||||
margin-top: 10
|
||||
margin-left: 6
|
||||
margin-right: 6
|
||||
move-policy: free updated
|
||||
MiniWindow
|
||||
icon: healthbar.png
|
||||
id: healthBarWindow
|
||||
text: Health Bar
|
||||
height: 64
|
||||
@onClose: HealthBar.toggle()
|
||||
|
||||
MiniWindowContents
|
||||
HealthBar
|
||||
HealthLabel
|
||||
ManaBar
|
||||
|
|
|
@ -145,7 +145,7 @@ end
|
|||
function HotkeysManager.onChooseItemMouseRelease(self, mousePosition, mouseButton)
|
||||
local item = nil
|
||||
if mouseButton == MouseLeftButton then
|
||||
local clickedWidget = g_game.gameUi:recursiveGetChildByPos(mousePosition)
|
||||
local clickedWidget = g_game.gameUi:recursiveGetChildByPos(mousePosition, false)
|
||||
if clickedWidget then
|
||||
if clickedWidget:getClassName() == 'UIMap' then
|
||||
local tile = clickedWidget:getTile(mousePosition)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
Inventory = {}
|
||||
|
||||
-- private variables
|
||||
local inventoryWindow
|
||||
local inventoryPanel
|
||||
local inventoryButton
|
||||
|
||||
|
@ -13,7 +14,9 @@ function Inventory.init()
|
|||
|
||||
Keyboard.bindKeyDown('Ctrl+I', Inventory.toggle)
|
||||
|
||||
inventoryPanel = displayUI('inventory.otui', GameInterface.getRightPanel()):getChildById('inventoryPanel')
|
||||
inventoryWindow = displayUI('inventory.otui', GameInterface.getRightPanel())
|
||||
inventoryWindow.onClose = Inventory.toggle
|
||||
inventoryPanel = inventoryWindow:getChildById('contentsPanel')
|
||||
inventoryButton = TopMenu.addGameToggleButton('inventoryButton', 'Inventory (Ctrl+I)', 'inventory.png', Inventory.toggle)
|
||||
inventoryButton:setOn(true)
|
||||
|
||||
|
@ -30,15 +33,16 @@ function Inventory.terminate()
|
|||
|
||||
Keyboard.unbindKeyDown('Ctrl+I')
|
||||
|
||||
inventoryPanel:destroy()
|
||||
inventoryPanel = nil
|
||||
inventoryWindow:destroy()
|
||||
inventoryButton:destroy()
|
||||
inventoryWindow = nil
|
||||
inventoryButton = nil
|
||||
inventoryPanel = nil
|
||||
end
|
||||
|
||||
function Inventory.toggle()
|
||||
local visible = not inventoryPanel:isExplicitlyVisible()
|
||||
inventoryPanel:setVisible(visible)
|
||||
local visible = not inventoryWindow:isExplicitlyVisible()
|
||||
inventoryWindow:setVisible(visible)
|
||||
inventoryButton:setOn(visible)
|
||||
end
|
||||
|
||||
|
|
|
@ -2,12 +2,10 @@ MiniWindow
|
|||
id: inventoryMiniWindow
|
||||
text: Inventory
|
||||
icon: inventory.png
|
||||
width: 192
|
||||
height: 154
|
||||
height: 180
|
||||
@onClose: Inventory.toggle()
|
||||
|
||||
MiniWindowContents
|
||||
id: inventoryPanel
|
||||
|
||||
Item
|
||||
// head
|
||||
id: slot1
|
||||
|
@ -37,7 +35,6 @@ MiniWindow
|
|||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
margin-bottom: 10
|
||||
&position: {x=65535, y=8, z=0}
|
||||
|
||||
Item
|
||||
|
|
|
@ -42,13 +42,37 @@ end
|
|||
|
||||
-- public functions
|
||||
function Skills.init()
|
||||
skillsWindow = displayUI('skills.otui', GameInterface.getRightPanel())
|
||||
skillsWindow:hide()
|
||||
skillsButton = TopMenu.addGameButton('skillsButton', 'Skills (Ctrl+S)', '/core_styles/icons/skills.png', Skills.toggle)
|
||||
connect(LocalPlayer, {
|
||||
onExperienceChange = Skills.onExperienceChange,
|
||||
onLevelChange = Skills.onLevelChange,
|
||||
onHealthChange = Skills.onHealthChange,
|
||||
onManaChange = Skills.onManaChange,
|
||||
onSoulChange = Skills.onSoulChange,
|
||||
onFreeCapacityChange = Skills.onFreeCapacityChange,
|
||||
onStaminaChange = Skills.onStaminaChange,
|
||||
onMagicLevelChange = Skills.onMagicLevelChange,
|
||||
onSkillChange = Skills.onSkillChange
|
||||
})
|
||||
|
||||
skillsWindow = displayUI('skills.otui', GameInterface.getLeftPanel())
|
||||
skillsButton = TopMenu.addGameToggleButton('skillsButton', 'Skills (Ctrl+S)', 'skills.png', Skills.toggle)
|
||||
skillsButton:setOn(true)
|
||||
Keyboard.bindKeyDown('Ctrl+S', Skills.toggle)
|
||||
end
|
||||
|
||||
function Skills.terminate()
|
||||
disconnect(LocalPlayer, {
|
||||
onExperienceChange = Skills.onExperienceChange,
|
||||
onLevelChange = Skills.onLevelChange,
|
||||
onHealthChange = Skills.onHealthChange,
|
||||
onManaChange = Skills.onManaChange,
|
||||
onSoulChange = Skills.onSoulChange,
|
||||
onFreeCapacityChange = Skills.onFreeCapacityChange,
|
||||
onStaminaChange = Skills.onStaminaChange,
|
||||
onMagicLevelChange = Skills.onMagicLevelChange,
|
||||
onSkillChange = Skills.onSkillChange
|
||||
})
|
||||
|
||||
Keyboard.unbindKeyDown('Ctrl+S')
|
||||
skillsButton:destroy()
|
||||
skillsButton = nil
|
||||
|
@ -122,16 +146,3 @@ function Skills.onSkillChange(localPlayer, id, level, percent)
|
|||
setSkillPercent('skillId' .. id, percent, 'You have ' .. (100 - percent) .. ' percent to go')
|
||||
end
|
||||
|
||||
connect(g_game, { onGameStart = Skills.create,
|
||||
onGameEnd = Skills.destroy })
|
||||
|
||||
connect(LocalPlayer, {
|
||||
onExperienceChange = Skills.onExperienceChange,
|
||||
onLevelChange = Skills.onLevelChange,
|
||||
onHealthChange = Skills.onHealthChange,
|
||||
onManaChange = Skills.onManaChange,
|
||||
onSoulChange = Skills.onSoulChange,
|
||||
onFreeCapacityChange = Skills.onFreeCapacityChange,
|
||||
onStaminaChange = Skills.onStaminaChange,
|
||||
onMagicLevelChange = Skills.onMagicLevelChange,
|
||||
onSkillChange = Skills.onSkillChange })
|
||||
|
|
|
@ -28,15 +28,16 @@ SkillPercentPanel < ProgressBar
|
|||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
tooltip: 0
|
||||
phantom: false
|
||||
|
||||
MiniWindow
|
||||
id: skillWindow
|
||||
text: Skills
|
||||
height: 350
|
||||
icon: skills.png
|
||||
@onClose: Skills.toggle()
|
||||
|
||||
Panel
|
||||
id: skillPanel
|
||||
MiniWindowContents
|
||||
anchors.fill: parent
|
||||
layout: verticalBox
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 646 B |
|
@ -6,13 +6,13 @@ local vipButton
|
|||
local addVipWindow
|
||||
|
||||
-- public functions
|
||||
function VipList.create()
|
||||
vipWindow = displayUI('viplist.otui', GameInterface.getRightPanel())
|
||||
vipWindow:hide()
|
||||
vipButton = TopMenu.addGameButton('vipListButton', 'VIP list', 'viplist.png', VipList.toggle)
|
||||
function VipList.init()
|
||||
vipWindow = displayUI('viplist.otui', GameInterface.getLeftPanel())
|
||||
vipButton = TopMenu.addGameToggleButton('vipListButton', 'VIP list', 'viplist.png', VipList.toggle)
|
||||
vipButton:setOn(true)
|
||||
end
|
||||
|
||||
function VipList.destroy()
|
||||
function VipList.terminate()
|
||||
vipWindow:destroy()
|
||||
vipWindow = nil
|
||||
vipButton:destroy()
|
||||
|
@ -41,7 +41,7 @@ end
|
|||
|
||||
-- hooked events
|
||||
function VipList.onAddVip(id, name, online)
|
||||
local vipList = vipWindow:getChildById('vipList')
|
||||
local vipList = vipWindow:getChildById('contentsPanel')
|
||||
|
||||
local label = createWidget('VipListLabel', nil)
|
||||
label:setId('vip' .. id)
|
||||
|
|
|
@ -6,3 +6,7 @@ Module
|
|||
|
||||
@onLoad: |
|
||||
dofile 'viplist'
|
||||
VipList.init()
|
||||
|
||||
@onUnload:
|
||||
VipList.terminate()
|
||||
|
|
|
@ -7,9 +7,10 @@ MiniWindow
|
|||
id: vipWindow
|
||||
text: VIP List
|
||||
height: 100
|
||||
icon: viplist.png
|
||||
@onClose: VipList.toggle()
|
||||
|
||||
UIWidget
|
||||
id: vipList
|
||||
MiniWindowContents
|
||||
layout: verticalBox
|
||||
anchors.fill: parent
|
||||
&onMousePress: VipList.onVipListMousePress
|
||||
|
|
|
@ -18,7 +18,7 @@ end
|
|||
local function onUseWithMouseRelease(self, mousePosition, mouseButton)
|
||||
if g_game.selectedThing == nil then return false end
|
||||
if mouseButton == MouseLeftButton then
|
||||
local clickedWidget = g_game.gameUi:recursiveGetChildByPos(mousePosition)
|
||||
local clickedWidget = g_game.gameUi:recursiveGetChildByPos(mousePosition, false)
|
||||
if clickedWidget then
|
||||
if clickedWidget:getClassName() == 'UIMap' then
|
||||
local tile = clickedWidget:getTile(mousePosition)
|
||||
|
|
|
@ -53,7 +53,7 @@ TexturePtr TextureManager::getTexture(const std::string& textureFile)
|
|||
g_resources.loadFile(textureFile, fin);
|
||||
texture = loadPNG(fin);
|
||||
} catch(Exception& e) {
|
||||
Fw::throwException("unable to load texture '", textureFile, "': ", e.what());
|
||||
logError("unable to load texture '", textureFile, "': ", e.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,11 @@ void UIAnchorLayout::removeAnchors(const UIWidgetPtr& anchoredWidget)
|
|||
update();
|
||||
}
|
||||
|
||||
bool UIAnchorLayout::hasAnchors(const UIWidgetPtr& anchoredWidget)
|
||||
{
|
||||
return m_anchorsGroups.find(anchoredWidget) != m_anchorsGroups.end();
|
||||
}
|
||||
|
||||
void UIAnchorLayout::centerIn(const UIWidgetPtr& anchoredWidget, const std::string& hookedWidgetId)
|
||||
{
|
||||
addAnchor(anchoredWidget, Fw::AnchorHorizontalCenter, hookedWidgetId, Fw::AnchorHorizontalCenter);
|
||||
|
|
|
@ -66,6 +66,7 @@ public:
|
|||
void addAnchor(const UIWidgetPtr& anchoredWidget, Fw::AnchorEdge anchoredEdge,
|
||||
const std::string& hookedWidgetId, Fw::AnchorEdge hookedEdge);
|
||||
void removeAnchors(const UIWidgetPtr& anchoredWidget);
|
||||
bool hasAnchors(const UIWidgetPtr& anchoredWidget);
|
||||
void centerIn(const UIWidgetPtr& anchoredWidget, const std::string& hookedWidgetId);
|
||||
void fill(const UIWidgetPtr& anchoredWidget, const std::string& hookedWidgetId);
|
||||
|
||||
|
|
|
@ -37,8 +37,10 @@ void UILayout::update()
|
|||
|
||||
m_updating = true;
|
||||
internalUpdate();
|
||||
if(UIWidgetPtr parentWidget = getParentWidget())
|
||||
if(UIWidgetPtr parentWidget = getParentWidget()) {
|
||||
if(!parentWidget->isDestroyed())
|
||||
parentWidget->onLayoutUpdate();
|
||||
}
|
||||
m_updating = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ void UIManager::inputEvent(const InputEvent& event)
|
|||
break;
|
||||
case Fw::MousePressInputEvent:
|
||||
if(event.mouseButton == Fw::MouseLeftButton && m_mouseReceiver->isVisible()) {
|
||||
UIWidgetPtr pressedWidget = m_mouseReceiver->recursiveGetChildByPos(event.mousePos);
|
||||
UIWidgetPtr pressedWidget = m_mouseReceiver->recursiveGetChildByPos(event.mousePos, false);
|
||||
if(pressedWidget && !pressedWidget->isEnabled())
|
||||
pressedWidget = nullptr;
|
||||
updatePressedWidget(pressedWidget, event.mousePos);
|
||||
|
@ -219,7 +219,7 @@ void UIManager::updateHoveredWidget()
|
|||
return;
|
||||
|
||||
m_hoverUpdateScheduled = false;
|
||||
UIWidgetPtr hoveredWidget = m_rootWidget->recursiveGetChildByPos(g_window.getMousePosition());
|
||||
UIWidgetPtr hoveredWidget = m_rootWidget->recursiveGetChildByPos(g_window.getMousePosition(), false);
|
||||
if(hoveredWidget && !hoveredWidget->isEnabled())
|
||||
hoveredWidget = nullptr;
|
||||
|
||||
|
|
|
@ -635,7 +635,7 @@ void UIWidget::bindRectToParent()
|
|||
Rect boundRect = m_rect;
|
||||
UIWidgetPtr parent = getParent();
|
||||
if(parent) {
|
||||
Rect parentRect = parent->getRect();
|
||||
Rect parentRect = parent->getClippingRect();
|
||||
boundRect.bind(parentRect);
|
||||
}
|
||||
|
||||
|
@ -872,6 +872,14 @@ bool UIWidget::isVisible()
|
|||
return asUIWidget() == g_ui.getRootWidget();
|
||||
}
|
||||
|
||||
bool UIWidget::isAnchored()
|
||||
{
|
||||
if(UIWidgetPtr parent = getParent())
|
||||
if(UIAnchorLayoutPtr anchorLayout = parent->getAnchoredLayout())
|
||||
return anchorLayout->hasAnchors(asUIWidget());
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UIWidget::isChildLocked(const UIWidgetPtr& child)
|
||||
{
|
||||
auto it = std::find(m_lockedChildren.begin(), m_lockedChildren.end(), child);
|
||||
|
@ -1013,7 +1021,7 @@ UIWidgetPtr UIWidget::recursiveGetChildById(const std::string& id)
|
|||
return widget;
|
||||
}
|
||||
|
||||
UIWidgetPtr UIWidget::recursiveGetChildByPos(const Point& childPos)
|
||||
UIWidgetPtr UIWidget::recursiveGetChildByPos(const Point& childPos, bool wantsPhantom)
|
||||
{
|
||||
if(!containsChildPoint(childPos))
|
||||
return nullptr;
|
||||
|
@ -1021,10 +1029,10 @@ UIWidgetPtr UIWidget::recursiveGetChildByPos(const Point& childPos)
|
|||
for(auto it = m_children.rbegin(); it != m_children.rend(); ++it) {
|
||||
const UIWidgetPtr& child = (*it);
|
||||
if(child->isExplicitlyVisible() && child->containsPoint(childPos)) {
|
||||
UIWidgetPtr subChild = child->recursiveGetChildByPos(childPos);
|
||||
UIWidgetPtr subChild = child->recursiveGetChildByPos(childPos, wantsPhantom);
|
||||
if(subChild)
|
||||
return subChild;
|
||||
else if(!child->isPhantom())
|
||||
else if(wantsPhantom || !child->isPhantom())
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
@ -1043,7 +1051,6 @@ UIWidgetList UIWidget::recursiveGetChildrenByPos(const Point& childPos)
|
|||
UIWidgetList subChildren = child->recursiveGetChildrenByPos(childPos);
|
||||
if(!subChildren.empty())
|
||||
children.insert(children.end(), subChildren.begin(), subChildren.end());
|
||||
else if(!child->isPhantom())
|
||||
children.push_back(child);
|
||||
}
|
||||
}
|
||||
|
@ -1279,6 +1286,12 @@ void UIWidget::onGeometryChange(const Rect& oldRect, const Rect& newRect)
|
|||
|
||||
if(m_textWrap && oldRect.size() != newRect.size())
|
||||
updateText();
|
||||
|
||||
// move children that is outside the parent rect to inside again
|
||||
for(const UIWidgetPtr& child : m_children) {
|
||||
if(!child->isAnchored())
|
||||
child->bindRectToParent();
|
||||
}
|
||||
}
|
||||
|
||||
void UIWidget::onLayoutUpdate()
|
||||
|
|
|
@ -130,6 +130,7 @@ public:
|
|||
void setVirtualOffset(const Point& offset);
|
||||
|
||||
bool isVisible();
|
||||
bool isAnchored();
|
||||
bool isChildLocked(const UIWidgetPtr& child);
|
||||
bool hasChild(const UIWidgetPtr& child);
|
||||
int getChildIndex(const UIWidgetPtr& child);
|
||||
|
@ -144,7 +145,7 @@ public:
|
|||
UIWidgetPtr getChildByPos(const Point& childPos);
|
||||
UIWidgetPtr getChildByIndex(int index);
|
||||
UIWidgetPtr recursiveGetChildById(const std::string& id);
|
||||
UIWidgetPtr recursiveGetChildByPos(const Point& childPos);
|
||||
UIWidgetPtr recursiveGetChildByPos(const Point& childPos, bool wantsPhantom);
|
||||
UIWidgetList recursiveGetChildrenByPos(const Point& childPos);
|
||||
UIWidgetPtr backwardsGetWidgetById(const std::string& id);
|
||||
|
||||
|
|
Loading…
Reference in New Issue