From e85afd4b6361844184de1853bcd616c26d53a3d9 Mon Sep 17 00:00:00 2001 From: Henrique Santiago Date: Fri, 1 Mar 2013 05:08:30 -0300 Subject: [PATCH] Platform modtime, little changes to entergame --- modules/client_entergame/entergame.otui | 10 ++++++---- src/framework/luafunctions.cpp | 1 + src/framework/platform/platform.h | 1 + src/framework/platform/unixplatform.cpp | 10 ++++++++++ src/framework/platform/win32platform.cpp | 9 +++++++++ src/framework/util/color.h | 2 +- 6 files changed, 28 insertions(+), 5 deletions(-) diff --git a/modules/client_entergame/entergame.otui b/modules/client_entergame/entergame.otui index 39213c98..8f35e137 100644 --- a/modules/client_entergame/entergame.otui +++ b/modules/client_entergame/entergame.otui @@ -1,4 +1,9 @@ EnterGameWindow < MainWindow + !text: tr('Enter Game') + size: 236 274 + +EnterGameButton < Button + width: 64 ServerListButton < UIButton size: 17 17 @@ -16,8 +21,6 @@ ServerListButton < UIButton EnterGameWindow id: enterGame - !text: tr('Enter Game') - size: 236 274 @onEnter: EnterGame.doLogin() MenuLabel @@ -130,9 +133,8 @@ EnterGameWindow anchors.top: prev.bottom margin-top: 2 - Button + EnterGameButton !text: tr('Ok') - width: 64 anchors.right: parent.right anchors.bottom: parent.bottom @onClick: EnterGame.doLogin() diff --git a/src/framework/luafunctions.cpp b/src/framework/luafunctions.cpp index 32d4df73..febb5c80 100644 --- a/src/framework/luafunctions.cpp +++ b/src/framework/luafunctions.cpp @@ -90,6 +90,7 @@ void Application::registerLuaFunctions() g_lua.bindSingletonFunction("g_platform", "getCPUName", &Platform::getCPUName, &g_platform); g_lua.bindSingletonFunction("g_platform", "getTotalSystemMemory", &Platform::getTotalSystemMemory, &g_platform); g_lua.bindSingletonFunction("g_platform", "getOSName", &Platform::getOSName, &g_platform); + g_lua.bindSingletonFunction("g_platform", "getFileModificationTime", &Platform::getFileModificationTime, &g_platform); // Application g_lua.registerSingletonClass("g_app"); diff --git a/src/framework/platform/platform.h b/src/framework/platform/platform.h index 1202f759..cdeee57a 100644 --- a/src/framework/platform/platform.h +++ b/src/framework/platform/platform.h @@ -43,6 +43,7 @@ public: std::string getCPUName(); double getTotalSystemMemory(); std::string getOSName(); + time_t getFileModificationTime(const std::string& filename); }; extern Platform g_platform; diff --git a/src/framework/platform/unixplatform.cpp b/src/framework/platform/unixplatform.cpp index c4d0d01b..c85bb62c 100644 --- a/src/framework/platform/unixplatform.cpp +++ b/src/framework/platform/unixplatform.cpp @@ -160,5 +160,15 @@ std::string Platform::getOSName() return std::string(); } +time_t Platform::getFileModificationTime(const std::string& filename) +{ + struct stat attrib; + if(stat(filename.c_str(), &attrib)) + perror(filename.c_str()); + else + return attrib.st_mtime; + return 0; +} + #endif diff --git a/src/framework/platform/win32platform.cpp b/src/framework/platform/win32platform.cpp index d1720ef4..ea01dea0 100644 --- a/src/framework/platform/win32platform.cpp +++ b/src/framework/platform/win32platform.cpp @@ -401,4 +401,13 @@ std::string Platform::getOSName() return ret; } +time_t Platform::getFileModificationTime(const std::string& filename) +{ + //TODO + /*WIN32_FILE_ATTRIBUTE_DATA fileAttrData = {0}; + GetFileAttributesEx(filename.c_str(), GetFileExInfoStandard, &fileAttrData); + return fileAttrData.ftLastWriteTime;*/ + return 0; +} + #endif diff --git a/src/framework/util/color.h b/src/framework/util/color.h index 666876cc..0b4c3351 100644 --- a/src/framework/util/color.h +++ b/src/framework/util/color.h @@ -83,7 +83,7 @@ public: c += (color.g() / 51) * 6; c += (color.b() / 51); return c; - }; + } static Color from8bit(int color) { if(color >= 216 || color <= 0)