Ticket #868: atlas-xdg-2012-03-04.patch
File atlas-xdg-2012-03-04.patch, 3.2 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 … … 112 112 g_HasSetDataDirectory = true; 113 113 } 114 114 115 wxString g_ConfigDir; 116 ATLASDLLIMPEXP void Atlas_SetConfigDirectory(const wchar_t* path) 117 { 118 wxFileName config (path); 119 g_ConfigDir = config.GetPath(wxPATH_GET_SEPARATOR); 120 } 121 115 122 ATLASDLLIMPEXP void Atlas_StartWindow(const wchar_t* type) 116 123 { 117 124 // Initialise libxml2 … … 188 195 wxHandleFatalExceptions(); 189 196 #endif 190 197 198 #ifndef __WXMSW__ // On Windows we use the registry so don't attempt to set the path. 199 // When launching a standalone executable g_ConfigDir may not be 200 // set. In this case we default to the XDG base dir spec and use 201 // 0ad/config/ as the config directory. 202 wxString configPath; 203 if (!g_ConfigDir.IsEmpty()) 204 configPath = g_ConfigDir; 205 else 206 configPath = (wxGetEnv(_T("XDG_CONFIG_HOME"), NULL)?wxGetenv(_T("XDG_CONFIG_HOME")):wxFileName::GetHomeDir() + _T("/.config")) + _T("/0ad/config/"); 207 #endif 208 191 209 // Initialise the global config file 192 wxConfigBase::Set(new wxConfig(_T("Atlas Editor"), _T("Wildfire Games"))); 210 wxConfigBase::Set(new wxConfig(_T("Atlas Editor"), _T("Wildfire Games") 211 #ifndef __WXMSW__ // On Windows we use wxRegConfig and setting this changes the Registry key 212 , configPath + _T("atlas.ini") 213 #endif 214 )); 193 215 194 216 if (! g_HasSetDataDirectory) 195 217 { -
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)));