void FGameConfigFile::CreateStandardAutoExec(const char *section, bool start)
{
	if (!SetSection(section))
	{
		FString path;
#ifdef __APPLE__
		char cpath[PATH_MAX];
		FSRef folder;
		
		if (noErr == FSFindFolder(kUserDomain, kDocumentsFolderType, kCreateFolder, &folder) &&
			noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
		{
			path << cpath << "/" GAME_DIR "/autoexec.cfg";
		}
#elif !defined(unix)
		path = "$PROGDIR/autoexec.cfg";
#else
		path = GetUserFile ("autoexec.cfg");
#endif
		SetSection (section, true);
		SetValueForKey ("Path", path.GetChars());
	}
	if (start)
	{
		MoveSectionToStart(section);
	}
}
Пример #2
0
void FGameConfigFile::CreateStandardAutoExec(const char *section, bool start)
{
	if (!SetSection(section))
	{
		FString path = M_GetAutoexecPath();
		SetSection (section, true);
		SetValueForKey ("Path", path.GetChars());
	}
	if (start)
	{
		MoveSectionToStart(section);
	}
}
FGameConfigFile::FGameConfigFile ()
{
#ifdef __APPLE__
	FString user_docs, user_app_support, local_app_support;
#endif
	FString pathname;
	
	bMigrating = false;
	pathname = GetConfigPath (true);
	ChangePathName (pathname);
	LoadConfigFile (MigrateStub, NULL);

	if (!HaveSections ())
	{ // Config file not found; try the old one
		MigrateOldConfig ();
	}

	// If zdoom.ini was read from the program directory, switch
	// to the user directory now. If it was read from the user
	// directory, this effectively does nothing.
	pathname = GetConfigPath (false);
	ChangePathName (pathname);

	// Set default IWAD search paths if none present
	if (!SetSection ("IWADSearch.Directories"))
	{
		SetSection ("IWADSearch.Directories", true);
		SetValueForKey ("Path", ".", true);
		SetValueForKey ("Path", "$DOOMWADDIR", true);
#ifdef __APPLE__
		char cpath[PATH_MAX];
		FSRef folder;
		
		if (noErr == FSFindFolder(kUserDomain, kDocumentsFolderType, kCreateFolder, &folder) &&
			noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
		{
			user_docs << cpath << "/" GAME_DIR;
			SetValueForKey("Path", user_docs, true);
		}
		else
		{
			SetValueForKey("Path", "~/" GAME_DIR, true);
		}
		if (noErr == FSFindFolder(kUserDomain, kApplicationSupportFolderType, kCreateFolder, &folder) &&
			noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
		{
			user_app_support << cpath << "/" GAME_DIR;
			SetValueForKey("Path", user_app_support, true);
		}
		SetValueForKey ("Path", "$PROGDIR", true);
		if (noErr == FSFindFolder(kLocalDomain, kApplicationSupportFolderType, kCreateFolder, &folder) &&
			noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
		{
			local_app_support << cpath << "/" GAME_DIR;
			SetValueForKey("Path", local_app_support, true);
		}
#elif !defined(unix)
		SetValueForKey ("Path", "$HOME", true);
		SetValueForKey ("Path", "$PROGDIR", true);
#else
		SetValueForKey ("Path", "~/" GAME_DIR, true);
		SetValueForKey ("Path", SHARE_DIR, true);
#endif
	}

	// Set default search paths if none present
	if (!SetSection ("FileSearch.Directories"))
	{
		SetSection ("FileSearch.Directories", true);
#ifdef __APPLE__
		SetValueForKey ("Path", user_docs, true);
		SetValueForKey ("Path", user_app_support, true);
		SetValueForKey ("Path", "$PROGDIR", true);
		SetValueForKey ("Path", local_app_support, true);
#elif !defined(unix)
		SetValueForKey ("Path", "$PROGDIR", true);
#else
		SetValueForKey ("Path", SHARE_DIR, true);
#endif
		SetValueForKey ("Path", "$DOOMWADDIR", true);
	}

	// Create auto-load sections, so users know what's available.
	// Note that this totem pole is the reverse of the order that
	// they will appear in the file.
	CreateSectionAtStart("Chex3.Autoload");
	CreateSectionAtStart("Chex.Autoload");
	CreateSectionAtStart("Strife.Autoload");
	CreateSectionAtStart("HexenDemo.Autoload");
	CreateSectionAtStart("HexenDK.Autoload");
	CreateSectionAtStart("Hexen.Autoload");
	CreateSectionAtStart("Heretic.Autoload");
	CreateSectionAtStart("FreeDM.Autoload");
	CreateSectionAtStart("Freedoom1.Autoload");
	CreateSectionAtStart("Freedoom.Autoload");
	CreateSectionAtStart("Plutonia.Autoload");
	CreateSectionAtStart("TNT.Autoload");
	CreateSectionAtStart("Doom2.Autoload");
	CreateSectionAtStart("Doom1.Autoload");
	CreateSectionAtStart("Doom.Autoload");
	CreateSectionAtStart("Global.Autoload");

	// The same goes for auto-exec files.
	CreateStandardAutoExec("Chex.AutoExec", true);
	CreateStandardAutoExec("Strife.AutoExec", true);
	CreateStandardAutoExec("Hexen.AutoExec", true);
	CreateStandardAutoExec("Heretic.AutoExec", true);
	CreateStandardAutoExec("Doom.AutoExec", true);

	// Move search paths back to the top.
	MoveSectionToStart("FileSearch.Directories");
	MoveSectionToStart("IWADSearch.Directories");

	// Add some self-documentation.
	SetSectionNote("IWADSearch.Directories",
		"# These are the directories to automatically search for IWADs.\n"
		"# Each directory should be on a separate line, preceded by Path=\n");
	SetSectionNote("FileSearch.Directories",
		"# These are the directories to search for wads added with the -file\n"
		"# command line parameter, if they cannot be found with the path\n"
		"# as-is. Layout is the same as for IWADSearch.Directories\n");
	SetSectionNote("Doom.AutoExec",
		"# Files to automatically execute when running the corresponding game.\n"
		"# Each file should be on its own line, preceded by Path=\n\n");
	SetSectionNote("Global.Autoload",
		"# WAD files to always load. These are loaded after the IWAD but before\n"
		"# any files added with -file. Place each file on its own line, preceded\n"
		"# by Path=\n");
	SetSectionNote("Doom.Autoload",
		"# Wad files to automatically load depending on the game and IWAD you are\n"
		"# playing.  You may have have files that are loaded for all similar IWADs\n"
		"# (the game) and files that are only loaded for particular IWADs. For example,\n"
		"# any files listed under Doom.Autoload will be loaded for any version of Doom,\n"
		"# but files listed under Doom2.Autoload will only load when you are\n"
		"# playing Doom 2.\n\n");
}
Пример #4
0
void FConfigFile::CreateSectionAtStart (const char *name)
{
	NewConfigSection (name);
	MoveSectionToStart (name);
}
Пример #5
0
void FGameConfigFile::DoAutoloadSetup (FIWadManager *iwad_man)
{
	// Create auto-load sections, so users know what's available.
	// Note that this totem pole is the reverse of the order that
	// they will appear in the file.

	double last = 0;
	if (SetSection ("LastRun"))
	{
		const char *lastver = GetValueForKey ("Version");
		if (lastver != NULL) last = atof(lastver);
	}

	if (last < 211)
	{
		RenameSection("Chex3.Autoload", "chex.chex3.Autoload");
		RenameSection("Chex1.Autoload", "chex.chex1.Autoload");
		RenameSection("HexenDK.Autoload", "hexen.deathkings.Autoload");
		RenameSection("HereticSR.Autoload", "heretic.shadow.Autoload");
		RenameSection("FreeDM.Autoload", "doom.freedoom.freedm.Autoload");
		RenameSection("Freedoom2.Autoload", "doom.freedoom.phase2.Autoload");
		RenameSection("Freedoom1.Autoload", "doom.freedoom.phase1.Autoload");
		RenameSection("Freedoom.Autoload", "doom.freedoom.Autoload");
		RenameSection("DoomBFG.Autoload", "doom.id.doom1.bfg.Autoload");
		RenameSection("DoomU.Autoload", "doom.id.doom1.ultimate.Autoload");
		RenameSection("Doom1.Autoload", "doom.id.doom1.registered.Autoload");
		RenameSection("TNT.Autoload", "doom.id.doom2.tnt.Autoload");
		RenameSection("Plutonia.Autoload", "doom.id.doom2.plutonia.Autoload");
		RenameSection("Doom2BFG.Autoload", "doom.id.doom2.bfg.Autoload");
		RenameSection("Doom2.Autoload", "doom.id.doom2.commercial.Autoload");
	}
	else if (last < 218)
	{
		RenameSection("doom.doom1.bfg.Autoload", "doom.id.doom1.bfg.Autoload");
		RenameSection("doom.doom1.ultimate.Autoload", "doom.id.doom1.ultimate.Autoload");
		RenameSection("doom.doom1.registered.Autoload", "doom.id.doom1.registered.Autoload");
		RenameSection("doom.doom2.tnt.Autoload", "doom.id.doom2.tnt.Autoload");
		RenameSection("doom.doom2.plutonia.Autoload", "doom.id.doom2.plutonia.Autoload");
		RenameSection("doom.doom2.bfg.Autoload", "doom.id.doom2.bfg.Autoload");
		RenameSection("doom.doom2.commercial.Autoload", "doom.id.doom2.commercial.Autoload");
	}
	const FString *pAuto;
	for (int num = 0; (pAuto = iwad_man->GetAutoname(num)) != NULL; num++)
	{
		if (!(iwad_man->GetIWadFlags(num) & GI_SHAREWARE))	// we do not want autoload sections for shareware IWADs (which may have an autoname for resource filtering)
		{
			FString workname = *pAuto;

			while (workname.IsNotEmpty())
			{
				FString section = workname + ".Autoload";
				CreateSectionAtStart(section.GetChars());
				long dotpos = workname.LastIndexOf('.');
				if (dotpos < 0) break;
				workname.Truncate(dotpos);
			}
		}
	}
	CreateSectionAtStart("Global.Autoload");

	// The same goes for auto-exec files.
	CreateStandardAutoExec("Chex.AutoExec", true);
	CreateStandardAutoExec("Strife.AutoExec", true);
	CreateStandardAutoExec("Hexen.AutoExec", true);
	CreateStandardAutoExec("Heretic.AutoExec", true);
	CreateStandardAutoExec("Doom.AutoExec", true);

	// Move search paths back to the top.
	MoveSectionToStart("SoundfontSearch.Directories");
	MoveSectionToStart("FileSearch.Directories");
	MoveSectionToStart("IWADSearch.Directories");

	SetSectionNote("Doom.AutoExec",
		"# Files to automatically execute when running the corresponding game.\n"
		"# Each file should be on its own line, preceded by Path=\n\n");
	SetSectionNote("Global.Autoload",
		"# WAD files to always load. These are loaded after the IWAD but before\n"
		"# any files added with -file. Place each file on its own line, preceded\n"
		"# by Path=\n");
	SetSectionNote("Doom.Autoload",
		"# Wad files to automatically load depending on the game and IWAD you are\n"
		"# playing.  You may have have files that are loaded for all similar IWADs\n"
		"# (the game) and files that are only loaded for particular IWADs. For example,\n"
		"# any files listed under 'doom.Autoload' will be loaded for any version of Doom,\n"
		"# but files listed under 'doom.doom2.Autoload' will only load when you are\n"
		"# playing a Doom 2 based game (doom2.wad, tnt.wad or plutonia.wad), and files listed under\n"
		"# 'doom.doom2.commercial.Autoload' only when playing doom2.wad.\n\n");
}