Better robotics console (#38023)
This commit is contained in:
@@ -28,6 +28,8 @@ public sealed partial class RoboticsConsoleWindow : FancyWindow
|
||||
|
||||
public EntityUid Entity;
|
||||
|
||||
private bool _allowBorgControl = true;
|
||||
|
||||
public RoboticsConsoleWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
@@ -72,6 +74,7 @@ public sealed partial class RoboticsConsoleWindow : FancyWindow
|
||||
public void UpdateState(RoboticsConsoleState state)
|
||||
{
|
||||
_cyborgs = state.Cyborgs;
|
||||
_allowBorgControl = state.AllowBorgControl;
|
||||
|
||||
// clear invalid selection
|
||||
if (_selected is {} selected && !_cyborgs.ContainsKey(selected))
|
||||
@@ -85,8 +88,8 @@ public sealed partial class RoboticsConsoleWindow : FancyWindow
|
||||
PopulateData();
|
||||
|
||||
var locked = _lock.IsLocked(Entity);
|
||||
DangerZone.Visible = !locked;
|
||||
LockedMessage.Visible = locked;
|
||||
DangerZone.Visible = !locked && _allowBorgControl;
|
||||
LockedMessage.Visible = locked && _allowBorgControl; // Only show if locked AND control is allowed
|
||||
}
|
||||
|
||||
private void PopulateCyborgs()
|
||||
@@ -120,11 +123,19 @@ public sealed partial class RoboticsConsoleWindow : FancyWindow
|
||||
BorgSprite.Texture = _sprite.Frame0(data.ChassisSprite!);
|
||||
|
||||
var batteryColor = data.Charge switch {
|
||||
< 0.2f => "red",
|
||||
< 0.4f => "orange",
|
||||
< 0.6f => "yellow",
|
||||
< 0.8f => "green",
|
||||
_ => "blue"
|
||||
< 0.2f => "#FF6C7F", // red
|
||||
< 0.4f => "#EF973C", // orange
|
||||
< 0.6f => "#E8CB2D", // yellow
|
||||
< 0.8f => "#30CC19", // green
|
||||
_ => "#00D3B8" // cyan
|
||||
};
|
||||
|
||||
var hpPercentColor = data.HpPercent switch {
|
||||
< 0.2f => "#FF6C7F", // red
|
||||
< 0.4f => "#EF973C", // orange
|
||||
< 0.6f => "#E8CB2D", // yellow
|
||||
< 0.8f => "#30CC19", // green
|
||||
_ => "#00D3B8" // cyan
|
||||
};
|
||||
|
||||
var text = new FormattedMessage();
|
||||
@@ -132,12 +143,14 @@ public sealed partial class RoboticsConsoleWindow : FancyWindow
|
||||
text.AddMarkupOrThrow(Loc.GetString("robotics-console-designation"));
|
||||
text.AddText($" {data.Name}\n"); // prevent players trolling by naming borg [color=red]satan[/color]
|
||||
text.AddMarkupOrThrow($"{Loc.GetString("robotics-console-battery", ("charge", (int)(data.Charge * 100f)), ("color", batteryColor))}\n");
|
||||
text.AddMarkupOrThrow($"{Loc.GetString("robotics-console-hp", ("hp", (int)(data.HpPercent * 100f)), ("color", hpPercentColor))}\n");
|
||||
text.AddMarkupOrThrow($"{Loc.GetString("robotics-console-brain", ("brain", data.HasBrain))}\n");
|
||||
text.AddMarkupOrThrow(Loc.GetString("robotics-console-modules", ("count", data.ModuleCount)));
|
||||
BorgInfo.SetMessage(text);
|
||||
|
||||
// how the turntables
|
||||
DisableButton.Disabled = !(data.HasBrain && data.CanDisable);
|
||||
DisableButton.Disabled = !_allowBorgControl || !(data.HasBrain && data.CanDisable);
|
||||
DestroyButton.Disabled = !_allowBorgControl;
|
||||
}
|
||||
|
||||
protected override void FrameUpdate(FrameEventArgs args)
|
||||
|
||||
Reference in New Issue
Block a user