- Moved ExpandEnvVars() from d_main.cpp to cmdlib.cpp.
- AutoExec paths now support the same variable expansion as the search paths. Additionally, on Windows, the default autoexec path is now relative to $PROGDIR, rather than using a fixed path to the executable's current directory. - All usable Autoload and AutoExec sections are now created at the top of the config file along with some brief explanatory notes so they are readily visible to anyone who wants to edit them. SVN r1307 (trunk)
This commit is contained in:
parent
fb75c46806
commit
ef3b57fb8f
8 changed files with 466 additions and 101 deletions
|
|
@ -3,7 +3,7 @@
|
|||
** An .ini parser specifically for zdoom.ini
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 1998-2006 Randy Heit
|
||||
** Copyright 1998-2008 Randy Heit
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -120,6 +120,60 @@ FGameConfigFile::FGameConfigFile ()
|
|||
#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");
|
||||
}
|
||||
|
||||
FGameConfigFile::~FGameConfigFile ()
|
||||
|
|
@ -128,8 +182,7 @@ FGameConfigFile::~FGameConfigFile ()
|
|||
|
||||
void FGameConfigFile::WriteCommentHeader (FILE *file) const
|
||||
{
|
||||
fprintf (file, "# This file was generated by " GAMENAME " " DOTVERSIONSTR " on %s"
|
||||
"# It is not really meant to be modified outside of ZDoom, nyo.\n\n", myasctime ());
|
||||
fprintf (file, "# This file was generated by " GAMENAME " " DOTVERSIONSTR " on %s\n", myasctime());
|
||||
}
|
||||
|
||||
void FGameConfigFile::MigrateStub (const char *pathname, FConfigFile *config, void *userdata)
|
||||
|
|
@ -507,6 +560,25 @@ FString FGameConfigFile::GetConfigPath (bool tryProg)
|
|||
#endif
|
||||
}
|
||||
|
||||
void FGameConfigFile::CreateStandardAutoExec(const char *section, bool start)
|
||||
{
|
||||
if (!SetSection(section))
|
||||
{
|
||||
FString path;
|
||||
#ifndef unix
|
||||
path = "$PROGDIR/autoexec.cfg";
|
||||
#else
|
||||
path = GetUserFile ("autoexec.cfg");
|
||||
#endif
|
||||
SetSection (section, true);
|
||||
SetValueForKey ("Path", path.GetChars());
|
||||
}
|
||||
if (start)
|
||||
{
|
||||
MoveSectionToStart(section);
|
||||
}
|
||||
}
|
||||
|
||||
void FGameConfigFile::AddAutoexec (DArgs *list, const char *game)
|
||||
{
|
||||
char section[64];
|
||||
|
|
@ -537,34 +609,19 @@ void FGameConfigFile::AddAutoexec (DArgs *list, const char *game)
|
|||
{
|
||||
// If <game>.AutoExec section does not exist, create it
|
||||
// with a default autoexec.cfg file present.
|
||||
if (!SetSection (section))
|
||||
{
|
||||
FString path;
|
||||
|
||||
#ifndef unix
|
||||
if (Args->CheckParm ("-cdrom"))
|
||||
{
|
||||
path = CDROM_DIR "\\autoexec.cfg";
|
||||
}
|
||||
else
|
||||
{
|
||||
path = progdir;
|
||||
path += "autoexec.cfg";
|
||||
}
|
||||
#else
|
||||
path = GetUserFile ("autoexec.cfg");
|
||||
#endif
|
||||
SetSection (section, true);
|
||||
SetValueForKey ("Path", path.GetChars());
|
||||
}
|
||||
CreateStandardAutoExec(section, false);
|
||||
// Run any files listed in the <game>.AutoExec section
|
||||
if (SetSection (section))
|
||||
if (!SectionIsEmpty())
|
||||
{
|
||||
while (NextInSection (key, value))
|
||||
{
|
||||
if (stricmp (key, "Path") == 0 && FileExists (value))
|
||||
if (stricmp (key, "Path") == 0 && *value != '\0')
|
||||
{
|
||||
list->AppendArg (value);
|
||||
FString expanded_path = ExpandEnvVars(value);
|
||||
if (FileExists(expanded_path))
|
||||
{
|
||||
list->AppendArg (ExpandEnvVars(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue