Files
kaizen/src/frontend/Settings/CPUSettings.cpp
T

44 lines
1.1 KiB
C++

#include <CPUSettings.hpp>
#include <Options.hpp>
#include <Log.hpp>
#include <imgui.h>
CPUSettings::CPUSettings() {
if (Options::GetInstance().GetValue<std::string>("cpu", "type") == "jit") {
selectedCpuTypeIndex = 1;
} else {
selectedCpuTypeIndex = 0;
}
}
void CPUSettings::render() {
const char* items[] = {
"Interpreter",
"Dynamic Recompiler"
};
const char* combo_preview_value = items[selectedCpuTypeIndex];
if (ImGui::BeginCombo("CPU Type", combo_preview_value)) {
for (int n = 0; n < IM_ARRAYSIZE(items); n++) {
const bool is_selected = (selectedCpuTypeIndex == n);
if (ImGui::Selectable(items[n], is_selected)) {
selectedCpuTypeIndex = n;
modified = true;
}
// Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
if (is_selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
if(modified) {
if(selectedCpuTypeIndex == 0) {
Options::GetInstance().SetValue<std::string>("cpu", "type", "interpreter");
} else {
Options::GetInstance().SetValue<std::string>("cpu", "type", "jit");
}
}
}