From f9449999ec5b0823c917213de30c8a0d80a626a6 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Thu, 23 May 2024 23:31:15 +0200 Subject: [PATCH] add required shit for loading per-window config (I think) --- src/frontend/qt_sdl/Config.cpp | 10 ++++++++-- src/frontend/qt_sdl/Config.h | 2 +- src/frontend/qt_sdl/EmuInstance.cpp | 2 +- src/frontend/qt_sdl/Window.cpp | 6 ++++-- src/frontend/qt_sdl/Window.h | 5 ++++- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/frontend/qt_sdl/Config.cpp b/src/frontend/qt_sdl/Config.cpp index 119ec4e2..dc121336 100644 --- a/src/frontend/qt_sdl/Config.cpp +++ b/src/frontend/qt_sdl/Config.cpp @@ -539,11 +539,17 @@ Array Table::GetArray(const std::string& path) return Array(arr); } -Table Table::GetTable(const std::string& path) +Table Table::GetTable(const std::string& path, const std::string& defpath) { toml::value& tbl = ResolvePath(path); if (!tbl.is_table()) - tbl = toml::table(); + { + toml::value defval = toml::table(); + if (!defpath.empty()) + defval = ResolvePath(defpath); + + tbl = defval; + } return Table(tbl, PathPrefix + path); } diff --git a/src/frontend/qt_sdl/Config.h b/src/frontend/qt_sdl/Config.h index 66f6dd1d..7d45bf37 100644 --- a/src/frontend/qt_sdl/Config.h +++ b/src/frontend/qt_sdl/Config.h @@ -116,7 +116,7 @@ public: Table& operator=(const Table& b); Array GetArray(const std::string& path); - Table GetTable(const std::string& path); + Table GetTable(const std::string& path, const std::string& defpath = ""); int GetInt(const std::string& path); int64_t GetInt64(const std::string& path); diff --git a/src/frontend/qt_sdl/EmuInstance.cpp b/src/frontend/qt_sdl/EmuInstance.cpp index e35738ad..1ea5a307 100644 --- a/src/frontend/qt_sdl/EmuInstance.cpp +++ b/src/frontend/qt_sdl/EmuInstance.cpp @@ -120,7 +120,7 @@ void EmuInstance::createWindow() if (id == -1) return; - MainWindow* win = new MainWindow(this, topWindow); + MainWindow* win = new MainWindow(id, this, topWindow); if (!topWindow) topWindow = win; if (!mainWindow) mainWindow = win; windowList[id] = win; diff --git a/src/frontend/qt_sdl/Window.cpp b/src/frontend/qt_sdl/Window.cpp index 40509bba..54240198 100644 --- a/src/frontend/qt_sdl/Window.cpp +++ b/src/frontend/qt_sdl/Window.cpp @@ -197,11 +197,13 @@ static void signalHandler(int) int test = 0; -MainWindow::MainWindow(EmuInstance* inst, QWidget* parent) : +MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) : QMainWindow(parent), + windowID(id), emuInstance(inst), globalCfg(inst->globalCfg), - localCfg(inst->localCfg) + localCfg(inst->localCfg), + windowCfg(localCfg.GetTable("Window"+std::to_string(id), "Window0")) { test_num = test++; #ifndef _WIN32 diff --git a/src/frontend/qt_sdl/Window.h b/src/frontend/qt_sdl/Window.h index 80e228e1..85d7778d 100644 --- a/src/frontend/qt_sdl/Window.h +++ b/src/frontend/qt_sdl/Window.h @@ -102,7 +102,7 @@ class MainWindow : public QMainWindow Q_OBJECT public: - explicit MainWindow(EmuInstance* inst, QWidget* parent = nullptr); + explicit MainWindow(int id, EmuInstance* inst, QWidget* parent = nullptr); ~MainWindow(); EmuInstance* getEmuInstance() { return emuInstance; } @@ -241,11 +241,14 @@ private: int test_num; + int windowID; + EmuInstance* emuInstance; EmuThread* emuThread; Config::Table& globalCfg; Config::Table& localCfg; + Config::Table windowCfg; public: ScreenPanel* panel;