mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 14:52:01 +00:00
- unified saved games path handling for all platforms
The current game subdirectory is now created on all platforms Added support for -savedir command line switch for all platforms Removed save_dir CVAR in favor of cl_savedir which was available on Windows only Made cl_savedir CVAR global instead of different value per each game
This commit is contained in:
parent
67a2952ead
commit
787211c9dc
3 changed files with 34 additions and 30 deletions
|
@ -47,13 +47,15 @@
|
|||
#include "quotemgr.h"
|
||||
#include "mapinfo.h"
|
||||
#include "v_video.h"
|
||||
#include "gamecontrol.h"
|
||||
#include "m_argv.h"
|
||||
|
||||
static CompositeSavegameWriter savewriter;
|
||||
static FResourceFile *savereader;
|
||||
void LoadEngineState();
|
||||
void SaveEngineState();
|
||||
|
||||
CVAR(String, save_dir, "", CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
|
||||
CVAR(String, cl_savedir, "", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
|
@ -344,14 +346,33 @@ int G_ValidateSavegame(FileReader &fr, FString *savetitle, bool formenu)
|
|||
|
||||
FString G_BuildSaveName (const char *prefix)
|
||||
{
|
||||
FString name = *save_dir;
|
||||
if (name.IsEmpty())
|
||||
name = M_GetSavegamesPath();
|
||||
size_t len = name.Len();
|
||||
if (name[0] != '\0' && name[len-1] != '\\' && name[len-1] != '/')
|
||||
FString name;
|
||||
bool usefilter;
|
||||
|
||||
if (const char *const dir = Args->CheckValue("-savedir"))
|
||||
{
|
||||
name << "/";
|
||||
name = dir;
|
||||
usefilter = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = **cl_savedir ? cl_savedir : M_GetSavegamesPath();
|
||||
usefilter = true;
|
||||
}
|
||||
|
||||
const size_t len = name.Len();
|
||||
if (len > 0)
|
||||
{
|
||||
name.Substitute("\\", "/");
|
||||
if (name[len - 1] != '/')
|
||||
name << '/';
|
||||
}
|
||||
|
||||
if (usefilter)
|
||||
name << LumpFilter << '/';
|
||||
|
||||
CreatePath(name);
|
||||
|
||||
name << prefix;
|
||||
if (!strchr(prefix, '.')) name << SAVEGAME_EXT; // only add an extension if the prefix doesn't have one already.
|
||||
name = NicePath(name);
|
||||
|
|
|
@ -199,7 +199,6 @@ FString M_GetSavegamesPath()
|
|||
path += "/" GAME_DIR "/Savegames/";
|
||||
}
|
||||
|
||||
CreatePath(path);
|
||||
return path;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
#include "cmdlib.h"
|
||||
#include "i_findfile.h"
|
||||
#include "gamecontrol.h"
|
||||
#include "m_argv.h"
|
||||
#include "version.h" // for GAMENAME
|
||||
|
||||
// Stuff that needs to be set up later.
|
||||
|
@ -267,47 +266,32 @@ FString M_GetScreenshotsPath()
|
|||
// Returns the path to the default save games directory.
|
||||
//
|
||||
//===========================================================================
|
||||
CVAR(String, cl_savedir, "", CVAR_ARCHIVE)
|
||||
|
||||
FString M_GetSavegamesPath()
|
||||
{
|
||||
FString path;
|
||||
|
||||
auto dir = Args->CheckValue("-savedir");
|
||||
if (dir)
|
||||
if (!UseKnownFolders())
|
||||
{
|
||||
path = dir;
|
||||
path.Substitute("\\", "/");
|
||||
if (path[path.Len() - 1] != '/') path << '/';
|
||||
}
|
||||
else if (**cl_savedir)
|
||||
{
|
||||
path = cl_savedir;
|
||||
path.Substitute("\\", "/");
|
||||
if (path[path.Len() - 1] != '/') path << '/';
|
||||
path << LumpFilter << '/';
|
||||
}
|
||||
else if (!UseKnownFolders())
|
||||
{
|
||||
path << progdir << "Save/" << LumpFilter << "/";
|
||||
path << progdir << "Save/";
|
||||
}
|
||||
// Try standard Saved Games folder
|
||||
else if (GetKnownFolder(-1, FOLDERID_SavedGames, true, path))
|
||||
{
|
||||
path << "/" GAMENAME "/" << LumpFilter << "/";
|
||||
path << "/" GAMENAME "/";
|
||||
}
|
||||
// Try defacto My Documents/My Games folder
|
||||
else if (GetKnownFolder(CSIDL_PERSONAL, FOLDERID_Documents, true, path))
|
||||
{
|
||||
// I assume since this isn't a standard folder, it doesn't have
|
||||
// a localized name either.
|
||||
path << "/My Games/" GAMENAME "/" << LumpFilter << "/";
|
||||
path << "/My Games/" GAMENAME "/";
|
||||
}
|
||||
else
|
||||
{
|
||||
path << progdir << "Save/" << LumpFilter << "/";
|
||||
path << progdir << "Save/";
|
||||
}
|
||||
CreatePath(path);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue