add required shit for loading per-window config (I think)

This commit is contained in:
Arisotura 2024-05-23 23:31:15 +02:00
parent d50f01b774
commit f9449999ec
5 changed files with 18 additions and 7 deletions

View File

@ -539,11 +539,17 @@ Array Table::GetArray(const std::string& path)
return Array(arr); 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); toml::value& tbl = ResolvePath(path);
if (!tbl.is_table()) 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); return Table(tbl, PathPrefix + path);
} }

View File

@ -116,7 +116,7 @@ public:
Table& operator=(const Table& b); Table& operator=(const Table& b);
Array GetArray(const std::string& path); 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); int GetInt(const std::string& path);
int64_t GetInt64(const std::string& path); int64_t GetInt64(const std::string& path);

View File

@ -120,7 +120,7 @@ void EmuInstance::createWindow()
if (id == -1) if (id == -1)
return; return;
MainWindow* win = new MainWindow(this, topWindow); MainWindow* win = new MainWindow(id, this, topWindow);
if (!topWindow) topWindow = win; if (!topWindow) topWindow = win;
if (!mainWindow) mainWindow = win; if (!mainWindow) mainWindow = win;
windowList[id] = win; windowList[id] = win;

View File

@ -197,11 +197,13 @@ static void signalHandler(int)
int test = 0; int test = 0;
MainWindow::MainWindow(EmuInstance* inst, QWidget* parent) : MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
QMainWindow(parent), QMainWindow(parent),
windowID(id),
emuInstance(inst), emuInstance(inst),
globalCfg(inst->globalCfg), globalCfg(inst->globalCfg),
localCfg(inst->localCfg) localCfg(inst->localCfg),
windowCfg(localCfg.GetTable("Window"+std::to_string(id), "Window0"))
{ {
test_num = test++; test_num = test++;
#ifndef _WIN32 #ifndef _WIN32

View File

@ -102,7 +102,7 @@ class MainWindow : public QMainWindow
Q_OBJECT Q_OBJECT
public: public:
explicit MainWindow(EmuInstance* inst, QWidget* parent = nullptr); explicit MainWindow(int id, EmuInstance* inst, QWidget* parent = nullptr);
~MainWindow(); ~MainWindow();
EmuInstance* getEmuInstance() { return emuInstance; } EmuInstance* getEmuInstance() { return emuInstance; }
@ -241,11 +241,14 @@ private:
int test_num; int test_num;
int windowID;
EmuInstance* emuInstance; EmuInstance* emuInstance;
EmuThread* emuThread; EmuThread* emuThread;
Config::Table& globalCfg; Config::Table& globalCfg;
Config::Table& localCfg; Config::Table& localCfg;
Config::Table windowCfg;
public: public:
ScreenPanel* panel; ScreenPanel* panel;