cxong / cdogs-sdl

Classic overhead run-and-gun game
https://cxong.github.io/cdogs-sdl/
GNU General Public License v2.0
891 stars 114 forks source link

Windows: store config in AppData/Roaming (%APPDATA%) #260

Closed cxong closed 10 years ago

cxong commented 10 years ago

To correctly follow conventions under Windows, C-Dogs config files should be stored in %APPDATA% instead of .cdogs in the home dir. There is no advantage to doing the latter.

carstene1ns commented 10 years ago

If I read that correctly, the only required changes would be to replace the environment variable in sys_specifics.h and change CDOGS_CFG_DIR in the CMakeLists.txt:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3ddc003..1149659 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -128,7 +128,11 @@ if(GCW0)
 else()
        set(CDOGS_DATA_DIR "../")
 endif()
-set(CDOGS_CFG_DIR ".config/cdogs-sdl/")
+if(WIN32)
+       set(CDOGS_CFG_DIR "cdogs-sdl/")
+else()
+       set(CDOGS_CFG_DIR ".config/cdogs-sdl/")
+endif()
 SET(SOURCE_DIRECTORY ".")
 SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ".")
 IF(UNIX AND NOT APPLE)
diff --git a/src/cdogs/sys_specifics.h b/src/cdogs/sys_specifics.h
index 59bdb79..7c4217f 100644
--- a/src/cdogs/sys_specifics.h
+++ b/src/cdogs/sys_specifics.h
@@ -42,7 +42,7 @@
 #endif

 #ifdef _MSC_VER
-#define HOME_DIR_ENV "UserProfile"
+#define HOME_DIR_ENV "AppData"
 #else
 #define HOME_DIR_ENV "HOME"
 #endif

I have not tested it, as I do not have the required windows development tools available, but this should work. However, this might be considered "quick'n'dirty".

cxong commented 10 years ago

@carstene1ns Thanks! Worked