void MapEditor::OnLevelMapCalc(Level& level, int number) { if (level.GetMapBG().IsEmpty()) { Exclamation(NFormat(t_("Please, select the image for level: %s"), level.GetName())); return; } String fp = AppendFileName( AppendFileName( GetFileDirectory(GetExeFilePath()), "Maps"), level.GetMapBG()); if (!FileExists(fp)) { Exclamation(NFormat(t_("Image file not exist: %s"), fp)); return; } String name = level.GetName(); double zx = level.GetZoomDX(); Size pz = level.GetPageSize(); Size sz = level.GetCellSize(); FileIn in(fp); One<StreamRaster> r = StreamRaster::OpenAny(in); if (!r) { Exclamation(NFormat(t_("Error while loading image file: %s"), fp)); return; } Image img = r->GetImage(); Calculate(sz.cx, sz.cy, pz.cx, pz.cy, zx, NFormat("%s-%d", _map.GetName(), number + 1), img); }
void MapEditor::OnLevelMapList(VectorMapEx<String, Value>& mapList) { Vector<String> files = GetDirectoryFiles( AppendFileName( GetFileDirectory(GetExeFilePath()), "Maps")); Sort(files); for (int i = 0; i < files.GetCount(); ++i) mapList.Add(files[i], files[i]); }
String GetUmkFile(const char *fn) { return GetFileOnPath(fn, GetHomeDirFile(".upp/umk") + ';' + GetHomeDirFile(".upp/theide") + ';' + GetHomeDirFile(".upp/ide") + ';' + GetHomeDirectory() + ';' + GetFileFolder(GetExeFilePath())); }
String GetUppDir() { Vector<String> s = GetUppDirs(); #ifdef PLATFORM_WIN32 return s.GetCount() == 0 ? GetFileFolder(GetExeFilePath()) : s[0]; #endif #ifdef PLATFORM_POSIX return s.GetCount() == 0 ? GetHomeDirectory() : s[0]; #endif }
// main updater proc inside normal mode // prepares environment, copy app in temporary folder // and restarts it in superuser mode // returns true if app must continue execution, false otherwise bool Updater::START_Updater(String const &operation) { // prepare environment for updating environment.Add("UPDATER_USER", user); environment.Add("UPDATER_OP", operation); environment.Add("UPDATER_STATE", "INSIDEUPDATER"); environment.Add("UPDATER_APPNAME", appName); environment.Add("UPDATER_EXEPATH", GetExeFilePath()); if(CommandLine().GetCount() && CommandLine()[0] != "--UNINSTALL") { String s; for(int i = 0; i < CommandLine().GetCount(); i++) s += CommandLine()[i] + " "; s = s.Left(s.GetCount() - 1); environment.Add("UPDATER_CMDLINE", s); } // gets current executable path String exePath = GetExeFilePath(); // creates a temporary filename and copies itself // in temporary folder String tempName = GetTempFileName(); #ifdef PLATFORM_WIN32 tempName += ".exe"; #endif if(!FileCopy(exePath, tempName)) return true; #ifdef PLATFORM_POSIX // for posix, change temp file permission // allowing its execution and executes it as a superuser if(chmod(~tempName, 0755) != 0) return true; #endif // executes the file asking for password bool res = !SysStartAdmin(tempName, "", environment); return res; }
void MapEditor::OnSaveMap() { CalculateAllPrompt(); if (!StoreAsXMLFile(_map, _map.GetName(), AppendFileName( AppendFileName(GetFileDirectory(GetExeFilePath()), "Mipmaps"), _map.GetName() + ".map" ))) { Exclamation(t_("Error while saving map to file!")); } UpdateEditorCtrls(); }
namespace Ini { INI_INT(port, 8001, "TCP/IP server port to listen on"); INI_STRING(ip, "0.0.0.0", "IP address to listen on"); INI_STRING(path, Nvl(GetEnv("UPP_ASSEMBLY__"), GetFileFolder(GetExeFilePath())), "Path to witz templates and static files"); INI_INT(threads, 3 * CPU_Cores() + 1, "Number of threads in each Skylark subprocess"); #ifdef _DEBUG INI_INT(prefork, 0, "Number of preforked Skylark subprocesses"); INI_INT(timeout, 0, "Timeout in seconds for Skylark event handler"); INI_BOOL(use_caching, false, "Cache compiled witz templates or other data"); INI_INT(caching, 1, "Agressivity of caching on static/** " "(0=no caching, 1=use ETag header, 2=use versioned path)"); #else INI_INT(prefork, 1, "Number of preforked Skylark subprocesses"); INI_INT(timeout, 300, "Timeout in seconds for Skylark event handler"); INI_BOOL(use_caching, true, "Cache compiled witz templates or other data"); INI_INT(caching, 1, "Agressivity of caching on static/** " "(0=no caching, 1=use ETag header, 2=use versioned path)"); #endif };
void MapEditor::OnLoadMap() { WithMapLoadLayout<TopWindow> dlg; CtrlLayoutOKCancel(dlg, t_("Load Map...")); String dir = AppendFileName( GetFileDirectory(GetExeFilePath()), "Mipmaps"); Vector<String> files = GetDirectoryFiles(dir, "*.map"); Sort(files); if (files.GetCount() <= 0) { Exclamation(t_("No any file to load!")); return; } for (int i = 0; i < files.GetCount(); ++i) dlg.MapList.Add(files[i], files[i]); dlg.MapList.SetIndex(0); if (dlg.Execute() != IDOK) return; String fp = AppendFileName(dir, (~dlg.MapList).ToString()); if (!FileExists(fp)) { Exclamation(NFormat(t_("File not found: %s"), fp)); return; } if (!LoadFromXMLFile(_map, fp)) { Exclamation(NFormat(t_("Error while loading map from file: %s"), fp)); return; } UpdateLevelList(); UpdateEditorCtrls(); }
// restarts app in normal mode after updater mode // either it re-launches the original one if update didn't succeed // or the new one if it did OR the temporary app if uninstalling void Updater::RestartApp(RestartModes restartMode) { String path; switch(restartMode) { case RestartTemp: path = GetExeFilePath(); break; case RestartOrig: default: path = exePath; break; case RestartNew: #ifdef PLATFORM_POSIX path = AppendFileName(GetProgramsFolder(), appName); #else path = AppendFileName(GetProgramsFolder(), appName + "/" + appName + ".exe"); #endif break; } // restart app in user mode, no gui, no password should be needed SysStartUser(user, "", path, commandLine, environment); }
UrpTopWindow::UrpTopWindow() { // These have to be here and called by default constructor, don't know why. exeFilePath = GetExeFilePath(); connectAsUser = GetUserName(); }
String GetExeTitle() { return GetFileTitle(GetExeFilePath()); }
String GetExeDirFile(const char *filename) { return AppendFileName(GetFileFolder(GetExeFilePath()), filename); }
// exeのあるフォルダを返す(最後に \ が付かない) CString GetExeDirName() { CString str = GetExeFilePath(); int n = str.ReverseFind( _T('\\') ); return str.Left(n); }
// exeのあるフォルダを返す(最後に \ がつく) CString GetExeDirectory() { CString str = GetExeFilePath(); int n = str.ReverseFind( _T('\\') ); return str.Left(n+1); }