From ca569363fbcfa3f335b713fb829b81e9789bf806 Mon Sep 17 00:00:00 2001 From: InnerCircleTFS Date: Tue, 10 Dec 2024 15:01:40 -0300 Subject: [PATCH] fix: clean cache + Change language in options --- modules/client_bottommenu/bottommenu.lua | 3 ++ modules/client_options/styles/misc/help.otui | 21 ++++++-- modules/client_topmenu/topmenu.lua | 48 +++++++++---------- .../game_healthcircle/game_healthcircle.lua | 1 + modules/game_textmessage/textmessage.lua | 7 +-- modules/game_viplist/addgroup.otui | 2 +- src/framework/core/config.cpp | 2 +- src/framework/core/config.h | 2 +- src/framework/luafunctions.cpp | 1 + 9 files changed, 53 insertions(+), 34 deletions(-) diff --git a/modules/client_bottommenu/bottommenu.lua b/modules/client_bottommenu/bottommenu.lua index c8052d90a1..6a039afe79 100644 --- a/modules/client_bottommenu/bottommenu.lua +++ b/modules/client_bottommenu/bottommenu.lua @@ -68,6 +68,9 @@ function init() boss2:setImageSource(randomItem.creature2) boss2:setVisible(true) end + if g_game.isOnline() then + hide() + end end function terminate() diff --git a/modules/client_options/styles/misc/help.otui b/modules/client_options/styles/misc/help.otui index 784cefa5b3..a23a309d08 100644 --- a/modules/client_options/styles/misc/help.otui +++ b/modules/client_options/styles/misc/help.otui @@ -30,7 +30,7 @@ UIWidget anchors.left: parent.left anchors.right: parent.right anchors.top: prev.bottom - height: 33 + height: 55 margin-top: 5 QtButton @@ -40,5 +40,20 @@ UIWidget margin-right: 10 anchors.left: parent.left anchors.top: parent.top - @onClick: g_platform.openUrl("https://github.com/mehah/otclient/wiki") - + @onClick: | + g_settings.clear() + controller:scheduleEvent(function() + g_app.restart() + end, 1000) + QtButton + !text: tr('Change language') + size: 130 20 + margin-top: 5 + anchors.top: prev.bottom + anchors.left: parent.left + @onClick: | + if g_game.isOnline() then + g_logger.warning("To prevent errors, change the language while offline." ) + else + modules.client_locales.createWindow() + end diff --git a/modules/client_topmenu/topmenu.lua b/modules/client_topmenu/topmenu.lua index f21fb6a6fe..f9115eae61 100644 --- a/modules/client_topmenu/topmenu.lua +++ b/modules/client_topmenu/topmenu.lua @@ -152,32 +152,30 @@ function online() pingImg:hide() end end + if PingWidget then + return + end + PingWidget = g_ui.loadUI("pingFps", modules.game_interface.getMapPanel()) + MainPingPanel = g_ui.createWidget("testPingPanel", PingWidget:getChildByIndex(1)) + MainPingPanel.setId(MainPingPanel, "ping") + pingImg = MainPingPanel.getChildByIndex(MainPingPanel, 1) + pingPanel = MainPingPanel.getChildByIndex(MainPingPanel, 2) + if modules.client_options.getOption('showPing') then + pingImg:setVisible(true) + pingPanel:setVisible(true) + else + pingImg:setVisible(false) + pingPanel:setVisible(true) + end + mainFpsPanel = g_ui.createWidget("testPingPanel", PingWidget:getChildByIndex(2)) + mainFpsPanel.setId(mainFpsPanel, "fps") + fpsPanel2 = mainFpsPanel.getChildByIndex(mainFpsPanel, 2) + if modules.client_options.getOption('showFps') then + fpsPanel2:setVisible(true) + else + fpsPanel2:setVisible(false) + end end) - if PingWidget then - return - end - - PingWidget = g_ui.loadUI("pingFps", modules.game_interface.getMapPanel()) - - MainPingPanel = g_ui.createWidget("testPingPanel", PingWidget:getChildByIndex(1)) - MainPingPanel.setId(MainPingPanel, "ping") - pingImg = MainPingPanel.getChildByIndex(MainPingPanel, 1) - pingPanel = MainPingPanel.getChildByIndex(MainPingPanel, 2) - if modules.client_options.getOption('showPing') then - pingImg:setVisible(true) - pingPanel:setVisible(true) - else - pingImg:setVisible(false) - pingPanel:setVisible(true) - end - mainFpsPanel = g_ui.createWidget("testPingPanel", PingWidget:getChildByIndex(2)) - mainFpsPanel.setId(mainFpsPanel, "fps") - fpsPanel2 = mainFpsPanel.getChildByIndex(mainFpsPanel, 2) - if modules.client_options.getOption('showFps') then - fpsPanel2:setVisible(true) - else - fpsPanel2:setVisible(false) - end end function offline() diff --git a/modules/game_healthcircle/game_healthcircle.lua b/modules/game_healthcircle/game_healthcircle.lua index e0b4b2bacf..1a57dbb6d9 100644 --- a/modules/game_healthcircle/game_healthcircle.lua +++ b/modules/game_healthcircle/game_healthcircle.lua @@ -114,6 +114,7 @@ function terminate() disconnect(g_game, { onGameStart = setPlayerValues }) + statsBarMenuLoaded = false end ------------------------------------------------- diff --git a/modules/game_textmessage/textmessage.lua b/modules/game_textmessage/textmessage.lua index 50279e654f..4e4df247a4 100644 --- a/modules/game_textmessage/textmessage.lua +++ b/modules/game_textmessage/textmessage.lua @@ -159,9 +159,10 @@ function displayMessage(mode, text) if msgtype == MessageSettings.loot then local coloredText = ItemsDatabase.setColorLootMessage(text) label:setColoredText(coloredText) - local console = modules.game_console - local consoleBuffer = console.consoleTabBar:getTabPanel(console.getTab("Server Log")):getChildById('consoleBuffer') - consoleBuffer:getLastChild():setColoredText(coloredText) + local getTabServerLog = modules.game_console.consoleTabBar:getTabPanel(modules.game_console.getTab("Server Log")) + if getTabServerLog then + getTabServerLog:getChildById('consoleBuffer'):getLastChild():setColoredText(coloredText) + end else label:setText(text) label:setColor(msgtype.color) diff --git a/modules/game_viplist/addgroup.otui b/modules/game_viplist/addgroup.otui index 0cefe46c50..eeeb159771 100644 --- a/modules/game_viplist/addgroup.otui +++ b/modules/game_viplist/addgroup.otui @@ -4,7 +4,7 @@ MainWindow text-offset: 0 1 @onEnter: modules.game_viplist.addGroup() @onEscape: | - self:getParent():destroy() + self:destroy() modules.game_viplist.addGroupWindow = nil Label diff --git a/src/framework/core/config.cpp b/src/framework/core/config.cpp index b78ff8a7db..56d569be36 100644 --- a/src/framework/core/config.cpp +++ b/src/framework/core/config.cpp @@ -66,7 +66,7 @@ bool Config::save() return m_confsDoc->save(m_fileName); } -void Config::clear() const +void Config::clear() { m_confsDoc->clear(); } diff --git a/src/framework/core/config.h b/src/framework/core/config.h index b31fdcf803..64dce0c3c8 100644 --- a/src/framework/core/config.h +++ b/src/framework/core/config.h @@ -36,7 +36,7 @@ class Config : public LuaObject bool load(const std::string& file); bool unload(); bool save(); - void clear() const; + void clear(); void setValue(const std::string& key, const std::string& value); void setList(const std::string& key, const std::vector& list); std::string getValue(const std::string& key); diff --git a/src/framework/luafunctions.cpp b/src/framework/luafunctions.cpp index 5c30bc681c..233ddac9bb 100644 --- a/src/framework/luafunctions.cpp +++ b/src/framework/luafunctions.cpp @@ -282,6 +282,7 @@ void Application::registerLuaFunctions() g_lua.bindClassMemberFunction("getOrCreateNode", &Config::getOrCreateNode); g_lua.bindClassMemberFunction("mergeNode", &Config::mergeNode); g_lua.bindClassMemberFunction("getFileName", &Config::getFileName); + g_lua.bindClassMemberFunction("clear", &Config::clear); // Module g_lua.registerClass();