From c2694ef75e2b626ebf52493f4a1282d500d33bbb Mon Sep 17 00:00:00 2001 From: Rewtio Date: Sun, 30 Oct 2022 05:09:13 +0700 Subject: [PATCH] Examples: Android: Using LoadIniSettingsFromMemory() / SaveIniSettingsToMemory() to save in appropriate location for Android. (#5836) --- docs/CHANGELOG.txt | 1 + examples/example_android_opengl3/main.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index f97cdf191..b10e57dc5 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -181,6 +181,7 @@ Other Changes: - Demo: Fixed Log & Console from losing scrolling position with Auto-Scroll when child is clipped. (#5721) - Examples: Added all SDL examples to default VS solution. - Examples: Win32: Always use RegisterClassW() to ensure windows are Unicode. (#5725) +- Examples: Android: Enable .ini file loading/saving into application internal data folder. (#5836) [@rewtio] - Backends: GLFW: Honor GLFW_CURSOR_DISABLED by not setting mouse position. (#5625) [@scorpion-26] - Backends: GLFW: Add glfwGetError() call on GLFW 3.3 to inhibit missing mouse cursor errors. (#5785) [@mitchellh] - Backends: SDL: Disable SDL 2.0.22 new "auto capture" which prevents drag and drop across windows diff --git a/examples/example_android_opengl3/main.cpp b/examples/example_android_opengl3/main.cpp index 4237e408a..0dab5d0c1 100644 --- a/examples/example_android_opengl3/main.cpp +++ b/examples/example_android_opengl3/main.cpp @@ -9,6 +9,7 @@ #include #include #include +#include // Data static EGLDisplay g_EglDisplay = EGL_NO_DISPLAY; @@ -17,6 +18,7 @@ static EGLContext g_EglContext = EGL_NO_CONTEXT; static struct android_app* g_App = NULL; static bool g_Initialized = false; static char g_LogTag[] = "ImGuiExample"; +static std::string g_IniFilename = ""; // Forward declarations of helper functions static int ShowSoftKeyboardInput(); @@ -70,9 +72,10 @@ void init(struct android_app* app) ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); - // Disable loading/saving of .ini file from disk. - // FIXME: Consider using LoadIniSettingsFromMemory() / SaveIniSettingsToMemory() to save in appropriate location for Android. - io.IniFilename = NULL; + // Redirect loading/saving of .ini file to our location. + // Make sure 'g_IniFilename' persists while we use Dear ImGui. + g_IniFilename = std::string(app->activity->internalDataPath) + "/imgui.ini"; + io.IniFilename = g_IniFilename.c_str();; // Setup Dear ImGui style ImGui::StyleColorsDark();