more changes to work on ARM

This commit is contained in:
Eduardo Bart 2011-12-30 02:50:19 -02:00
parent a394033872
commit e95973174c
12 changed files with 33 additions and 23 deletions

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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<Logger>();
@ -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));
}

View File

@ -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

View File

@ -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,

View File

@ -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(); }

View File

@ -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;

View File

@ -610,3 +610,8 @@ std::string WIN32Window::getClipboardText()
return text;
}
std::string WIN32Window::getPlatformType()
{
return "WIN32-WGL";
}

View File

@ -68,6 +68,7 @@ public:
Size getDisplaySize();
std::string getClipboardText();
std::string getPlatformType();
bool isMaximized() { return m_maximized; }

View File

@ -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);

View File

@ -75,6 +75,7 @@ public:
Size getDisplaySize();
std::string getClipboardText();
std::string getPlatformType();
bool isMaximized();