Skip to content

Commit

Permalink
Add "Debug HUD" to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
gleblebedev committed Sep 14, 2024
1 parent 5f2424c commit 830d584
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Content/Common/Data/UI/Options.rml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@
<input id="effects" type="range" min="0.0" max="1.0" step="0.05" orient="horizontal" class="blue-slider" data-value="effects" style="display: block"/>
</td>
</tr>
<tr>
<td>
<label for="debughud">Debug HUD</label>
</td>
<td>
<input id="debughud" type="checkbox" class="blue-checkbox" data-checked="debughud"/>
</td>
</tr>

</table>
<br/>
<div style="text-align: right;">
Expand Down
26 changes: 26 additions & 0 deletions RbfxTemplate/SettingsMenuState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,35 @@ public override void OnDataModelInitialized(GameRmlUIComponent menuComponent)
val => Settings.MusicVolume = val.Float);
menuComponent.BindDataModelProperty("effects", val => val.Set(Settings.EffectVolume),
val => Settings.EffectVolume = val.Float);
menuComponent.BindDataModelProperty("debughud", val => val.Set(GetDebugHUD()),
val => SetDebugHUD(val.Bool));
//menuComponent.BindDataModelProperty("shadows", val => val.Set(_shadowsQuality), (val) => _shadowsQuality = val.Convert(VariantType.VarInt).Int);
}

private void SetDebugHUD(bool value)
{
if (value)
{
Context.Engine.CreateDebugHud().Mode = DebugHudMode.DebughudShowAll;
}
else
{
var hud = GetSubsystem<DebugHud>();
if (hud != null)
{
hud.Mode = DebugHudMode.DebughudShowNone;
}
}
}

private bool GetDebugHUD()
{
var hud = GetSubsystem<DebugHud>();
if (hud == null)
return false;
return hud.Mode != DebugHudMode.DebughudShowNone;
}

public override void Activate(StringVariantMap bundle)
{
Settings = Application.Settings;
Expand Down

0 comments on commit 830d584

Please sign in to comment.