Added renderer api switch dropdown (#775)

* Added renderer api switch

* Joined backend api and names into a pair

* Added close button on input editor
This commit is contained in:
KiritoDev 2022-07-18 18:21:31 -05:00 committed by GitHub
parent d45968270a
commit 2daddd8a5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 1 deletions

View File

@ -68,6 +68,7 @@ namespace SohImGui {
static ImVector<ImRect> 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<const char*, const char*> backends[] = {
#ifdef _WIN32
{ "dx11", "DirectX" },
#endif
{ "sdl", "OpenGL" }
};
const char* powers[9] = {
"Vanilla (1x)",
"Double (2x)",
@ -91,6 +100,21 @@ namespace SohImGui {
std::map<std::string, std::vector<std::string>> windowCategories;
std::map<std::string, CustomWindow> customWindows;
int GetBackendID(std::shared_ptr<Mercury> 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<Window> wnd = GlobalCtx2::GetInstance()->GetWindow();
const std::shared_ptr<Mercury> 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);

View File

@ -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");