Ticket #868: atlas-xdg-2012-02-25.patch
File atlas-xdg-2012-02-25.patch, 5.7 KB (added by , 12 years ago) |
---|
-
0ad/source/tools/atlas/AtlasUI/Misc/DLLInterface.cpp
1 /* Copyright (C) 20 09Wildfire Games.1 /* Copyright (C) 2012 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify … … 22 22 #include "General/AtlasEventLoop.h" 23 23 24 24 #include "General/Datafile.h" 25 #include "General/Config.h" 25 26 26 27 #include "ActorEditor/ActorEditor.h" 27 28 #include "ScenarioEditor/ScenarioEditor.h" … … 112 113 g_HasSetDataDirectory = true; 113 114 } 114 115 116 ATLASDLLIMPEXP void Atlas_SetConfigDirectory(const wchar_t* path) 117 { 118 Config::SetConfigDirectory(path); 119 } 120 115 121 ATLASDLLIMPEXP void Atlas_StartWindow(const wchar_t* type) 116 122 { 117 123 // Initialise libxml2 … … 188 194 wxHandleFatalExceptions(); 189 195 #endif 190 196 197 wxString configPath = Config::GetConfigDirectory(); 198 // ActorEditor doesn't rely on the paths set in Paths.cpp so 199 // we need to special case it here. 200 // TODO ActorEditor should be incorporated into Atlas in the 201 // future (as in using the same binary) and won't be needed 202 // anymore. 203 if (g_InitialWindowType == _T("ActorEditor")) 204 configPath = (wxGetEnv(_T("XDG_CONFIG_HOME"), NULL)?wxGetenv(_T("XDG_CONFIG_HOME")):wxFileName::GetHomeDir() + _T("/.config")) + _T("/0ad/config/"); 205 191 206 // Initialise the global config file 192 wxConfigBase::Set(new wxConfig(_T("Atlas Editor"), _T("Wildfire Games"))); 207 wxConfigBase::Set(new wxConfig(_T("Atlas Editor"), _T("Wildfire Games") 208 #ifndef __WXMSW__ // On Windows we use wxRegConfig and setting this changes the Registry key 209 , configPath + _T("atlas.ini") 210 #endif 211 )); 193 212 194 213 if (! g_HasSetDataDirectory) 195 214 { -
0ad/source/tools/atlas/AtlasUI/General/Config.cpp
1 /* Copyright (C) 2012 Wildfire Games. 2 * This file is part of 0 A.D. 3 * 4 * 0 A.D. is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * 0 A.D. is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #include "precompiled.h" 19 20 #include "Config.h" 21 22 static wxString g_ConfigDir; 23 24 void Config::SetConfigDirectory(const wxString& dir) 25 { 26 wxFileName config (dir); 27 // We need to get the separator at the end of the path (/ or \) 28 g_ConfigDir = config.GetPath(wxPATH_GET_SEPARATOR); 29 } 30 31 wxString Config::GetConfigDirectory() 32 { 33 return g_ConfigDir; 34 } 35 -
0ad/source/tools/atlas/AtlasUI/General/Config.h
1 /* Copyright (C) 2012 Wildfire Games. 2 * This file is part of 0 A.D. 3 * 4 * 0 A.D. is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * 0 A.D. is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #include "AtlasObject/AtlasObject.h" 19 20 namespace Config 21 { 22 void SetConfigDirectory(const wxString& dir); 23 24 wxString GetConfigDirectory(); 25 } -
0ad/source/tools/atlas/GameInterface/GameLoop.cpp
52 52 // Loaded from DLL: 53 53 void (*Atlas_StartWindow)(const wchar_t* type); 54 54 void (*Atlas_SetDataDirectory)(const wchar_t* path); 55 void (*Atlas_SetConfigDirectory)(const wchar_t* path); 55 56 void (*Atlas_SetMessagePasser)(MessagePasser*); 56 57 void (*Atlas_GLSetCurrent)(void* cavas); 57 58 void (*Atlas_GLSwapBuffers)(void* canvas); … … 277 278 dll.LoadSymbol("Atlas_StartWindow", Atlas_StartWindow); 278 279 dll.LoadSymbol("Atlas_SetMessagePasser", Atlas_SetMessagePasser); 279 280 dll.LoadSymbol("Atlas_SetDataDirectory", Atlas_SetDataDirectory); 281 dll.LoadSymbol("Atlas_SetConfigDirectory", Atlas_SetConfigDirectory); 280 282 dll.LoadSymbol("Atlas_GLSetCurrent", Atlas_GLSetCurrent); 281 283 dll.LoadSymbol("Atlas_GLSwapBuffers", Atlas_GLSwapBuffers); 282 284 dll.LoadSymbol("Atlas_NotifyEndOfFrame", Atlas_NotifyEndOfFrame); … … 303 305 const Paths paths(args); 304 306 Atlas_SetDataDirectory(paths.RData().string().c_str()); 305 307 308 // Tell Atlas the location of the user config directory 309 Atlas_SetConfigDirectory(paths.Config().string().c_str()); 310 306 311 // Run the engine loop in a new thread 307 312 pthread_t engineThread; 308 313 pthread_create(&engineThread, NULL, RunEngine, reinterpret_cast<void*>(const_cast<CmdLineArgs*>(&args)));