diff --git a/README.rdoc b/README.rdoc index 68516714..9989ae7d 100644 --- a/README.rdoc +++ b/README.rdoc @@ -29,6 +29,11 @@ http://otclient.info/tracker We encourage you to contribute to OTClient! Please check out {our website}[http://otclient.info/] for guidelines about how to proceed. Join us! +== Contact + +You have 3 options, post at http://otclient.info/ , talk directly with us at #otclient irc.freenode.net or send +an email directly to the project leader edub4rt@gmail.com + == Authors * edubart (project creator and leader developer) @@ -37,5 +42,5 @@ We encourage you to contribute to OTClient! Please check out == License -OTClient is made available under the MIT License +OTClient is made available under the MIT License, thus this means that you can do whatever you want, commercial, non-commercial, closed or open. diff --git a/modules/client/client.otmod b/modules/client/client.otmod index 7d68479a..893587d0 100644 --- a/modules/client/client.otmod +++ b/modules/client/client.otmod @@ -9,7 +9,7 @@ Module load-later: - client_topmenu - client_background - - client_about + //- client_about - client_options - client_terminal - client_modulemanager diff --git a/modules/client_background/background.lua b/modules/client_background/background.lua index 2cd62aec..420418a9 100644 --- a/modules/client_background/background.lua +++ b/modules/client_background/background.lua @@ -8,6 +8,11 @@ function Background.init() background = displayUI('background.otui') background:lower() + local clientVersionLabel = background:getChildById('clientVersionLabel') + clientVersionLabel:setText('OTClient ' .. g_app.getVersion() .. '\n' .. + 'Built on ' .. g_app.getBuildDate()) + Effects.fadeIn(clientVersionLabel, 1500) + connect(g_game, { onGameStart = Background.hide }) connect(g_game, { onGameEnd = Background.show }) end diff --git a/modules/client_background/background.otui b/modules/client_background/background.otui index 9eebbb86..79c869fe 100644 --- a/modules/client_background/background.otui +++ b/modules/client_background/background.otui @@ -1,6 +1,6 @@ Panel id: background - image-source: /client_background/background.png + image-source: /client_background/bg.png image-smooth: true image-fixed-ratio: true anchors.top: topMenu.bottom @@ -9,3 +9,14 @@ Panel anchors.bottom: parent.bottom margin-top: 1 focusable: false + + UILabel + background-color: #00000099 + id: clientVersionLabel + anchors.right: parent.right + anchors.bottom: parent.bottom + text-offset: 4 2 + height: 32 + width: 120 + color: #ffffff + font: verdana-11px-monochrome \ No newline at end of file diff --git a/modules/client_background/background.png b/modules/client_background/background.png index 2c9c1041..8e3c7a07 100644 Binary files a/modules/client_background/background.png and b/modules/client_background/background.png differ diff --git a/modules/client_entergame/entergame.lua b/modules/client_entergame/entergame.lua index caba4504..1a11945b 100644 --- a/modules/client_entergame/entergame.lua +++ b/modules/client_entergame/entergame.lua @@ -80,6 +80,7 @@ function EnterGame.init() enterGame:getChildById('accountNameLineEdit'):focus() -- only open entergame when app starts + enterGame:hide() if not g_app.isRunning() then if #account > 0 and autologin then addEvent(EnterGame.doLogin) diff --git a/modules/core_styles/styles/labels.otui b/modules/core_styles/styles/labels.otui index 7046c6b5..0c5a8f9f 100644 --- a/modules/core_styles/styles/labels.otui +++ b/modules/core_styles/styles/labels.otui @@ -1,13 +1,13 @@ Label < UILabel font: verdana-11px-antialised - color: #aaaaaa + color: #bbbbbb $disabled: - color: #aaaaaa88 + color: #bbbbbb88 GameLabel < UILabel font: verdana-11px-antialised - color: #aaaaaa + color: #bbbbbb FrameCounter < UIFrameCounter size: 68 16 diff --git a/src/framework/application.cpp b/src/framework/application.cpp index 41935e36..9eba169b 100644 --- a/src/framework/application.cpp +++ b/src/framework/application.cpp @@ -67,7 +67,7 @@ Application::~Application() void Application::init(const std::vector& args, int appFlags) { m_appFlags = appFlags; - logInfo("Starting application..."); + logInfo("Starting ", m_appName, " ", m_appVersion); // capture exit signals signal(SIGTERM, exitSignalHandler); diff --git a/src/framework/application.h b/src/framework/application.h index 502523b9..04b7cd77 100644 --- a/src/framework/application.h +++ b/src/framework/application.h @@ -47,7 +47,9 @@ public: bool isRunning() { return m_running; } bool isStopping() { return m_stopping; } - const std::string& getAppName() { return m_appName; } + const std::string& getName() { return m_appName; } + const std::string& getVersion() { return m_appVersion; } + const std::string& getBuildDate() { return m_appBuildDate; } protected: virtual void render(); @@ -55,6 +57,8 @@ protected: virtual void inputEvent(const InputEvent& event); std::string m_appName; + std::string m_appVersion; + std::string m_appBuildDate; int m_appFlags; int m_pollCycleDelay; Boolean m_running; diff --git a/src/framework/core/modulemanager.cpp b/src/framework/core/modulemanager.cpp index 05901fae..6373ddbe 100644 --- a/src/framework/core/modulemanager.cpp +++ b/src/framework/core/modulemanager.cpp @@ -64,7 +64,7 @@ void ModuleManager::discoverModulesPath() std::string possibleModulesDirs[] = { "modules", g_resources.getBaseDir() + "modules", g_resources.getBaseDir() + "../modules", - g_resources.getBaseDir() + "../share/" + g_app->getAppName() + "/modules", + g_resources.getBaseDir() + "../share/" + g_app->getName() + "/modules", "" }; bool found = false; for(const std::string& dir : possibleModulesDirs) { @@ -83,7 +83,7 @@ void ModuleManager::discoverModulesPath() std::string possibleAddonsDirs[] = { "addons", g_resources.getBaseDir() + "addons", g_resources.getBaseDir() + "../addons", - g_resources.getBaseDir() + "../addons/" + g_app->getAppName() + "/modules", + g_resources.getBaseDir() + "../addons/" + g_app->getName() + "/modules", "" }; for(const std::string& dir : possibleAddonsDirs) { // try to add module directory diff --git a/src/framework/luafunctions.cpp b/src/framework/luafunctions.cpp index 8474270d..1952d865 100644 --- a/src/framework/luafunctions.cpp +++ b/src/framework/luafunctions.cpp @@ -418,6 +418,9 @@ void Application::registerLuaFunctions() g_lua.bindClassStaticFunction("g_app", "exit", std::bind(&Application::exit, g_app)); g_lua.bindClassStaticFunction("g_app", "isRunning", std::bind(&Application::isRunning, g_app)); g_lua.bindClassStaticFunction("g_app", "isStopping", std::bind(&Application::isStopping, g_app)); + g_lua.bindClassStaticFunction("g_app", "getName", std::bind(&Application::getName, g_app)); + g_lua.bindClassStaticFunction("g_app", "getVersion", std::bind(&Application::getVersion, g_app)); + g_lua.bindClassStaticFunction("g_app", "getBuildDate", std::bind(&Application::getBuildDate, g_app)); // ConfigManager g_lua.registerStaticClass("g_configs"); diff --git a/src/framework/platform/unixcrashhandler.cpp b/src/framework/platform/unixcrashhandler.cpp index 8f27128c..34bf0ebe 100644 --- a/src/framework/platform/unixcrashhandler.cpp +++ b/src/framework/platform/unixcrashhandler.cpp @@ -41,7 +41,7 @@ void crashHandler(int signum, siginfo_t* info, void* secret) char fileName[128]; time(&tnow); tm *ts = localtime(&tnow); - strftime(fileName, 128, (g_app->getAppName() + "-crash_-%d-%m-%Y_%H:%M:%S.txt").c_str(), ts); + strftime(fileName, 128, (g_app->getName() + "-crash_-%d-%m-%Y_%H:%M:%S.txt").c_str(), ts); std::stringstream ss; ss.flags(std::ios::hex | std::ios::showbase); diff --git a/src/framework/platform/win32crashhandler.cpp b/src/framework/platform/win32crashhandler.cpp index 084683fc..ad01bcff 100644 --- a/src/framework/platform/win32crashhandler.cpp +++ b/src/framework/platform/win32crashhandler.cpp @@ -46,7 +46,7 @@ LONG WINAPI crashHandler(EXCEPTION_POINTERS* exceptionPointers) SYSTEMTIME systemTime; GetSystemTime(&systemTime); - snprintf(fileName, 128, "%s_%02u-%02u-%04u_%02u-%02u-%02u.mdmp", g_app->getAppName().c_str(), + snprintf(fileName, 128, "%s_%02u-%02u-%04u_%02u-%02u-%02u.mdmp", g_app->getName().c_str(), systemTime.wDay, systemTime.wMonth, systemTime.wYear, systemTime.wHour, systemTime.wMinute, systemTime.wSecond); diff --git a/src/framework/platform/win32window.cpp b/src/framework/platform/win32window.cpp index 681d46fa..43c029a2 100644 --- a/src/framework/platform/win32window.cpp +++ b/src/framework/platform/win32window.cpp @@ -226,7 +226,7 @@ void WIN32Window::terminate() } if(m_instance) { - if(!UnregisterClassA(g_app->getAppName().c_str(), m_instance)) + if(!UnregisterClassA(g_app->getName().c_str(), m_instance)) logError("UnregisterClassA failed"); m_instance = NULL; } @@ -252,7 +252,7 @@ void WIN32Window::internalRegisterWindowClass() wc.hCursor = m_defaultCursor; wc.hbrBackground = NULL; wc.lpszMenuName = NULL; - wc.lpszClassName = g_app->getAppName().c_str(); + wc.lpszClassName = g_app->getName().c_str(); if(!RegisterClassA(&wc)) logFatal("Failed to register the window class."); @@ -272,7 +272,7 @@ void WIN32Window::internalCreateWindow() updateUnmaximizedCoords(); m_window = CreateWindowExA(dwExStyle, - g_app->getAppName().c_str(), + g_app->getName().c_str(), NULL, dwStyle, windowRect.left, diff --git a/src/framework/ui/uiframecounter.cpp b/src/framework/ui/uiframecounter.cpp index 792ab842..d5fe06b6 100644 --- a/src/framework/ui/uiframecounter.cpp +++ b/src/framework/ui/uiframecounter.cpp @@ -41,7 +41,7 @@ void UIFrameCounter::draw() UIWidget::draw(); if(g_clock.ticksElapsed(m_lastFrameTicks) >= 1000) { - m_fpsText = Fw::mkstr("FPS: ", m_frameCount); + m_fpsText = Fw::formatString("FPS: %d", m_frameCount); m_lastFrameTicks = g_clock.ticks(); m_frameCount = 0; } diff --git a/src/framework/ui/uiwidgettext.cpp b/src/framework/ui/uiwidgettext.cpp index 672c2e8b..1089368d 100644 --- a/src/framework/ui/uiwidgettext.cpp +++ b/src/framework/ui/uiwidgettext.cpp @@ -61,9 +61,10 @@ void UIWidget::drawText(const Rect& screenCoords) m_textFramebuffer->bind(); Rect virtualTextRect(0, 0, boxSize); virtualTextRect.translate(m_textOffset); + g_painter.saveAndResetState(); g_painter.setCompositionMode(Painter::CompositionMode_DestBlending); m_font->renderText(m_text, virtualTextRect, m_textAlign, Fw::white); - g_painter.resetCompositionMode(); + g_painter.restoreSavedState(); m_textFramebuffer->release(); m_textMustRecache = false; diff --git a/src/framework/util/tools.h b/src/framework/util/tools.h index 641e44ea..b431d390 100644 --- a/src/framework/util/tools.h +++ b/src/framework/util/tools.h @@ -113,6 +113,23 @@ void println(const T&... args) { std::cout << std::endl; } +// useful std::string version of sprintf :) +template +std::string formatString(const std::string& format, Args... args) { + int n, size = 1024; + std::string str; + while(true) { + str.resize(size); + n = snprintf(&str[0], size, format.c_str(), args...); + assert(n != -1); + if(n < size) { + str.resize(n); + return str; + } + size *= 2; + } +} + // demangle names for GNU g++ compiler inline std::string demangleName(const char* name) { size_t len; diff --git a/src/otclient/const.h b/src/otclient/const.h index f38d115d..49669461 100644 --- a/src/otclient/const.h +++ b/src/otclient/const.h @@ -30,6 +30,7 @@ namespace Otc constexpr const char* AppName = "OTClient"; constexpr const char* AppCompactName = "otclient"; constexpr const char* AppVersion = "0.4.0"; + constexpr const char* AppBuild = "_dev"; enum { TILE_PIXELS = 32, diff --git a/src/otclient/otclient.cpp b/src/otclient/otclient.cpp index 2e5b1da0..1e5b2893 100644 --- a/src/otclient/otclient.cpp +++ b/src/otclient/otclient.cpp @@ -26,14 +26,14 @@ #include #include "core/map.h" -OTClient::OTClient(const std::string& appName) : Application(appName) +OTClient::OTClient() : Application(Otc::AppCompactName) { - + m_appVersion = Fw::formatString("%s%s", Otc::AppVersion, Otc::AppBuild); + m_appBuildDate = __DATE__; } void OTClient::init(const std::vector& args) { - logInfo(Otc::AppName, " ", Otc::AppVersion); Application::init(args, Fw::AppEnableAll); g_modules.discoverModules(); diff --git a/src/otclient/otclient.h b/src/otclient/otclient.h index 42fc9879..1401ee17 100644 --- a/src/otclient/otclient.h +++ b/src/otclient/otclient.h @@ -29,7 +29,7 @@ class OTClient : public Application { public: - OTClient(const std::string &appName = Otc::AppCompactName); + OTClient(); void init(const std::vector& args); void registerLuaFunctions(); };