diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index 153a193e8..ff04133ce 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -68,6 +68,7 @@ namespace SohImGui { static ImVector s_GroupPanelLabelStack; bool p_open = false; bool needs_save = false; + int lastBackendID = 0; const char* filters[3] = { "Three-Point", @@ -75,6 +76,14 @@ namespace SohImGui { "None" }; + std::pair backends[] = { +#ifdef _WIN32 + { "dx11", "DirectX" }, +#endif + { "sdl", "OpenGL" } + }; + + const char* powers[9] = { "Vanilla (1x)", "Double (2x)", @@ -91,6 +100,21 @@ namespace SohImGui { std::map> windowCategories; std::map customWindows; + int GetBackendID(std::shared_ptr cfg) { + std::string backend = cfg->getString("Window.GfxBackend"); + if (backend.empty()) { + return 0; + } + + for (size_t i = 0; i < (sizeof(backends) / sizeof(backends[0])); i++) { + if(backend == backends[i].first) { + return i; + } + } + + return 0; + } + int ClampFloatToInt(float value, int min, int max) { return fmin(fmax(value, min), max); } @@ -315,6 +339,8 @@ namespace SohImGui { io = &ImGui::GetIO(); io->ConfigFlags |= ImGuiConfigFlags_DockingEnable; io->Fonts->AddFontDefault(); + + lastBackendID = GetBackendID(GlobalCtx2::GetInstance()->GetConfig()); if (CVar_GetS32("gOpenMenuBar", 0) != 1) { SohImGui::overlay->TextDrawNotification(30.0f, true, "Press F1 to access enhancements menu"); } @@ -653,6 +679,8 @@ namespace SohImGui { ImGui::NewFrame(); const std::shared_ptr wnd = GlobalCtx2::GetInstance()->GetWindow(); + const std::shared_ptr pConf = GlobalCtx2::GetInstance()->GetConfig(); + ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus | ImGuiWindowFlags_NoResize; @@ -822,6 +850,18 @@ namespace SohImGui { "to do CPU + GPU work in time."); } + + ImGui::Text("Renderer API (Needs reload)"); + if (ImGui::BeginCombo("##RApi", backends[lastBackendID].second)) { + for (uint8_t i = 0; i < sizeof(backends) / sizeof(backends[0]); i++) { + if (ImGui::Selectable(backends[i].second, i == lastBackendID)) { + pConf->setString("Window.GfxBackend", backends[i].first); + lastBackendID = i; + } + } + ImGui::EndCombo(); + } + EXPERIMENTAL(); ImGui::Text("Texture Filter (Needs reload)"); EnhancementCombobox("gTextureFilter", filters, 3, 0); diff --git a/libultraship/libultraship/InputEditor.cpp b/libultraship/libultraship/InputEditor.cpp index 0d170e305..f03e94d57 100644 --- a/libultraship/libultraship/InputEditor.cpp +++ b/libultraship/libultraship/InputEditor.cpp @@ -5,6 +5,7 @@ #include "ImGuiImpl.h" #include "Utils/StringHelper.h" #include "Lib/ImGui/imgui_internal.h" +#include "Cvar.h" namespace Ship { @@ -249,13 +250,14 @@ namespace Ship { if (!this->Opened) { BtnReading = -1; + CVar_SetS32("gControllerConfigurationEnabled", 0); return; } ImGui::SetNextWindowSizeConstraints(ImVec2(641, 250), ImVec2(1200, 290)); //OTRTODO: Disable this stupid workaround ( ReadRawPress() only works when the window is on the main viewport ) ImGui::SetNextWindowViewport(ImGui::GetMainViewport()->ID); - ImGui::Begin("Controller Configuration", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize); + ImGui::Begin("Controller Configuration", &this->Opened, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize); ImGui::BeginTabBar("##Controllers");