Various item status fixes/tweaks (#27267)
* Always display item status panel fully Initial feedback from the UI changes seems to be that a lot of people go "why is there empty space" so let's fix that. * Fix item status middle hand being on the wrong side I think I switched this around when fixing the left/right being inverted in the UI code. * Minor status panel UI tweaks Bottom-align contents now that the panel itself doesn't dynamically expand, prevent weird gaps. Clip contents for panel * Fix clipping on implanters and network configurators. Made them take less space. For implanters the name has to be cut off, which I did by adding a new ClipControl to achieve that in rich text. * Update visibility of item status panels based on whether you have hands at all. This avoids UI for borgs looking silly. Added a new "HandUILocation" enum that doesn't have middle hands to avoid confusion in UI code. * Use BulletRender for laser guns too. Provides all the benefits like fixing layout overflow and allowing multi-line stuff. Looks great now. This involved generalizing BulletRender a bit so it can be used for not-just-bullets. * Fix geiger word wrapping if you're really fucked
This commit is contained in:
committed by
GitHub
parent
38f490e5eb
commit
7b90c08a2c
@@ -116,7 +116,7 @@ public sealed partial class GunSystem
|
||||
|
||||
public sealed class BoxesStatusControl : Control
|
||||
{
|
||||
private readonly BoxContainer _bulletsList;
|
||||
private readonly BatteryBulletRenderer _bullets;
|
||||
private readonly Label _ammoCount;
|
||||
|
||||
public BoxesStatusControl()
|
||||
@@ -128,27 +128,18 @@ public sealed partial class GunSystem
|
||||
AddChild(new BoxContainer
|
||||
{
|
||||
Orientation = BoxContainer.LayoutOrientation.Horizontal,
|
||||
HorizontalExpand = true,
|
||||
Children =
|
||||
{
|
||||
new Control
|
||||
(_bullets = new BatteryBulletRenderer
|
||||
{
|
||||
HorizontalExpand = true,
|
||||
Children =
|
||||
{
|
||||
(_bulletsList = new BoxContainer
|
||||
{
|
||||
Orientation = BoxContainer.LayoutOrientation.Horizontal,
|
||||
VerticalAlignment = VAlignment.Center,
|
||||
SeparationOverride = 4
|
||||
}),
|
||||
}
|
||||
},
|
||||
new Control() { MinSize = new Vector2(5, 0) },
|
||||
Margin = new Thickness(0, 0, 5, 0),
|
||||
HorizontalExpand = true
|
||||
}),
|
||||
(_ammoCount = new Label
|
||||
{
|
||||
StyleClasses = { StyleNano.StyleClassItemStatus },
|
||||
HorizontalAlignment = HAlignment.Right,
|
||||
VerticalAlignment = VAlignment.Bottom
|
||||
}),
|
||||
}
|
||||
});
|
||||
@@ -156,46 +147,12 @@ public sealed partial class GunSystem
|
||||
|
||||
public void Update(int count, int max)
|
||||
{
|
||||
_bulletsList.RemoveAllChildren();
|
||||
|
||||
_ammoCount.Visible = true;
|
||||
|
||||
_ammoCount.Text = $"x{count:00}";
|
||||
max = Math.Min(max, 8);
|
||||
FillBulletRow(_bulletsList, count, max);
|
||||
}
|
||||
|
||||
private static void FillBulletRow(Control container, int count, int capacity)
|
||||
{
|
||||
var colorGone = Color.FromHex("#000000");
|
||||
var color = Color.FromHex("#E00000");
|
||||
|
||||
// Draw the empty ones
|
||||
for (var i = count; i < capacity; i++)
|
||||
{
|
||||
container.AddChild(new PanelContainer
|
||||
{
|
||||
PanelOverride = new StyleBoxFlat()
|
||||
{
|
||||
BackgroundColor = colorGone,
|
||||
},
|
||||
MinSize = new Vector2(10, 15),
|
||||
});
|
||||
}
|
||||
|
||||
// Draw the full ones, but limit the count to the capacity
|
||||
count = Math.Min(count, capacity);
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
container.AddChild(new PanelContainer
|
||||
{
|
||||
PanelOverride = new StyleBoxFlat()
|
||||
{
|
||||
BackgroundColor = color,
|
||||
},
|
||||
MinSize = new Vector2(10, 15),
|
||||
});
|
||||
}
|
||||
_bullets.Capacity = max;
|
||||
_bullets.Count = count;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user