Skip to content

Commit

Permalink
Fix draw order of inventory item labels in resizable mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmoffat committed Apr 30, 2023
1 parent 687baa9 commit 90de46a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion EndlessClient/HUD/HudStateActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void SwitchToState(InGameStates newState)
var targetPanel = _hudControlProvider.HudPanels.Single(x => IsPanelForRequestedState(x, newState));
targetPanel.Visible = !targetPanel.Visible;

if (targetPanel.Visible)
if (targetPanel.Visible && _clientWindowSizeProvider.Resizable)
targetPanel.DrawOrder = _hudControlProvider.HudPanels.Select(x => x.DrawOrder).Max() + 1;
}

Expand Down
16 changes: 15 additions & 1 deletion EndlessClient/HUD/Panels/InventoryPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class InventoryPanel : DraggableHudPanel, IHudPanel, IDraggableItemContai
private readonly IActiveDialogProvider _activeDialogProvider;
private readonly ISfxPlayer _sfxPlayer;
private readonly IConfigurationProvider _configProvider;

private readonly IClientWindowSizeProvider _clientWindowSizeProvider;
private readonly List<InventoryPanelItem> _childItems = new List<InventoryPanelItem>();

private readonly IXNALabel _weightLabel;
Expand Down Expand Up @@ -98,6 +98,7 @@ public InventoryPanel(INativeGraphicsManager nativeGraphicsManager,
_activeDialogProvider = activeDialogProvider;
_sfxPlayer = sfxPlayer;
_configProvider = configProvider;
_clientWindowSizeProvider = clientWindowSizeProvider;

_weightLabel = new XNALabel(Constants.FontSize08pt5)
{
Expand Down Expand Up @@ -161,6 +162,19 @@ public override void Initialize()
base.Initialize();
}

protected override void OnDrawOrderChanged(object sender, EventArgs args)
{
base.OnDrawOrderChanged(sender, args);

if (_clientWindowSizeProvider.Resizable)
{
// ensure labels have a high enough draw order when in resizable mode
// this is because draw order is updated when panels are opened in resizable mode
foreach (var label in ChildControls.OfType<XNALabel>())
label.DrawOrder = DrawOrder + 70;
}
}

protected override void OnUpdateControl(GameTime gameTime)
{
_cachedStats.Match(
Expand Down

0 comments on commit 90de46a

Please sign in to comment.