Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5231: Move PreferenceSystem to the core module. This required a few …
…interfaces to be created along the way. The GameManager is already prepared to be moved, which is the next step.
- Loading branch information
1 parent
aa28109
commit 3dafa39
Showing
24 changed files
with
356 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#pragma once | ||
|
||
#include "igame.h" | ||
|
||
#include "registry/registry.h" | ||
#include "os/path.h" | ||
#include "os/file.h" | ||
|
||
namespace game | ||
{ | ||
|
||
/** | ||
* Some algorithms built around the GameConfiguration class. | ||
*/ | ||
class GameConfigUtil | ||
{ | ||
public: | ||
// Loads the property values of this instance from the XMLRegistry | ||
static GameConfiguration LoadFromRegistry() | ||
{ | ||
GameConfiguration result; | ||
|
||
result.gameType = registry::getValue<std::string>(RKEY_GAME_TYPE); | ||
result.enginePath = os::standardPathWithSlash(registry::getValue<std::string>(RKEY_ENGINE_PATH)); | ||
result.modPath = os::standardPathWithSlash(registry::getValue<std::string>(RKEY_MOD_PATH)); | ||
result.modBasePath = os::standardPathWithSlash(registry::getValue<std::string>(RKEY_MOD_BASE_PATH)); | ||
|
||
return result; | ||
} | ||
|
||
// Persists the values of this instance to the XMLRegistry | ||
static void SaveToRegistry(const GameConfiguration& config) | ||
{ | ||
registry::setValue(RKEY_GAME_TYPE, config.gameType); | ||
registry::setValue(RKEY_ENGINE_PATH, config.enginePath); | ||
registry::setValue(RKEY_MOD_PATH, config.modPath); | ||
registry::setValue(RKEY_MOD_BASE_PATH, config.modBasePath); | ||
} | ||
|
||
// Makes sure that all paths are normalised OS paths | ||
static void EnsurePathsNormalised(GameConfiguration& config) | ||
{ | ||
config.enginePath = os::standardPathWithSlash(config.enginePath); | ||
config.modPath = os::standardPathWithSlash(config.modPath); | ||
config.modBasePath = os::standardPathWithSlash(config.modBasePath); | ||
} | ||
|
||
// Returns true if the paths in this config are pointing to valid OS folders | ||
static bool PathsValid(const GameConfiguration& config) | ||
{ | ||
if (!os::fileOrDirExists(config.enginePath)) | ||
{ | ||
// Engine path doesn't exist | ||
return false; | ||
} | ||
|
||
// Check the mod base path, if appropriate | ||
if (!config.modBasePath.empty() && !os::fileOrDirExists(config.modBasePath)) | ||
{ | ||
// Mod base name is not empty, but folder doesnt' exist | ||
return false; | ||
} | ||
|
||
// Check the mod path, if appropriate | ||
if (!config.modPath.empty() && !os::fileOrDirExists(config.modPath)) | ||
{ | ||
// Mod name is not empty, but mod folder doesnt' exist | ||
return false; | ||
} | ||
|
||
return true; // all paths ok | ||
} | ||
}; | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.