Hlavní menu, synchronizace jmen hráčů. Client hru spustí až ve chvíli kdy dostane správný packet. Oprava bugu v se scalováním UIElementu

This commit is contained in:
Perry 2026-03-11 22:35:30 +01:00
parent e6128dc9f5
commit 7656707177
19 changed files with 315 additions and 53 deletions

View file

@ -14,10 +14,11 @@ public class UIElement {
public bool Pressable { get; set; } = false;
public bool Visible { get; set; } = true;
protected (Point, Point) _bounds;
public (Point, Point) Bounds{
get;
private set { field = value; UpdateBounds(); }
} // TODO: Change this to support non-rectangular hitboxes
get => _bounds;
protected set { _bounds = value; UpdateBounds(); }
}
protected (Point, Point) screenSpaceBounds;
public List<TextureRegion> Textures = new();
@ -33,13 +34,14 @@ public class UIElement {
LoadPixelScaleMultiplier();
}
}
private int pixelScaleMultiplier = 1;
protected int pixelScaleMultiplier = 1;
private void LoadPixelScaleMultiplier() {
pixelScaleMultiplier = (int)(UIManager.GlobalPixelMultiplier * _scaleMultiplier); // TODO: move GlobalPixelMultiplier somewhere where it would make sense
UpdateBounds();
}
private void UpdateBounds() {
protected virtual void UpdateBounds() {
_bounds = (Bounds.Item1, (Bounds.Item2 - Bounds.Item1).MultiplyByScalar(ScaleMultiplier) + Bounds.Item1);
screenSpaceBounds = (Bounds.Item1.MultiplyByScalar(pixelScaleMultiplier), Bounds.Item2.MultiplyByScalar(pixelScaleMultiplier));
}