remove stupid abstraction
This commit is contained in:
@@ -3,66 +3,73 @@
|
||||
#include <nfd.hpp>
|
||||
#include <log.hpp>
|
||||
#include <Options.hpp>
|
||||
#include <imgui.h>
|
||||
|
||||
std::string savePath;
|
||||
|
||||
SettingsWindow::SettingsWindow() {
|
||||
savesFolder.setName(fmt::format("Save path: {}",
|
||||
Options::GetInstance().GetValue<std::string>("general", "savePath")));
|
||||
bool SettingsWindow::render() {
|
||||
static bool applyEnabled = false;
|
||||
ImGui::OpenPopup("Settings", ImGuiPopupFlags_None);
|
||||
ImVec2 center = ImGui::GetMainViewport()->GetCenter();
|
||||
ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
|
||||
|
||||
tabs.addTab({"General", [&]() {
|
||||
if(savesFolder.render()) {
|
||||
NFD::Guard guard;
|
||||
NFD::UniquePath outPath;
|
||||
if(ImGui::BeginPopupModal("Settings")) {
|
||||
if(ImGui::BeginTabBar("SettingsTabBar")) {
|
||||
if(ImGui::BeginTabItem("General")) {
|
||||
ImGui::BeginDisabled();
|
||||
ImGui::InputText("Save Path", (char*)savesPath.c_str(), savesPath.length());
|
||||
ImGui::EndDisabled();
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Button("Pick...")) {
|
||||
NFD::Guard guard;
|
||||
NFD::UniquePath outPath;
|
||||
|
||||
auto result = NFD::PickFolder(outPath);
|
||||
if(result == NFD_CANCEL)
|
||||
return;
|
||||
if(result == NFD_ERROR)
|
||||
Util::panic("Error: {}", NFD::GetError());
|
||||
auto result = NFD::PickFolder(outPath);
|
||||
if(result == NFD_ERROR)
|
||||
Util::panic("Error: {}", NFD::GetError());
|
||||
|
||||
savesFolder.setName(fmt::format("Save path: {}", outPath.get()));
|
||||
Options::GetInstance().SetValue<std::string>("general", "savePath", outPath.get());
|
||||
apply.setEnabled(true);
|
||||
if(result != NFD_CANCEL) {
|
||||
savesPath = outPath.get();
|
||||
Options::GetInstance().SetValue<std::string>("general", "savePath", savesPath);
|
||||
applyEnabled = true;
|
||||
}
|
||||
}
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if(ImGui::BeginTabItem("Core")) {
|
||||
if(cpuSettings.render()) {
|
||||
if(cpuSettings.getModified())
|
||||
applyEnabled = true;
|
||||
}
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if(ImGui::BeginTabItem("Audio")) {
|
||||
if(audioSettings.render()) {
|
||||
if(audioSettings.getModified())
|
||||
applyEnabled = true;
|
||||
}
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
}});
|
||||
|
||||
tabs.addTab({"CPU", [&]() {
|
||||
if(cpuSettings.render()) {
|
||||
if(cpuSettings.getModified())
|
||||
apply.setEnabled(true);
|
||||
}
|
||||
}});
|
||||
|
||||
tabs.addTab({"Audio", [&]() {
|
||||
if(audioSettings.render()) {
|
||||
if(audioSettings.getModified())
|
||||
apply.setEnabled(true);
|
||||
}
|
||||
}});
|
||||
|
||||
apply.setEnabled(false);
|
||||
|
||||
popup.setFunc([&]() {
|
||||
tabs.render();
|
||||
|
||||
if(apply.render()) {
|
||||
apply.setEnabled(false);
|
||||
ImGui::BeginDisabled(!applyEnabled);
|
||||
if(ImGui::Button("Apply")) {
|
||||
applyEnabled = false;
|
||||
Options::GetInstance().Apply();
|
||||
}
|
||||
|
||||
ImGui::EndDisabled();
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
|
||||
if(ImGui::Button("Cancel")) {
|
||||
popup.setOpened(false);
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
});
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
bool SettingsWindow::render() {
|
||||
if(popup.render())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user