Examples: Android: Using LoadIniSettingsFromMemory() / SaveIniSettingsToMemory() to save in appropriate location for Android. (#5836)

This commit is contained in:
Rewtio
2022-10-30 05:09:13 +07:00
committed by ocornut
parent 22bcfca700
commit c2694ef75e
2 changed files with 7 additions and 3 deletions

View File

@ -9,6 +9,7 @@
#include <android/asset_manager.h>
#include <EGL/egl.h>
#include <GLES3/gl3.h>
#include <string>
// 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();