From 8d14d9bc995e4e27c7caac73e7aeec82023a066b Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Wed, 28 Mar 2012 11:10:21 -0300 Subject: [PATCH] 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 --- modules/core_styles/styles/progressbars.otui | 2 +- modules/game/game.otmod | 7 +- modules/game/gameinterface.otui | 4 +- modules/game/images/miniwindowbuttons.png | Bin 551 -> 626 bytes modules/game/styles/miniwindow.otui | 32 +++-- modules/game/widgets/uiitem.lua | 2 +- modules/game/widgets/uiminiwindow.lua | 40 +++++- .../game/widgets/uiminiwindowcontainer.lua | 3 +- modules/game_battle/battle.lua | 47 ++++---- modules/game_battle/battle.otmod | 6 + modules/game_battle/battle.otui | 114 +++++++++--------- modules/game_battle/battle.png | Bin 2063 -> 1104 bytes modules/game_battle/battleButton.otui | 4 +- .../game_combatcontrols/combatcontrols.lua | 12 +- .../game_combatcontrols/combatcontrols.otui | 46 +++---- modules/game_healthbar/healthbar.lua | 12 +- modules/game_healthbar/healthbar.otui | 26 ++-- modules/game_hotkeys/hotkeys_manager.lua | 2 +- modules/game_inventory/inventory.lua | 14 ++- modules/game_inventory/inventory.otui | 7 +- modules/game_skills/skills.lua | 43 ++++--- modules/game_skills/skills.otui | 7 +- modules/game_skills/skills.png | Bin 0 -> 646 bytes modules/game_viplist/viplist.lua | 12 +- modules/game_viplist/viplist.otmod | 4 + modules/game_viplist/viplist.otui | 5 +- modules/old/game/game.lua | 2 +- src/framework/graphics/texturemanager.cpp | 2 +- src/framework/ui/uianchorlayout.cpp | 5 + src/framework/ui/uianchorlayout.h | 1 + src/framework/ui/uilayout.cpp | 4 +- src/framework/ui/uimanager.cpp | 4 +- src/framework/ui/uiwidget.cpp | 25 +++- src/framework/ui/uiwidget.h | 3 +- 34 files changed, 301 insertions(+), 196 deletions(-) create mode 100644 modules/game_skills/skills.png diff --git a/modules/core_styles/styles/progressbars.otui b/modules/core_styles/styles/progressbars.otui index e5f41c9a..889b3591 100644 --- a/modules/core_styles/styles/progressbars.otui +++ b/modules/core_styles/styles/progressbars.otui @@ -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 diff --git a/modules/game/game.otmod b/modules/game/game.otmod index 017b88b2..49b7344d 100644 --- a/modules/game/game.otmod +++ b/modules/game/game.otmod @@ -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: | diff --git a/modules/game/gameinterface.otui b/modules/game/gameinterface.otui index 8e003060..2c9c80ab 100644 --- a/modules/game/gameinterface.otui +++ b/modules/game/gameinterface.otui @@ -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 diff --git a/modules/game/images/miniwindowbuttons.png b/modules/game/images/miniwindowbuttons.png index 890d194c2b3dad28e8789d8973a424b61d8f0077..bc06501592f37fd775c78146eb58e2fc0d5e2944 100644 GIT binary patch delta 548 zcmV+<0^9wk1o8wSiBL{Q4GJ0x0000DNk~Le0000g0000g2nGNE0L8<}Tah6a3I729 z0RN!9r<0LDAP5``5e?8aLdub7EPu&KL_t(o!|hlxYr;Sjez7T{V}=aYp>*op-y)(Q z{)P^M#X^UGC4mgmp+7(bMf@$!PU2#R2z3xzN)(;$IO99brMaAeyv>(<^5uQsy?Z>( zFw1*LLFfPg`9e_$^!NJ%N#k_#W9$2ozBDOZE^djuqSbz-WLe_ugCSS?-PTv@QI;f2jM#w9#ZFXI@*qjf zpHifkg~R*kKH~K+5vQePD1XU8Nnu=z-r)>9>?VjSCp5kmXVRla}F55jR m-92SDQ`~nw`BKqH5_bS5u6>*c9n75o0000If~lvom7%Azl_+s0YQ;@lOeBioJ)Nx#aWRqD2ES?i{ArLTXZy4F?2Ll5hYHwIE)AjK{33e zsfr;YEQB_-MMYg3+)`u*tbbUw1}=xy!Us3b;Wb!6!-!~0u~~*;;e<)k=v!M%m^O!^ zgaZpkWS`;l!jut)u2IB8clvu?x P00000NkvXXu0mjfz?RGv diff --git a/modules/game/styles/miniwindow.otui b/modules/game/styles/miniwindow.otui index cde84ea2..4a44541d 100644 --- a/modules/game/styles/miniwindow.otui +++ b/modules/game/styles/miniwindow.otui @@ -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 diff --git a/modules/game/widgets/uiitem.lua b/modules/game/widgets/uiitem.lua index 4f2b1249..b99c5c34 100644 --- a/modules/game/widgets/uiitem.lua +++ b/modules/game/widgets/uiitem.lua @@ -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() diff --git a/modules/game/widgets/uiminiwindow.lua b/modules/game/widgets/uiminiwindow.lua index 10af00e7..aa04b7e3 100644 --- a/modules/game/widgets/uiminiwindow.lua +++ b/modules/game/widgets/uiminiwindow.lua @@ -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 + diff --git a/modules/game/widgets/uiminiwindowcontainer.lua b/modules/game/widgets/uiminiwindowcontainer.lua index 944bfd8c..a463c5d1 100644 --- a/modules/game/widgets/uiminiwindowcontainer.lua +++ b/modules/game/widgets/uiminiwindowcontainer.lua @@ -8,7 +8,8 @@ function UIMiniWindowContainer.create() end function UIMiniWindowContainer:onDrop(widget, mousePos) - print 'drop' + widget:setParent(self) + return true end function UIMiniWindowContainer:getClassName() diff --git a/modules/game_battle/battle.lua b/modules/game_battle/battle.lua index 67514e42..ca38a98a 100644 --- a/modules/game_battle/battle.lua +++ b/modules/game_battle/battle.lua @@ -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 } ) \ No newline at end of file diff --git a/modules/game_battle/battle.otmod b/modules/game_battle/battle.otmod index a1341672..f602bdcc 100644 --- a/modules/game_battle/battle.otmod +++ b/modules/game_battle/battle.otmod @@ -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() + diff --git a/modules/game_battle/battle.otui b/modules/game_battle/battle.otui index f235c4ca..f8258d97 100644 --- a/modules/game_battle/battle.otui +++ b/modules/game_battle/battle.otui @@ -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 + + diff --git a/modules/game_battle/battle.png b/modules/game_battle/battle.png index 247c6ec68f406aa9c1348e4b4a33643514ee6b7a..ed67347b491eef848304dbc2a71252d8efdb7985 100644 GIT binary patch delta 1083 zcmV-B1jPG~5YPyaB!2;OQb$4nuFf3k00006VoOIv0RI600RN!9r;`8x010qNS#tmY z3ljhU3ljkVnw%H_000McNliru+yfj9FdM17h))0j1JFrCK~y-)wUmEI+;teoU*Gfm zo?o?bZqA+GU9)qiY%Ge_4@8_`tq4Zo+K)e)%#gwrL{NX!=6?#x*!m+3!5fr_8~u@6 zjBYly5SIhdbAt0~Ig)ugJ(oZ7{E@fYJnx?VP`{f$=0?y14}8DR_xZedKF{-f-wF?~ z45y8`@X}b{&0!wZOv?kAPMr*=4R=i$=2!&oxg*Ucj`Yos1Xk{UairO3zkHgU-9;iq zao3a~BKI-{UVq#FA;iSc=NnSi0-KFWGj!UTs(Ef#p|oE<4Jf?)N)ebqqGGVmRegjK z4zaJeTy74GC~H>iNVC!9sp0wDH>9npniqE$&G$LQvf_Ym^ezD3e0_xd?^FKPVDGEu6Dgd?aOLTg?)b-91RpXfxShr3CAU?%L{xLV59xt`-ODng+tSFdcP11Gc z9C>*KY)iJVDcK6Zg~m4g!{c;%y!_yeBPwubHp*su5$3NE-4u^5~tX~4Ha+NG;gHbWS^q7Ah9GyqcMxyNA zVlv>q!4a-`>iA_am1~|le1jtfG%kF5^&dncg0g(6fhbY(9)~Jd2@TC1JejqJ?)G|y z$0liL?x4z5LiyWStM9Qy1jVEfoSHI%{{%xs5PwXVXl@_C47e&z(cNCpz^%XesmX(@ z;uLWTykF@dZZ-0D=Vq=qm$BWc%WoHt%Cp<-vNtPD4!z_QT~lSE?yS7}M5^=$0@CX3 zlcQzd%ewSk(jN#&>dt3G*HlT_nl5&$g+&K2U%xTL>u-Ii7@~dIEsmYMGy0hQr30FAh?8{G3#N zn$HI(FV633jNt1ZBRfH*?DG;n`RoJ@i5pSJhw!wv7`MJXGfi-65`d||I0eP;-6xX{ z8_m^6$Z*)Cw*0VsSGrGhO_hODCuQej7Jtz-Ra)LH5M5Ix_vuWrTP>`RRtx{R;)mIa;Vd)%>HNnQi7sQEaS1NDpCbYL%$9vLKS(h!(eHqh2e5Z zu~3#Ymlet;qoUB_crmOl608pmOr4S>8n0K&kb=caHUK)w(*kfJovqpi#pl7Q;tKJ+ zwPRFxa52-IBJSKciCn7$N--y@tV17;SMS+9apWfyZn9xCID@Iv2lms*v8+Ra!H>V( zw2=W>I?Vw6m?(C7TpslF_M^wEgKhsB6zr%OO2ezCj$o4%lph-+8W0~tX92iaa})RN z&8UCsg=R2eKu#nsE}GX&iAfBlb;=t_bY{6(5AL3Y#ZrXn2`VNgjN`o8Yj@ym?_&75 zW+Q0S{ay`|QseRDziy7xI^~TdI=!MmlN&=+MyA z3OeY=Y{wbe`tmjYykTeGC_C9wX@@abIf5}mZs5bZ5;13bs#uXdMXXztAyT3ZqNo0h z$onc;JnQZjx0_o;N%jhHBsbO$u?|XS92E{xzNmTAGz;9)B z95F=+IG%N4-dF?5_myJT-UGNC^Cg4qw;PAb@a}CN+iq7cYgcy{ii$S}*V!QW#ftC6 zsr{??Gh2_BiL6+a?Z%&rSm(^n6x88pH^G7(550nBOLo)YJvdQeLv`D0lo+2N;jJPb@wf^VNV76&`r&`*e`5FbCMvy<~9XUYj7kFXhs#MvbHOOJQhiwXL_ kJC1xwr2i=$N7j7C{?XF1hHCZH78*hR;^o%!x$F0R0I}Ge-~a#s diff --git a/modules/game_battle/battleButton.otui b/modules/game_battle/battleButton.otui index bfee2035..b75254dc 100644 --- a/modules/game_battle/battleButton.otui +++ b/modules/game_battle/battleButton.otui @@ -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 \ No newline at end of file + phantom: true diff --git a/modules/game_combatcontrols/combatcontrols.lua b/modules/game_combatcontrols/combatcontrols.lua index 3e64d33b..9048f75e 100644 --- a/modules/game_combatcontrols/combatcontrols.lua +++ b/modules/game_combatcontrols/combatcontrols.lua @@ -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) diff --git a/modules/game_combatcontrols/combatcontrols.otui b/modules/game_combatcontrols/combatcontrols.otui index e9a3af05..366ad8db 100644 --- a/modules/game_combatcontrols/combatcontrols.otui +++ b/modules/game_combatcontrols/combatcontrols.otui @@ -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() - FightOffensiveBox - id: fightOffensiveBox - anchors.right: next.left - FightBalancedBox - id: fightBalancedBox - anchors.right: next.left - FightDefensiveBox - id: fightDefensiveBox - anchors.horizontalCenter: parent.horizontalCenter - ChaseModeBox - id: chaseModeBox - anchors.left: prev.right - SafeFightBox - id: safeFightBox - anchors.left: prev.right + 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.centerIn: parent + ChaseModeBox + id: chaseModeBox + anchors.left: prev.right + anchors.top: prev.top + SafeFightBox + id: safeFightBox + anchors.left: prev.right + anchors.top: prev.top diff --git a/modules/game_healthbar/healthbar.lua b/modules/game_healthbar/healthbar.lua index 99b8cefc..bc861cb8 100644 --- a/modules/game_healthbar/healthbar.lua +++ b/modules/game_healthbar/healthbar.lua @@ -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 diff --git a/modules/game_healthbar/healthbar.otui b/modules/game_healthbar/healthbar.otui index dda120fe..d687bb4d 100644 --- a/modules/game_healthbar/healthbar.otui +++ b/modules/game_healthbar/healthbar.otui @@ -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,16 +33,15 @@ 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() - HealthBar - HealthLabel - ManaBar - ManaLabel + MiniWindowContents + HealthBar + HealthLabel + ManaBar + ManaLabel diff --git a/modules/game_hotkeys/hotkeys_manager.lua b/modules/game_hotkeys/hotkeys_manager.lua index c1b81100..133c229a 100644 --- a/modules/game_hotkeys/hotkeys_manager.lua +++ b/modules/game_hotkeys/hotkeys_manager.lua @@ -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) diff --git a/modules/game_inventory/inventory.lua b/modules/game_inventory/inventory.lua index 96bd2021..c14d8e8a 100644 --- a/modules/game_inventory/inventory.lua +++ b/modules/game_inventory/inventory.lua @@ -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 diff --git a/modules/game_inventory/inventory.otui b/modules/game_inventory/inventory.otui index 03cbd647..f787ed48 100644 --- a/modules/game_inventory/inventory.otui +++ b/modules/game_inventory/inventory.otui @@ -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 diff --git a/modules/game_skills/skills.lua b/modules/game_skills/skills.lua index a125f486..bb44bd3e 100644 --- a/modules/game_skills/skills.lua +++ b/modules/game_skills/skills.lua @@ -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 }) diff --git a/modules/game_skills/skills.otui b/modules/game_skills/skills.otui index a9909c56..a716d440 100644 --- a/modules/game_skills/skills.otui +++ b/modules/game_skills/skills.otui @@ -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 diff --git a/modules/game_skills/skills.png b/modules/game_skills/skills.png new file mode 100644 index 0000000000000000000000000000000000000000..52deb107b711b43d0c0c803a17d31ec4e7a452b3 GIT binary patch literal 646 zcmV;10(t$3P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L00!&;00!&<9(6c100007bV*G`2iyS< z0s%1aZJLn)00IU{L_t(I%bk-kYZO5khM(`-J+rsFx3@_ynka`z2zX$1S_EuTSX)|0 z77+{m0k(oaLO2CUC$aD+*qcTRF{L6xt~ip5n%vHO7PoszKt%mu7#QZAdEe)o5r9r- zDH#s;t^&s2m2^5wABV%e!+K%E{;_}!fN(GvP!xp+7>|y*w{^f$OK6=F;-=7w0$P!f z&IxHGbTiMj)fB)3gq4Faz_AN>c1JM*5yea}0dHU!-eBT{)0(g-3V;k?a`c5qZ(^3) zO5TJl7TU3rHHB6r^v*ky*a3+F+4jz4=D-8|ES0Td0v3P?Wf|ba5c8M_r76yb0P@=i zX{6lWYSOzH&|M6;(RJjJp{j@oqDm0VIx*fmFmx~&%p%0u0#9#yHrE}u)+WqHh6X_; z3{X`9)%t+!{bzSJf~Yc|z;us*D2M<79w_}xY=HmpwWLPcH?wz#`$HbS3R!6@d7|Xa z>D+EAE4k2H1~X_h8i>esV5fGFO(DYbO@TlvPFjun9y#qGTYud>8zF8ecVEDT4AKaa z$dk@N8VSjqkVFtQgqy3=E`0hngbHHc%*?zubNgm~Z03KMl}F~vV{_%iyerMTGc#X5 zisDestroyed()) parentWidget->onLayoutUpdate(); + } m_updating = false; } diff --git a/src/framework/ui/uimanager.cpp b/src/framework/ui/uimanager.cpp index 7a806411..412825af 100644 --- a/src/framework/ui/uimanager.cpp +++ b/src/framework/ui/uimanager.cpp @@ -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; diff --git a/src/framework/ui/uiwidget.cpp b/src/framework/ui/uiwidget.cpp index d95f935c..a516ee90 100644 --- a/src/framework/ui/uiwidget.cpp +++ b/src/framework/ui/uiwidget.cpp @@ -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,8 +1051,7 @@ 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); + children.push_back(child); } } return children; @@ -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() diff --git a/src/framework/ui/uiwidget.h b/src/framework/ui/uiwidget.h index c297cb41..d678c998 100644 --- a/src/framework/ui/uiwidget.h +++ b/src/framework/ui/uiwidget.h @@ -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);