diff --git a/modules/about/about.lua b/modules/about/about.lua new file mode 100644 index 00000000..e25fa8af --- /dev/null +++ b/modules/about/about.lua @@ -0,0 +1,19 @@ +About = {} + +-- private variables +local about + +-- public functions +function About.create() + about = UI.loadAndDisplay("/about/about.otui") + UI.root:lockChild(about) +end + +function About.destroy() + about:destroy() + about = nil +end + +function About.openWebpage() + displayErrorBox("Error", "Not implemented yet") +end \ No newline at end of file diff --git a/modules/about/about.otmod b/modules/about/about.otmod new file mode 100644 index 00000000..7c1a14c4 --- /dev/null +++ b/modules/about/about.otmod @@ -0,0 +1,13 @@ +Module + name: about + description: Create the about window + author: OTClient team + website: https://github.com/edubart/otclient + autoLoad: true + dependencies: + - core + + onLoad: | + require 'about' + return true + diff --git a/modules/about/about.otui b/modules/about/about.otui new file mode 100644 index 00000000..a92e93bc --- /dev/null +++ b/modules/about/about.otui @@ -0,0 +1,61 @@ +MainWindow + id: about + title: Info + size: 244 221 + + FlatPanel + size: 208 129 + anchors.left: parent.left + anchors.top: parent.top + margin.top: 32 + margin.left: 18 + + Label + align: center + text: |- + OTClient + Version 0.2.0 + Created by edubart + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + margin.top: 20 + + HorizontalSeparator + size: 190 2 + anchors.left: parent.left + anchors.top: parent.top + margin.top: 83 + margin.left: 9 + + Label + text: Official Website + anchors.left: parent.left + anchors.bottom: parent.bottom + margin.bottom: 14 + margin.left: 9 + + Button + text: Github Page + size: 88 24 + anchors.right: parent.right + anchors.bottom: parent.bottom + margin.bottom: 9 + margin.right: 9 + onClick: About.openWebpage() + + HorizontalSeparator + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + margin.bottom: 40 + margin.left: 13 + margin.right: 13 + + Button + text: Ok + size: 46 24 + anchors.left: parent.left + anchors.top: parent.top + margin.top: 191 + margin.left: 188 + onClick: About.destroy() diff --git a/modules/core_styles/images/interface_panel.png b/modules/core_styles/images/interface_panel.png new file mode 100644 index 00000000..7943a0d0 Binary files /dev/null and b/modules/core_styles/images/interface_panel.png differ diff --git a/modules/core_styles/images/map_panel.png b/modules/core_styles/images/map_panel.png new file mode 100644 index 00000000..8f113879 Binary files /dev/null and b/modules/core_styles/images/map_panel.png differ diff --git a/modules/core_styles/images/panel_rounded.png b/modules/core_styles/images/panel_rounded.png deleted file mode 100644 index e4b33872..00000000 Binary files a/modules/core_styles/images/panel_rounded.png and /dev/null differ diff --git a/modules/core_styles/images/top_panel.png b/modules/core_styles/images/top_panel.png index 284378f4..fd9f434c 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 9baaf638..fde10861 100644 --- a/modules/core_styles/styles/panels.otui +++ b/modules/core_styles/styles/panels.otui @@ -1,23 +1,28 @@ Panel < UIWidget phantom: true +RectPanel < UIWidget + image: /core_styles/images/empty_rect.png + FlatPanel < Panel border-image: source: /core_styles/images/panel_flat.png border: 4 TopPanel < Panel - height: 34 + height: 36 image: source: /core_styles/images/top_panel.png repeated: true -RoundedPanel < Panel - background-color: #ffffffdd +InterfacePanel < Panel + focusable: false border-image: - source: /core_styles/images/panel_rounded.png + source: /core_styles/images/interface_panel.png border: 4 - -RectPanel < UIWidget - image: /core_styles/images/empty_rect.png \ No newline at end of file +MapPanel < UIMap + map margin: 4 + border-image: + source: /core_styles/images/map_panel.png + border: 4 \ No newline at end of file diff --git a/modules/entergame/characterlist.lua b/modules/entergame/characterlist.lua index 921d2a3f..49f98714 100644 --- a/modules/entergame/characterlist.lua +++ b/modules/entergame/characterlist.lua @@ -91,12 +91,15 @@ end function CharacterList.destroy() CharacterList.hide() - EnterGame.show() + if not Game.isOnline then + EnterGame.show() + end end function CharacterList.show() if not loadBox then charactersWindow:show() + charactersWindow:focus() end end diff --git a/modules/entergame/entergame.lua b/modules/entergame/entergame.lua index 8407404e..952fcc3c 100644 --- a/modules/entergame/entergame.lua +++ b/modules/entergame/entergame.lua @@ -43,6 +43,7 @@ end function EnterGame.show() enterGame:show() + enterGame:focus() end function EnterGame.hide() diff --git a/modules/game/game.lua b/modules/game/game.lua index 76c826f6..0bc74031 100644 --- a/modules/game/game.lua +++ b/modules/game/game.lua @@ -1,6 +1,4 @@ require 'textmessage' -require 'skill' -require 'vip' -- private functions local function onGameKeyPress(self, keyCode, keyChar, keyboardModifiers) @@ -16,28 +14,37 @@ local function onGameKeyPress(self, keyCode, keyChar, keyboardModifiers) return false end -local function createMainInterface() +-- public functions +function Game.create() Game.gameUi = loadUI('/game/ui/gameinterface.otui', UI.root) Game.gameMapUi = Game.gameUi:getChildById('gameMap') Game.gameUi.onKeyPress = onGameKeyPress - createTextInterface() - createVipWindow() + TextMessage.create() end - -local function destroyMainInterface() +function Game.destroy() if Game.gameUi then Game.gameUi:destroy() Game.gameUi = nil end end --- public functions +function Game.show() + Game.gameUi:show() + Game.gameUi:focus() + Game.gameMapUi:focus() +end + +function Game.hide() + Game.gameUi:hide() +end + +-- hooked events function Game.onLogin() Background.hide() CharacterList.destroyLoadBox() - createMainInterface() + Game.show() end function Game.onLoginError(message) @@ -53,7 +60,7 @@ function Game.onConnectionError(message) end function Game.onLogout() + Game.hide() Background.show() CharacterList.show() - destroyMainInterface() end diff --git a/modules/game/game.otmod b/modules/game/game.otmod index fe0c91bd..c1efc1df 100644 --- a/modules/game/game.otmod +++ b/modules/game/game.otmod @@ -3,7 +3,6 @@ Module description: Create the game interface, where the ingame stuff starts author: OTClient team website: https://github.com/edubart/otclient - version: 0.2 autoLoad: true dependencies: - core @@ -14,4 +13,7 @@ Module onLoad: | require 'game' + require 'textmessage' + Game.create() + Game.hide() return true diff --git a/modules/game/textmessage.lua b/modules/game/textmessage.lua index 275203cc..efc800e5 100644 --- a/modules/game/textmessage.lua +++ b/modules/game/textmessage.lua @@ -1,37 +1,41 @@ -importStyles('/game/ui/textmessage.otui') +TextMessage = {} -local bottomLabelWidget, centerLabelWidget +-- require styles +importStyles '/game/ui/textmessage.otui' +-- private variables +local bottomLabelWidget, centerLabelWidget local messageTypes = { -first = 12, -{ type = 'MessageOrange', color = '#C87832', showOnConsole = true, showOnWindow = false }, -{ type = 'MessageOrange', color = '#C87832', showOnConsole = true, showOnWindow = false }, -{ type = 'MessageRed', color = '#C83200', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, -{ type = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, -{ type = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' }, -{ type = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' }, -{ type = 'MessageGreen', color = '#3FBE32', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, -{ type = 'MessageWhite', color = '#FFFFFF', showOnConsole = false, showOnWindow = true, windowLocation = 'BottomLabel' }, -{ type = 'MessageBlue', color = '#3264C8', showOnConsole = true, showOnWindow = false }, -{ type = 'MessageRed', color = '#C83200', showOnConsole = true, showOnWindow = false } + first = 12, + { type = 'MessageOrange', color = '#C87832', showOnConsole = true, showOnWindow = false }, + { type = 'MessageOrange', color = '#C87832', showOnConsole = true, showOnWindow = false }, + { type = 'MessageRed', color = '#C83200', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, + { type = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, + { type = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' }, + { type = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' }, + { type = 'MessageGreen', color = '#3FBE32', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, + { type = 'MessageWhite', color = '#FFFFFF', showOnConsole = false, showOnWindow = true, windowLocation = 'BottomLabel' }, + { type = 'MessageBlue', color = '#3264C8', showOnConsole = true, showOnWindow = false }, + { type = 'MessageRed', color = '#C83200', showOnConsole = true, showOnWindow = false } } -function createTextInterface() +-- public functions +function TextMessage.create() bottomLabelWidget = UILabel.create() Game.gameMapUi:addChild(bottomLabelWidget) - + centerLabelWidget = UILabel.create() Game.gameMapUi:addChild(centerLabelWidget) end +-- hooked events function Game.onTextMessage(type, message) - local messageType = messageTypes[type - messageTypes.first] - + if messageType.showOnConsole then -- TODO end - + if messageType.showOnWindow then local label if messageType.windowLocation == 'BottomLabel' then @@ -39,18 +43,16 @@ function Game.onTextMessage(type, message) elseif messageType.windowLocation == 'CenterLabel' then label = centerLabelWidget end - + label:setVisible(true) label:setForegroundColor(messageType.color) label:setText(message) - + label:setStyle(messageType.windowLocation) - + time = #message * 75 scheduleEvent(function() label:setVisible(false) end, time) end - end - diff --git a/modules/game/ui/gameinterface.otui b/modules/game/ui/gameinterface.otui index 619b27a2..b62906f1 100644 --- a/modules/game/ui/gameinterface.otui +++ b/modules/game/ui/gameinterface.otui @@ -2,9 +2,24 @@ UIWidget id: gameRootInterface anchors.fill: parent anchors.top: topMenu.bottom - margin.top: 1 - UIMap + InterfacePanel + id: rightPanel + width: 200 + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + + InterfacePanel + id: bottomPanel + height: 140 + anchors.left: parent.left + anchors.right: rightPanel.left + anchors.bottom: parent.bottom + + MapPanel id: gameMap - anchors.fill:parent - margin.right: 200 \ No newline at end of file + anchors.left: parent.left + anchors.right: rightPanel.left + anchors.top: parent.top + anchors.bottom: bottomPanel.top \ No newline at end of file diff --git a/modules/options/options.lua b/modules/options/options.lua new file mode 100644 index 00000000..ade5a6fa --- /dev/null +++ b/modules/options/options.lua @@ -0,0 +1,19 @@ +Options = {} + +-- private variables +local options + +-- public functions +function Options.create() + options = UI.loadAndDisplay("/options/options.otui") + UI.root:lockChild(options) +end + +function Options.destroy() + options:destroy() + options = nil +end + +function Options.openWebpage() + displayErrorBox("Error", "Not implemented yet") +end \ No newline at end of file diff --git a/modules/options/options.otmod b/modules/options/options.otmod new file mode 100644 index 00000000..254ca702 --- /dev/null +++ b/modules/options/options.otmod @@ -0,0 +1,13 @@ +Module + name: options + description: Create the options window + author: OTClient team + website: https://github.com/edubart/otclient + autoLoad: true + dependencies: + - core + + onLoad: | + require 'options' + return true + diff --git a/modules/options/options.otui b/modules/options/options.otui new file mode 100644 index 00000000..d074a9e5 --- /dev/null +++ b/modules/options/options.otui @@ -0,0 +1,116 @@ +MainWindow + id: optionsWindow + title: Options + size: 286 262 + + // general + Button + text: General + anchors.left: parent.left + anchors.top: parent.top + margin.left: 18 + margin.top: 32 + onClick: displayErrorBox("Error", "Not implemented yet") + + Label + text: |- + Change general + game options + anchors.left: prev.right + anchors.top: prev.top + margin.left: 10 + margin.top: -2 + + // graphics + Button + text: Graphics + anchors.left: parent.left + anchors.top: parent.top + margin.left: 18 + margin.top: 65 + onClick: displayErrorBox("Error", "Not implemented yet") + + Label + text: |- + Change graphics and + performance settings + anchors.left: prev.right + anchors.top: prev.top + margin.left: 10 + margin.top: -2 + + // console + Button + text: Console + anchors.left: parent.left + anchors.top: parent.top + margin.left: 18 + margin.top: 98 + onClick: displayErrorBox("Error", "Not implemented yet") + + Label + text: Customise the console + anchors.left: prev.right + anchors.top: prev.top + margin.left: 10 + margin.top: -2 + + // hotkeys + Button + text: Hotkeys + anchors.left: parent.left + anchors.top: parent.top + margin.left: 18 + margin.top: 131 + onClick: displayErrorBox("Error", "Not implemented yet") + + Label + text: Edit your hotkey texts + anchors.left: prev.right + anchors.top: prev.top + margin.left: 10 + margin.top: -2 + + HorizontalSeparator + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + margin.bottom: 97 + margin.left: 18 + margin.right: 18 + + // motd + Button + text: Motd + anchors.left: parent.left + anchors.bottom: parent.bottom + margin.left: 18 + margin.bottom: 60 + onClick: displayErrorBox("Error", "Not implemented yet") + + Label + text: |- + Show the most recent + Message of the Day + anchors.left: prev.right + anchors.top: prev.top + margin.left: 10 + margin.top: -2 + + HorizontalSeparator + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + margin.bottom: 40 + margin.left: 13 + margin.right: 13 + + // ok button + Button + text: Ok + width: 64 + anchors.right: parent.right + anchors.bottom: parent.bottom + margin.right: 10 + margin.bottom: 10 + onClick: Options.destroy() \ No newline at end of file diff --git a/modules/game/skill.lua b/modules/skills/skills.lua similarity index 97% rename from modules/game/skill.lua rename to modules/skills/skills.lua index d2810290..839bf94d 100644 --- a/modules/game/skill.lua +++ b/modules/skills/skills.lua @@ -1,32 +1,30 @@ skillWindow = nil -local skills = {"Fist Fighting", "Club Fighting", "Sword Fighting", "Axe Fighting", "Distance Fighting", "Shielding", "Fishing"} +local skills = {"Fist Fighting", "Club Fighting", "Sword Fighting", "Axe Fighting", "Distance Fighting", "Shielding", "Fishing"} function csw() skillWindow = loadUI("/game/ui/skillwindow.otui", UI.root) - + local skillPanel = skillWindow:getChildById('skillPanel') - + -- create first widget cause of layout local widget = UIWidget.create() skillPanel:addChild(widget) widget:setStyle('SkillFirstWidget') - + -- create skills for i=1,#skills,1 do local nameLabel = UILabel.create() skillPanel:addChild(nameLabel) nameLabel:setStyle('SkillNameLabel') nameLabel:setText(skills[i]) - local levelLabel = UILabel.create() skillPanel:addChild(levelLabel) levelLabel:setStyle('SkillLevelLabel') levelLabel:setId('skillLevelId' .. i) levelLabel:setText('10') - - + local percentPanel = UIWidget.create() skillPanel:addChild(percentPanel) percentPanel:setStyle('SkillPercentPanel') @@ -36,5 +34,4 @@ end function Game.setSkill(id, level, percent) local skillPanel = skillWindow:getChildById('skillPanel') local levelLabel = skillPanel:getChildById('skillLevel' .. id) -end - +end \ No newline at end of file diff --git a/modules/skills/skills.otmod b/modules/skills/skills.otmod new file mode 100644 index 00000000..e69de29b diff --git a/modules/game/ui/skillwindow.otui b/modules/skills/skills.otui similarity index 97% rename from modules/game/ui/skillwindow.otui rename to modules/skills/skills.otui index 26d61e48..30c2db8a 100644 --- a/modules/game/ui/skillwindow.otui +++ b/modules/skills/skills.otui @@ -44,4 +44,4 @@ Window margin.top: 19 margin.bottom: 3 margin.left: 3 - margin.right: 3 + margin.right: 3 \ No newline at end of file diff --git a/modules/topmenu/topmenu.otui b/modules/topmenu/topmenu.otui index 1d444644..0a6f02d4 100644 --- a/modules/topmenu/topmenu.otui +++ b/modules/topmenu/topmenu.otui @@ -11,6 +11,7 @@ TopPanel anchors.left: parent.left margin.top: 3 margin.left: 6 + onClick: Options.create() UIWidget size: 16 16 @@ -22,7 +23,12 @@ TopPanel anchors.top: prev.top anchors.left: prev.right margin.left: 6 - onClick: EnterGame.show() + onClick: | + if Game.isOnline() then + CharacterList.show() + else + EnterGame.show() + end UIWidget size: 16 16 @@ -46,4 +52,17 @@ TopPanel size: 16 16 image: /core_styles/icons/logout.png anchors.centerIn: parent + phantom: true + + TopButton + anchors.top: parent.top + anchors.right: prev.left + margin.top: 3 + margin.right: 6 + onClick: About.create() + + UIWidget + size: 16 16 + image: /core_styles/icons/about.png + anchors.centerIn: parent phantom: true \ No newline at end of file diff --git a/modules/game/vip.lua b/modules/viplist/viplist.lua similarity index 98% rename from modules/game/vip.lua rename to modules/viplist/viplist.lua index 8cc575c0..b5de510b 100644 --- a/modules/game/vip.lua +++ b/modules/viplist/viplist.lua @@ -6,31 +6,31 @@ end function Game.onAddVip(id, name, online) local vipList = vipWindow:getChildById('vipList') - + local label = UILabel.create() vipList:addChild(label) label:setId('vip' .. id) label:setText(name) label:setStyle('VipListLabel') - + if online then label:setForegroundColor('#00ff00') else label:setForegroundColor('#ff0000') end - + label.vipOnline = online end function Game.onVipStateChange(id, online) local vipList = vipWindow:getChildById('vipList') local label = vipList:getChildById('vip' .. id) - + if online then label:setForegroundColor('#00ff00') else label:setForegroundColor('#ff0000') end - + label.vipOnline = online end diff --git a/modules/viplist/viplist.otmod b/modules/viplist/viplist.otmod new file mode 100644 index 00000000..e69de29b diff --git a/modules/game/ui/vipwindow.otui b/modules/viplist/viplist.otui similarity index 100% rename from modules/game/ui/vipwindow.otui rename to modules/viplist/viplist.otui diff --git a/src/framework/luascript/luafunctions.cpp b/src/framework/luascript/luafunctions.cpp index 1a692275..a8c85e10 100644 --- a/src/framework/luascript/luafunctions.cpp +++ b/src/framework/luascript/luafunctions.cpp @@ -71,6 +71,7 @@ void LuaInterface::registerFunctions() g_lua.bindClassMemberFunction("show", &UIWidget::show); g_lua.bindClassMemberFunction("lock", &UIWidget::lock); g_lua.bindClassMemberFunction("unlock", &UIWidget::unlock); + g_lua.bindClassMemberFunction("focus", &UIWidget::focus); g_lua.bindClassMemberFunction("getChildren", &UIWidget::getChildren); g_lua.bindClassMemberFunction("getChildById", &UIWidget::getChildById); g_lua.bindClassMemberFunction("getChildByIndex", &UIWidget::getChildByIndex); diff --git a/src/framework/ui/uiwidget.cpp b/src/framework/ui/uiwidget.cpp index cc8a308d..8c07a5d7 100644 --- a/src/framework/ui/uiwidget.cpp +++ b/src/framework/ui/uiwidget.cpp @@ -82,13 +82,22 @@ void UIWidget::destroy() } void UIWidget::render() +{ + renderSelf(); + renderChildren(); +} + +void UIWidget::renderSelf() { // draw background if(m_image) { g_graphics.bindColor(m_backgroundColor); m_image->draw(m_rect); } +} +void UIWidget::renderChildren() +{ // draw children for(const UIWidgetPtr& child : m_children) { // render only visible children with a valid rect @@ -191,6 +200,12 @@ void UIWidget::unlock() parent->unlockChild(asUIWidget()); } +void UIWidget::focus() +{ + if(UIWidgetPtr parent = getParent()) + parent->focusChild(asUIWidget(), Fw::ActiveFocusReason); +} + bool UIWidget::isVisible() { if(!m_visible) diff --git a/src/framework/ui/uiwidget.h b/src/framework/ui/uiwidget.h index d89ea3f9..92105e56 100644 --- a/src/framework/ui/uiwidget.h +++ b/src/framework/ui/uiwidget.h @@ -40,6 +40,8 @@ public: virtual void setup(); virtual void render(); + void renderSelf(); + void renderChildren(); void setVisible(bool visible); void setEnabled(bool enabled) { m_enabled = enabled; updateState(Fw::DisabledState); } @@ -76,6 +78,7 @@ public: void enable() { setEnabled(true); } void lock(); void unlock(); + void focus(); bool isActive() const { return hasState(Fw::ActiveState); } bool isEnabled() const { return !hasState(Fw::DisabledState); } diff --git a/src/otclient/otclient.cpp b/src/otclient/otclient.cpp index 3c74f55a..2c6146ad 100644 --- a/src/otclient/otclient.cpp +++ b/src/otclient/otclient.cpp @@ -148,7 +148,7 @@ void OTClient::run() render(); // render fps - defaultFont->renderText(fpsText, Point(g_graphics.getScreenSize().width() - fpsTextSize.width() - 10, 34)); + defaultFont->renderText(fpsText, Point(g_graphics.getScreenSize().width() - fpsTextSize.width() - 10, 38)); // render end g_graphics.endRender(); diff --git a/src/otclient/ui/uimap.cpp b/src/otclient/ui/uimap.cpp index c203aeaf..3554d68b 100644 --- a/src/otclient/ui/uimap.cpp +++ b/src/otclient/ui/uimap.cpp @@ -23,6 +23,8 @@ #include "uimap.h" #include #include +#include +#include void UIMap::setup() { @@ -31,10 +33,15 @@ void UIMap::setup() void UIMap::render() { - if(g_game.isOnline()) - g_map.draw(m_rect); + renderSelf(); - UIWidget::render(); + if(g_game.isOnline()) { + g_graphics.bindColor(Fw::black); + g_graphics.drawBoundingRect(m_mapRect.expanded(1)); + g_map.draw(m_mapRect); + } + + renderChildren(); } bool UIMap::onKeyPress(uchar keyCode, char keyChar, int keyboardModifiers) @@ -83,6 +90,16 @@ bool UIMap::onKeyPress(uchar keyCode, char keyChar, int keyboardModifiers) return UIWidget::onKeyPress(keyCode, keyChar, keyboardModifiers); } +void UIMap::onStyleApply(const OTMLNodePtr& styleNode) +{ + for(OTMLNodePtr node : styleNode->children()) { + if(node->tag() == "map margin") + m_mapMargin = node->value(); + } + + UIWidget::onStyleApply(styleNode); +} + bool UIMap::onMousePress(const Point& mousePos, Fw::MouseButton button) { return UIWidget::onMousePress(mousePos, button); @@ -90,10 +107,9 @@ bool UIMap::onMousePress(const Point& mousePos, Fw::MouseButton button) void UIMap::onGeometryUpdate(const Rect& oldRect, const Rect& newRect) { - Rect mapRect = newRect; + Rect mapRect = newRect.expanded(-m_mapMargin-1); Size mapSize(15*32, 11*32); mapSize.scale(mapRect.size(), Fw::KeepAspectRatio); - mapRect.setSize(mapSize); - if(mapRect != newRect) - setRect(mapRect); + m_mapRect.setSize(mapSize); + m_mapRect.moveCenter(newRect.center()); } diff --git a/src/otclient/ui/uimap.h b/src/otclient/ui/uimap.h index f9ecd2f4..15c518b4 100644 --- a/src/otclient/ui/uimap.h +++ b/src/otclient/ui/uimap.h @@ -33,11 +33,14 @@ public: void render(); protected: + virtual void onStyleApply(const OTMLNodePtr& styleNode); virtual bool onKeyPress(uchar keyCode, char keyChar, int keyboardModifiers); virtual bool onMousePress(const Point& mousePos, Fw::MouseButton button); virtual void onGeometryUpdate(const Rect& oldRect, const Rect& newRect); private: + int m_mapMargin; + Rect m_mapRect; }; #endif