int main (int argc, char *argv[]) { #ifdef WIN32 if (__argv[0]) { applicationPath = __argv[0]; applicationPath.erase (applicationPath.find_last_of ('\\')+1, applicationPath.size()); } #else if (argv[0]) { applicationPath = argv[0]; applicationPath.erase (applicationPath.find_last_of ('/')+1, applicationPath.size()); } #endif // Setup logger callback, so error messages are reported with fltk::message logger.AddCallback (LogCallbackProc, 0); #ifdef _DEBUG logger.SetDebugMode (true); #endif // math_test(); // Initialize the class system creg::ClassBinder::InitializeClasses (); int r = 0; if (ParseCmdLine(argc, argv, r)) { // Bring up the main editor dialog EditorUI editor; editorUI = &editor; editor.Show(true); editor.LoadToolWindowSettings(); // luaBinder.Init(); lua_State *L = lua_open(); luaL_openlibs(L); luaopen_upspring(L); editor.luaState = L; if (luaL_dostring(L, "require(\"jit.opt\").start()") != 0) { const char *err = lua_tostring(L, -1); fltk::message("Unable to start Lua JIT: %s", err); } if (luaL_dofile(L, "scripts/init.lua") != 0) { const char *err = lua_tostring(L, -1); fltk::message("Error while executing init.lua: %s", err); } fltk::run(); } // Shutdown scripting system and class system creg::ClassBinder::FreeClasses (); return r; }
int main (int argc, char *argv[]) { #ifdef WIN32 if (__argv[0]) { applicationPath = __argv[0]; applicationPath.erase (applicationPath.find_last_of ('\\')+1, applicationPath.size()); } #else if (argv[0]) { applicationPath = argv[0]; applicationPath.erase (applicationPath.find_last_of ('/')+1, applicationPath.size()); } #endif // Setup logger callback, so error messages are reported with fltk::message logger.AddCallback (LogCallbackProc, 0); #ifdef _DEBUG logger.SetDebugMode (true); #endif // math_test(); // Initialize the class system creg::System::InitializeClasses (); int r = 0; if (ParseCmdLine(argc, argv, r)) { // Bring up the main editor dialog EditorUI editor; editorUI = &editor; editor.Show(true); editor.LoadToolWindowSettings(); // luaBinder.Init(); lua_State *L = lua_open(); luaL_openlibs(L); luaopen_upspring(L); editor.luaState = L; if (luaL_dostring(L, "require(\"jit.opt\").start()") != 0) { const char *err = lua_tostring(L, -1); fltk::message("Unable to start Lua JIT: %s", err); } if (luaL_dofile(L, "scripts/init.lua") != 0) { const char *err = lua_tostring(L, -1); fltk::message("Error while executing init.lua: %s", err); } // NOTE: the "scripts/plugins" literal was changed to "scripts/plugins/" std::list<std::string>* luaFiles = FindFiles("*.lua", false, #ifdef WIN32 "scripts\\plugins"); #else "scripts/plugins/"); #endif for (std::list<std::string>::iterator i = luaFiles->begin(); i != luaFiles->end(); ++i) { if (luaL_dofile(L, i->c_str()) != 0) { const char *err = lua_tostring(L, -1); fltk::message("Error while executing \'%s\': %s", i->c_str(), err); } } fltk::run(); } // Shutdown scripting system and class system creg::System::FreeClasses (); return r; }