Adds slider to developer overlay

Also adds PBR config values. Refs #8535
This commit is contained in:
Vladislav Belov 2026-04-29 19:25:03 +02:00
parent 0f7417bb47
commit c4fb0eed3a
No known key found for this signature in database
GPG key ID: 353545E45DB9CCB3
6 changed files with 121 additions and 1 deletions

View file

@ -160,6 +160,15 @@ textures.maxanisotropy = 2
; GPU skinning via compute shaders, requires up-to-date drivers
gpuskinning = true
; Currently experimental feature to transit to PBR pipelines.
pbr = false
; We might want to render to different texture formats depending on quality and
; performance we need. We support: r11g11b10, rgba16, rgba32.
pbr.framebufferformat = "rgba16"
; Adjust exposure of the scene.
pbr.brightness = "0.5"
; Use smooth LOS interpolation
smoothlos = true

View file

@ -17,6 +17,10 @@ class DeveloperOverlay
new DeveloperOverlayControlDropDown(
new DeveloperOverlayControlDrowDowns.prototype[name](playerViewControl, selection),
i + this.checkBoxes.length));
this.sliders = this.getSliderNames().map((name, i) =>
new DeveloperOverlayControlSlider(
new DeveloperOverlayControlSliders.prototype[name](playerViewControl, selection),
i + this.checkBoxes.length + this.dropDowns.length));
this.resize();
}
@ -34,6 +38,11 @@ class DeveloperOverlay
return Object.keys(DeveloperOverlayControlDrowDowns.prototype);
}
getSliderNames()
{
return Object.keys(DeveloperOverlayControlSliders.prototype);
}
toggle()
{
if (g_IsNetworked && !g_InitAttributes.settings.CheatsEnabled)
@ -49,6 +58,10 @@ class DeveloperOverlay
{
dropDown.setHidden(this.devCommandsOverlay.hidden);
});
this.sliders.forEach(slider =>
{
slider.setHidden(this.devCommandsOverlay.hidden);
});
}
sendNotification()
@ -73,7 +86,8 @@ class DeveloperOverlay
this.devCommandsOverlay.size.bottom =
this.devCommandsOverlay.size.top +
this.checkBoxes.reduce((height, checkbox) => height + checkbox.getHeight(), 0) +
this.dropDowns.reduce((height, dropDown) => height + dropDown.getHeight(), 0);
this.dropDowns.reduce((height, dropDown) => height + dropDown.getHeight(), 0) +
this.sliders.reduce((height, slider) => height + slider.getHeight(), 0);
}
}

View file

@ -14,6 +14,7 @@
<object name="dev_command_label[n]" size="0 0 100%-26 100%" type="text" style="devCommandsText" hidden="true"/>
<object name="dev_command_checkbox[n]" size="100%-24 1 100% 100%" type="checkbox" style="ModernTickBox" hidden="true"/>
<object name="dev_command_dropdown[n]" size="0 0 100% 100%" type="dropdown" style="devCommandsDropDown" tooltip_style="tooltipInstant" hidden="true"/>
<object name="dev_command_slider[n]" size="0 0 100% 100%" type="slider" style="ModernSlider" hidden="true"/>
</object>
</repeat>
</object>

View file

@ -0,0 +1,43 @@
/**
* This class sets up a slider in the developer overlay and assigns its specific handler.
*/
class DeveloperOverlayControlSlider extends DeveloperOverlayControl
{
constructor(handler, i)
{
super(handler, i);
this.slider = Engine.GetGUIObjectByName("dev_command_slider[" + i + "]");
this.slider.onValueChange = this.onValueChange.bind(this);
this.slider.hidden = false;
}
onValueChange()
{
this.handler.onValueChange(this.slider.value);
this.update();
}
update()
{
this.slider.min_value = this.handler.min();
this.slider.max_value = this.handler.max();
this.slider.value = this.handler.value();
this.slider.tooltip = sprintf(translate("%(label)s\n\nValue: %(value)s (min: %(min)s, max: %(max)s)"), {
"label": this.handler.label(),
"value": this.handler.value().toFixed(2),
"min": this.handler.min().toFixed(2),
"max": this.handler.max().toFixed(2)
});
if (this.handler.enabled)
this.slider.enabled = this.handler.enabled();
}
setHidden(hidden)
{
if (hidden)
unregisterSimulationUpdateHandler(this.updater);
else
registerSimulationUpdateHandler(this.updater);
}
}

View file

@ -0,0 +1,41 @@
/**
* This class stores the handlers for the individual sliders available in the developer overlay.
* Such a class must have onSelectionChange function.
* If the class has a selected property, then that will be called every simulation update to
* synchronize the state of the slider (only if the developer overaly is opened).
*/
class DeveloperOverlayControlSliders
{
}
DeveloperOverlayControlSliders.prototype.PBRBrightness = class
{
constructor()
{
}
min()
{
return 0.0;
}
max()
{
return 1.0;
}
value()
{
return Engine.Renderer_GetPBRBrightness();
}
label()
{
return translate("PBR brightness");
}
onValueChange(value)
{
Engine.Renderer_SetPBRBrightness(value);
}
};

View file

@ -67,6 +67,16 @@ bool TextureExists(const std::wstring& filename)
return g_Renderer.GetTextureManager().TextureExists(filename);
}
float GetPBRBrightness()
{
return g_RenderingOptions.GetPBRBrightness();
}
void SetPBRBrightness(const float value)
{
g_RenderingOptions.SetPBRBrightness(value);
}
#define REGISTER_BOOLEAN_SCRIPT_SETTING(NAME) \
ScriptFunction::Register<&Get##NAME##Enabled>(rq, "Renderer_Get" #NAME "Enabled"); \
ScriptFunction::Register<&Set##NAME##Enabled>(rq, "Renderer_Set" #NAME "Enabled");
@ -77,6 +87,8 @@ void RegisterScriptFunctions(const ScriptRequest& rq)
ScriptFunction::Register<&TextureExists>(rq, "TextureExists");
ScriptFunction::Register<&GetRenderDebugMode>(rq, "Renderer_GetRenderDebugMode");
ScriptFunction::Register<&SetRenderDebugMode>(rq, "Renderer_SetRenderDebugMode");
ScriptFunction::Register<&GetPBRBrightness>(rq, "Renderer_GetPBRBrightness");
ScriptFunction::Register<&SetPBRBrightness>(rq, "Renderer_SetPBRBrightness");
REGISTER_BOOLEAN_SCRIPT_SETTING(CutsceneMode);
REGISTER_BOOLEAN_SCRIPT_SETTING(DisplayFrustum);
REGISTER_BOOLEAN_SCRIPT_SETTING(DisplayShadowsFrustum);