From 3979a2aaebacca290c9e6f7d2fee95b941aba32a Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Tue, 5 Mar 2024 17:39:10 +0100 Subject: save config to appdata folder on windows --- src/main_windows.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main_windows.cpp b/src/main_windows.cpp index 2a9d3a0..61f9876 100644 --- a/src/main_windows.cpp +++ b/src/main_windows.cpp @@ -14,11 +14,14 @@ #define WIN32_LEAN_AND_MEAN #endif #include +#include #include #include #define IDI_LOGO 123 +char config_path[MAX_INPUT_LENGTH]; + void ts_create_gui(int window_w, int window_h); void ts_load_images(); void ts_init(); @@ -36,6 +39,17 @@ void CleanupDeviceWGL(HWND hWnd, WGL_WindowData* data); void ResetDeviceWGL(); LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); +static const char* _ts_platform_get_config_file_path(char* buffer) { + if(SUCCEEDED(SHGetFolderPathA(0, CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE, NULL, 0, buffer))) + { + strcat_s(buffer, MAX_INPUT_LENGTH, "\\text-search\\config.ini"); + printf("%s\n", buffer); + return buffer; + } + + return 0; +} + int main(int, char**) { // Create application window @@ -67,7 +81,7 @@ int main(int, char**) ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); (void)io; io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - io.IniFilename = NULL; + io.IniFilename = _ts_platform_get_config_file_path(config_path); // Setup Dear ImGui style ImGui::Spectrum::StyleColorsSpectrum(); -- cgit v1.2.3-70-g09d2