From 750ba3e809186dcb40c2047cc139dfa5542101bd Mon Sep 17 00:00:00 2001 From: Ethan Moffat Date: Fri, 8 Apr 2022 09:16:37 -0700 Subject: [PATCH] Add Session EXP dialog --- .../Character/CharacterSessionRepository.cs | 52 ++++++++ EOLib/Domain/Character/CharacterStat.cs | 2 +- EOLib/Domain/Login/LoginActions.cs | 6 +- EOLib/PacketHandlers/NPCLeaveMapHandler.cs | 12 +- EOLib/PacketHandlers/PlayerLevelUpHandler.cs | 6 +- .../Dialogs/Actions/InGameDialogActions.cs | 17 +++ .../Dialogs/ActiveDialogRepository.cs | 8 ++ .../Factories/SessionExpDialogFactory.cs | 49 +++++++ EndlessClient/Dialogs/Old/SessionExpDialog.cs | 118 ----------------- EndlessClient/Dialogs/SessionExpDialog.cs | 124 ++++++++++++++++++ .../HUD/Controls/HudControlIdentifier.cs | 2 +- .../HUD/Controls/HudControlsFactory.cs | 6 +- EndlessClient/HUD/HudButtonController.cs | 4 +- EndlessClient/HUD/IHudButtonController.cs | 2 +- 14 files changed, 277 insertions(+), 131 deletions(-) create mode 100644 EOLib/Domain/Character/CharacterSessionRepository.cs create mode 100644 EndlessClient/Dialogs/Factories/SessionExpDialogFactory.cs delete mode 100644 EndlessClient/Dialogs/Old/SessionExpDialog.cs create mode 100644 EndlessClient/Dialogs/SessionExpDialog.cs diff --git a/EOLib/Domain/Character/CharacterSessionRepository.cs b/EOLib/Domain/Character/CharacterSessionRepository.cs new file mode 100644 index 000000000..fee709c83 --- /dev/null +++ b/EOLib/Domain/Character/CharacterSessionRepository.cs @@ -0,0 +1,52 @@ +using AutomaticTypeMapper; +using System; + +namespace EOLib.Domain.Character +{ + public interface ICharacterSessionRepository : IResettable + { + DateTime SessionStartTime { get; set; } + + int BestKillExp { get; set; } + + int LastKillExp { get; set; } + + int TodayTotalExp { get; set; } + } + + public interface ICharacterSessionProvider : IResettable + { + DateTime SessionStartTime { get; } + + int BestKillExp { get; } + + int LastKillExp { get; } + + int TodayTotalExp { get; } + } + + [AutoMappedType(IsSingleton = true)] + public class CharacterSessionRepository : ICharacterSessionRepository, ICharacterSessionProvider + { + public DateTime SessionStartTime { get; set; } + + public int BestKillExp { get; set; } + + public int LastKillExp { get; set; } + + public int TodayTotalExp { get; set; } + + public CharacterSessionRepository() + { + ResetState(); + } + + public void ResetState() + { + SessionStartTime = DateTime.Now; + BestKillExp = 0; + LastKillExp = 0; + TodayTotalExp = 0; + } + } +} diff --git a/EOLib/Domain/Character/CharacterStat.cs b/EOLib/Domain/Character/CharacterStat.cs index 55fbb42db..a67dbe094 100644 --- a/EOLib/Domain/Character/CharacterStat.cs +++ b/EOLib/Domain/Character/CharacterStat.cs @@ -30,6 +30,6 @@ public enum CharacterStat Charisma, Weight, - MaxWeight + MaxWeight, } } diff --git a/EOLib/Domain/Login/LoginActions.cs b/EOLib/Domain/Login/LoginActions.cs index b670bb7d9..469f110b8 100644 --- a/EOLib/Domain/Login/LoginActions.cs +++ b/EOLib/Domain/Login/LoginActions.cs @@ -28,6 +28,7 @@ public class LoginActions : ILoginActions private readonly INewsRepository _newsRepository; private readonly ICharacterInventoryRepository _characterInventoryRepository; private readonly IPaperdollRepository _paperdollRepository; + private readonly ICharacterSessionRepository _characterSessionRepository; public LoginActions(IPacketSendService packetSendService, IPacketTranslator loginPacketTranslator, @@ -40,7 +41,8 @@ public class LoginActions : ILoginActions ILoginFileChecksumRepository loginFileChecksumRepository, INewsRepository newsRepository, ICharacterInventoryRepository characterInventoryRepository, - IPaperdollRepository paperdollRepository) + IPaperdollRepository paperdollRepository, + ICharacterSessionRepository characterSessionRepository) { _packetSendService = packetSendService; _loginPacketTranslator = loginPacketTranslator; @@ -54,6 +56,7 @@ public class LoginActions : ILoginActions _newsRepository = newsRepository; _characterInventoryRepository = characterInventoryRepository; _paperdollRepository = paperdollRepository; + _characterSessionRepository = characterSessionRepository; } public bool LoginParametersAreValid(ILoginParameters parameters) @@ -185,6 +188,7 @@ public async Task CompleteCharacterLogin(short sessionID) _currentMapStateRepository.MapItems = new HashSet(data.MapItems); _playerInfoRepository.PlayerIsInGame = true; + _characterSessionRepository.ResetState(); return CharacterLoginReply.RequestCompleted; } diff --git a/EOLib/PacketHandlers/NPCLeaveMapHandler.cs b/EOLib/PacketHandlers/NPCLeaveMapHandler.cs index d4aa52bd7..5b83aafbf 100644 --- a/EOLib/PacketHandlers/NPCLeaveMapHandler.cs +++ b/EOLib/PacketHandlers/NPCLeaveMapHandler.cs @@ -16,6 +16,7 @@ public class NPCLeaveMapHandler : InGameOnlyPacketHandler { protected readonly ICurrentMapStateRepository _currentMapStateRepository; protected readonly ICharacterRepository _characterRepository; + private readonly ICharacterSessionRepository _characterSessionRepository; private readonly IEnumerable _npcAnimationNotifiers; private readonly IEnumerable _mainCharacterEventNotifiers; @@ -26,12 +27,14 @@ public class NPCLeaveMapHandler : InGameOnlyPacketHandler public NPCLeaveMapHandler(IPlayerInfoProvider playerInfoProvider, ICurrentMapStateRepository currentMapStateRepository, ICharacterRepository characterRepository, + ICharacterSessionRepository characterSessionRepository, IEnumerable npcAnimationNotifiers, IEnumerable mainCharacterEventNotifiers) : base(playerInfoProvider) { _currentMapStateRepository = currentMapStateRepository; _characterRepository = characterRepository; + _characterSessionRepository = characterSessionRepository; _npcAnimationNotifiers = npcAnimationNotifiers; _mainCharacterEventNotifiers = mainCharacterEventNotifiers; } @@ -79,7 +82,11 @@ public override bool HandlePacket(IPacket packet) notifier.NotifyGainedExp(expDifference); UpdateCharacterStat(CharacterStat.Experience, playerExp); - //todo: update last kill, best kill, and today exp + + _characterSessionRepository.LastKillExp = expDifference; + if (expDifference > _characterSessionRepository.BestKillExp) + _characterSessionRepository.BestKillExp = expDifference; + _characterSessionRepository.TodayTotalExp += expDifference; } if (droppedItemID > 0) @@ -153,9 +160,10 @@ public class NPCDieFromSpellCastHandler : NPCLeaveMapHandler public NPCDieFromSpellCastHandler(IPlayerInfoProvider playerInfoProvider, ICurrentMapStateRepository currentMapStateRepository, ICharacterRepository characterRepository, + ICharacterSessionRepository characterSessionRepository, IEnumerable npcAnimationNotifiers, IEnumerable mainCharacterEventNotifiers) - : base(playerInfoProvider, currentMapStateRepository, characterRepository, + : base(playerInfoProvider, currentMapStateRepository, characterRepository, characterSessionRepository, npcAnimationNotifiers, mainCharacterEventNotifiers) { } } } diff --git a/EOLib/PacketHandlers/PlayerLevelUpHandler.cs b/EOLib/PacketHandlers/PlayerLevelUpHandler.cs index 9e1345fbe..3a55a335a 100644 --- a/EOLib/PacketHandlers/PlayerLevelUpHandler.cs +++ b/EOLib/PacketHandlers/PlayerLevelUpHandler.cs @@ -20,10 +20,11 @@ public class PlayerLevelUpHandler : NPCLeaveMapHandler public PlayerLevelUpHandler(IPlayerInfoProvider playerInfoProvider, ICurrentMapStateRepository currentMapStateRepository, ICharacterRepository characterRepository, + ICharacterSessionRepository characterSessionRepository, IEnumerable npcAnimationNotifiers, IEnumerable mainCharacterEventNotifiers, IEnumerable emoteNotifiers) - : base(playerInfoProvider, currentMapStateRepository, characterRepository, + : base(playerInfoProvider, currentMapStateRepository, characterRepository, characterSessionRepository, npcAnimationNotifiers, mainCharacterEventNotifiers) { _emoteNotifiers = emoteNotifiers; @@ -67,10 +68,11 @@ public class PlayerLevelUpFromSpellCastHandler : PlayerLevelUpHandler public PlayerLevelUpFromSpellCastHandler(IPlayerInfoProvider playerInfoProvider, ICurrentMapStateRepository currentMapStateRepository, ICharacterRepository characterRepository, + ICharacterSessionRepository characterSessionRepository, IEnumerable npcAnimationNotifiers, IEnumerable mainCharacterEventNotifiers, IEnumerable emoteNotifiers) - : base(playerInfoProvider, currentMapStateRepository, characterRepository, + : base(playerInfoProvider, currentMapStateRepository, characterRepository, characterSessionRepository, npcAnimationNotifiers, mainCharacterEventNotifiers, emoteNotifiers) { } } } diff --git a/EndlessClient/Dialogs/Actions/InGameDialogActions.cs b/EndlessClient/Dialogs/Actions/InGameDialogActions.cs index 3ec157764..9faa41c78 100644 --- a/EndlessClient/Dialogs/Actions/InGameDialogActions.cs +++ b/EndlessClient/Dialogs/Actions/InGameDialogActions.cs @@ -15,6 +15,7 @@ public class InGameDialogActions : IInGameDialogActions, INPCInteractionNotifier { private readonly IFriendIgnoreListDialogFactory _friendIgnoreListDialogFactory; private readonly IPaperdollDialogFactory _paperdollDialogFactory; + private readonly ISessionExpDialogFactory _sessionExpDialogFactory; private readonly IQuestStatusDialogFactory _questStatusDialogFactory; private readonly IActiveDialogRepository _activeDialogRepository; private readonly IShopDataRepository _shopDataRepository; @@ -24,6 +25,7 @@ public class InGameDialogActions : IInGameDialogActions, INPCInteractionNotifier public InGameDialogActions(IFriendIgnoreListDialogFactory friendIgnoreListDialogFactory, IPaperdollDialogFactory paperdollDialogFactory, + ISessionExpDialogFactory sessionExpDialogFactory, IQuestStatusDialogFactory questStatusDialogFactory, IShopDialogFactory shopDialogFactory, IQuestDialogFactory questDialogFactory, @@ -33,6 +35,7 @@ public class InGameDialogActions : IInGameDialogActions, INPCInteractionNotifier { _friendIgnoreListDialogFactory = friendIgnoreListDialogFactory; _paperdollDialogFactory = paperdollDialogFactory; + _sessionExpDialogFactory = sessionExpDialogFactory; _questStatusDialogFactory = questStatusDialogFactory; _activeDialogRepository = activeDialogRepository; _shopDataRepository = shopDataRepository; @@ -65,6 +68,18 @@ public void ShowIgnoreListDialog() }); } + public void ShowSessionExpDialog() + { + _activeDialogRepository.SessionExpDialog.MatchNone(() => + { + var dlg = _sessionExpDialogFactory.Create(); + dlg.DialogClosed += (_, _) => _activeDialogRepository.SessionExpDialog = Option.None(); + _activeDialogRepository.SessionExpDialog = Option.Some(dlg); + + dlg.Show(); + }); + } + public void ShowQuestStatusDialog() { _activeDialogRepository.QuestStatusDialog.MatchNone(() => @@ -141,6 +156,8 @@ public interface IInGameDialogActions void ShowIgnoreListDialog(); + void ShowSessionExpDialog(); + void ShowQuestStatusDialog(); void ShowPaperdollDialog(ICharacter character, bool isMainCharacter); diff --git a/EndlessClient/Dialogs/ActiveDialogRepository.cs b/EndlessClient/Dialogs/ActiveDialogRepository.cs index 5a7096e10..bd7bf1060 100644 --- a/EndlessClient/Dialogs/ActiveDialogRepository.cs +++ b/EndlessClient/Dialogs/ActiveDialogRepository.cs @@ -11,6 +11,8 @@ public interface IActiveDialogProvider : IDisposable { Option FriendIgnoreDialog { get; } + Option SessionExpDialog { get; } + Option QuestStatusDialog { get; } Option PaperdollDialog { get; } @@ -26,6 +28,8 @@ public interface IActiveDialogRepository : IDisposable { Option FriendIgnoreDialog { get; set; } + Option SessionExpDialog { get; set; } + Option QuestStatusDialog { get; set; } Option PaperdollDialog { get; set; } @@ -42,6 +46,8 @@ public class ActiveDialogRepository : IActiveDialogRepository, IActiveDialogProv { public Option FriendIgnoreDialog { get; set; } + public Option SessionExpDialog { get; set; } + public Option QuestStatusDialog { get; set; } public Option PaperdollDialog { get; set; } @@ -57,6 +63,7 @@ IReadOnlyList> ActiveDialogs return new[] { FriendIgnoreDialog.Map(d => (IXNADialog)d), + SessionExpDialog.Map(d => (IXNADialog)d), QuestStatusDialog.Map(d => (IXNADialog)d), PaperdollDialog.Map(d => (IXNADialog)d), ShopDialog.Map(d => (IXNADialog)d), @@ -75,6 +82,7 @@ public void Dispose() dlg.MatchSome(d => d.Dispose()); FriendIgnoreDialog = Option.None(); + SessionExpDialog = Option.None(); QuestStatusDialog = Option.None(); PaperdollDialog = Option.None(); ShopDialog = Option.None(); diff --git a/EndlessClient/Dialogs/Factories/SessionExpDialogFactory.cs b/EndlessClient/Dialogs/Factories/SessionExpDialogFactory.cs new file mode 100644 index 000000000..6eb6e954c --- /dev/null +++ b/EndlessClient/Dialogs/Factories/SessionExpDialogFactory.cs @@ -0,0 +1,49 @@ +using AutomaticTypeMapper; +using EndlessClient.Dialogs.Services; +using EOLib.Domain.Character; +using EOLib.Graphics; +using EOLib.Localization; + +namespace EndlessClient.Dialogs.Factories +{ + [AutoMappedType] + public class SessionExpDialogFactory : ISessionExpDialogFactory + { + private readonly INativeGraphicsManager _nativeGraphicsManager; + private readonly IEODialogButtonService _dialogButtonService; + private readonly ILocalizedStringFinder _localizedStringFinder; + private readonly ICharacterProvider _characterProvider; + private readonly IExperienceTableProvider _expTableProvider; + private readonly ICharacterSessionProvider _characterSessionProvider; + + public SessionExpDialogFactory(INativeGraphicsManager nativeGraphicsManager, + IEODialogButtonService dialogButtonService, + ILocalizedStringFinder localizedStringFinder, + ICharacterProvider characterProvider, + IExperienceTableProvider expTableProvider, + ICharacterSessionProvider characterSessionProvider) + { + _nativeGraphicsManager = nativeGraphicsManager; + _dialogButtonService = dialogButtonService; + _localizedStringFinder = localizedStringFinder; + _characterProvider = characterProvider; + _expTableProvider = expTableProvider; + _characterSessionProvider = characterSessionProvider; + } + + public SessionExpDialog Create() + { + return new SessionExpDialog(_nativeGraphicsManager, + _dialogButtonService, + _localizedStringFinder, + _characterProvider, + _expTableProvider, + _characterSessionProvider); + } + } + + public interface ISessionExpDialogFactory + { + SessionExpDialog Create(); + } +} diff --git a/EndlessClient/Dialogs/Old/SessionExpDialog.cs b/EndlessClient/Dialogs/Old/SessionExpDialog.cs deleted file mode 100644 index d36f37ab9..000000000 --- a/EndlessClient/Dialogs/Old/SessionExpDialog.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System; -using EndlessClient.Dialogs.Services; -using EndlessClient.Old; -using EOLib; -using EOLib.Graphics; -using EOLib.Localization; -using EOLib.Net.API; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using XNAControls.Old; - -namespace EndlessClient.Dialogs.Old -{ - public class SessionExpDialog : EODialogBase - { - private static SessionExpDialog inst; - public new static void Show() - { - if (inst != null) return; - - inst = new SessionExpDialog(); - inst.DialogClosing += (o, e) => inst = null; - } - - private readonly Texture2D m_icons; - private readonly Rectangle m_signal; - private readonly Rectangle m_icon; - - private SessionExpDialog() - : base((PacketAPI)null) - { - bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 61); - _setSize(bgTexture.Width, bgTexture.Height); - - m_icons = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 68, true); - m_signal = new Rectangle(0, 15, 15, 15); - m_icon = new Rectangle(0, 0, 15, 15); - - XNAButton okButton = new XNAButton(smallButtonSheet, new Vector2(98, 214), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok)); - okButton.OnClick += (sender, args) => Close(okButton, XNADialogResult.OK); - okButton.SetParent(this); - - XNALabel title = new XNALabel(new Rectangle(20, 17, 1, 1), Constants.FontSize08pt5) - { - AutoSize = false, - Text = OldWorld.GetString(EOResourceID.DIALOG_TITLE_PERFORMANCE), - ForeColor = ColorConstants.LightGrayText - }; - title.SetParent(this); - - XNALabel[] leftSide = new XNALabel[8], rightSide = new XNALabel[8]; - for (int i = 48; i <= 160; i += 16) - { - leftSide[(i - 48) / 16] = new XNALabel(new Rectangle(38, i, 1, 1), Constants.FontSize08pt5) - { - AutoSize = false, - ForeColor = ColorConstants.LightGrayText - }; - leftSide[(i - 48) / 16].SetParent(this); - rightSide[(i - 48) / 16] = new XNALabel(new Rectangle(158, i, 1, 1), Constants.FontSize08pt5) - { - AutoSize = false, - ForeColor = ColorConstants.LightGrayText - }; - rightSide[(i - 48) / 16].SetParent(this); - } - - leftSide[0].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_TOTALEXP); - leftSide[1].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_NEXT_LEVEL); - leftSide[2].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_EXP_NEEDED); - leftSide[3].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_TODAY_EXP); - leftSide[4].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_TOTAL_AVG); - leftSide[5].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_TODAY_AVG); - leftSide[6].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_BEST_KILL); - leftSide[7].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_LAST_KILL); - OldCharacter c = OldWorld.Instance.MainPlayer.ActiveCharacter; - rightSide[0].Text = $"{c.Stats.Experience}"; - rightSide[1].Text = $"{OldWorld.Instance.exp_table[c.Stats.Level + 1]}"; - rightSide[2].Text = $"{OldWorld.Instance.exp_table[c.Stats.Level + 1] - c.Stats.Experience}"; - rightSide[3].Text = $"{c.TodayExp}"; - rightSide[4].Text = $"{(int) (c.Stats.Experience/(c.Stats.Usage/60.0))}"; - int sessionTime = (int)(DateTime.Now - EOGame.Instance.Hud.SessionStartTime).TotalMinutes; - rightSide[5].Text = $"{(sessionTime > 0 ? (c.TodayExp/sessionTime) : 0)}"; - rightSide[6].Text = $"{c.TodayBestKill}"; - rightSide[7].Text = $"{c.TodayLastKill}"; - - Array.ForEach(leftSide, lbl => lbl.ResizeBasedOnText()); - Array.ForEach(rightSide, lbl => lbl.ResizeBasedOnText()); - - Center(Game.GraphicsDevice); - DrawLocation = new Vector2(DrawLocation.X, 15); - endConstructor(false); - } - - public override void Draw(GameTime gt) - { - //base draw logic handles drawing the background + child controls - base.Draw(gt); - - SpriteBatch.Begin(); - //icons next to labels - SpriteBatch.Draw(m_icons, new Vector2(DrawAreaWithOffset.X + 22, DrawAreaWithOffset.Y + 48), m_icon, Color.White); - SpriteBatch.Draw(m_icons, new Vector2(DrawAreaWithOffset.X + 22, DrawAreaWithOffset.Y + 64), m_icon, Color.White); - SpriteBatch.Draw(m_icons, new Vector2(DrawAreaWithOffset.X + 22, DrawAreaWithOffset.Y + 80), m_icon, Color.White); - SpriteBatch.Draw(m_icons, new Vector2(DrawAreaWithOffset.X + 22, DrawAreaWithOffset.Y + 96), m_icon, Color.White); - SpriteBatch.Draw(m_icons, new Vector2(DrawAreaWithOffset.X + 22, DrawAreaWithOffset.Y + 112), m_icon, Color.White); - SpriteBatch.Draw(m_icons, new Vector2(DrawAreaWithOffset.X + 22, DrawAreaWithOffset.Y + 128), m_icon, Color.White); - SpriteBatch.Draw(m_icons, new Vector2(DrawAreaWithOffset.X + 22, DrawAreaWithOffset.Y + 144), m_icon, Color.White); - SpriteBatch.Draw(m_icons, new Vector2(DrawAreaWithOffset.X + 22, DrawAreaWithOffset.Y + 160), m_icon, Color.White); - - //signal next to exp labels - SpriteBatch.Draw(m_icons, new Vector2(DrawAreaWithOffset.X + 142, DrawAreaWithOffset.Y + 48), m_signal, Color.White); - SpriteBatch.Draw(m_icons, new Vector2(DrawAreaWithOffset.X + 142, DrawAreaWithOffset.Y + 64), m_signal, Color.White); - SpriteBatch.Draw(m_icons, new Vector2(DrawAreaWithOffset.X + 142, DrawAreaWithOffset.Y + 80), m_signal, Color.White); - SpriteBatch.End(); - } - } -} diff --git a/EndlessClient/Dialogs/SessionExpDialog.cs b/EndlessClient/Dialogs/SessionExpDialog.cs new file mode 100644 index 000000000..917e06635 --- /dev/null +++ b/EndlessClient/Dialogs/SessionExpDialog.cs @@ -0,0 +1,124 @@ +using System; +using EndlessClient.Dialogs.Services; +using EOLib; +using EOLib.Domain.Character; +using EOLib.Graphics; +using EOLib.Localization; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using XNAControls; + +namespace EndlessClient.Dialogs +{ + public class SessionExpDialog : BaseEODialog + { + private static readonly Rectangle _signalSource; + private static readonly Rectangle _iconSource; + + private readonly Texture2D _icons; + + static SessionExpDialog() + { + _signalSource = new Rectangle(0, 15, 15, 15); + _iconSource = new Rectangle(0, 0, 15, 15); + } + + public SessionExpDialog(INativeGraphicsManager nativeGraphicsManager, + IEODialogButtonService dialogButtonService, + ILocalizedStringFinder localizedStringFinder, + ICharacterProvider characterProvider, + IExperienceTableProvider expTableProvider, + ICharacterSessionProvider characterSessionProvider) + : base(isInGame: true) + { + BackgroundTexture = nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 61); + + _icons = nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 68, true); + + var okButton = new XNAButton(dialogButtonService.SmallButtonSheet, + new Vector2(98, 214), + dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok), + dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Ok)); + okButton.OnClick += (_, _) => Close(XNADialogResult.OK); + okButton.SetParentControl(this); + okButton.Initialize(); + + var title = new XNALabel(Constants.FontSize09) + { + DrawPosition = new Vector2(20, 17), + AutoSize = false, + Text = localizedStringFinder.GetString(EOResourceID.DIALOG_TITLE_PERFORMANCE), + ForeColor = ColorConstants.LightGrayText + }; + title.SetParentControl(this); + title.Initialize(); + + XNALabel[] leftSide = new XNALabel[8], rightSide = new XNALabel[8]; + for (int i = 0; i < leftSide.Length; i++) + { + leftSide[i] = new XNALabel(Constants.FontSize09) + { + DrawPosition = new Vector2(38, 48 + 18 * i), + AutoSize = false, + ForeColor = ColorConstants.LightGrayText + }; + leftSide[i].SetParentControl(this); + leftSide[i].Initialize(); + + rightSide[i] = new XNALabel(Constants.FontSize09) + { + DrawPosition = new Vector2(158, 48 + 18 * i), + AutoSize = false, + ForeColor = ColorConstants.LightGrayText + }; + rightSide[i].SetParentControl(this); + rightSide[i].Initialize(); + } + + leftSide[0].Text = localizedStringFinder.GetString(EOResourceID.DIALOG_PERFORMANCE_TOTALEXP); + leftSide[1].Text = localizedStringFinder.GetString(EOResourceID.DIALOG_PERFORMANCE_NEXT_LEVEL); + leftSide[2].Text = localizedStringFinder.GetString(EOResourceID.DIALOG_PERFORMANCE_EXP_NEEDED); + leftSide[3].Text = localizedStringFinder.GetString(EOResourceID.DIALOG_PERFORMANCE_TODAY_EXP); + leftSide[4].Text = localizedStringFinder.GetString(EOResourceID.DIALOG_PERFORMANCE_TOTAL_AVG); + leftSide[5].Text = localizedStringFinder.GetString(EOResourceID.DIALOG_PERFORMANCE_TODAY_AVG); + leftSide[6].Text = localizedStringFinder.GetString(EOResourceID.DIALOG_PERFORMANCE_BEST_KILL); + leftSide[7].Text = localizedStringFinder.GetString(EOResourceID.DIALOG_PERFORMANCE_LAST_KILL); + + var c = characterProvider.MainCharacter; + var level = c.Stats[CharacterStat.Level]; + var exp = c.Stats[CharacterStat.Experience]; + var usage = c.Stats[CharacterStat.Usage]; + + rightSide[0].Text = $"{exp}"; + rightSide[1].Text = $"{expTableProvider.ExperienceByLevel[level + 1]}"; + rightSide[2].Text = $"{expTableProvider.ExperienceByLevel[level + 1] - exp}"; + rightSide[3].Text = $"{characterSessionProvider.TodayTotalExp}"; + rightSide[4].Text = $"{(int)(exp / (usage/60.0))}"; + int sessionTimeMinutes = (int)(DateTime.Now - characterSessionProvider.SessionStartTime).TotalMinutes; + rightSide[5].Text = $"{(sessionTimeMinutes > 0 ? (int)(characterSessionProvider.TodayTotalExp / (sessionTimeMinutes/60.0)) : 0)}"; + rightSide[6].Text = $"{characterSessionProvider.BestKillExp}"; + rightSide[7].Text = $"{characterSessionProvider.LastKillExp}"; + + Array.ForEach(leftSide, lbl => lbl.ResizeBasedOnText()); + Array.ForEach(rightSide, lbl => lbl.ResizeBasedOnText()); + + CenterInGameView(); + DrawPosition = new Vector2(DrawPosition.X, 15); + } + + protected override void OnDrawControl(GameTime gameTime) + { + base.OnDrawControl(gameTime); + + _spriteBatch.Begin(); + + for (int i = 0; i < 8; i++) + _spriteBatch.Draw(_icons, new Vector2(DrawPositionWithParentOffset.X + 18, DrawPositionWithParentOffset.Y + 47 + 18 * i), _iconSource, Color.White); + + for(int i = 0; i < 3; i++) + _spriteBatch.Draw(_icons, new Vector2(DrawPositionWithParentOffset.X + 142, DrawPositionWithParentOffset.Y + 48 + 18 * i), _signalSource, Color.White); + + _spriteBatch.End(); + } + } +} diff --git a/EndlessClient/HUD/Controls/HudControlIdentifier.cs b/EndlessClient/HUD/Controls/HudControlIdentifier.cs index fa0bd0a2a..941639eee 100644 --- a/EndlessClient/HUD/Controls/HudControlIdentifier.cs +++ b/EndlessClient/HUD/Controls/HudControlIdentifier.cs @@ -45,7 +45,7 @@ public enum HudControlIdentifier NewsPanel, //top bar - UsageAndStatsButton, + SessionExpButton, QuestsButton, HPStatusBar, diff --git a/EndlessClient/HUD/Controls/HudControlsFactory.cs b/EndlessClient/HUD/Controls/HudControlsFactory.cs index 79a284a17..b42e1817c 100644 --- a/EndlessClient/HUD/Controls/HudControlsFactory.cs +++ b/EndlessClient/HUD/Controls/HudControlsFactory.cs @@ -154,7 +154,7 @@ public void InjectChatController(IChatController chatController) {HudControlIdentifier.SettingsPanel, CreateStatePanel(InGameStates.Settings)}, {HudControlIdentifier.HelpPanel, CreateStatePanel(InGameStates.Help)}, - {HudControlIdentifier.UsageAndStatsButton, CreateUsageAndStatsButton()}, + {HudControlIdentifier.SessionExpButton, CreateSessionExpButton()}, {HudControlIdentifier.QuestsButton, CreateQuestButton()}, {HudControlIdentifier.HPStatusBar, CreateHPStatusBar()}, @@ -305,7 +305,7 @@ private IGameComponent CreateStatePanel(InGameStates whichState) return retPanel; } - private IGameComponent CreateUsageAndStatsButton() + private IGameComponent CreateSessionExpButton() { var btn = new XNAButton( _nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 58), @@ -315,7 +315,7 @@ private IGameComponent CreateUsageAndStatsButton() { DrawOrder = HUD_CONTROL_LAYER }; - btn.OnClick += (_, _) => _hudButtonController.ClickUsageAndStats(); + btn.OnClick += (_, _) => _hudButtonController.ClickSessionExp(); return btn; } diff --git a/EndlessClient/HUD/HudButtonController.cs b/EndlessClient/HUD/HudButtonController.cs index 19f7632de..73cb03522 100644 --- a/EndlessClient/HUD/HudButtonController.cs +++ b/EndlessClient/HUD/HudButtonController.cs @@ -121,9 +121,9 @@ public async Task ClickIgnoreList() _localizedStringFinder.GetString(EOResourceID.STATUS_LABEL_USE_RIGHT_MOUSE_CLICK_DELETE)); } - public void ClickUsageAndStats() + public void ClickSessionExp() { - // todo + _inGameDialogActions.ShowSessionExpDialog(); } public void ClickQuestStatus() diff --git a/EndlessClient/HUD/IHudButtonController.cs b/EndlessClient/HUD/IHudButtonController.cs index 1e0806ccf..ecc327ee1 100644 --- a/EndlessClient/HUD/IHudButtonController.cs +++ b/EndlessClient/HUD/IHudButtonController.cs @@ -28,7 +28,7 @@ public interface IHudButtonController Task ClickIgnoreList(); - void ClickUsageAndStats(); + void ClickSessionExp(); void ClickQuestStatus(); }