diff --git a/modules/core_styles/images/interface_panel.png b/modules/core_styles/images/interface_panel.png index 7943a0d0..a8e1b081 100644 Binary files a/modules/core_styles/images/interface_panel.png and b/modules/core_styles/images/interface_panel.png differ diff --git a/modules/core_styles/images/interface_panel2.png b/modules/core_styles/images/interface_panel2.png new file mode 100644 index 00000000..70e8d6b9 Binary files /dev/null and b/modules/core_styles/images/interface_panel2.png differ diff --git a/modules/core_styles/images/mini_window.png b/modules/core_styles/images/mini_window.png new file mode 100644 index 00000000..fb11621f Binary files /dev/null and b/modules/core_styles/images/mini_window.png differ diff --git a/modules/core_styles/images/top_panel.png b/modules/core_styles/images/top_panel.png index fd9f434c..e3ea84e7 100644 Binary files a/modules/core_styles/images/top_panel.png and b/modules/core_styles/images/top_panel.png differ diff --git a/modules/core_styles/styles/panels.otui b/modules/core_styles/styles/panels.otui index fde10861..6e4dfd72 100644 --- a/modules/core_styles/styles/panels.otui +++ b/modules/core_styles/styles/panels.otui @@ -21,6 +21,12 @@ InterfacePanel < Panel source: /core_styles/images/interface_panel.png border: 4 +InterfacePanel2 < Panel + focusable: false + border-image: + source: /core_styles/images/interface_panel2.png + border: 4 + MapPanel < UIMap map margin: 4 border-image: diff --git a/modules/core_styles/styles/windows.otui b/modules/core_styles/styles/windows.otui index a23bf97e..960be2de 100644 --- a/modules/core_styles/styles/windows.otui +++ b/modules/core_styles/styles/windows.otui @@ -5,6 +5,7 @@ Window < UIWindow background-color: white head height: 20 head text align: center + free move: true border-image: source: /core_styles/images/window.png border: 4 @@ -13,5 +14,20 @@ Window < UIWindow state.pressed: opacity: 192 +MiniWindow < UIWindow + font: verdana-11px-antialised + size: 192 200 + head height: 25 + head text align: center + margin.top: 6 + margin.left: 6 + margin.right: 6 + margin.bottom: 6 + free move: true + border-image: + source: /core_styles/images/mini_window.png + border: 4 + border.top: 25 + MainWindow < Window anchors.centerIn: parent \ No newline at end of file diff --git a/modules/game/game.lua b/modules/game/game.lua index 0bc74031..f583dfdd 100644 --- a/modules/game/game.lua +++ b/modules/game/game.lua @@ -17,7 +17,8 @@ end -- public functions function Game.create() Game.gameUi = loadUI('/game/ui/gameinterface.otui', UI.root) - Game.gameMapUi = Game.gameUi:getChildById('gameMap') + Game.gameMapPanel = Game.gameUi:getChildById('mapPanel') + Game.gameRightPanel = Game.gameUi:getChildById('rightPanel') Game.gameUi.onKeyPress = onGameKeyPress TextMessage.create() @@ -33,7 +34,7 @@ end function Game.show() Game.gameUi:show() Game.gameUi:focus() - Game.gameMapUi:focus() + Game.gameMapPanel:focus() end function Game.hide() diff --git a/modules/game/textmessage.lua b/modules/game/textmessage.lua index efc800e5..a1fd61f6 100644 --- a/modules/game/textmessage.lua +++ b/modules/game/textmessage.lua @@ -22,10 +22,10 @@ local messageTypes = { -- public functions function TextMessage.create() bottomLabelWidget = UILabel.create() - Game.gameMapUi:addChild(bottomLabelWidget) + Game.gameMapPanel:addChild(bottomLabelWidget) centerLabelWidget = UILabel.create() - Game.gameMapUi:addChild(centerLabelWidget) + Game.gameMapPanel:addChild(centerLabelWidget) end -- hooked events diff --git a/modules/game/ui/gameinterface.otui b/modules/game/ui/gameinterface.otui index b62906f1..af813472 100644 --- a/modules/game/ui/gameinterface.otui +++ b/modules/game/ui/gameinterface.otui @@ -6,11 +6,12 @@ UIWidget InterfacePanel id: rightPanel width: 200 + layout: verticalBox anchors.right: parent.right anchors.top: parent.top anchors.bottom: parent.bottom - InterfacePanel + InterfacePanel2 id: bottomPanel height: 140 anchors.left: parent.left @@ -18,7 +19,7 @@ UIWidget anchors.bottom: parent.bottom MapPanel - id: gameMap + id: mapPanel anchors.left: parent.left anchors.right: rightPanel.left anchors.top: parent.top diff --git a/modules/game/ui/textmessage.otui b/modules/game/ui/textmessage.otui index 31b7020b..38e1135d 100644 --- a/modules/game/ui/textmessage.otui +++ b/modules/game/ui/textmessage.otui @@ -11,6 +11,7 @@ BottomLabel < Label font: verdana-11px-rounded height: 16 align: center + margin.bottom: 2 anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right diff --git a/modules/skills/skills.lua b/modules/skills/skills.lua index 839bf94d..c73f6b7c 100644 --- a/modules/skills/skills.lua +++ b/modules/skills/skills.lua @@ -1,9 +1,12 @@ -skillWindow = nil +Skills = {} +-- private variables +local skillWindow = nil local skills = {"Fist Fighting", "Club Fighting", "Sword Fighting", "Axe Fighting", "Distance Fighting", "Shielding", "Fishing"} -function csw() - skillWindow = loadUI("/game/ui/skillwindow.otui", UI.root) +-- public functions +function Skills.create() + skillWindow = loadUI("/skills/skills.otui", Game.gameRightPanel) local skillPanel = skillWindow:getChildById('skillPanel') @@ -31,6 +34,12 @@ function csw() end end +function Skills.destroy() + skillWindow:destroy() + skillWindow = nil +end + +-- hooked events function Game.setSkill(id, level, percent) local skillPanel = skillWindow:getChildById('skillPanel') local levelLabel = skillPanel:getChildById('skillLevel' .. id) diff --git a/modules/skills/skills.otmod b/modules/skills/skills.otmod index e69de29b..fd9152d9 100644 --- a/modules/skills/skills.otmod +++ b/modules/skills/skills.otmod @@ -0,0 +1,18 @@ +Module + name: skills + description: Manage skills window + author: OTClient team + website: https://github.com/edubart/otclient + autoLoad: true + dependencies: + - game + + onLoad: | + require 'skills' + Skills.create() + return true + + onUnload: + Skills.destroy() + + diff --git a/modules/skills/skills.otui b/modules/skills/skills.otui index 30c2db8a..914e8de0 100644 --- a/modules/skills/skills.otui +++ b/modules/skills/skills.otui @@ -33,15 +33,15 @@ SkillPercentPanel < UIWidget anchors.left: parent.left anchors.right: parent.right -Window +MiniWindow id: skillWindow title: Skills - size: 200 200 + size: 200 185 Panel id: skillPanel anchors.fill: parent - margin.top: 19 + margin.top: 26 margin.bottom: 3 margin.left: 3 margin.right: 3 \ No newline at end of file diff --git a/modules/topmenu/topmenu.otui b/modules/topmenu/topmenu.otui index 0a6f02d4..7a0d0fca 100644 --- a/modules/topmenu/topmenu.otui +++ b/modules/topmenu/topmenu.otui @@ -9,7 +9,7 @@ TopPanel id: settingsButton anchors.top: parent.top anchors.left: parent.left - margin.top: 3 + margin.top: 4 margin.left: 6 onClick: Options.create() @@ -39,7 +39,7 @@ TopPanel TopButton anchors.top: parent.top anchors.right: parent.right - margin.top: 3 + margin.top: 4 margin.right: 6 onClick: | if Game.isOnline() then @@ -57,7 +57,7 @@ TopPanel TopButton anchors.top: parent.top anchors.right: prev.left - margin.top: 3 + margin.top: 4 margin.right: 6 onClick: About.create() diff --git a/modules/viplist/viplist.lua b/modules/viplist/viplist.lua index b5de510b..01651c81 100644 --- a/modules/viplist/viplist.lua +++ b/modules/viplist/viplist.lua @@ -1,9 +1,19 @@ -vipWindow = nil +VipList = {} -function createVipWindow() - vipWindow = loadUI("/game/ui/vipwindow.otui", Game.gameUi) +-- private variables +local vipWindow = nil + +-- public functions +function VipList.create() + vipWindow = loadUI("/viplist/viplist.otui", Game.gameRightPanel) +end + +function VipList.destroy() + vipWindow:destroy() + vipWindow = nil end +-- hooked events function Game.onAddVip(id, name, online) local vipList = vipWindow:getChildById('vipList') diff --git a/modules/viplist/viplist.otmod b/modules/viplist/viplist.otmod index e69de29b..cde05e4f 100644 --- a/modules/viplist/viplist.otmod +++ b/modules/viplist/viplist.otmod @@ -0,0 +1,18 @@ +Module + name: viplist + description: Manage vip list window + author: OTClient team + website: https://github.com/edubart/otclient + autoLoad: true + dependencies: + - game + + onLoad: | + require 'viplist' + VipList.create() + return true + + onUnload: + VipList.destroy() + + diff --git a/modules/viplist/viplist.otui b/modules/viplist/viplist.otui index 3d57ee93..8829fe92 100644 --- a/modules/viplist/viplist.otui +++ b/modules/viplist/viplist.otui @@ -1,16 +1,15 @@ VipListLabel < Label font: verdana-11px-monochrome - margin.left: 30 + margin.left: 5 -Window +MiniWindow id: vipWindow - title: VIP - size: 200 200 + title: VIP List TextList id: vipList anchors.fill: parent - margin.top: 19 - margin.bottom: 3 - margin.left: 3 - margin.right: 3 + margin.top: 26 + margin.bottom: 6 + margin.left: 6 + margin.right: 6 diff --git a/src/framework/ui/uiwindow.cpp b/src/framework/ui/uiwindow.cpp index c5d6685d..4b38b446 100644 --- a/src/framework/ui/uiwindow.cpp +++ b/src/framework/ui/uiwindow.cpp @@ -30,6 +30,7 @@ void UIWindow::setup() { UIWidget::setup(); m_moving = false; + m_freeMove = false; m_headHeight = 0; m_titleAlign = Fw::AlignCenter; } @@ -69,6 +70,8 @@ void UIWindow::onStyleApply(const OTMLNodePtr& styleNode) setTitle(node->value()); else if(node->tag() == "head text align") m_titleAlign = Fw::translateAlignment(node->value()); + else if(node->tag() == "free move") + m_freeMove = node->value(); else if(node->tag() == "onEnter") { g_lua.loadFunction(node->value(), "@" + node->source() + "[" + node->tag() + "]"); luaSetField(node->tag()); @@ -112,10 +115,12 @@ void UIWindow::onFocusChange(bool focused, Fw::FocusReason reason) bool UIWindow::onMousePress(const Point& mousePos, Fw::MouseButton button) { - UIWidgetPtr clickedChild = getChildByPos(mousePos); - if(!clickedChild || clickedChild->isPhantom()) { - m_moving = true; - m_movingReference = mousePos - getRect().topLeft(); + if(m_freeMove) { + UIWidgetPtr clickedChild = getChildByPos(mousePos); + if(!clickedChild || clickedChild->isPhantom()) { + m_moving = true; + m_movingReference = mousePos - getRect().topLeft(); + } } return UIWidget::onMousePress(mousePos, button); } diff --git a/src/framework/ui/uiwindow.h b/src/framework/ui/uiwindow.h index d87c67f4..48b5e010 100644 --- a/src/framework/ui/uiwindow.h +++ b/src/framework/ui/uiwindow.h @@ -46,6 +46,7 @@ protected: private: std::string m_title; bool m_moving; + bool m_freeMove; Point m_movingReference; // styling