From 8638c980ec39e861fa5dc3df4549659cec818b56 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Fri, 9 Dec 2011 13:01:04 -0200 Subject: [PATCH] fix some issues --- TODO | 1 + modules/client_entergame/characterlist.lua | 5 ++++- src/framework/CMakeLists.txt | 2 +- src/framework/core/logger.cpp | 18 +++++++----------- src/framework/core/logger.h | 6 +----- src/framework/core/resourcemanager.h | 3 --- src/otclient/otclient.cpp | 8 ++++++++ src/otclient/otclient.h | 1 + 8 files changed, 23 insertions(+), 21 deletions(-) diff --git a/TODO b/TODO index e4b9fe8f..8f85bed6 100644 --- a/TODO +++ b/TODO @@ -15,6 +15,7 @@ todo display otclient icon in window bar remake otui styles states system padding break UILabel lines +find a way to add new widgets without focusing them rename Game to g_game, etc implement Console key binding diff --git a/modules/client_entergame/characterlist.lua b/modules/client_entergame/characterlist.lua index 9a9cae5b..e8b378f9 100644 --- a/modules/client_entergame/characterlist.lua +++ b/modules/client_entergame/characterlist.lua @@ -61,6 +61,7 @@ function CharacterList.create(characters, premDays) local accountStatusLabel = charactersWindow:getChildById('accountStatusLabel') charactersWindow.onKeyPress = onCharactersWindowKeyPress + local focusLabel for i,characterInfo in ipairs(characters) do local characterName = characterInfo[1] local worldName = characterInfo[2] @@ -76,10 +77,12 @@ function CharacterList.create(characters, premDays) label.worldPort = worldIp if i == 1 or g_configs.get('lastUsedCharacter') == characterName then - characterList:focusChild(label, ActiveFocusReason) + focusLabel = label end end + characterList:focusChild(focusLabel, ActiveFocusReason) + if premDays > 0 then accountStatusLabel:setText("Account Status:\nPremium Account (" .. premDays .. ' days left)') end diff --git a/src/framework/CMakeLists.txt b/src/framework/CMakeLists.txt index cc69643a..193fdbb8 100644 --- a/src/framework/CMakeLists.txt +++ b/src/framework/CMakeLists.txt @@ -79,7 +79,7 @@ IF(WIN32) ENDIF(NO_CONSOLE) ELSE(WIN32) SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -rdynamic") - SET(ADDITIONAL_LIBRARIES pthread X11) + SET(ADDITIONAL_LIBRARIES pthread X11 dl) SET(framework_SOURCES ${framework_SOURCES} ${CMAKE_CURRENT_LIST_DIR}/platform/x11window.cpp) ENDIF(WIN32) diff --git a/src/framework/core/logger.cpp b/src/framework/core/logger.cpp index e061a4f4..f4e636d6 100644 --- a/src/framework/core/logger.cpp +++ b/src/framework/core/logger.cpp @@ -34,21 +34,17 @@ void Logger::log(Fw::LogLevel level, std::string message) { const static std::string logPrefixes[] = { "", "", "WARNING: ", "ERROR: ", "FATAL ERROR: " }; - if(!m_terminated) { - message.insert(0, logPrefixes[level]); - std::cout << message << std::endl; + message.insert(0, logPrefixes[level]); + std::cout << message << std::endl; - std::size_t now = std::time(NULL); - m_logMessages.push_back(LogMessage(level, message, now)); + std::size_t now = std::time(NULL); + m_logMessages.push_back(LogMessage(level, message, now)); - if(m_onLog) - m_onLog(level, message, now); - } + if(m_onLog) + m_onLog(level, message, now); - if(level == Fw::LogFatal) { - m_terminated = true; + if(level == Fw::LogFatal) throw std::runtime_error(message); - } } void Logger::logFunc(Fw::LogLevel level, const std::string& message, std::string prettyFunction) diff --git a/src/framework/core/logger.h b/src/framework/core/logger.h index 5f687086..70ab5b0f 100644 --- a/src/framework/core/logger.h +++ b/src/framework/core/logger.h @@ -23,11 +23,7 @@ #ifndef LOGGER_H #define LOGGER_H -#include "../util/tools.h" -#include "../const.h" -#include -#include -#include +#include struct LogMessage { LogMessage(Fw::LogLevel level, const std::string& message, std::size_t when) : level(level), message(message), when(when) { } diff --git a/src/framework/core/resourcemanager.h b/src/framework/core/resourcemanager.h index de1f4de2..4a00be94 100644 --- a/src/framework/core/resourcemanager.h +++ b/src/framework/core/resourcemanager.h @@ -33,10 +33,7 @@ public: bool setupWriteDir(const std::string& appWriteDirName); - /// Add an package or directory to the search path bool addToSearchPath(const std::string& path, bool insertInFront = true); - - /// Search and packages from a directory to the search path void searchAndAddPackages(const std::string& packagesDir, const std::string& packagesExt, bool append); bool fileExists(const std::string& fileName); diff --git a/src/otclient/otclient.cpp b/src/otclient/otclient.cpp index 6d5e4f47..c4e29dd3 100644 --- a/src/otclient/otclient.cpp +++ b/src/otclient/otclient.cpp @@ -22,6 +22,7 @@ #include "otclient.h" #include +#include "core/game.h" OTClient::OTClient() : Application(Otc::AppCompactName) { @@ -38,3 +39,10 @@ void OTClient::init(const std::vector& args) g_modules.ensureModuleLoaded("client"); g_modules.autoLoadModules(1000); } + +void OTClient::close() +{ + if(g_game.isOnline()) + g_game.logout(true); + exit(); +} diff --git a/src/otclient/otclient.h b/src/otclient/otclient.h index e7bd8e55..7be16aee 100644 --- a/src/otclient/otclient.h +++ b/src/otclient/otclient.h @@ -31,6 +31,7 @@ class OTClient : public Application public: OTClient(); void init(const std::vector& args); + void close(); void registerLuaFunctions(); };