Fix all 6 60 FPS Soul Pass findings and add permanent regression tests
This commit is contained in:
parent
0f36eed3a0
commit
f5d23ce49e
12 changed files with 1031 additions and 305 deletions
|
|
@ -59,6 +59,7 @@ public partial class InventoryGridControl : Control
|
|||
private float[,] _hitPulse = new float[0, 0];
|
||||
|
||||
private int _lastSelectedCargoIndex = int.MinValue;
|
||||
private string? _lastSelectedCargoId;
|
||||
private int _lastMountedSig = int.MinValue;
|
||||
private Vector2I? _hoveredCell;
|
||||
private bool _thermalEnabled;
|
||||
|
|
@ -115,6 +116,9 @@ public partial class InventoryGridControl : Control
|
|||
}
|
||||
|
||||
public float ThermalBlend => _thermalBlend;
|
||||
internal int LabelsDrawCount => _labelsOverlay.DrawCount;
|
||||
internal string? GetLastDrawnLabel(string hardpointId) =>
|
||||
_labelsOverlay.LastDrawnTags.TryGetValue(hardpointId, out string? tag) ? tag : null;
|
||||
|
||||
public void SetThermalInstant(bool enabled)
|
||||
{
|
||||
|
|
@ -216,11 +220,15 @@ public partial class InventoryGridControl : Control
|
|||
_grid = grid;
|
||||
_spec = grid.Spec;
|
||||
_selectedCargoIndex = selectedCargoIndex;
|
||||
string? selectedCargoId = selectedCargoIndex >= 0 && selectedCargoIndex < grid.Cargo.Count
|
||||
? grid.Cargo[selectedCargoIndex].Id
|
||||
: null;
|
||||
|
||||
if (gridIdentityChanged)
|
||||
{
|
||||
EnsureBackingBuffers(grid);
|
||||
_lastSelectedCargoIndex = selectedCargoIndex;
|
||||
_lastSelectedCargoId = selectedCargoId;
|
||||
_lastMountedSig = ComputeMountedSignature(grid);
|
||||
SnapshotTemperatures(grid);
|
||||
PackDataTexture(grid);
|
||||
|
|
@ -233,9 +241,12 @@ public partial class InventoryGridControl : Control
|
|||
|
||||
bool dataChanged = DetectHits(grid);
|
||||
int mountedSig = ComputeMountedSignature(grid);
|
||||
if (_lastSelectedCargoIndex != selectedCargoIndex || _lastMountedSig != mountedSig)
|
||||
if (_lastSelectedCargoIndex != selectedCargoIndex ||
|
||||
!string.Equals(_lastSelectedCargoId, selectedCargoId, StringComparison.Ordinal) ||
|
||||
_lastMountedSig != mountedSig)
|
||||
{
|
||||
_lastSelectedCargoIndex = selectedCargoIndex;
|
||||
_lastSelectedCargoId = selectedCargoId;
|
||||
_lastMountedSig = mountedSig;
|
||||
dataChanged = true;
|
||||
}
|
||||
|
|
@ -245,7 +256,6 @@ public partial class InventoryGridControl : Control
|
|||
if (dataChanged)
|
||||
{
|
||||
PackDataTexture(grid);
|
||||
_labelsOverlay.QueueRedraw();
|
||||
}
|
||||
if (tempChanged)
|
||||
{
|
||||
|
|
@ -254,6 +264,7 @@ public partial class InventoryGridControl : Control
|
|||
}
|
||||
if (dataChanged || tempChanged)
|
||||
{
|
||||
_labelsOverlay.QueueRedraw();
|
||||
FlushTextures();
|
||||
}
|
||||
}
|
||||
|
|
@ -730,11 +741,15 @@ public partial class InventoryGridControl : Control
|
|||
private sealed partial class LabelsOverlay : Control
|
||||
{
|
||||
private readonly InventoryGridControl _owner;
|
||||
public int DrawCount { get; private set; }
|
||||
public readonly Dictionary<string, string> LastDrawnTags = new(StringComparer.Ordinal);
|
||||
|
||||
public LabelsOverlay(InventoryGridControl owner) => _owner = owner;
|
||||
|
||||
public override void _Draw()
|
||||
{
|
||||
DrawCount++;
|
||||
LastDrawnTags.Clear();
|
||||
var grid = _owner._grid;
|
||||
if (grid is null) return;
|
||||
|
||||
|
|
@ -755,6 +770,7 @@ public partial class InventoryGridControl : Control
|
|||
string tag = mounted is not null
|
||||
? $"{mounted.Spec.Kind.ToString()[..1]}:{mounted.CurrentTemp:F0}°"
|
||||
: hp.Kind.ToString()[..3].ToUpperInvariant();
|
||||
LastDrawnTags[hp.Id] = tag;
|
||||
|
||||
Color col = mounted is { Spec.IsImperial: true } ? ColGold : ColTextLight;
|
||||
col.A = alpha;
|
||||
|
|
|
|||
Loading…
Reference in a new issue