Esempio n. 1
0
bool Settings::SaveSettings()
////////////////////////////////////////////////////////////////////////
{
	DataFile settingsfile;
	if (settingsfile.CreateDataFile(GetSettingsFile()))
	{
		settingsfile.WriteText(BString("############################\n"));
		settingsfile.WriteText(BString("# Genesis Commander settings file\n"));
		settingsfile.WriteText(BString("############################\n"));
		settingsfile.WriteText(BString("\n"));
		settingsfile.WriteText(BString("# General settings\n"));
		settingsfile.WriteString(BString("LANGUAGE"), GetLanguage());
		settingsfile.WriteBool(BString("ASKONEXIT"), GetAskOnExit());
		settingsfile.WriteInteger(BString("WINDOWLEFT"), GetWindowLeft());
		settingsfile.WriteInteger(BString("WINDOWTOP"), GetWindowTop());
		settingsfile.WriteInteger(BString("WINDOWWIDTH"), GetWindowWidth());
		settingsfile.WriteInteger(BString("WINDOWHEIGHT"), GetWindowHeight());
		settingsfile.WriteString(BString("TERMINALWINDOW"), GetTerminalWindow());
		settingsfile.WriteText(BString("\n"));
		settingsfile.WriteText(BString("# Left panel\n"));
		settingsfile.WriteString(BString("LEFTPANELPATH"), GetLeftPanelPath());
		settingsfile.WriteText(BString("\n"));
		settingsfile.WriteText(BString("# Right panel\n"));
		settingsfile.WriteString(BString("RIGHTPANELPATH"), GetRightPanelPath());
	
		return true;
	}
	else
		return false;
}
Esempio n. 2
0
bool Settings::LoadSettings()
////////////////////////////////////////////////////////////////////////
{
	#define GETSTRING(a,b) if (settingsfile.GetString(a, tempstring)) Set##b(tempstring);
	#define GETBOOL(a,b) if (settingsfile.GetBool(a, tempbool)) Set##b(tempbool);
	#define GETINT(a,b) if (settingsfile.GetInteger(a, tempint)) Set##b(tempint);

	BString tempstring;
	bool tempbool;
	int tempint;
	
	DataFile settingsfile;
	if (settingsfile.LoadDataFile(GetSettingsFile()))
	{
		if (settingsfile.GetBool("ASKONEXIT", tempbool))
			SetAskOnExit(tempbool);
		if (settingsfile.GetString("LANGUAGE", tempstring))
			SetLanguage(tempstring);
		if (settingsfile.GetInteger("WINDOWLEFT", tempint))
			SetWindowLeft(tempint);
		GETINT("WINDOWTOP", WindowTop);
		GETINT("WINDOWWIDTH", WindowWidth);
		GETINT("WINDOWHEIGHT", WindowHeight);
		GETSTRING("TERMINALWINDOW", TerminalWindow);
		
		GETSTRING("LEFTPANELPATH", LeftPanelPath);
		GETSTRING("RIGHTPANELPATH", RightPanelPath);
		
		return true;		
	}
	else
		return false;
}
Esempio n. 3
0
#else
	settings_path += "/";
	settings_path += SETTINGS_DIR;
	MakeDir(settings_path);
#endif

	temporary_folder = settings_path+"/tmp";

	MakeDir(GetTrackRecordsPath());
	MakeDir(GetReplayPath());
	MakeDir(GetScreenshotPath());
	MakeDir(GetTemporaryFolder());

	// Print diagnostic info.
	info_output << "Home directory: " << home_directory << std::endl;
	bool settings_file_present = FileExists(GetSettingsFile());
	info_output << "Settings file: " << GetSettingsFile();
	if (!settings_file_present)
		info_output << " (does not exist, will be created)";
	info_output << std::endl;
	info_output << "Data directory: " << data_directory;
	if (datadir)
		info_output << "\nVDRIFT_DATA_DIRECTORY: " << datadir;
#ifndef _WIN32
	info_output << "\nDATA_DIR: " << DATA_DIR;
#endif
	info_output << std::endl;
	info_output << "Temporary directory: " << GetTemporaryFolder() << std::endl;
	info_output << "Log file: " << GetLogFile() << std::endl;
}
Esempio n. 4
0
void PATHMANAGER::Init(std::ostream & info_output, std::ostream & error_output)
{
	// Figure out the user's home directory.
	const char* homedir;
#ifndef _WIN32
	if ((homedir = getenv("HOME")) == NULL)
	{
		if ((homedir = getenv("USER")) == NULL)
			if ((homedir = getenv("USERNAME")) == NULL)
				error_output << "Could not find user's home directory!" << std::endl;
		home_directory = "/home/";
	}
#else
	if ((homedir = getenv("USERPROFILE")) == NULL)
		homedir = "data";	// WIN 9x/Me
#endif
	home_directory += homedir;

	// Find data dir.
	const char * datadir = getenv("VDRIFT_DATA_DIRECTORY");
	if (datadir == NULL)
		if (FileExists("data/settings/options.config"))
			data_directory = "data";
        else
			data_directory = DATA_DIR;
	else
		data_directory = std::string(datadir);

	// Find settings file.
	settings_path = home_directory;
#ifdef _WIN32
	MakeDir(settings_path+"\\My Documents");
	MakeDir(settings_path+"\\My Documents\\My Games");
	settings_path += "\\My Documents\\My Games\\VDrift";
	MakeDir(settings_path);
#else
	settings_path += "/";
	settings_path += SETTINGS_DIR;
	MakeDir(settings_path);
#endif

	temporary_folder = settings_path+"/tmp";

	MakeDir(GetTrackRecordsPath());
	MakeDir(GetReplayPath());
	MakeDir(GetScreenshotPath());
	MakeDir(GetTemporaryFolder());

	// Print diagnostic info.
	info_output << "Home directory: " << home_directory << std::endl;
	bool settings_file_present = FileExists(GetSettingsFile());
	info_output << "Settings file: " << GetSettingsFile();
	if (!settings_file_present)
		info_output << " (does not exist, will be created)";
	info_output << std::endl;
	info_output << "Data directory: " << data_directory;
	if (datadir)
		info_output << "\nVDRIFT_DATA_DIRECTORY: " << datadir;
#ifndef _WIN32
	info_output << "\nDATA_DIR: " << DATA_DIR;
#endif
	info_output << std::endl;
	info_output << "Temporary directory: " << GetTemporaryFolder() << std::endl;
	info_output << "Log file: " << GetLogFile() << std::endl;
}