more changes to work on ARM
This commit is contained in:
		
							父節點
							
								
									a394033872
								
							
						
					
					
						當前提交
						e95973174c
					
				|  | @ -2,8 +2,13 @@ Client = { } | ||||||
| 
 | 
 | ||||||
| -- TODO: load and save configurations | -- TODO: load and save configurations | ||||||
| function Client.init() | function Client.init() | ||||||
|  |   -- 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.move({ x=220, y=220 }) | ||||||
|     g_window.resize({ width=800, height=480 }) |     g_window.resize({ width=800, height=480 }) | ||||||
|  |   end | ||||||
|   g_window.setTitle('OTClient') |   g_window.setTitle('OTClient') | ||||||
|   g_window.setIcon('clienticon.png') |   g_window.setIcon('clienticon.png') | ||||||
|   return true |   return true | ||||||
|  |  | ||||||
|  | @ -32,25 +32,10 @@ function createEnvironment() | ||||||
|   return env |   return env | ||||||
| end | 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) | function resolveFileFullPath(filePath, depth) | ||||||
|   depth = depth or 1 |   depth = depth or 1 | ||||||
|   if filePath:sub(0, 1) ~= '/' then |   if filePath:sub(0, 1) ~= '/' then | ||||||
|     return getCallingScriptSourcePath(depth+1) .. '/' .. filePath |     return getCurrentSourcePath(depth+1) .. '/' .. filePath | ||||||
|   else |   else | ||||||
|     return filePath |     return filePath | ||||||
|   end |   end | ||||||
|  |  | ||||||
|  | @ -164,7 +164,7 @@ std::string ResourceManager::resolvePath(const std::string& path) | ||||||
|     if(boost::starts_with(path, "/")) |     if(boost::starts_with(path, "/")) | ||||||
|         fullPath = path; |         fullPath = path; | ||||||
|     else { |     else { | ||||||
|         std::string scriptPath = "/" + g_lua.currentSourcePath(); |         std::string scriptPath = "/" + g_lua.getCurrentSourcePath(); | ||||||
|         if(!scriptPath.empty()) |         if(!scriptPath.empty()) | ||||||
|             fullPath += scriptPath + "/"; |             fullPath += scriptPath + "/"; | ||||||
|         fullPath += path; |         fullPath += path; | ||||||
|  |  | ||||||
|  | @ -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", "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", "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", "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", "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", "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", "getMousePos", std::bind(&PlatformWindow::getMousePos, &g_window)); | ||||||
|     g_lua.bindClassStaticFunction("g_window", "getSize", std::bind(&PlatformWindow::getSize, &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
 |     // Logger
 | ||||||
|     g_lua.registerClass<Logger>(); |     g_lua.registerClass<Logger>(); | ||||||
|  | @ -235,4 +237,5 @@ void Application::registerLuaFunctions() | ||||||
|     g_lua.bindGlobalFunction("setDefaultFont", std::bind(&FontManager::setDefaultFont, &g_fonts, _1)); |     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("loadUI", std::bind(&UIManager::loadUI, &g_ui, _1, _2)); | ||||||
|     g_lua.bindGlobalFunction("getRootWidget", std::bind(&UIManager::getRootWidget, &g_ui)); |     g_lua.bindGlobalFunction("getRootWidget", std::bind(&UIManager::getRootWidget, &g_ui)); | ||||||
|  |     g_lua.bindGlobalFunction("getCurrentSourcePath", std::bind(&LuaInterface::getCurrentSourcePath, &g_lua, _1)); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -352,14 +352,13 @@ std::string LuaInterface::traceback(const std::string& errorMessage, int level) | ||||||
|     return popString(); |     return popString(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::string LuaInterface::currentSourcePath() | std::string LuaInterface::getCurrentSourcePath(int level) | ||||||
| { | { | ||||||
|     std::string path; |     std::string path; | ||||||
|     if(!L) |     if(!L) | ||||||
|         return path; |         return path; | ||||||
| 
 | 
 | ||||||
|     // check all stack functions for script source path
 |     // check all stack functions for script source path
 | ||||||
|     int level = 0; |  | ||||||
|     while(true) { |     while(true) { | ||||||
|         getStackFunction(level); // pushes stack function
 |         getStackFunction(level); // pushes stack function
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -154,7 +154,7 @@ public: | ||||||
|     std::string traceback(const std::string& errorMessage = "", int level = 0); |     std::string traceback(const std::string& errorMessage = "", int level = 0); | ||||||
| 
 | 
 | ||||||
|     /// Searches for the source of the current running function
 |     /// Searches for the source of the current running function
 | ||||||
|     std::string currentSourcePath(); |     std::string getCurrentSourcePath(int level = 0); | ||||||
| 
 | 
 | ||||||
|     /// @brief Calls a function
 |     /// @brief Calls a function
 | ||||||
|     /// The function and arguments must be on top of the stack in order,
 |     /// The function and arguments must be on top of the stack in order,
 | ||||||
|  |  | ||||||
|  | @ -54,6 +54,7 @@ public: | ||||||
| 
 | 
 | ||||||
|     virtual Size getDisplaySize() = 0; |     virtual Size getDisplaySize() = 0; | ||||||
|     virtual std::string getClipboardText() = 0; |     virtual std::string getClipboardText() = 0; | ||||||
|  |     virtual std::string getPlatformType() = 0; | ||||||
| 
 | 
 | ||||||
|     int getDisplayWidth() { return getDisplaySize().width(); } |     int getDisplayWidth() { return getDisplaySize().width(); } | ||||||
|     int getDisplayHeight() { return getDisplaySize().width(); } |     int getDisplayHeight() { return getDisplaySize().width(); } | ||||||
|  |  | ||||||
|  | @ -53,6 +53,7 @@ void crashHandler(int signum, siginfo_t* info, void* secret) | ||||||
|     ss << "     ebp = " << context.uc_mcontext.gregs[REG_EBP] << std::endl; |     ss << "     ebp = " << context.uc_mcontext.gregs[REG_EBP] << std::endl; | ||||||
|     ss << "     esp = " << context.uc_mcontext.gregs[REG_ESP] << std::endl; |     ss << "     esp = " << context.uc_mcontext.gregs[REG_ESP] << std::endl; | ||||||
|     ss << "     efl = " << context.uc_mcontext.gregs[REG_EFL] << std::endl; |     ss << "     efl = " << context.uc_mcontext.gregs[REG_EFL] << std::endl; | ||||||
|  |     ss << std::endl; | ||||||
| #elif __WORDSIZE == 64 | #elif __WORDSIZE == 64 | ||||||
|     ss << "  at rip = " << context.uc_mcontext.gregs[REG_RIP] << std::endl; |     ss << "  at rip = " << context.uc_mcontext.gregs[REG_RIP] << std::endl; | ||||||
|     ss << "     rax = " << context.uc_mcontext.gregs[REG_RAX] << 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 << "     rbp = " << context.uc_mcontext.gregs[REG_RBP] << std::endl; | ||||||
|     ss << "     rsp = " << context.uc_mcontext.gregs[REG_RSP] << std::endl; |     ss << "     rsp = " << context.uc_mcontext.gregs[REG_RSP] << std::endl; | ||||||
|     ss << "     efl = " << context.uc_mcontext.gregs[REG_EFL] << std::endl; |     ss << "     efl = " << context.uc_mcontext.gregs[REG_EFL] << std::endl; | ||||||
| #endif |  | ||||||
|     ss << std::endl; |     ss << std::endl; | ||||||
|  | #endif | ||||||
|     ss.flags(std::ios::dec); |     ss.flags(std::ios::dec); | ||||||
|     ss << "  backtrace:" << std::endl; |     ss << "  backtrace:" << std::endl; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -610,3 +610,8 @@ std::string WIN32Window::getClipboardText() | ||||||
|     return text; |     return text; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | std::string WIN32Window::getPlatformType() | ||||||
|  | { | ||||||
|  |     return "WIN32-WGL"; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  |  | ||||||
|  | @ -68,6 +68,7 @@ public: | ||||||
| 
 | 
 | ||||||
|     Size getDisplaySize(); |     Size getDisplaySize(); | ||||||
|     std::string getClipboardText(); |     std::string getClipboardText(); | ||||||
|  |     std::string getPlatformType(); | ||||||
| 
 | 
 | ||||||
|     bool isMaximized() { return m_maximized; } |     bool isMaximized() { return m_maximized; } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -904,6 +904,15 @@ std::string X11Window::getClipboardText() | ||||||
|     return clipboardText; |     return clipboardText; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | std::string X11Window::getPlatformType() | ||||||
|  | { | ||||||
|  | #ifndef OPENGL_ES2 | ||||||
|  |     return "X11-GLX"; | ||||||
|  | #else | ||||||
|  |     return "X11-EGL"; | ||||||
|  | #endif | ||||||
|  | } | ||||||
|  | 
 | ||||||
| bool X11Window::isMaximized() | bool X11Window::isMaximized() | ||||||
| { | { | ||||||
|     Atom wmState = XInternAtom(m_display, "_NET_WM_STATE", False); |     Atom wmState = XInternAtom(m_display, "_NET_WM_STATE", False); | ||||||
|  |  | ||||||
|  | @ -75,6 +75,7 @@ public: | ||||||
| 
 | 
 | ||||||
|     Size getDisplaySize(); |     Size getDisplaySize(); | ||||||
|     std::string getClipboardText(); |     std::string getClipboardText(); | ||||||
|  |     std::string getPlatformType(); | ||||||
| 
 | 
 | ||||||
|     bool isMaximized(); |     bool isMaximized(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		載入中…
	
		新增問題並參考
	
	 Eduardo Bart
						Eduardo Bart