Client HUD/Renderer: fix dead laser visibility, radar orientation, Garage grow direction, chyron churn, and NativeLibraries
This commit is contained in:
parent
bb68620d1c
commit
3cb60447ff
3 changed files with 82 additions and 28 deletions
|
|
@ -46,6 +46,9 @@ public partial class Hud : CanvasLayer
|
|||
private PanelContainer _bottomLeftPanel = null!;
|
||||
|
||||
private VBoxContainer _chyronBox = null!;
|
||||
private readonly Label[] _chyronLabels = new Label[3];
|
||||
private BroadcastFeed? _lastBroadcastFeed;
|
||||
private int _lastChyronCount = -1;
|
||||
private PanelContainer _outcomeBanner = null!;
|
||||
private Label _outcomeLabel = null!;
|
||||
|
||||
|
|
@ -140,7 +143,7 @@ public partial class Hud : CanvasLayer
|
|||
}
|
||||
|
||||
// Broadcast Chyron
|
||||
SyncBroadcastChyron(state.Broadcast.Lines);
|
||||
SyncBroadcastChyron(state.Broadcast);
|
||||
|
||||
// Outcome
|
||||
if (state.Phase == MatchPhase.Victory)
|
||||
|
|
@ -263,6 +266,7 @@ public partial class Hud : CanvasLayer
|
|||
_bottomLeftPanel.AnchorLeft = 0f;
|
||||
_bottomLeftPanel.AnchorTop = 1f;
|
||||
_bottomLeftPanel.AnchorBottom = 1f;
|
||||
_bottomLeftPanel.GrowVertical = Control.GrowDirection.Begin;
|
||||
_bottomLeftPanel.OffsetLeft = 14f;
|
||||
_bottomLeftPanel.OffsetTop = -248f;
|
||||
_bottomLeftPanel.OffsetBottom = -14f;
|
||||
|
|
@ -332,6 +336,19 @@ public partial class Hud : CanvasLayer
|
|||
_chyronBox = new VBoxContainer();
|
||||
_chyronBox.AddThemeConstantOverride("separation", 2);
|
||||
vbox.AddChild(_chyronBox);
|
||||
|
||||
for (int i = 0; i < _chyronLabels.Length; i++)
|
||||
{
|
||||
var lbl = new Label
|
||||
{
|
||||
Visible = false,
|
||||
AutowrapMode = TextServer.AutowrapMode.Word
|
||||
};
|
||||
lbl.AddThemeFontSizeOverride("font_size", 11);
|
||||
lbl.AddThemeColorOverride("font_color", TextMuted);
|
||||
_chyronBox.AddChild(lbl);
|
||||
_chyronLabels[i] = lbl;
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildOutcomeBanner()
|
||||
|
|
@ -452,28 +469,37 @@ public partial class Hud : CanvasLayer
|
|||
}
|
||||
}
|
||||
|
||||
private void SyncBroadcastChyron(IReadOnlyList<BroadcastLine> lines)
|
||||
private void SyncBroadcastChyron(BroadcastFeed broadcast)
|
||||
{
|
||||
for (int i = _chyronBox.GetChildCount() - 1; i >= 0; i--)
|
||||
var lines = broadcast.Lines;
|
||||
if (ReferenceEquals(_lastBroadcastFeed, broadcast) && lines.Count == _lastChyronCount)
|
||||
{
|
||||
var c = _chyronBox.GetChild(i);
|
||||
_chyronBox.RemoveChild(c);
|
||||
c.QueueFree();
|
||||
return;
|
||||
}
|
||||
|
||||
int start = Math.Max(0, lines.Count - 3);
|
||||
for (int i = start; i < lines.Count; i++)
|
||||
_lastBroadcastFeed = broadcast;
|
||||
_lastChyronCount = lines.Count;
|
||||
|
||||
int start = Math.Max(0, lines.Count - _chyronLabels.Length);
|
||||
int visibleCount = lines.Count - start;
|
||||
for (int slot = 0; slot < _chyronLabels.Length; slot++)
|
||||
{
|
||||
var line = lines[i];
|
||||
bool isLatest = i == lines.Count - 1;
|
||||
var lbl = new Label
|
||||
var lbl = _chyronLabels[slot];
|
||||
if (slot < visibleCount)
|
||||
{
|
||||
Text = $"[{line.Timestamp:00.0}s] {line.Text}",
|
||||
AutowrapMode = TextServer.AutowrapMode.Word
|
||||
};
|
||||
lbl.AddThemeFontSizeOverride("font_size", isLatest ? 12 : 11);
|
||||
lbl.AddThemeColorOverride("font_color", isLatest ? TextLight : TextMuted);
|
||||
_chyronBox.AddChild(lbl);
|
||||
int lineIdx = start + slot;
|
||||
var line = lines[lineIdx];
|
||||
bool isLatest = lineIdx == lines.Count - 1;
|
||||
lbl.Visible = true;
|
||||
lbl.Text = $"[{line.Timestamp:00.0}s] {line.Text}";
|
||||
lbl.AddThemeFontSizeOverride("font_size", isLatest ? 12 : 11);
|
||||
lbl.AddThemeColorOverride("font_color", isLatest ? TextLight : TextMuted);
|
||||
}
|
||||
else
|
||||
{
|
||||
lbl.Visible = false;
|
||||
lbl.Text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -546,6 +572,10 @@ public partial class Hud : CanvasLayer
|
|||
|
||||
public void SetState(MatchState state) => _state = state;
|
||||
|
||||
private static Vector2 WorldToRadar(Vector2 center, float scale, float wx, float wz) =>
|
||||
// Match chase camera orientation: screen-up = +Z, screen-right = -X.
|
||||
center + new Vector2(-wx, -wz) * scale;
|
||||
|
||||
public override void _Draw()
|
||||
{
|
||||
Vector2 center = Size * 0.5f;
|
||||
|
|
@ -566,7 +596,7 @@ public partial class Hud : CanvasLayer
|
|||
{
|
||||
var d = _state.GroundDrops[i];
|
||||
if (d.PickedUp) continue;
|
||||
var p = center + new Vector2(d.X, d.Z) * scale;
|
||||
var p = WorldToRadar(center, scale, d.X, d.Z);
|
||||
if (d.Chassis is not null)
|
||||
{
|
||||
DrawRect(new Rect2(p - new Vector2(2.5f, 2.5f), new Vector2(5f, 5f)), CyanCol);
|
||||
|
|
@ -583,7 +613,7 @@ public partial class Hud : CanvasLayer
|
|||
{
|
||||
var s = specs[i];
|
||||
if (!s.Alive) continue;
|
||||
var p = center + new Vector2(s.X, s.Z) * scale;
|
||||
var p = WorldToRadar(center, scale, s.X, s.Z);
|
||||
float blipR = 1.6f + s.RadarSignature * 3.1f;
|
||||
|
||||
Color col = s.Tier switch
|
||||
|
|
@ -599,7 +629,7 @@ public partial class Hud : CanvasLayer
|
|||
if (tid >= 0 && tid < _state.Contenders.Count && _state.Contenders[tid].Alive)
|
||||
{
|
||||
var tgt = _state.Contenders[tid];
|
||||
var tp = center + new Vector2(tgt.X, tgt.Z) * scale;
|
||||
var tp = WorldToRadar(center, scale, tgt.X, tgt.Z);
|
||||
DrawLine(p, tp, new Color(RedCol.R, RedCol.G, RedCol.B, 0.65f), 1.3f);
|
||||
}
|
||||
col = RedCol;
|
||||
|
|
@ -613,10 +643,10 @@ public partial class Hud : CanvasLayer
|
|||
{
|
||||
var c = _state.Contenders[i];
|
||||
if (!c.Alive) continue;
|
||||
var p = center + new Vector2(c.X, c.Z) * scale;
|
||||
var p = WorldToRadar(center, scale, c.X, c.Z);
|
||||
if (c.IsPlayer)
|
||||
{
|
||||
var dir = new Vector2(MathF.Sin(c.Yaw), MathF.Cos(c.Yaw));
|
||||
var dir = new Vector2(-MathF.Sin(c.Yaw), -MathF.Cos(c.Yaw));
|
||||
var perp = new Vector2(-dir.Y, dir.X);
|
||||
var pts = new[]
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue