コード例 #1
0
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);
}
コード例 #2
0
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]);
}
コード例 #3
0
ファイル: umake.cpp プロジェクト: ultimatepp/mirror
String GetUmkFile(const char *fn)
{
    return GetFileOnPath(fn,
                         GetHomeDirFile(".upp/umk") + ';' +
                         GetHomeDirFile(".upp/theide") + ';' +
                         GetHomeDirFile(".upp/ide") + ';' +
                         GetHomeDirectory() + ';' +
                         GetFileFolder(GetExeFilePath()));
}
コード例 #4
0
ファイル: Workspace.cpp プロジェクト: kolyden/mirror
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
}
コード例 #5
0
ファイル: Updater.cpp プロジェクト: AbdelghaniDr/mirror
// 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;

}
コード例 #6
0
ファイル: MapEditorMap.cpp プロジェクト: AbdelghaniDr/mirror
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();
}
コード例 #7
0
ファイル: App.cpp プロジェクト: dreamsxin/ultimatepp
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
};
コード例 #8
0
ファイル: MapEditorMap.cpp プロジェクト: AbdelghaniDr/mirror
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();
}
コード例 #9
0
ファイル: Updater.cpp プロジェクト: AbdelghaniDr/mirror
// 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);
}
コード例 #10
0
ファイル: UrpTopWindow.cpp プロジェクト: radtek/lister
UrpTopWindow::UrpTopWindow() {
	// These have to be here and called by default constructor, don't know why.
	exeFilePath = GetExeFilePath();
	connectAsUser = GetUserName();	
}
コード例 #11
0
ファイル: App.cpp プロジェクト: guowei8412/upp-mirror
String GetExeTitle()
{
	return GetFileTitle(GetExeFilePath());
}
コード例 #12
0
ファイル: App.cpp プロジェクト: guowei8412/upp-mirror
String GetExeDirFile(const char *filename)
{
	return AppendFileName(GetFileFolder(GetExeFilePath()), filename);
}
コード例 #13
0
ファイル: Utility.cpp プロジェクト: amate/PeerCastPX
// exeのあるフォルダを返す(最後に \ が付かない)
CString GetExeDirName()
{
	CString str = GetExeFilePath();
	int		n	= str.ReverseFind( _T('\\') );
	return str.Left(n);
}
コード例 #14
0
ファイル: Utility.cpp プロジェクト: amate/PeerCastPX
// exeのあるフォルダを返す(最後に \ がつく)
CString GetExeDirectory()
{
	CString str = GetExeFilePath();
	int		n	= str.ReverseFind( _T('\\') );
	return str.Left(n+1);
}