start work

This commit is contained in:
2026-06-04 14:06:56 +02:00
parent 3080d4d45a
commit 506e4ff6f9
301 changed files with 240 additions and 140133 deletions
+22 -30
View File
@@ -1,35 +1,27 @@
#include <GeneralSettings.hpp>
#include <Options.hpp>
#include <imgui.h>
#include <log.hpp>
#include <QSettings>
#include <QFileDialog>
#include <QCoreApplication>
GeneralSettings::GeneralSettings(gui::NativeWindow& window) : window(window) {
savesPath = Options::GetInstance().GetValue<std::string>("general", "savePath");
GeneralSettings::GeneralSettings() {
QSettings settings;
description.setText("Saves path:");
selectedFolderLabel.setDisabled(true);
selectedFolderLabel.setText(Options::GetSavesPath().c_str());
folderSelectButton.setText("Choose...");
connect(&folderSelectButton, &QPushButton::clicked, this, [&] {
auto dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), QCoreApplication::applicationDirPath(),
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
selectedFolderLabel.setText(dir);
Options::SetSavesPath(dir.toStdString());
settings.setValue("general/saves_path", dir);
});
h.addWidget(&description);
h.addWidget(&selectedFolderLabel);
h.addWidget(&folderSelectButton);
v.addLayout(&h);
setLayout(&v);
}
void GeneralSettings::render() {
if(ImGui::Button("Pick...")) {
SDL_ShowOpenFolderDialog([](void *userdata, const char * const *filelist, int _) {
auto* general = static_cast<GeneralSettings*>(userdata);
if (!filelist) {
panic("An error occurred: {}", SDL_GetError());
}
if (!*filelist) {
warn("The user did not select any file.");
warn("Most likely, the dialog was canceled.");
general->modified = false;
return;
}
general->savesPath = fs::absolute(*filelist).string();
Options::GetInstance().SetValue<std::string>("general", "savePath", general->savesPath);
general->modified = true;
}, this, window.getHandle(), nullptr, false);
}
ImGui::SameLine();
ImGui::BeginDisabled();
ImGui::InputText("Save Path", const_cast<char*>(savesPath.c_str()), savesPath.length());
ImGui::EndDisabled();
}