Skip to content

Commit

Permalink
[ADD] : add projected size in display quality menu
Browse files Browse the repository at this point in the history
  • Loading branch information
aiekick committed Aug 6, 2024
1 parent 6331b7e commit c07add4
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 39 deletions.
50 changes: 28 additions & 22 deletions src/Backends/MainBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ bool MainBackend::Init(const ct::ivec2& vScreenSize) {
SoundSystem::Instance()->GetRenderPack().expired()) //
res = false;

PreCalc_Menu_DisplayQuality();

return res;
}

Expand Down Expand Up @@ -490,6 +492,8 @@ bool MainBackend::Load(const std::string& vFileToLoad) {
CameraSystem::Instance()->NeedCamChange();
MainBackend::Instance()->NeedRefresh();

PreCalc_Menu_DisplayQuality();

return res;
}

Expand Down Expand Up @@ -651,6 +655,7 @@ void MainBackend::ResizeIfNeeded() {
ReSize(prNewSize, prNewQuality, prResizeISForced);
prResizeISNeeded = false;
prResizeISForced = false;
PreCalc_Menu_DisplayQuality();
}
if (prClearingIsNeeded) {
ApplyColorClearing();
Expand Down Expand Up @@ -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();
}
Expand Down
8 changes: 7 additions & 1 deletion src/Backends/MainBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ class MainBackend : public conf::ConfigAbstract
int64_t prLastTimeMeasure = 0;
float prDeltaTime = 0.0f;

std::map<std::string, float> m_QualityDisplayMenu;
std::vector<float> 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()
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -249,6 +254,7 @@ class MainBackend : public conf::ConfigAbstract

bool DoShaderCodeUpdateOfRenderPack(RenderPackWeak vRenderPack, bool vForceUpdate, std::set<std::string>* 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;
Expand Down
43 changes: 29 additions & 14 deletions src/Generator/CodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/Gui/MainFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/Headers/NoodlesPlateBuild.h
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit c07add4

Please sign in to comment.