Rip out any observer stuff for home directories

This commit is contained in:
Marco Cawthorne 2021-06-05 16:38:35 +02:00
parent 859744cd1f
commit 750b916448
6 changed files with 0 additions and 135 deletions

View file

@ -143,15 +143,9 @@ void gamedetect()
}
namespace {
CopiedString home_path;
CopiedString app_path;
}
const char *environment_get_home_path()
{
return home_path.c_str();
}
const char *environment_get_app_path()
{
return app_path.c_str();
@ -162,7 +156,6 @@ bool portable_app_setup()
StringOutputStream confdir(256);
confdir << app_path.c_str() << "settings/";
if (file_exists(confdir.c_str())) {
home_path = confdir.c_str();
return true;
}
return false;
@ -234,12 +227,6 @@ void environment_init(int argc, char const *argv[])
ASSERT_MESSAGE(!string_empty(app_path.c_str()), "failed to deduce app path");
}
if (!portable_app_setup()) {
StringOutputStream home(256);
home << DirectoryCleaned(g_get_user_data_dir()) << "worldspawn/";
Q_mkdir(home.c_str());
home_path = home.c_str();
}
gamedetect();
}
@ -263,21 +250,6 @@ void environment_init( int argc, char const* argv[] ){
StringOutputStream app( 256 );
app << PathCleaned( filename );
app_path = app.c_str();
if ( !portable_app_setup() ) {
char *appdata = getenv( "APPDATA" );
StringOutputStream home( 256 );
if ( !appdata || string_empty( appdata ) ) {
ERROR_MESSAGE( "Application Data folder not available.\n"
"WorldSpawn will use C:\\ for user preferences.\n" );
home << "C:";
} else {
home << PathCleaned( appdata );
}
home << "/WorldSpawnSettings/";
Q_mkdir( home.c_str() );
home_path = home.c_str();
}
gamedetect();
}

View file

@ -181,89 +181,12 @@ VFSModuleObserver g_VFSModuleObserver;
void VFS_Construct()
{
Radiant_attachHomePathsObserver(g_VFSModuleObserver);
}
void VFS_Destroy()
{
Radiant_detachHomePathsObserver(g_VFSModuleObserver);
}
// Home Paths
#if GDEF_OS_WINDOWS
#include <shlobj.h>
#include <objbase.h>
const GUID qFOLDERID_SavedGames = {0x4C5C32FF, 0xBB9D, 0x43b0, {0xB5, 0xB4, 0x2D, 0x72, 0xE5, 0x4E, 0xAA, 0xA4}};
#define qREFKNOWNFOLDERID GUID
#define qKF_FLAG_CREATE 0x8000
#define qKF_FLAG_NO_ALIAS 0x1000
typedef HRESULT ( WINAPI qSHGetKnownFolderPath_t )( qREFKNOWNFOLDERID rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath );
static qSHGetKnownFolderPath_t *qSHGetKnownFolderPath;
#endif
void HomePaths_Realise()
{
g_qeglobals.m_userEnginePath = EnginePath_get();
Q_mkdir(g_qeglobals.m_userEnginePath.c_str());
{
StringOutputStream path(256);
path << g_qeglobals.m_userEnginePath.c_str() << gamename_get() << '/';
g_qeglobals.m_userGamePath = path.c_str();
}
ASSERT_MESSAGE(!string_empty(g_qeglobals.m_userGamePath.c_str()), "HomePaths_Realise: user-game-path is empty");
Q_mkdir(g_qeglobals.m_userGamePath.c_str());
}
ModuleObservers g_homePathObservers;
void Radiant_attachHomePathsObserver(ModuleObserver &observer)
{
g_homePathObservers.attach(observer);
}
void Radiant_detachHomePathsObserver(ModuleObserver &observer)
{
g_homePathObservers.detach(observer);
}
class HomePathsModuleObserver : public ModuleObserver {
std::size_t m_unrealised;
public:
HomePathsModuleObserver() : m_unrealised(1)
{
}
void realise()
{
if (--m_unrealised == 0) {
HomePaths_Realise();
g_homePathObservers.realise();
}
}
void unrealise()
{
if (++m_unrealised == 1) {
g_homePathObservers.unrealise();
}
}
};
HomePathsModuleObserver g_HomePathsModuleObserver;
void HomePaths_Construct()
{
Radiant_attachEnginePathObserver(g_HomePathsModuleObserver);
}
void HomePaths_Destroy()
{
Radiant_detachEnginePathObserver(g_HomePathsModuleObserver);
}
// Engine Path
CopiedString g_strEnginePath;
@ -390,7 +313,6 @@ struct EnginePath {
};
bool g_disableEnginePath = false;
bool g_disableHomePath = false;
void Paths_constructPreferences(PreferencesPage &page)
{
@ -400,11 +322,6 @@ void Paths_constructPreferences(PreferencesPage &page)
"", "Do not use Engine Path",
g_disableEnginePath
);
page.appendCheckBox(
"", "Do not use Home Path",
g_disableHomePath
);
}
void Paths_constructPage(PreferenceGroup &group)
@ -3436,7 +3353,6 @@ void MainFrame_Construct()
GlobalPreferenceSystem().registerPreference("EnginePath", make_property_string(g_strEnginePath));
GlobalPreferenceSystem().registerPreference("DisableEnginePath", make_property_string(g_disableEnginePath));
GlobalPreferenceSystem().registerPreference("DisableHomePath", make_property_string(g_disableHomePath));
g_Layout_enablePluginToolbar.useLatched();

View file

@ -229,7 +229,6 @@ const char *EnginePath_get();
const char *QERApp_GetGamePath();
extern bool g_disableEnginePath;
extern bool g_disableHomePath;
extern CopiedString g_strAppPath;
@ -289,14 +288,6 @@ void VFS_Construct();
void VFS_Destroy();
void HomePaths_Construct();
void HomePaths_Destroy();
void Radiant_attachHomePathsObserver(ModuleObserver &observer);
void Radiant_detachHomePathsObserver(ModuleObserver &observer);
void MainFrame_Construct();

View file

@ -1645,8 +1645,6 @@ bool Map_ImportFile(const char *filename)
output.push_string((type && *type) ? type : "quake3");
output.push_string(" -fs_basepath \"");
output.push_string(EnginePath_get());
output.push_string("\" -fs_homepath \"");
output.push_string(g_qeglobals.m_userEnginePath.c_str());
output.push_string("\"");
// extra switches
@ -1654,10 +1652,6 @@ bool Map_ImportFile(const char *filename)
output.push_string(" -fs_nobasepath ");
}
if (g_disableHomePath) {
output.push_string(" -fs_nohomepath ");
}
output.push_string(" -fs_game ");
output.push_string(gamename_get());
output.push_string(" -convert -format ");
@ -2353,11 +2347,9 @@ void Map_Construct()
PreferencesDialog_addSettingsPreferences(makeCallbackF(Map_constructPreferences));
GlobalEntityClassManager().attach(g_MapEntityClasses);
Radiant_attachHomePathsObserver(g_MapModuleObserver);
}
void Map_Destroy()
{
Radiant_detachHomePathsObserver(g_MapModuleObserver);
GlobalEntityClassManager().detach(g_MapEntityClasses);
}

View file

@ -242,7 +242,6 @@ public:
GlobalFiletypes().addType("sound", "wav", filetype_t("PCM sound files", "*.wav"));
Selection_construct();
HomePaths_Construct();
VFS_Construct();
Grid_construct();
MultiMon_Construct();
@ -298,7 +297,6 @@ public:
MultiMon_Destroy();
Grid_destroy();
VFS_Destroy();
HomePaths_Destroy();
Selection_destroy();
}
};

View file

@ -165,10 +165,6 @@ void bsp_init()
ExtraQ3map2Args.push_string(" -fs_nobasepath ");
}
if (g_disableHomePath) {
ExtraQ3map2Args.push_string(" -fs_nohomepath ");
}
build_set_variable("ExtraQ3map2Args", ExtraQ3map2Args.c_str());
const char *mapname = Map_Name(g_map);