From c07add4d6eb3fe4ac4e0b9330d2ede9d28ccd99f Mon Sep 17 00:00:00 2001 From: aiekick Date: Tue, 6 Aug 2024 14:08:22 +0200 Subject: [PATCH] [ADD] : add projected size in display quality menu --- src/Backends/MainBackend.cpp | 50 ++++++++++++++++++--------------- src/Backends/MainBackend.h | 8 +++++- src/Generator/CodeGenerator.cpp | 43 +++++++++++++++++++--------- src/Gui/MainFrame.cpp | 1 + src/Headers/NoodlesPlateBuild.h | 4 +-- 5 files changed, 67 insertions(+), 39 deletions(-) diff --git a/src/Backends/MainBackend.cpp b/src/Backends/MainBackend.cpp index d0efa6b..5745dc1 100644 --- a/src/Backends/MainBackend.cpp +++ b/src/Backends/MainBackend.cpp @@ -430,6 +430,8 @@ bool MainBackend::Init(const ct::ivec2& vScreenSize) { SoundSystem::Instance()->GetRenderPack().expired()) // res = false; + PreCalc_Menu_DisplayQuality(); + return res; } @@ -490,6 +492,8 @@ bool MainBackend::Load(const std::string& vFileToLoad) { CameraSystem::Instance()->NeedCamChange(); MainBackend::Instance()->NeedRefresh(); + PreCalc_Menu_DisplayQuality(); + return res; } @@ -651,6 +655,7 @@ void MainBackend::ResizeIfNeeded() { ReSize(prNewSize, prNewQuality, prResizeISForced); prResizeISNeeded = false; prResizeISForced = false; + PreCalc_Menu_DisplayQuality(); } if (prClearingIsNeeded) { ApplyColorClearing(); @@ -1642,30 +1647,31 @@ void MainBackend::UpdateUniforms(RenderPackWeak vRenderPack, UniformVariantPtr v } //////////////// IMGUI /////////////////////////////////////////////////// +void MainBackend::PreCalc_Menu_DisplayQuality() { + m_QualityDisplayMenu.clear(); + auto dPtr = puDisplay_RenderPack.lock(); + if (dPtr != nullptr && dPtr->GetPipe()!=nullptr) { + const auto& dpSize = puScreenSize; + for (const auto q : m_DisplayQualities) { + const auto newSize = ct::fvec2(dpSize) / q; + const auto s = ct::toStr("%f (%i x %i)", q, (int32_t)newSize.x, (int32_t)newSize.y); + m_QualityDisplayMenu[s] = q; + } + } else { + for (const auto q : m_DisplayQualities) { + const auto s = ct::toStr("%f", q); + m_QualityDisplayMenu[s] = q; + } + } +} + void MainBackend::DrawMenu_DisplayQuality() { if (ImGui::BeginMenu("Quality")) { - if (ImGui::MenuItem("0.25", "", IS_FLOAT_EQUAL(puDisplayQuality, 0.25f))) - SetRenderQuality(0.25f); - if (ImGui::MenuItem("0.5", "", IS_FLOAT_EQUAL(puDisplayQuality, 0.5f))) - SetRenderQuality(0.5f); - if (ImGui::MenuItem("1.0", "", IS_FLOAT_EQUAL(puDisplayQuality, 1.0f))) - SetRenderQuality(1.0f); - if (ImGui::MenuItem("1.5", "", IS_FLOAT_EQUAL(puDisplayQuality, 1.5f))) - SetRenderQuality(1.5f); - if (ImGui::MenuItem("2.0", "", IS_FLOAT_EQUAL(puDisplayQuality, 2.0f))) - SetRenderQuality(2.0f); - if (ImGui::MenuItem("2.5", "", IS_FLOAT_EQUAL(puDisplayQuality, 2.5f))) - SetRenderQuality(2.5f); - if (ImGui::MenuItem("3.0", "", IS_FLOAT_EQUAL(puDisplayQuality, 3.0f))) - SetRenderQuality(3.0f); - if (ImGui::MenuItem("3.5", "", IS_FLOAT_EQUAL(puDisplayQuality, 3.5f))) - SetRenderQuality(3.5f); - if (ImGui::MenuItem("4.0", "", IS_FLOAT_EQUAL(puDisplayQuality, 4.0f))) - SetRenderQuality(4.0f); - if (ImGui::MenuItem("4.5", "", IS_FLOAT_EQUAL(puDisplayQuality, 4.5f))) - SetRenderQuality(4.5f); - if (ImGui::MenuItem("5.0", "", IS_FLOAT_EQUAL(puDisplayQuality, 5.0f))) - SetRenderQuality(5.0f); + for (const auto& p : m_QualityDisplayMenu) { + if (ImGui::MenuItem(p.first.c_str(), "", IS_FLOAT_EQUAL(puDisplayQuality, p.second))) { + SetRenderQuality(p.second); + } + } ImGui::EndMenu(); } diff --git a/src/Backends/MainBackend.h b/src/Backends/MainBackend.h index b45ce09..f56439e 100644 --- a/src/Backends/MainBackend.h +++ b/src/Backends/MainBackend.h @@ -119,6 +119,9 @@ class MainBackend : public conf::ConfigAbstract int64_t prLastTimeMeasure = 0; float prDeltaTime = 0.0f; + std::map m_QualityDisplayMenu; + std::vector m_DisplayQualities{0.125, 0.25, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0}; + public: static MainBackend* Instance() { @@ -216,8 +219,10 @@ class MainBackend : public conf::ConfigAbstract void LoadToClipBoard(std::string vString); void SetConsoleVisibility(bool vShow); - + + void PreCalc_Menu_DisplayQuality(); void DrawMenu_DisplayQuality(); + void DrawMenu_FXAA(); void DrawMenu_Edit(); void ShowEditFileMenuKey(ShaderKeyPtr vKey, ct::fvec4 vLURD); @@ -249,6 +254,7 @@ class MainBackend : public conf::ConfigAbstract bool DoShaderCodeUpdateOfRenderPack(RenderPackWeak vRenderPack, bool vForceUpdate, std::set* vUpdatedFiles); + public: std::string getXml(const std::string& vOffset, const std::string& vUserDatas) override; bool setFromXml(tinyxml2::XMLElement* vElem, tinyxml2::XMLElement* vParent, const std::string& vUserDatas) override; diff --git a/src/Generator/CodeGenerator.cpp b/src/Generator/CodeGenerator.cpp index bdbae59..3f41bec 100644 --- a/src/Generator/CodeGenerator.cpp +++ b/src/Generator/CodeGenerator.cpp @@ -2361,20 +2361,35 @@ uniform(frame) int(frame) uFrame; uniform(deltatime) float(deltatime) uDeltaTime; // last render time uniform(buffer) vec2(buffer:target=0) uBufferSize; -uniform(Sliders Float) float(-2:2:0:0.1) uSliderF; -uniform(Sliders Float) vec2(-2:2:0:0.1) uSliderV2; -uniform(Sliders Float) vec3(-2:2:0:0.1) uSliderV3; -uniform(Sliders Float) vec4(-2:2:0:0.1) uSliderV4; - -uniform(Sliders Int:-1) int(-100:100:0) uSliderI; -uniform(Sliders Int) ivec2(-100:100:0) uSliderIV2; -uniform(Sliders Int) ivec3(-100:100:0) uSliderIV3; -uniform(Sliders Int) ivec4(-100:100:0) uSliderIV4; - -uniform(Sliders UInt) uint(0:200:100) uSliderU; -uniform(Sliders UInt) uvec2(0:200:100) uSliderUV2; -uniform(Sliders UInt) uvec3(0:200:100) uSliderUV3; -uniform(Sliders UInt) uvec4(0:200:100) uSliderUV4; +uniform(Sliders Float) float(-2:2:0.0:0.1) uSliderF; +uniform(Sliders Float) vec2(-2:2:0.0,0.5:0.1) uSliderV2; +uniform(Sliders Float) vec3(-2:2:0.0,0.5,1.0:0.1) uSliderV3; +uniform(Sliders Float) vec4(-2:2:0.0,0.5,1.0,1.5:0.1) uSliderV4; + +uniform(Sliders Int:-1) int(-100:100:10) uSliderI; +uniform(Sliders Int) ivec2(-100:100:20) uSliderIV2; +uniform(Sliders Int) ivec3(-100:100:30) uSliderIV3; +uniform(Sliders Int) ivec4(-100:100:40) uSliderIV4; + +uniform(Sliders UInt) uint(0:200:50) uSliderU; +uniform(Sliders UInt) uvec2(0:200:60) uSliderUV2; +uniform(Sliders UInt) uvec3(0:200:70) uSliderUV3; +uniform(Sliders UInt) uvec4(0:200:80) uSliderUV4; + +uniform(Inputs Float) float(input:-2:2:0.0:0.1) uInputF; +uniform(Inputs Float) vec2(input:-2:2:0.0,0.5:0.1) uInputV2; +uniform(Inputs Float) vec3(input:-2:2:0.0,0.5,1.0:0.1) uInputV3; +uniform(Inputs Float) vec4(input:-2:2:0.0,0.5,1.0,1.5:0.1) uInputV4; + +uniform(Inputs Int:-1) int(input:-100:100:10) uInputI; +uniform(Inputs Int) ivec2(input:-100:100:20) uInputIV2; +uniform(Inputs Int) ivec3(input:-100:100:30) uInputIV3; +uniform(Inputs Int) ivec4(input:-100:100:40) uInputIV4; + +uniform(Inputs UInt) uint(input:0:200:50) uInputU; +uniform(Inputs UInt) uvec2(input:0:200:60) uInputUV2; +uniform(Inputs UInt) uvec3(input:0:200:70) uInputUV3; +uniform(Inputs UInt) uvec4(input:0:200:80) uInputUV4; uniform(checkbox float:0) float(checkbox:true) uCheckF; uniform(checkbox float:1) vec2(checkbox:false,true) uCheckV2; diff --git a/src/Gui/MainFrame.cpp b/src/Gui/MainFrame.cpp index dbdb70a..ed55433 100644 --- a/src/Gui/MainFrame.cpp +++ b/src/Gui/MainFrame.cpp @@ -1021,6 +1021,7 @@ void MainFrame::DrawMainMenuBar() { if (ImGui::MenuItem(ICON_NDP_QUESTION " Help")) { FileHelper::Instance()->OpenUrl("https://github.com/aiekick/NoodlesPlate/wiki"); } + #ifdef USE_NETWORK if (ImGui::MenuItem(ICON_NDP_INFO " ChangeLog")) { VersionSystem::Instance()->ShowVersionChangeLog(); diff --git a/src/Headers/NoodlesPlateBuild.h b/src/Headers/NoodlesPlateBuild.h index f858464..f03e56a 100644 --- a/src/Headers/NoodlesPlateBuild.h +++ b/src/Headers/NoodlesPlateBuild.h @@ -1,7 +1,7 @@ #pragma once #define NoodlesPlate_Prefix "NoodlesPlate" -#define NoodlesPlate_BuildNumber 829 +#define NoodlesPlate_BuildNumber 838 #define NoodlesPlate_MinorNumber 7 #define NoodlesPlate_MajorNumber 0 -#define NoodlesPlate_BuildId "0.7.829" +#define NoodlesPlate_BuildId "0.7.838"