Skip to content

Commit

Permalink
Fix render position of context menus for resizable display
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmoffat committed May 3, 2023
1 parent 1f091bc commit e621a0c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 6 additions & 3 deletions EndlessClient/Rendering/ContextMenuRenderer.cs
Expand Up @@ -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;
Expand All @@ -74,7 +75,8 @@ private enum MenuAction
IPartyDataProvider partyDataProvider,
ICharacterRenderer characterRenderer,
ICurrentMapStateProvider currentMapStateProvider,
IEOMessageBoxFactory messageBoxFactory)
IEOMessageBoxFactory messageBoxFactory,
IClientWindowSizeProvider clientWindowSizeProvider)
{
_menuActions = new Dictionary<Rectangle, Action>();
_inGameDialogActions = inGameDialogActions;
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Expand Up @@ -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,
Expand All @@ -41,7 +42,8 @@ public class ContextMenuRendererFactory : IContextMenuRendererFactory
IContextMenuRepository contextMenuRepository,
IPartyDataProvider partyDataProvider,
ICurrentMapStateProvider currentMapStateProvider,
IEOMessageBoxFactory messageBoxFactory)
IEOMessageBoxFactory messageBoxFactory,
IClientWindowSizeProvider clientWindowSizeProvider)
{
_nativeGraphicsManager = nativeGraphicsManager;
_inGameDialogActions = inGameDialogActions;
Expand All @@ -55,6 +57,7 @@ public class ContextMenuRendererFactory : IContextMenuRendererFactory
_partyDataProvider = partyDataProvider;
_currentMapStateProvider = currentMapStateProvider;
_messageBoxFactory = messageBoxFactory;
_clientWindowSizeProvider = clientWindowSizeProvider;
}

public IContextMenuRenderer CreateContextMenuRenderer(ICharacterRenderer characterRenderer)
Expand All @@ -71,7 +74,8 @@ public IContextMenuRenderer CreateContextMenuRenderer(ICharacterRenderer charact
_partyDataProvider,
characterRenderer,
_currentMapStateProvider,
_messageBoxFactory);
_messageBoxFactory,
_clientWindowSizeProvider);
}
}

Expand Down

0 comments on commit e621a0c

Please sign in to comment.