Skip to content

Commit

Permalink
Ensure Paperdoll is not click/dragged when an inventory item is dragg…
Browse files Browse the repository at this point in the history
…ed over it
  • Loading branch information
ethanmoffat committed Apr 1, 2022
1 parent 769fa69 commit 14188b3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
5 changes: 5 additions & 0 deletions EndlessClient/Dialogs/Factories/PaperdollDialogFactory.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using AutomaticTypeMapper;
using EndlessClient.Controllers;
using EndlessClient.ControlSets;
using EndlessClient.Dialogs.Services;
using EndlessClient.GameExecution;
using EndlessClient.HUD;
Expand All @@ -20,20 +21,23 @@ public class PaperdollDialogFactory : IPaperdollDialogFactory
private readonly IStatusLabelSetter _statusLabelSetter;
private readonly IPaperdollProvider _paperdollProvider;
private readonly IPubFileProvider _pubFileProvider;
private readonly IHudControlProvider _hudControlProvider;
private readonly INativeGraphicsManager _nativeGraphicsManager;
private IInventoryController _inventoryController;

public PaperdollDialogFactory(IGameStateProvider gameStateProvider,
INativeGraphicsManager nativeGraphicsManager,
IPaperdollProvider paperdollProvider,
IPubFileProvider pubFileProvider,
IHudControlProvider hudControlProvider,
IEODialogButtonService eoDialogButtonService,
IInventorySpaceValidator inventorySpaceValidator,
IEOMessageBoxFactory eoMessageBoxFactory,
IStatusLabelSetter statusLabelSetter)
{
_paperdollProvider = paperdollProvider;
_pubFileProvider = pubFileProvider;
_hudControlProvider = hudControlProvider;
_nativeGraphicsManager = nativeGraphicsManager;
_gameStateProvider = gameStateProvider;
_eoDialogButtonService = eoDialogButtonService;
Expand All @@ -49,6 +53,7 @@ public PaperdollDialog Create(ICharacter character, bool isMainCharacter)
_inventoryController,
_paperdollProvider,
_pubFileProvider,
_hudControlProvider,
_eoDialogButtonService,
_inventorySpaceValidator,
_eoMessageBoxFactory,
Expand Down
23 changes: 8 additions & 15 deletions EndlessClient/Dialogs/PaperdollDialog.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using EndlessClient.Controllers;
using EndlessClient.ControlSets;
using EndlessClient.Dialogs.Factories;
using EndlessClient.Dialogs.Services;
using EndlessClient.GameExecution;
using EndlessClient.HUD;
using EndlessClient.HUD.Inventory;
using EndlessClient.HUD.Panels;
using EOLib;
using EOLib.Domain.Character;
using EOLib.Domain.Online;
Expand All @@ -30,6 +32,7 @@ public class PaperdollDialog : BaseEODialog
private readonly IInventoryController _inventoryController;
private readonly IPaperdollProvider _paperdollProvider;
private readonly IPubFileProvider _pubFileProvider;
private readonly IHudControlProvider _hudControlProvider;
private readonly IInventorySpaceValidator _inventorySpaceValidator;
private readonly IEOMessageBoxFactory _eoMessageBoxFactory;
private readonly IStatusLabelSetter _statusLabelSetter;
Expand All @@ -55,6 +58,7 @@ public PaperdollDialog(IGameStateProvider gameStateProvider,
IInventoryController inventoryController,
IPaperdollProvider paperdollProvider,
IPubFileProvider pubFileProvider,
IHudControlProvider hudControlProvider,
IEODialogButtonService eoDialogButtonService,
IInventorySpaceValidator inventorySpaceValidator,
IEOMessageBoxFactory eoMessageBoxFactory,
Expand All @@ -64,6 +68,7 @@ public PaperdollDialog(IGameStateProvider gameStateProvider,
{
_paperdollProvider = paperdollProvider;
_pubFileProvider = pubFileProvider;
_hudControlProvider = hudControlProvider;
_inventorySpaceValidator = inventorySpaceValidator;
_eoMessageBoxFactory = eoMessageBoxFactory;
_statusLabelSetter = statusLabelSetter;
Expand Down Expand Up @@ -125,8 +130,6 @@ public PaperdollDialog(IGameStateProvider gameStateProvider,

protected override void OnUpdateControl(GameTime gameTime)
{
base.OnUpdateControl(gameTime);

_paperdollData = _paperdollData.FlatMap(paperdollData =>
paperdollData.NoneWhen(d => _paperdollProvider.VisibleCharacterPaperdolls.ContainsKey(Character.ID) &&
!_paperdollProvider.VisibleCharacterPaperdolls[Character.ID].Equals(d)));
Expand All @@ -141,19 +144,9 @@ protected override void OnUpdateControl(GameTime gameTime)
}
});

// todo: dragging to equip/unequip from inventory
/*
if (EOGame.Instance.Hud.IsInventoryDragging())
{
shouldClickDrag = false;
SuppressParentClickDrag(true);
}
else
{
shouldClickDrag = true;
SuppressParentClickDrag(false);
}
*/
SuppressClickDragEvent(!_hudControlProvider.GetComponent<InventoryPanel>(HUD.Controls.HudControlIdentifier.InventoryPanel).NoItemsDragging());

base.OnUpdateControl(gameTime);
}

protected override void OnDrawControl(GameTime gameTime)
Expand Down
2 changes: 1 addition & 1 deletion EndlessClient/EndlessClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@
<PackageReference Include="Monogame.Content.Builder.Task" Version="3.8.0.1641" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />
<PackageReference Include="XNAControls" Version="1.3.3" />
<PackageReference Include="XNAControls" Version="1.3.4" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion EndlessClient/HUD/Panels/InventoryPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public InventoryPanel(INativeGraphicsManager nativeGraphicsManager,
Game.Exiting += SaveInventoryFile;
}

public bool NoItemsDragging() => _childItems.All(x => !x.IsDragging);
public bool NoItemsDragging() => !_childItems.Any(x => x.IsDragging);

public override void Initialize()
{
Expand Down

0 comments on commit 14188b3

Please sign in to comment.