Removed Control.Update, moved all update code to Control.FrameUpdate. UI controls have no business running code inside simulation Ticks. Because of how the update loop is ordered, this will actually make the UI elements more responsive to simulation changes.

Fixed multiple bugs in the action UI where the Control.Update method was calling the base Control.FrameUpdate.
This commit is contained in:
Acruid
2021-03-26 17:10:31 -07:00
parent f17ead47c1
commit 3e7e44df29
13 changed files with 41 additions and 38 deletions

View File

@@ -1,4 +1,4 @@
using Content.Client.UserInterface.Stylesheets; using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility; using Content.Client.Utility;
using Content.Shared.GameObjects.Components; using Content.Shared.GameObjects.Components;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
@@ -14,13 +14,14 @@ namespace Content.Client.GameObjects.Components.Atmos
internal class GasAnalyzerComponent : SharedGasAnalyzerComponent, IItemStatus internal class GasAnalyzerComponent : SharedGasAnalyzerComponent, IItemStatus
{ {
[ViewVariables(VVAccess.ReadWrite)] private bool _uiUpdateNeeded; [ViewVariables(VVAccess.ReadWrite)] private bool _uiUpdateNeeded;
[ViewVariables] public GasAnalyzerDanger Danger { get; private set; } [ViewVariables] private GasAnalyzerDanger Danger { get; set; }
Control IItemStatus.MakeControl() Control IItemStatus.MakeControl()
{ {
return new StatusControl(this); return new StatusControl(this);
} }
/// <inheritdoc />
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState) public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{ {
if (curState is not GasAnalyzerComponentState state) if (curState is not GasAnalyzerComponentState state)
@@ -44,9 +45,10 @@ namespace Content.Client.GameObjects.Components.Atmos
parent._uiUpdateNeeded = true; parent._uiUpdateNeeded = true;
} }
protected override void Update(FrameEventArgs args) /// <inheritdoc />
protected override void FrameUpdate(FrameEventArgs args)
{ {
base.Update(args); base.FrameUpdate(args);
if (!_parent._uiUpdateNeeded) if (!_parent._uiUpdateNeeded)
{ {
@@ -62,9 +64,7 @@ namespace Content.Client.GameObjects.Components.Atmos
_ => "green", _ => "green",
}; };
_label.SetMarkup(Loc.GetString("Pressure: [color={0}]{1}[/color]", _label.SetMarkup(Loc.GetString("itemstatus-pressure-warn", ("color", color), ("danger", _parent.Danger)));
color,
_parent.Danger));
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using Content.Client.UserInterface.Stylesheets; using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility; using Content.Client.Utility;
using Content.Shared.Chemistry; using Content.Shared.Chemistry;
using Content.Shared.GameObjects.Components.Chemistry; using Content.Shared.GameObjects.Components.Chemistry;
@@ -47,9 +47,10 @@ namespace Content.Client.GameObjects.Components.Chemistry
parent._uiUpdateNeeded = true; parent._uiUpdateNeeded = true;
} }
protected override void Update(FrameEventArgs args) /// <inheritdoc />
protected override void FrameUpdate(FrameEventArgs args)
{ {
base.Update(args); base.FrameUpdate(args);
if (!_parent._uiUpdateNeeded) if (!_parent._uiUpdateNeeded)
{ {
return; return;

View File

@@ -1,4 +1,4 @@
using Content.Client.UserInterface.Stylesheets; using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility; using Content.Client.Utility;
using Content.Shared.Chemistry; using Content.Shared.Chemistry;
using Content.Shared.GameObjects.Components.Chemistry; using Content.Shared.GameObjects.Components.Chemistry;
@@ -57,9 +57,9 @@ namespace Content.Client.GameObjects.Components.Chemistry
parent._uiUpdateNeeded = true; parent._uiUpdateNeeded = true;
} }
protected override void Update(FrameEventArgs args) protected override void FrameUpdate(FrameEventArgs args)
{ {
base.Update(args); base.FrameUpdate(args);
if (!_parent._uiUpdateNeeded) if (!_parent._uiUpdateNeeded)
{ {
return; return;

View File

@@ -1,4 +1,4 @@
using Content.Client.UserInterface.Stylesheets; using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility; using Content.Client.Utility;
using Content.Shared.GameObjects.Components; using Content.Shared.GameObjects.Components;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
@@ -51,9 +51,9 @@ namespace Content.Client.GameObjects.Components.Crayon
parent._uiUpdateNeeded = true; parent._uiUpdateNeeded = true;
} }
protected override void Update(FrameEventArgs args) protected override void FrameUpdate(FrameEventArgs args)
{ {
base.Update(args); base.FrameUpdate(args);
if (!_parent._uiUpdateNeeded) if (!_parent._uiUpdateNeeded)
{ {

View File

@@ -1,4 +1,4 @@
using Content.Shared.GameObjects.Components; using Content.Shared.GameObjects.Components;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
@@ -70,9 +70,9 @@ namespace Content.Client.GameObjects.Components
} }
} }
protected override void Update(FrameEventArgs args) protected override void FrameUpdate(FrameEventArgs args)
{ {
base.Update(args); base.FrameUpdate(args);
if (!_parent.HasCell) if (!_parent.HasCell)
return; return;

View File

@@ -1,4 +1,4 @@
using Content.Client.UserInterface.Stylesheets; using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility; using Content.Client.Utility;
using Content.Shared.GameObjects; using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Interactable; using Content.Shared.GameObjects.Components.Interactable;
@@ -52,9 +52,9 @@ namespace Content.Client.GameObjects.Components.Interactable
parent._uiUpdateNeeded = true; parent._uiUpdateNeeded = true;
} }
protected override void Update(FrameEventArgs args) protected override void FrameUpdate(FrameEventArgs args)
{ {
base.Update(args); base.FrameUpdate(args);
if (!_parent._uiUpdateNeeded) if (!_parent._uiUpdateNeeded)
{ {

View File

@@ -55,9 +55,10 @@ namespace Content.Client.GameObjects.Components.Interactable
parent._uiUpdateNeeded = true; parent._uiUpdateNeeded = true;
} }
protected override void Update(FrameEventArgs args) /// <inheritdoc />
protected override void FrameUpdate(FrameEventArgs args)
{ {
base.Update(args); base.FrameUpdate(args);
if (!_parent._uiUpdateNeeded) if (!_parent._uiUpdateNeeded)
{ {

View File

@@ -1,4 +1,4 @@
#nullable enable #nullable enable
using Content.Client.UserInterface.Stylesheets; using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility; using Content.Client.Utility;
@@ -65,9 +65,9 @@ namespace Content.Client.GameObjects.Components
parent._uiUpdateNeeded = true; parent._uiUpdateNeeded = true;
} }
protected override void Update(FrameEventArgs args) protected override void FrameUpdate(FrameEventArgs args)
{ {
base.Update(args); base.FrameUpdate(args);
if (!_parent._uiUpdateNeeded) if (!_parent._uiUpdateNeeded)
{ {

View File

@@ -1,4 +1,4 @@
#nullable enable #nullable enable
using Content.Client.Utility; using Content.Client.Utility;
using Content.Shared.GameObjects.Components.Damage; using Content.Shared.GameObjects.Components.Damage;
using Content.Shared.GameObjects.Components.Mobs.State; using Content.Shared.GameObjects.Components.Mobs.State;
@@ -69,10 +69,8 @@ namespace Content.Client.GameObjects.EntitySystems.HealthOverlay
Panel.Visible = val; Panel.Visible = val;
} }
protected override void Update(FrameEventArgs args) private void MoreFrameUpdate(FrameEventArgs args)
{ {
base.Update(args);
if (Entity.Deleted) if (Entity.Deleted)
{ {
return; return;
@@ -137,6 +135,8 @@ namespace Content.Client.GameObjects.EntitySystems.HealthOverlay
{ {
base.FrameUpdate(args); base.FrameUpdate(args);
MoreFrameUpdate(args);
if (Entity.Deleted || if (Entity.Deleted ||
_eyeManager.CurrentMap != Entity.Transform.MapID) _eyeManager.CurrentMap != Entity.Transform.MapID)
{ {

View File

@@ -179,9 +179,9 @@ namespace Content.Client.Instruments
_owner.Instrument.PlayerTick = (int)Math.Ceiling(PlaybackSlider.Value); _owner.Instrument.PlayerTick = (int)Math.Ceiling(PlaybackSlider.Value);
} }
protected override void Update(FrameEventArgs args) protected override void FrameUpdate(FrameEventArgs args)
{ {
base.Update(args); base.FrameUpdate(args);
if (_owner.Instrument == null) return; if (_owner.Instrument == null) return;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
@@ -510,7 +510,7 @@ namespace Content.Client.UserInterface
protected override void FrameUpdate(FrameEventArgs args) protected override void FrameUpdate(FrameEventArgs args)
{ {
base.Update(args); base.FrameUpdate(args);
_dragDropHelper.Update(args.DeltaSeconds); _dragDropHelper.Update(args.DeltaSeconds);
} }
} }

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using Content.Client.GameObjects.Components.Mobs; using Content.Client.GameObjects.Components.Mobs;
using Content.Client.GameObjects.Components.Mobs.Actions; using Content.Client.GameObjects.Components.Mobs.Actions;
using Content.Client.UserInterface.Controls; using Content.Client.UserInterface.Controls;
@@ -576,7 +576,7 @@ namespace Content.Client.UserInterface
protected override void FrameUpdate(FrameEventArgs args) protected override void FrameUpdate(FrameEventArgs args)
{ {
base.Update(args); base.FrameUpdate(args);
DragDropHelper.Update(args.DeltaSeconds); DragDropHelper.Update(args.DeltaSeconds);
} }
} }

View File

@@ -3,3 +3,4 @@
# Used for GasEntry.ToString() # Used for GasEntry.ToString()
gas-entry-info = {$gasName}: {$gasAmount} mol gas-entry-info = {$gasName}: {$gasAmount} mol
itemstatus-pressure-warn = Pressure: [color={$color}]{$danger}[/color]