diff --git a/CMakeLists.txt b/CMakeLists.txt index fd5ad92..be8e9eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,8 +33,3 @@ if (WIN32) "${PROJECT_SOURCE_DIR}/dependencies/SDL2/lib/${PROJECT_ARCH}/SDL2.dll" # <--this is in-file $) # <--this is out-file path endif () - -add_custom_command(TARGET izanagi POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..." - "${PROJECT_SOURCE_DIR}/assets/config.ini" # <--this is in-file - $) # <--this is out-file path \ No newline at end of file diff --git a/assets/config.ini b/docs/reference/files/config.ini similarity index 91% rename from assets/config.ini rename to docs/reference/files/config.ini index d18aa37..4c793cc 100644 --- a/assets/config.ini +++ b/docs/reference/files/config.ini @@ -1,21 +1,21 @@ -[Video] -Width=640 -Height=480 - -[Controls.0.Keyboard] -Right=Right -Down=Down -Left=Left -Up=Up -Affirm=Return -Negate=Backspace -Action0=A -Action1=S -Action2=D -Action3=F -Action4=Z -Action5=X -Action6=C -Action7=V -Action8=W -Action9=E +[Video] +Width=640 +Height=480 + +[Controls.0.Keyboard] +Right=Right +Down=Down +Left=Left +Up=Up +Affirm=Return +Negate=Backspace +Action0=A +Action1=S +Action2=D +Action3=F +Action4=Z +Action5=X +Action6=C +Action7=V +Action8=W +Action9=E diff --git a/src/packages/game/main.c b/src/packages/game/main.c index 2f053a7..1d94fc3 100644 --- a/src/packages/game/main.c +++ b/src/packages/game/main.c @@ -72,6 +72,24 @@ static void IZ_GetConfigPath(char* config_path) { strcat_s(config_path, 128, "config.ini"); } +static void IZ_SaveConfig(IZ_Config* config) { + static char config_path[128]; + IZ_GetConfigPath(config_path); + FILE* fp; + fopen_s(&fp, config_path, "w"); + fprintf_s(fp, "[Video]\n"); + fprintf_s(fp, "Width=%u\n", config->video.width); + fprintf_s(fp, "Height=%u\n", config->video.height); + fprintf_s(fp, "\n"); + + for (unsigned int p = 0; p < PLAYERS; p += 1) { + fprintf_s(fp, "[Controls.%u.Keyboard]\n", p); + for (unsigned int i = 0; i < CONTROLS; i += 1) { + fprintf_s(fp, "%s=%s\n", ACTION_NAMES[i], SDL_GetKeyName(config->controls[p].keyboard[i])); + } + } +} + static void IZ_LoadConfig(IZ_Config* config) { static char config_path[128]; IZ_GetConfigPath(config_path); @@ -90,6 +108,7 @@ int main(int argc, char* args[]) { SDL_Surface* screen_surface = NULL; IZ_Config config; IZ_LoadConfig(&config); + IZ_SaveConfig(&config); if (SDL_Init( SDL_INIT_VIDEO