From e621a0cbe419bf2bf275fb2161e70cc953444753 Mon Sep 17 00:00:00 2001 From: Ethan Moffat Date: Wed, 3 May 2023 10:39:21 -0700 Subject: [PATCH] Fix render position of context menus for resizable display --- EndlessClient/Rendering/ContextMenuRenderer.cs | 9 ++++++--- .../Rendering/Factories/ContextMenuRendererFactory.cs | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/EndlessClient/Rendering/ContextMenuRenderer.cs b/EndlessClient/Rendering/ContextMenuRenderer.cs index 3698bb6b..d8f301f9 100644 --- a/EndlessClient/Rendering/ContextMenuRenderer.cs +++ b/EndlessClient/Rendering/ContextMenuRenderer.cs @@ -58,6 +58,7 @@ private enum MenuAction private readonly ICharacterRenderer _characterRenderer; private readonly ICurrentMapStateProvider _currentMapStateProvider; private readonly IEOMessageBoxFactory _messageBoxFactory; + private readonly IClientWindowSizeProvider _clientWindowSizeProvider; private static DateTime? _lastTradeRequestedTime; private static DateTime? _lastPartyRequestTime; @@ -74,7 +75,8 @@ private enum MenuAction IPartyDataProvider partyDataProvider, ICharacterRenderer characterRenderer, ICurrentMapStateProvider currentMapStateProvider, - IEOMessageBoxFactory messageBoxFactory) + IEOMessageBoxFactory messageBoxFactory, + IClientWindowSizeProvider clientWindowSizeProvider) { _menuActions = new Dictionary(); _inGameDialogActions = inGameDialogActions; @@ -89,6 +91,7 @@ private enum MenuAction _characterRenderer = characterRenderer; _currentMapStateProvider = currentMapStateProvider; _messageBoxFactory = messageBoxFactory; + _clientWindowSizeProvider = clientWindowSizeProvider; //first, load up the images. split in half: the right half is the 'over' text _backgroundTexture = nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 41, true); @@ -139,14 +142,14 @@ private void SetPositionBasedOnCharacterRenderer(ICharacterRenderer renderer) DrawPosition = new Vector2(rendRect.Right + 20, rendRect.Y); - if (DrawArea.Right > Game.GraphicsDevice.PresentationParameters.BackBufferWidth - 15) + if (DrawArea.Right > _clientWindowSizeProvider.Width - 15) { // case: goes off the right side of the screen, show on the left DrawPosition = new Vector2(rendRect.X - DrawArea.Width - 20, DrawPosition.Y); } // 308px is the bottom of the display area for map stuff - if (DrawArea.Bottom > 308) + if (DrawArea.Bottom > (_clientWindowSizeProvider.Resizable ? _clientWindowSizeProvider.Height : 308)) { //case: goes off bottom of the screen, adjust new rectangle so it is above 308 DrawPosition = new Vector2(DrawPosition.X, 298 - DrawArea.Height); diff --git a/EndlessClient/Rendering/Factories/ContextMenuRendererFactory.cs b/EndlessClient/Rendering/Factories/ContextMenuRendererFactory.cs index d39fcbf7..8e46cdf6 100644 --- a/EndlessClient/Rendering/Factories/ContextMenuRendererFactory.cs +++ b/EndlessClient/Rendering/Factories/ContextMenuRendererFactory.cs @@ -29,6 +29,7 @@ public class ContextMenuRendererFactory : IContextMenuRendererFactory private readonly IPartyDataProvider _partyDataProvider; private readonly ICurrentMapStateProvider _currentMapStateProvider; private readonly IEOMessageBoxFactory _messageBoxFactory; + private readonly IClientWindowSizeProvider _clientWindowSizeProvider; public ContextMenuRendererFactory(INativeGraphicsManager nativeGraphicsManager, IInGameDialogActions inGameDialogActions, @@ -41,7 +42,8 @@ public class ContextMenuRendererFactory : IContextMenuRendererFactory IContextMenuRepository contextMenuRepository, IPartyDataProvider partyDataProvider, ICurrentMapStateProvider currentMapStateProvider, - IEOMessageBoxFactory messageBoxFactory) + IEOMessageBoxFactory messageBoxFactory, + IClientWindowSizeProvider clientWindowSizeProvider) { _nativeGraphicsManager = nativeGraphicsManager; _inGameDialogActions = inGameDialogActions; @@ -55,6 +57,7 @@ public class ContextMenuRendererFactory : IContextMenuRendererFactory _partyDataProvider = partyDataProvider; _currentMapStateProvider = currentMapStateProvider; _messageBoxFactory = messageBoxFactory; + _clientWindowSizeProvider = clientWindowSizeProvider; } public IContextMenuRenderer CreateContextMenuRenderer(ICharacterRenderer characterRenderer) @@ -71,7 +74,8 @@ public IContextMenuRenderer CreateContextMenuRenderer(ICharacterRenderer charact _partyDataProvider, characterRenderer, _currentMapStateProvider, - _messageBoxFactory); + _messageBoxFactory, + _clientWindowSizeProvider); } }