From e95973174c97ee8d14aaec253355f383c58ec25c Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Fri, 30 Dec 2011 02:50:19 -0200 Subject: [PATCH] more changes to work on ARM --- modules/client/client.lua | 9 +++++++-- modules/core_scripts/util.lua | 17 +---------------- src/framework/core/resourcemanager.cpp | 2 +- src/framework/luafunctions.cpp | 3 +++ src/framework/luascript/luainterface.cpp | 3 +-- src/framework/luascript/luainterface.h | 2 +- src/framework/platform/platformwindow.h | 1 + src/framework/platform/unixcrashhandler.cpp | 3 ++- src/framework/platform/win32window.cpp | 5 +++++ src/framework/platform/win32window.h | 1 + src/framework/platform/x11window.cpp | 9 +++++++++ src/framework/platform/x11window.h | 1 + 12 files changed, 33 insertions(+), 23 deletions(-) diff --git a/modules/client/client.lua b/modules/client/client.lua index 8d074c04..c70a83d9 100644 --- a/modules/client/client.lua +++ b/modules/client/client.lua @@ -2,8 +2,13 @@ Client = { } -- TODO: load and save configurations function Client.init() - g_window.move({ x=220, y=220 }) - g_window.resize({ width=800, height=480 }) + -- initialize in fullscreen mode on mobile devices + if g_window.getPlatformType() == "X11-EGL" then + g_window:setFullscreen() + else + g_window.move({ x=220, y=220 }) + g_window.resize({ width=800, height=480 }) + end g_window.setTitle('OTClient') g_window.setIcon('clienticon.png') return true diff --git a/modules/core_scripts/util.lua b/modules/core_scripts/util.lua index b7173229..786a3b01 100644 --- a/modules/core_scripts/util.lua +++ b/modules/core_scripts/util.lua @@ -32,25 +32,10 @@ function createEnvironment() return env end -function getCallingScriptSourcePath(depth) - depth = depth or 2 - local info = debug.getinfo(1+depth, "Sn") - local path - if info.short_src then - path = info.short_src:match("(.*)/.*") - end - if not path then - path = '/' - elseif path:sub(0, 1) ~= '/' then - path = '/' .. path - end - return path -end - function resolveFileFullPath(filePath, depth) depth = depth or 1 if filePath:sub(0, 1) ~= '/' then - return getCallingScriptSourcePath(depth+1) .. '/' .. filePath + return getCurrentSourcePath(depth+1) .. '/' .. filePath else return filePath end diff --git a/src/framework/core/resourcemanager.cpp b/src/framework/core/resourcemanager.cpp index e84d2ac4..a2cb6e6f 100644 --- a/src/framework/core/resourcemanager.cpp +++ b/src/framework/core/resourcemanager.cpp @@ -164,7 +164,7 @@ std::string ResourceManager::resolvePath(const std::string& path) if(boost::starts_with(path, "/")) fullPath = path; else { - std::string scriptPath = "/" + g_lua.currentSourcePath(); + std::string scriptPath = "/" + g_lua.getCurrentSourcePath(); if(!scriptPath.empty()) fullPath += scriptPath + "/"; fullPath += path; diff --git a/src/framework/luafunctions.cpp b/src/framework/luafunctions.cpp index c9aad99b..c3f76ff5 100644 --- a/src/framework/luafunctions.cpp +++ b/src/framework/luafunctions.cpp @@ -201,10 +201,12 @@ void Application::registerLuaFunctions() g_lua.bindClassStaticFunction("g_window", "move", std::bind(&PlatformWindow::move, &g_window, _1)); g_lua.bindClassStaticFunction("g_window", "resize", std::bind(&PlatformWindow::resize, &g_window, _1)); g_lua.bindClassStaticFunction("g_window", "setVerticalSync", std::bind(&PlatformWindow::setVerticalSync, &g_window, _1)); + g_lua.bindClassStaticFunction("g_window", "setFullscreen", std::bind(&PlatformWindow::setFullscreen, &g_window, _1)); g_lua.bindClassStaticFunction("g_window", "setTitle", std::bind(&PlatformWindow::setTitle, &g_window, _1)); g_lua.bindClassStaticFunction("g_window", "setIcon", std::bind(&PlatformWindow::setIcon, &g_window, _1)); g_lua.bindClassStaticFunction("g_window", "getMousePos", std::bind(&PlatformWindow::getMousePos, &g_window)); g_lua.bindClassStaticFunction("g_window", "getSize", std::bind(&PlatformWindow::getSize, &g_window)); + g_lua.bindClassStaticFunction("g_window", "getPlatformType", std::bind(&PlatformWindow::getPlatformType, &g_window)); // Logger g_lua.registerClass(); @@ -235,4 +237,5 @@ void Application::registerLuaFunctions() g_lua.bindGlobalFunction("setDefaultFont", std::bind(&FontManager::setDefaultFont, &g_fonts, _1)); g_lua.bindGlobalFunction("loadUI", std::bind(&UIManager::loadUI, &g_ui, _1, _2)); g_lua.bindGlobalFunction("getRootWidget", std::bind(&UIManager::getRootWidget, &g_ui)); + g_lua.bindGlobalFunction("getCurrentSourcePath", std::bind(&LuaInterface::getCurrentSourcePath, &g_lua, _1)); } diff --git a/src/framework/luascript/luainterface.cpp b/src/framework/luascript/luainterface.cpp index 28650441..504a2248 100644 --- a/src/framework/luascript/luainterface.cpp +++ b/src/framework/luascript/luainterface.cpp @@ -352,14 +352,13 @@ std::string LuaInterface::traceback(const std::string& errorMessage, int level) return popString(); } -std::string LuaInterface::currentSourcePath() +std::string LuaInterface::getCurrentSourcePath(int level) { std::string path; if(!L) return path; // check all stack functions for script source path - int level = 0; while(true) { getStackFunction(level); // pushes stack function diff --git a/src/framework/luascript/luainterface.h b/src/framework/luascript/luainterface.h index 59a3c74b..34469824 100644 --- a/src/framework/luascript/luainterface.h +++ b/src/framework/luascript/luainterface.h @@ -154,7 +154,7 @@ public: std::string traceback(const std::string& errorMessage = "", int level = 0); /// Searches for the source of the current running function - std::string currentSourcePath(); + std::string getCurrentSourcePath(int level = 0); /// @brief Calls a function /// The function and arguments must be on top of the stack in order, diff --git a/src/framework/platform/platformwindow.h b/src/framework/platform/platformwindow.h index bb9fd2d5..1f54264c 100644 --- a/src/framework/platform/platformwindow.h +++ b/src/framework/platform/platformwindow.h @@ -54,6 +54,7 @@ public: virtual Size getDisplaySize() = 0; virtual std::string getClipboardText() = 0; + virtual std::string getPlatformType() = 0; int getDisplayWidth() { return getDisplaySize().width(); } int getDisplayHeight() { return getDisplaySize().width(); } diff --git a/src/framework/platform/unixcrashhandler.cpp b/src/framework/platform/unixcrashhandler.cpp index 1faa49ce..195929a8 100644 --- a/src/framework/platform/unixcrashhandler.cpp +++ b/src/framework/platform/unixcrashhandler.cpp @@ -53,6 +53,7 @@ void crashHandler(int signum, siginfo_t* info, void* secret) ss << " ebp = " << context.uc_mcontext.gregs[REG_EBP] << std::endl; ss << " esp = " << context.uc_mcontext.gregs[REG_ESP] << std::endl; ss << " efl = " << context.uc_mcontext.gregs[REG_EFL] << std::endl; + ss << std::endl; #elif __WORDSIZE == 64 ss << " at rip = " << context.uc_mcontext.gregs[REG_RIP] << std::endl; ss << " rax = " << context.uc_mcontext.gregs[REG_RAX] << std::endl; @@ -64,8 +65,8 @@ void crashHandler(int signum, siginfo_t* info, void* secret) ss << " rbp = " << context.uc_mcontext.gregs[REG_RBP] << std::endl; ss << " rsp = " << context.uc_mcontext.gregs[REG_RSP] << std::endl; ss << " efl = " << context.uc_mcontext.gregs[REG_EFL] << std::endl; -#endif ss << std::endl; +#endif ss.flags(std::ios::dec); ss << " backtrace:" << std::endl; diff --git a/src/framework/platform/win32window.cpp b/src/framework/platform/win32window.cpp index dd234a51..739ce421 100644 --- a/src/framework/platform/win32window.cpp +++ b/src/framework/platform/win32window.cpp @@ -610,3 +610,8 @@ std::string WIN32Window::getClipboardText() return text; } +std::string WIN32Window::getPlatformType() +{ + return "WIN32-WGL"; +} + diff --git a/src/framework/platform/win32window.h b/src/framework/platform/win32window.h index 64024576..856baeb9 100644 --- a/src/framework/platform/win32window.h +++ b/src/framework/platform/win32window.h @@ -68,6 +68,7 @@ public: Size getDisplaySize(); std::string getClipboardText(); + std::string getPlatformType(); bool isMaximized() { return m_maximized; } diff --git a/src/framework/platform/x11window.cpp b/src/framework/platform/x11window.cpp index dcecfb6c..1b736e50 100644 --- a/src/framework/platform/x11window.cpp +++ b/src/framework/platform/x11window.cpp @@ -904,6 +904,15 @@ std::string X11Window::getClipboardText() return clipboardText; } +std::string X11Window::getPlatformType() +{ +#ifndef OPENGL_ES2 + return "X11-GLX"; +#else + return "X11-EGL"; +#endif +} + bool X11Window::isMaximized() { Atom wmState = XInternAtom(m_display, "_NET_WM_STATE", False); diff --git a/src/framework/platform/x11window.h b/src/framework/platform/x11window.h index 47e3c443..40dfe753 100644 --- a/src/framework/platform/x11window.h +++ b/src/framework/platform/x11window.h @@ -75,6 +75,7 @@ public: Size getDisplaySize(); std::string getClipboardText(); + std::string getPlatformType(); bool isMaximized();