mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Allow config files to be placed under the memstick.
This way, they can be configured more easily on Android, etc.
This commit is contained in:
1 parent
82c56dccff
commit
79143b56d2
6 files changed
+79
-40
No files matched your search
+34
-3
@@ -19,6 +19,7 @@
|
||||
#include "base/NativeApp.h"
|
||||
#include "Common/KeyMap.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Config.h"
|
||||
#include "file/ini_file.h"
|
||||
#include "i18n/i18n.h"
|
||||
@@ -36,9 +37,8 @@ Config::~Config() { }
|
||||
|
||||
void Config::Load(const char *iniFileName, const char *controllerIniFilename)
|
||||
{
|
||||
iniFilename_ = iniFileName != NULL ? iniFileName : "ppsspp.ini";
|
||||
|
||||
controllerIniFilename_ = controllerIniFilename != NULL ? controllerIniFilename : "controls.ini";
|
||||
iniFilename_ = FindConfigFile(iniFileName != NULL ? iniFileName : "ppsspp.ini");
|
||||
controllerIniFilename_ = FindConfigFile(controllerIniFilename != NULL ? controllerIniFilename : "controls.ini");
|
||||
|
||||
INFO_LOG(LOADER, "Loading config: %s", iniFilename_.c_str());
|
||||
bSaveSettings = true;
|
||||
@@ -462,7 +462,38 @@ void Config::CleanRecent() {
|
||||
recentIsos = cleanedRecent;
|
||||
}
|
||||
|
||||
void Config::SetDefaultPath(const std::string &defaultPath) {
|
||||
defaultPath_ = defaultPath;
|
||||
}
|
||||
|
||||
void Config::AddSearchPath(const std::string &path) {
|
||||
searchPath_.push_back(path);
|
||||
}
|
||||
|
||||
const std::string Config::FindConfigFile(const std::string &baseFilename) {
|
||||
// Don't search for an absolute path.
|
||||
if (baseFilename.size() > 1 && baseFilename[0] == '/') {
|
||||
return baseFilename;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < searchPath_.size(); ++i) {
|
||||
std::string filename = searchPath_[i] + baseFilename;
|
||||
if (File::Exists(filename)) {
|
||||
return filename;
|
||||
}
|
||||
}
|
||||
|
||||
const std::string filename = defaultPath_.empty() ? baseFilename : defaultPath_ + baseFilename;
|
||||
if (!File::Exists(filename)) {
|
||||
std::string path;
|
||||
SplitPath(filename, &path, NULL, NULL);
|
||||
File::CreateFullPath(path);
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
void Config::RestoreDefaults() {
|
||||
// TODO: This should probably use the correct path?
|
||||
if(File::Exists("ppsspp.ini"))
|
||||
File::Delete("ppsspp.ini");
|
||||
recentIsos.clear();
|
||||
|
||||
@@ -180,6 +180,12 @@ public:
|
||||
void Save();
|
||||
void RestoreDefaults();
|
||||
|
||||
// Used when the file is not found in the search path. Trailing slash.
|
||||
void SetDefaultPath(const std::string &defaultPath);
|
||||
// Use a trailing slash.
|
||||
void AddSearchPath(const std::string &path);
|
||||
const std::string FindConfigFile(const std::string &baseFilename);
|
||||
|
||||
// Utility functions for "recent" management
|
||||
void AddRecent(const std::string &file);
|
||||
void CleanRecent();
|
||||
@@ -187,6 +193,8 @@ public:
|
||||
private:
|
||||
std::string iniFilename_;
|
||||
std::string controllerIniFilename_;
|
||||
std::vector<std::string> searchPath_;
|
||||
std::string defaultPath_;
|
||||
};
|
||||
|
||||
extern Config g_Config;
|
||||
+5
-5
@@ -29,7 +29,6 @@ Texture *uiTexture;
|
||||
UIContext *uiContext;
|
||||
|
||||
ScreenManager *screenManager;
|
||||
std::string config_filename;
|
||||
std::string game_title;
|
||||
|
||||
event m_hGPUStepEvent;
|
||||
@@ -228,18 +227,19 @@ void QtHost::NextGPUStep()
|
||||
|
||||
void NativeInit(int argc, const char *argv[], const char *savegame_directory, const char *external_directory, const char *installID)
|
||||
{
|
||||
std::string config_filename;
|
||||
Common::EnableCrashingOnCrashes();
|
||||
isMessagePending = false;
|
||||
|
||||
std::string user_data_path = savegame_directory;
|
||||
std::string memcard_path = QDir::homePath().toStdString() + "/.ppsspp/";
|
||||
|
||||
VFSRegister("", new DirectoryAssetReader("assets/"));
|
||||
VFSRegister("", new DirectoryAssetReader(user_data_path.c_str()));
|
||||
|
||||
config_filename = user_data_path + "ppsspp.ini";
|
||||
|
||||
g_Config.Load(config_filename.c_str());
|
||||
g_Config.AddSearchPath(user_data_path);
|
||||
g_Config.AddSearchPath(memcard_path + "PSP/SYSTEM/");
|
||||
g_Config.SetDefaultPath(g_Config.memCardDirectory + "PSP/SYSTEM/");
|
||||
g_Config.Load();
|
||||
|
||||
const char *fileToLog = 0;
|
||||
|
||||
|
||||
+24
-22
@@ -246,6 +246,22 @@ void NativeInit(int argc, const char *argv[],
|
||||
|
||||
host = new NativeHost();
|
||||
|
||||
#if defined(ANDROID)
|
||||
g_Config.internalDataDirectory = savegame_directory;
|
||||
// Maybe there should be an option to use internal memory instead, but I think
|
||||
// that for most people, using external memory (SDCard/USB Storage) makes the
|
||||
// most sense.
|
||||
g_Config.memCardDirectory = std::string(external_directory) + "/";
|
||||
g_Config.flashDirectory = std::string(external_directory) + "/flash0/";
|
||||
#elif defined(BLACKBERRY) || defined(__SYMBIAN32__) || defined(MEEGO_EDITION_HARMATTAN) || defined(IOS)
|
||||
g_Config.memCardDirectory = user_data_path;
|
||||
g_Config.flashDirectory = std::string(external_directory) + "/flash0/";
|
||||
#elif !defined(_WIN32)
|
||||
// Linux, Mac. Does this path really make sense?
|
||||
g_Config.memCardDirectory = std::string(getenv("HOME")) + "/.ppsspp/";
|
||||
g_Config.flashDirectory = g_Config.memCardDirectory + "/flash0/";
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
logger = new AndroidLogger();
|
||||
|
||||
@@ -253,19 +269,20 @@ void NativeInit(int argc, const char *argv[],
|
||||
LogManager *logman = LogManager::GetInstance();
|
||||
ILOG("Logman: %p", logman);
|
||||
|
||||
config_filename = user_data_path + "/ppsspp.ini";
|
||||
std::string controls_filename = user_data_path + "/controls.ini";
|
||||
g_Config.Load(config_filename.c_str(), controls_filename.c_str());
|
||||
g_Config.AddSearchPath(user_data_path);
|
||||
g_Config.AddSearchPath(g_Config.memCardDirectory + "PSP/SYSTEM/");
|
||||
g_Config.SetDefaultPath(g_Config.memCardDirectory + "PSP/SYSTEM/");
|
||||
g_Config.Load();
|
||||
g_Config.externalDirectory = external_directory;
|
||||
#endif
|
||||
|
||||
#ifdef ANDROID
|
||||
// On Android, create a PSP directory tree in the external_directory,
|
||||
// to hopefully reduce confusion a bit.
|
||||
ILOG("Creating %s", (g_Config.externalDirectory + "/PSP").c_str());
|
||||
mkDir((g_Config.externalDirectory + "/PSP").c_str());
|
||||
mkDir((g_Config.externalDirectory + "/PSP/SAVEDATA").c_str());
|
||||
mkDir((g_Config.externalDirectory + "/PSP/GAME").c_str());
|
||||
ILOG("Creating %s", (g_Config.memCardDirectory + "PSP").c_str());
|
||||
mkDir((g_Config.memCardDirectory + "PSP").c_str());
|
||||
mkDir((g_Config.memCardDirectory + "PSP/SAVEDATA").c_str());
|
||||
mkDir((g_Config.memCardDirectory + "PSP/GAME").c_str());
|
||||
#endif
|
||||
|
||||
const char *fileToLog = 0;
|
||||
@@ -331,21 +348,6 @@ void NativeInit(int argc, const char *argv[],
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(ANDROID)
|
||||
g_Config.internalDataDirectory = savegame_directory;
|
||||
// Maybe there should be an option to use internal memory instead, but I think
|
||||
// that for most people, using external memory (SDCard/USB Storage) makes the
|
||||
// most sense.
|
||||
g_Config.memCardDirectory = std::string(external_directory) + "/";
|
||||
g_Config.flashDirectory = std::string(external_directory)+"/flash0/";
|
||||
#elif defined(BLACKBERRY) || defined(__SYMBIAN32__) || defined(MEEGO_EDITION_HARMATTAN) || defined(IOS) || defined(_WIN32)
|
||||
g_Config.memCardDirectory = user_data_path;
|
||||
g_Config.flashDirectory = std::string(external_directory)+"flash0/";
|
||||
#else
|
||||
g_Config.memCardDirectory = std::string(getenv("HOME"))+"/.ppsspp/";
|
||||
g_Config.flashDirectory = g_Config.memCardDirectory+"/flash0/";
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
|
||||
{
|
||||
LogTypes::LOG_TYPE type = (LogTypes::LOG_TYPE)i;
|
||||
|
||||
@@ -18,8 +18,6 @@ static int xres, yres;
|
||||
// TODO: Make config?
|
||||
static bool enableGLDebug = false;
|
||||
|
||||
#pragma optimize("", off)
|
||||
|
||||
void GL_Resized() {
|
||||
if (!hWnd)
|
||||
return;
|
||||
|
||||
+8
-8
@@ -195,10 +195,10 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
|
||||
|
||||
osName = GetWindowsVersion() + " " + GetWindowsSystemArchitecture();
|
||||
|
||||
std::string configFilename;
|
||||
const char *configFilename = NULL;
|
||||
const char *configOption = "--config=";
|
||||
|
||||
std::string controlsConfigFilename;
|
||||
const char *controlsConfigFilename = NULL;
|
||||
const char *controlsOption = "--controlconfig=";
|
||||
|
||||
for (int i = 1; i < __argc; ++i)
|
||||
@@ -216,15 +216,15 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
|
||||
}
|
||||
}
|
||||
|
||||
if(configFilename.empty())
|
||||
configFilename = "ppsspp.ini";
|
||||
|
||||
if(controlsConfigFilename.empty())
|
||||
controlsConfigFilename = "controls.ini";
|
||||
std::string memstickpath, flash0path;
|
||||
GetSysDirectories(memstickpath, flash0path);
|
||||
|
||||
// Load config up here, because those changes below would be overwritten
|
||||
// if it's not loaded here first.
|
||||
g_Config.Load(configFilename.c_str(), controlsConfigFilename.c_str());
|
||||
g_Config.AddSearchPath("");
|
||||
g_Config.AddSearchPath(memstickpath + "PSP/SYSTEM/");
|
||||
g_Config.SetDefaultPath(memstickpath + "PSP/SYSTEM/");
|
||||
g_Config.Load(configFilename, controlsConfigFilename);
|
||||
|
||||
// The rest is handled in NativeInit().
|
||||
for (int i = 1; i < __argc; ++i)
|
||||
|
||||
Reference in new issue
Block a user