Skip to content

Commit

Permalink
Unset selected spell when clicking on a non-target. Make map sign dia…
Browse files Browse the repository at this point in the history
…logs modal.
  • Loading branch information
ethanmoffat committed Sep 17, 2022
1 parent bf737a2 commit d0db16d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
5 changes: 4 additions & 1 deletion EndlessClient/Controllers/MapInteractionController.cs
Expand Up @@ -159,7 +159,8 @@ public void LeftClick(IMapCellState cellState, Option<IMouseCursorRenderer> mous
}
else if (cellState.InBounds && !cellState.Character.HasValue && !cellState.NPC.HasValue
&& _walkValidationActions.IsCellStateWalkable(cellState)
&& _characterProvider.MainCharacter.RenderProperties.IsActing(CharacterActionState.Standing))
&& _characterProvider.MainCharacter.RenderProperties.IsActing(CharacterActionState.Standing)
&& !_spellSlotDataRepository.SelectedSpellSlot.HasValue)
{
mouseRenderer.MatchSome(r => r.AnimateClick());
_hudControlProvider.GetComponent<ICharacterAnimator>(HudControlIdentifier.CharacterAnimator)
Expand All @@ -182,6 +183,8 @@ public void LeftClick(IMapCellState cellState, Option<IMouseCursorRenderer> mous
});
});

_spellSlotDataRepository.SelectedSpellSlot = Option.None<int>();

_userInputTimeRepository.LastInputTime = DateTime.Now;
}

Expand Down
8 changes: 8 additions & 0 deletions EndlessClient/Dialogs/ActiveDialogRepository.cs
Expand Up @@ -35,6 +35,8 @@ public interface IActiveDialogProvider : IDisposable

Option<TradeDialog> TradeDialog { get; }

Option<EOMessageBox> MessageBox { get; }

IReadOnlyList<Option<IXNADialog>> ActiveDialogs { get; }
}

Expand Down Expand Up @@ -66,6 +68,8 @@ public interface IActiveDialogRepository : IDisposable

Option<TradeDialog> TradeDialog { get; set; }

Option<EOMessageBox> MessageBox { get; set; }

IReadOnlyList<Option<IXNADialog>> ActiveDialogs { get; }
}

Expand Down Expand Up @@ -98,6 +102,8 @@ public class ActiveDialogRepository : IActiveDialogRepository, IActiveDialogProv

public Option<TradeDialog> TradeDialog { get; set; }

public Option<EOMessageBox> MessageBox { get; set; }

IReadOnlyList<Option<IXNADialog>> ActiveDialogs
{
get
Expand All @@ -117,6 +123,7 @@ IReadOnlyList<Option<IXNADialog>> ActiveDialogs
BardDialog.Map(d => (IXNADialog)d),
MessageDialog.Map(d => (IXNADialog)d),
TradeDialog.Map(d => (IXNADialog)d),
MessageBox.Map(d => (IXNADialog)d),
}.ToList();
}
}
Expand All @@ -143,6 +150,7 @@ public void Dispose()
BardDialog = Option.None<BardDialog>();
MessageDialog = Option.None<ScrollingListDialog>();
TradeDialog = Option.None<TradeDialog>();
MessageBox = Option.None<EOMessageBox>();
}
}
}
8 changes: 8 additions & 0 deletions EndlessClient/Dialogs/Factories/EOMessageBoxFactory.cs
Expand Up @@ -4,6 +4,7 @@
using EndlessClient.GameExecution;
using EOLib.Graphics;
using EOLib.Localization;
using Optional;
using XNAControls;

namespace EndlessClient.Dialogs.Factories
Expand All @@ -15,18 +16,21 @@ public class EOMessageBoxFactory : IEOMessageBoxFactory
private readonly IGameStateProvider _gameStateProvider;
private readonly IEODialogButtonService _eoDialogButtonService;
private readonly ILocalizedStringFinder _localizedStringFinder;
private readonly IActiveDialogRepository _activeDialogRepository;
private readonly ISfxPlayer _sfxPlayer;

public EOMessageBoxFactory(INativeGraphicsManager nativeGraphicsManager,
IGameStateProvider gameStateProvider,
IEODialogButtonService eoDialogButtonService,
ILocalizedStringFinder localizedStringFinder,
IActiveDialogRepository activeDialogRepository,
ISfxPlayer sfxPlayer)
{
_nativeGraphicsManager = nativeGraphicsManager;
_gameStateProvider = gameStateProvider;
_eoDialogButtonService = eoDialogButtonService;
_localizedStringFinder = localizedStringFinder;
_activeDialogRepository = activeDialogRepository;
_sfxPlayer = sfxPlayer;
}

Expand All @@ -35,6 +39,7 @@ public class EOMessageBoxFactory : IEOMessageBoxFactory
EODialogButtons whichButtons = EODialogButtons.Ok,
EOMessageBoxStyle style = EOMessageBoxStyle.SmallDialogSmallHeader)
{

var messageBox = new EOMessageBox(_nativeGraphicsManager,
_gameStateProvider,
_eoDialogButtonService,
Expand All @@ -43,6 +48,9 @@ public class EOMessageBoxFactory : IEOMessageBoxFactory
style,
whichButtons);
messageBox.DialogClosing += (_, _) => _sfxPlayer.PlaySfx(SoundEffectID.DialogButtonClick);
messageBox.DialogClosed += (_, _) => _activeDialogRepository.MessageBox = Option.None<EOMessageBox>();

_activeDialogRepository.MessageBox = Option.Some(messageBox);

return messageBox;
}
Expand Down
7 changes: 7 additions & 0 deletions EndlessClient/Rendering/Map/DynamicMapObjectUpdater.cs
@@ -1,6 +1,7 @@
using AutomaticTypeMapper;
using EndlessClient.Audio;
using EndlessClient.Controllers;
using EndlessClient.HUD.Spells;
using EndlessClient.Input;
using EndlessClient.Rendering.Character;
using EOLib.Config;
Expand Down Expand Up @@ -36,6 +37,7 @@ private class DoorTimePair
private readonly IMapObjectBoundsCalculator _mapObjectBoundsCalculator;
private readonly IMapInteractionController _mapInteractionController;
private readonly IConfigurationProvider _configurationProvider;
private readonly ISpellSlotDataRepository _spellSlotDataRepository;
private readonly ISfxPlayer _sfxPlayer;

private readonly List<DoorTimePair> _cachedDoorState;
Expand All @@ -50,6 +52,7 @@ private class DoorTimePair
IMapObjectBoundsCalculator mapObjectBoundsCalculator,
IMapInteractionController mapInteractionController,
IConfigurationProvider configurationProvider,
ISpellSlotDataRepository spellSlotDataRepository,
ISfxPlayer sfxPlayer)
{
_characterProvider = characterProvider;
Expand All @@ -60,6 +63,7 @@ private class DoorTimePair
_mapObjectBoundsCalculator = mapObjectBoundsCalculator;
_mapInteractionController = mapInteractionController;
_configurationProvider = configurationProvider;
_spellSlotDataRepository = spellSlotDataRepository;
_sfxPlayer = sfxPlayer;

_cachedDoorState = new List<DoorTimePair>();
Expand Down Expand Up @@ -180,6 +184,9 @@ private void CheckForObjectClicks()
}

// todo: check for board object clicks

if (_userInputRepository.ClickHandled)
_spellSlotDataRepository.SelectedSpellSlot = Option.None<int>();
}
}

Expand Down

0 comments on commit d0db16d

Please sign in to comment.