fixed incorrect ImGui::EndTabBar usage

This commit is contained in:
myT 2024-07-02 22:23:39 +02:00
parent eee321a641
commit 4955060c9f
3 changed files with 185 additions and 180 deletions

View file

@ -1622,153 +1622,154 @@ void VolumetricLight::DrawGUI()
const char* axisNames[3] = { "X", "Y", "Z" };
ImGui::BeginTabBar("Tabs#Fogs", ImGuiTabBarFlags_AutoSelectNewTabs);
for(int i = 0; i < fogCount; i++)
if(ImGui::BeginTabBar("Tabs#Fogs", ImGuiTabBarFlags_AutoSelectNewTabs))
{
if(ImGui::BeginTabItem(va("#%d", i + 1)))
for(int i = 0; i < fogCount; i++)
{
Fog& fog = fogs[i];
ImGui::Checkbox("Global fog", &fog.isGlobalFog);
if(!fog.isGlobalFog)
if(ImGui::BeginTabItem(va("#%d", i + 1)))
{
for(int a = 0; a < 3; a++)
Fog& fog = fogs[i];
ImGui::Checkbox("Global fog", &fog.isGlobalFog);
if(!fog.isGlobalFog)
{
ImGui::SliderFloat(va("Box min %s", axisNames[a]), &fog.boxMin[a], mapBoxMin[a], mapBoxMax[a], "%g");
ImGui::SliderFloat(va("Box max %s", axisNames[a]), &fog.boxMax[a], mapBoxMin[a], mapBoxMax[a], "%g");
for(int a = 0; a < 3; a++)
{
ImGui::SliderFloat(va("Box min %s", axisNames[a]), &fog.boxMin[a], mapBoxMin[a], mapBoxMax[a], "%g");
ImGui::SliderFloat(va("Box max %s", axisNames[a]), &fog.boxMax[a], mapBoxMin[a], mapBoxMax[a], "%g");
}
}
float opaqueDistance = ExtinctionToOpaqueDistance(fog.extinction);
ImGui::SliderFloat("Distance to opaque", &opaqueDistance, 1.0f, 10000.0f, "%g");
fog.extinction = OpaqueDistanceToExtinction(opaqueDistance);
ImGui::ColorEdit3("Reflective (scatter) color", fog.scatterColor, colorEditFlags);
ImGui::SliderFloat("Reflectivity (albedo)", &fog.albedo, 0.0f, 1.0f, "%g");
ImGui::SliderFloat("Directionality (anisotropy)", &fog.anisotropy, 0.0f, 1.0f, "%g");
ImGui::SliderFloat("Emissive strength", &fog.emissive, 0.0f, 0.001f, "%g");
ImGui::ColorEdit3("Emissive color", fog.emissiveColor, colorEditFlags);
ImGui::SliderFloat("Noise strength", &fog.noiseStrength, 1.0f, 10.0f, "%g");
ImGui::SliderFloat("Noise space period", &fog.noiseSpatialPeriod, 0.0f, 200.0f, "%g");
ImGui::SliderFloat("Noise time period", &fog.noiseTimePeriod, 0.0f, 20.0f, "%g");
ImGui::Checkbox("Height fog", &fog.isHeightFog);
ImGui::EndTabItem();
ImGui::Separator();
if(ImGui::Button("Remove"))
{
if(i < fogCount - 1)
{
memmove(&fogs[i], &fogs[i + 1], (fogCount - 1 - i) * sizeof(fogs[0]));
}
fogCount--;
}
}
float opaqueDistance = ExtinctionToOpaqueDistance(fog.extinction);
ImGui::SliderFloat("Distance to opaque", &opaqueDistance, 1.0f, 10000.0f, "%g");
fog.extinction = OpaqueDistanceToExtinction(opaqueDistance);
ImGui::ColorEdit3("Reflective (scatter) color", fog.scatterColor, colorEditFlags);
ImGui::SliderFloat("Reflectivity (albedo)", &fog.albedo, 0.0f, 1.0f, "%g");
ImGui::SliderFloat("Directionality (anisotropy)", &fog.anisotropy, 0.0f, 1.0f, "%g");
ImGui::SliderFloat("Emissive strength", &fog.emissive, 0.0f, 0.001f, "%g");
ImGui::ColorEdit3("Emissive color", fog.emissiveColor, colorEditFlags);
ImGui::SliderFloat("Noise strength", &fog.noiseStrength, 1.0f, 10.0f, "%g");
ImGui::SliderFloat("Noise space period", &fog.noiseSpatialPeriod, 0.0f, 200.0f, "%g");
ImGui::SliderFloat("Noise time period", &fog.noiseTimePeriod, 0.0f, 20.0f, "%g");
ImGui::Checkbox("Height fog", &fog.isHeightFog);
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Main"))
{
bool enableVL = crp_volLight->integer != 0;
if(ImGui::Checkbox("Enable volumetric lighting", &enableVL))
{
Cvar_Set(crp_volLight->name, enableVL ? "1" : "0");
}
ImGui::Checkbox("Enable sunlight", &drawSunlight);
ImGui::Separator();
if(ImGui::Button("Remove"))
ImGui::Checkbox("Enable light grid", &enableLightGrid);
ImGui::ColorEdit3("Ambient light color", ambientColorGUI, colorEditFlags);
ImGui::SliderFloat("Ambient light intensity", &ambientIntensity, 0.0f, 1.0f);
ImGui::Separator();
ImGui::SliderFloat("Sunlight intensity", &crp.sunlightData.intensityVL, 0.0f, 200.0f);
ImGui::SliderFloat("Point light intensity", &pointLightIntensity, 0.0f, 200.0f);
const float brightness = Brightness(ambientColorGUI);
if(brightness > 0.000001f)
{
if(i < fogCount - 1)
const float scale = 0.5f / brightness;
for(int i = 0; i < 3; i++)
{
memmove(&fogs[i], &fogs[i + 1], (fogCount - 1 - i) * sizeof(fogs[0]));
ambientColor[i] = ambientColorGUI[i] * scale;
}
fogCount--;
}
}
}
if(ImGui::BeginTabItem("Main"))
{
bool enableVL = crp_volLight->integer != 0;
if(ImGui::Checkbox("Enable volumetric lighting", &enableVL))
{
Cvar_Set(crp_volLight->name, enableVL ? "1" : "0");
}
ImGui::Checkbox("Enable sunlight", &drawSunlight);
ImGui::Separator();
ImGui::Checkbox("Enable light grid", &enableLightGrid);
ImGui::ColorEdit3("Ambient light color", ambientColorGUI, colorEditFlags);
ImGui::SliderFloat("Ambient light intensity", &ambientIntensity, 0.0f, 1.0f);
ImGui::Separator();
ImGui::SliderFloat("Sunlight intensity", &crp.sunlightData.intensityVL, 0.0f, 200.0f);
ImGui::SliderFloat("Point light intensity", &pointLightIntensity, 0.0f, 200.0f);
const float brightness = Brightness(ambientColorGUI);
if(brightness > 0.000001f)
{
const float scale = 0.5f / brightness;
for(int i = 0; i < 3; i++)
else
{
ambientColor[i] = ambientColorGUI[i] * scale;
VectorSet(ambientColor, 0.5f, 0.5f, 0.5f);
}
}
else
{
VectorSet(ambientColor, 0.5f, 0.5f, 0.5f);
ImGui::EndTabItem();
}
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Resolution"))
{
const float titleWidth = 14.0f * ImGui::GetFontSize();
RadioButton(&xySubsampling, titleWidth, "X/Y sub-sampling", 3, "2x", 1, "4x", 2, "8x", 3);
RadioButton(&zResolution, titleWidth, "Z resolution", 3, "128", 128, "256", 256, "512", 512);
RadioButton(&extinctionResolution, titleWidth, "Extinction resolution", 3, "64", 64, "128", 128, "256", 256);
RadioButton(&sunShadowResolution, titleWidth, "Sun shadow resolution", 3, "64", 64, "128", 128, "256", 256);
RadioButton(&pointShadowResolution, titleWidth, "Point shadow resolution", 3, "32", 32, "64", 64, "128", 128);
int divisor = 1;
for(int i = 0; i < xySubsampling; i++)
if(ImGui::BeginTabItem("Resolution"))
{
divisor *= 2;
}
const float titleWidth = 14.0f * ImGui::GetFontSize();
RadioButton(&xySubsampling, titleWidth, "X/Y sub-sampling", 3, "2x", 1, "4x", 2, "8x", 3);
RadioButton(&zResolution, titleWidth, "Z resolution", 3, "128", 128, "256", 256, "512", 512);
RadioButton(&extinctionResolution, titleWidth, "Extinction resolution", 3, "64", 64, "128", 128, "256", 256);
RadioButton(&sunShadowResolution, titleWidth, "Sun shadow resolution", 3, "64", 64, "128", 128, "256", 256);
RadioButton(&pointShadowResolution, titleWidth, "Point shadow resolution", 3, "32", 32, "64", 64, "128", 128);
if((glConfig.vidWidth / divisor) != frustumSize[0] ||
(glConfig.vidHeight / divisor) != frustumSize[1] ||
zResolution != frustumSize[2] ||
extinctionResolution != extinctionSize[0] ||
sunShadowResolution != sunShadowSize[0] ||
pointShadowResolution != shadowPixelCount)
{
if(ImGui::Button("Video restart"))
int divisor = 1;
for(int i = 0; i < xySubsampling; i++)
{
Cbuf_AddText("vid_restart\n");
divisor *= 2;
}
}
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Debug"))
{
if(tr.world->lightGridData != NULL)
{
ImGui::Checkbox("Draw ambient light grid", &drawAmbientDebug);
if(drawAmbientDebug)
if((glConfig.vidWidth / divisor) != frustumSize[0] ||
(glConfig.vidHeight / divisor) != frustumSize[1] ||
zResolution != frustumSize[2] ||
extinctionResolution != extinctionSize[0] ||
sunShadowResolution != sunShadowSize[0] ||
pointShadowResolution != shadowPixelCount)
{
ImGui::SliderFloat("Voxel sphere scale", &debugSphereScale, 0.25f, 1.0f);
if(ImGui::Button("Video restart"))
{
Cbuf_AddText("vid_restart\n");
}
}
ImGui::EndTabItem();
}
else
if(ImGui::BeginTabItem("Debug"))
{
ImGui::TextColored(ImVec4(1.0f, 0.5f, 0.0f, 1.0f), "No valid light grid was found for this map");
if(tr.world->lightGridData != NULL)
{
ImGui::Checkbox("Draw ambient light grid", &drawAmbientDebug);
if(drawAmbientDebug)
{
ImGui::SliderFloat("Voxel sphere scale", &debugSphereScale, 0.25f, 1.0f);
}
}
else
{
ImGui::TextColored(ImVec4(1.0f, 0.5f, 0.0f, 1.0f), "No valid light grid was found for this map");
}
ImGui::Separator();
ImGui::Checkbox("Draw extinction volume", &drawExtinctionDebug);
if(drawExtinctionDebug)
{
ImGui::SliderInt("Extinction cascade", &debugExtinctionCascadeIndex, 0, 3);
ImGui::SliderFloat("Extinction value scale", &debugExtinctionScale, 1.0f, 1000.0f);
}
ImGui::Separator();
ImGui::Checkbox("Draw sun shadow volume", &drawSunShadowDebug);
if(drawSunShadowDebug)
{
ImGui::SliderInt("Sun shadow cascade", &debugSunShadowCascadeIndex, 0, 3);
}
ImGui::Separator();
ImGui::Checkbox("Lock camera position", &lockCameraPosition);
ImGui::SliderFloat("Voxel box scale", &debugBoxScale, 0.25f, 1.0f);
ImGui::EndTabItem();
}
ImGui::Separator();
ImGui::Checkbox("Draw extinction volume", &drawExtinctionDebug);
if(drawExtinctionDebug)
{
ImGui::SliderInt("Extinction cascade", &debugExtinctionCascadeIndex, 0, 3);
ImGui::SliderFloat("Extinction value scale", &debugExtinctionScale, 1.0f, 1000.0f);
}
ImGui::Separator();
ImGui::Checkbox("Draw sun shadow volume", &drawSunShadowDebug);
if(drawSunShadowDebug)
{
ImGui::SliderInt("Sun shadow cascade", &debugSunShadowCascadeIndex, 0, 3);
}
ImGui::Separator();
ImGui::Checkbox("Lock camera position", &lockCameraPosition);
ImGui::SliderFloat("Voxel box scale", &debugBoxScale, 0.25f, 1.0f);
ImGui::EndTabItem();
ImGui::EndTabBar();
}
ImGui::EndTabBar();
if(SaveFileDialog_Do())
{
SaveFogFile(SaveFileDialog_GetPath());

View file

@ -3137,12 +3137,14 @@ namespace RHI
{
if(ImGui::Begin("Direct3D 12 RHI", &resourcesActive))
{
ImGui::BeginTabBar("Tabs#RHI");
DrawSection("Resources", &DrawResourceUsage);
DrawSection("Caps", &DrawCaps);
DrawSection("Textures", &DrawTextures);
DrawSection("Buffers", &DrawBuffers);
ImGui::EndTabBar();
if(ImGui::BeginTabBar("Tabs#RHI"))
{
DrawSection("Resources", &DrawResourceUsage);
DrawSection("Caps", &DrawCaps);
DrawSection("Textures", &DrawTextures);
DrawSection("Buffers", &DrawBuffers);
ImGui::EndTabBar();
}
}
ImGui::End();
}

View file

@ -1802,64 +1802,66 @@ static void DrawSettings()
DrawFilter(cvarFilter, sizeof(cvarFilter));
ImGui::NewLine();
ImGui::BeginTabBar("Tabs#ClientSettings");
if(ImGui::BeginTabItem("All"))
if(ImGui::BeginTabBar("Tabs#ClientSettings"))
{
DrawCVarTable(&restartNeeded, "All settings", -1);
ImGui::EndTabItem();
if(ImGui::BeginTabItem("All"))
{
DrawCVarTable(&restartNeeded, "All settings", -1);
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("General"))
{
DrawCVarTable(&restartNeeded, "General settings", CVARCAT_GENERAL);
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Gameplay"))
{
DrawCVarTable(&restartNeeded, "Gameplay settings", CVARCAT_GAMEPLAY);
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("HUD"))
{
DrawCVarTable(&restartNeeded, "HUD settings", CVARCAT_HUD);
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Video"))
{
DrawCVarTable(&restartNeeded, "Display settings", CVARCAT_DISPLAY);
DrawCVarTable(&restartNeeded, "Graphics settings", CVARCAT_GRAPHICS);
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Audio"))
{
DrawCVarTable(&restartNeeded, "Sound settings", CVARCAT_SOUND);
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Input"))
{
DrawCVarTable(&restartNeeded, "Input settings", CVARCAT_INPUT);
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Network"))
{
DrawCVarTable(&restartNeeded, "Network and client-side prediction settings", CVARCAT_NETWORK);
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Console"))
{
DrawCVarTable(&restartNeeded, "Console settings", CVARCAT_CONSOLE);
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Demo"))
{
DrawCVarTable(&restartNeeded, "Demo playback settings", CVARCAT_DEMO);
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Performance"))
{
DrawCVarTable(&restartNeeded, "Performance settings", CVARCAT_PERFORMANCE);
ImGui::EndTabItem();
}
ImGui::EndTabBar();
}
if(ImGui::BeginTabItem("General"))
{
DrawCVarTable(&restartNeeded, "General settings", CVARCAT_GENERAL);
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Gameplay"))
{
DrawCVarTable(&restartNeeded, "Gameplay settings", CVARCAT_GAMEPLAY);
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("HUD"))
{
DrawCVarTable(&restartNeeded, "HUD settings", CVARCAT_HUD);
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Video"))
{
DrawCVarTable(&restartNeeded, "Display settings", CVARCAT_DISPLAY);
DrawCVarTable(&restartNeeded, "Graphics settings", CVARCAT_GRAPHICS);
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Audio"))
{
DrawCVarTable(&restartNeeded, "Sound settings", CVARCAT_SOUND);
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Input"))
{
DrawCVarTable(&restartNeeded, "Input settings", CVARCAT_INPUT);
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Network"))
{
DrawCVarTable(&restartNeeded, "Network and client-side prediction settings", CVARCAT_NETWORK);
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Console"))
{
DrawCVarTable(&restartNeeded, "Console settings", CVARCAT_CONSOLE);
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Demo"))
{
DrawCVarTable(&restartNeeded, "Demo playback settings", CVARCAT_DEMO);
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Performance"))
{
DrawCVarTable(&restartNeeded, "Performance settings", CVARCAT_PERFORMANCE);
ImGui::EndTabItem();
}
ImGui::EndTabBar();
DrawVideoRestart(restartNeeded);
}