Index: 0ad/source/tools/atlas/AtlasUI/Misc/DLLInterface.cpp
===================================================================
--- 0ad/source/tools/atlas/AtlasUI/Misc/DLLInterface.cpp (revision 11148)
+++ 0ad/source/tools/atlas/AtlasUI/Misc/DLLInterface.cpp (working copy)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2009 Wildfire Games.
+/* Copyright (C) 2012 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -22,6 +22,7 @@
#include "General/AtlasEventLoop.h"
#include "General/Datafile.h"
+#include "General/Config.h"
#include "ActorEditor/ActorEditor.h"
#include "ScenarioEditor/ScenarioEditor.h"
@@ -112,6 +113,11 @@
g_HasSetDataDirectory = true;
}
+ATLASDLLIMPEXP void Atlas_SetConfigDirectory(const wchar_t* path)
+{
+ Config::SetConfigDirectory(path);
+}
+
ATLASDLLIMPEXP void Atlas_StartWindow(const wchar_t* type)
{
// Initialise libxml2
@@ -188,8 +194,21 @@
wxHandleFatalExceptions();
#endif
+ wxString configPath = Config::GetConfigDirectory();
+ // ActorEditor doesn't rely on the paths set in Paths.cpp so
+ // we need to special case it here.
+ // TODO ActorEditor should be incorporated into Atlas in the
+ // future (as in using the same binary) and won't be needed
+ // anymore.
+ if (g_InitialWindowType == _T("ActorEditor"))
+ configPath = (wxGetEnv(_T("XDG_CONFIG_HOME"), NULL)?wxGetenv(_T("XDG_CONFIG_HOME")):wxFileName::GetHomeDir() + _T("/.config")) + _T("/0ad/config/");
+
// Initialise the global config file
- wxConfigBase::Set(new wxConfig(_T("Atlas Editor"), _T("Wildfire Games")));
+ wxConfigBase::Set(new wxConfig(_T("Atlas Editor"), _T("Wildfire Games")
+#ifndef __WXMSW__ // On Windows we use wxRegConfig and setting this changes the Registry key
+ , configPath + _T("atlas.ini")
+#endif
+ ));
if (! g_HasSetDataDirectory)
{
Index: 0ad/source/tools/atlas/AtlasUI/General/Config.cpp
===================================================================
--- 0ad/source/tools/atlas/AtlasUI/General/Config.cpp (revision 0)
+++ 0ad/source/tools/atlas/AtlasUI/General/Config.cpp (working copy)
@@ -0,0 +1,35 @@
+/* Copyright (C) 2012 Wildfire Games.
+ * This file is part of 0 A.D.
+ *
+ * 0 A.D. is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 0 A.D. is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with 0 A.D. If not, see .
+ */
+
+#include "precompiled.h"
+
+#include "Config.h"
+
+static wxString g_ConfigDir;
+
+void Config::SetConfigDirectory(const wxString& dir)
+{
+ wxFileName config (dir);
+ // We need to get the separator at the end of the path (/ or \)
+ g_ConfigDir = config.GetPath(wxPATH_GET_SEPARATOR);
+}
+
+wxString Config::GetConfigDirectory()
+{
+ return g_ConfigDir;
+}
+
Index: 0ad/source/tools/atlas/AtlasUI/General/Config.h
===================================================================
--- 0ad/source/tools/atlas/AtlasUI/General/Config.h (revision 0)
+++ 0ad/source/tools/atlas/AtlasUI/General/Config.h (working copy)
@@ -0,0 +1,25 @@
+/* Copyright (C) 2012 Wildfire Games.
+ * This file is part of 0 A.D.
+ *
+ * 0 A.D. is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 0 A.D. is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with 0 A.D. If not, see .
+ */
+
+#include "AtlasObject/AtlasObject.h"
+
+namespace Config
+{
+ void SetConfigDirectory(const wxString& dir);
+
+ wxString GetConfigDirectory();
+}
Index: 0ad/source/tools/atlas/GameInterface/GameLoop.cpp
===================================================================
--- 0ad/source/tools/atlas/GameInterface/GameLoop.cpp (revision 11148)
+++ 0ad/source/tools/atlas/GameInterface/GameLoop.cpp (working copy)
@@ -52,6 +52,7 @@
// Loaded from DLL:
void (*Atlas_StartWindow)(const wchar_t* type);
void (*Atlas_SetDataDirectory)(const wchar_t* path);
+void (*Atlas_SetConfigDirectory)(const wchar_t* path);
void (*Atlas_SetMessagePasser)(MessagePasser*);
void (*Atlas_GLSetCurrent)(void* cavas);
void (*Atlas_GLSwapBuffers)(void* canvas);
@@ -277,6 +278,7 @@
dll.LoadSymbol("Atlas_StartWindow", Atlas_StartWindow);
dll.LoadSymbol("Atlas_SetMessagePasser", Atlas_SetMessagePasser);
dll.LoadSymbol("Atlas_SetDataDirectory", Atlas_SetDataDirectory);
+ dll.LoadSymbol("Atlas_SetConfigDirectory", Atlas_SetConfigDirectory);
dll.LoadSymbol("Atlas_GLSetCurrent", Atlas_GLSetCurrent);
dll.LoadSymbol("Atlas_GLSwapBuffers", Atlas_GLSwapBuffers);
dll.LoadSymbol("Atlas_NotifyEndOfFrame", Atlas_NotifyEndOfFrame);
@@ -303,6 +305,9 @@
const Paths paths(args);
Atlas_SetDataDirectory(paths.RData().string().c_str());
+ // Tell Atlas the location of the user config directory
+ Atlas_SetConfigDirectory(paths.Config().string().c_str());
+
// Run the engine loop in a new thread
pthread_t engineThread;
pthread_create(&engineThread, NULL, RunEngine, reinterpret_cast(const_cast(&args)));