Add imgui settings back using FileStoreManager to get the path

This commit is contained in:
Phillip Stephens 2022-02-27 17:55:47 -08:00
parent b305454199
commit fcda2eb261
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
6 changed files with 31 additions and 3 deletions

View File

@ -102,6 +102,8 @@ public:
void parseCommandLine(const std::vector<std::string>& args);
FileStoreManager& fileStoreManager() { return m_store; }
private:
bool suppressDeveloper();
void restoreDeveloper(bool oldDeveloper);

View File

@ -17,9 +17,17 @@ using namespace Windows::Storage;
#endif
namespace metaforce {
namespace {
static logvisor::Module Log("FileStoreManager");
FileStoreManager* g_instance = nullptr;
}
FileStoreManager::FileStoreManager(std::string_view org, std::string_view domain) : m_org(org), m_domain(domain) {
if (g_instance == this) {
Log.report(logvisor::Fatal, FMT_STRING("Attempting to build another FileStoreManager!!"));
return;
}
auto prefPath = SDL_GetPrefPath(org.data(), domain.data());
if (prefPath == nullptr) {
#if _WIN32
@ -64,6 +72,14 @@ FileStoreManager::FileStoreManager(std::string_view org, std::string_view domain
} else {
m_storeRoot = std::string(prefPath);
}
g_instance = this;
}
FileStoreManager* FileStoreManager::instance() {
if (g_instance == nullptr) {
Log.report(logvisor::Fatal, FMT_STRING("Requested FileStoreManager instance before it's built!"));
return nullptr;
}
return g_instance;
}
} // namespace hecl::Runtime

View File

@ -12,6 +12,10 @@ class FileStoreManager {
std::string m_storeRoot;
public:
FileStoreManager(FileStoreManager&) = delete;
FileStoreManager(FileStoreManager&&) = delete;
void operator=(FileStoreManager&) = delete;
void operator=(FileStoreManager&&) = delete;
FileStoreManager(std::string_view org, std::string_view domain);
std::string_view getOrg() const { return m_org; }
std::string_view getDomain() const { return m_domain; }
@ -20,5 +24,6 @@ public:
* @return Full path to store e.g /home/foo/.hecl/bar
*/
std::string_view getStoreRoot() const { return m_storeRoot; }
static FileStoreManager* instance();
};
}

View File

@ -29,7 +29,7 @@ add_library(aurora STATIC
lib/gfx/colored_quad/shader.cpp
)
target_compile_definitions(aurora PRIVATE IMGUI_USER_CONFIG="imconfig_user.h") # IMGUI_USE_WCHAR32
target_include_directories(aurora PUBLIC include ../Runtime)
target_include_directories(aurora PUBLIC include ../ )
target_include_directories(aurora PRIVATE ../imgui ../extern/imgui)
target_include_directories(aurora PRIVATE
../extern/dawn/src

View File

@ -4,7 +4,7 @@
#include <vector>
#include <type_traits>
#include "RetroTypes.hpp"
#include "Runtime/RetroTypes.hpp"
namespace aurora {
template <typename T>

View File

@ -16,11 +16,16 @@ using gpu::g_queue;
static float g_scale;
static std::string g_imguiSettings{};
static std::string g_imguiLog{};
void create_context() noexcept {
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
io.IniFilename = nullptr;
g_imguiSettings = std::string(metaforce::FileStoreManager::instance()->getStoreRoot()) + "/imgui.ini";
g_imguiLog = std::string(metaforce::FileStoreManager::instance()->getStoreRoot()) + "/imgui.log";
io.IniFilename = g_imguiSettings.c_str();
io.LogFilename = g_imguiLog.c_str();
}
void initialize(SDL_Window* window) noexcept {