From e29ec80f2f963a4200da986ef2036de6a847a3cc Mon Sep 17 00:00:00 2001 From: Ethan Moffat Date: Tue, 19 Apr 2022 23:01:31 -0700 Subject: [PATCH] First pass re-implementation of skillmaster dialog (initial state) --- .../Controllers/NPCInteractionController.cs | 4 + .../Dialogs/Actions/InGameDialogActions.cs | 25 +- .../Dialogs/ActiveDialogRepository.cs | 8 + .../Factories/SkillmasterDialogFactory.cs | 54 +++ .../Dialogs/Old/OldScrollingListDialog.cs | 283 ------------ .../Dialogs/Old/SkillmasterDialog.cs | 398 ----------------- EndlessClient/Dialogs/Old/TextInputDialog.cs | 69 --- EndlessClient/Dialogs/SkillmasterDialog.cs | 405 ++++++++++++++++++ EndlessClient/Rendering/OldNPCRenderer.cs | 32 -- 9 files changed, 495 insertions(+), 783 deletions(-) create mode 100644 EndlessClient/Dialogs/Factories/SkillmasterDialogFactory.cs delete mode 100644 EndlessClient/Dialogs/Old/OldScrollingListDialog.cs delete mode 100644 EndlessClient/Dialogs/Old/SkillmasterDialog.cs delete mode 100644 EndlessClient/Dialogs/Old/TextInputDialog.cs create mode 100644 EndlessClient/Dialogs/SkillmasterDialog.cs diff --git a/EndlessClient/Controllers/NPCInteractionController.cs b/EndlessClient/Controllers/NPCInteractionController.cs index 5d5a4e27d..0324d6ed0 100644 --- a/EndlessClient/Controllers/NPCInteractionController.cs +++ b/EndlessClient/Controllers/NPCInteractionController.cs @@ -64,6 +64,10 @@ public void ShowNPCDialog(INPC npc) _inGameDialogActions.ShowBankAccountDialog(); _userInputRepository.ClickHandled = true; break; + case EOLib.IO.NPCType.Skills: + _mapNpcActions.RequestSkillmaster(npc); + _userInputRepository.ClickHandled = true; + break; } } } diff --git a/EndlessClient/Dialogs/Actions/InGameDialogActions.cs b/EndlessClient/Dialogs/Actions/InGameDialogActions.cs index 63d1e33f4..c54d2077d 100644 --- a/EndlessClient/Dialogs/Actions/InGameDialogActions.cs +++ b/EndlessClient/Dialogs/Actions/InGameDialogActions.cs @@ -4,6 +4,7 @@ using EOLib.Domain.Interact; using EOLib.Domain.Interact.Quest; using EOLib.Domain.Interact.Shop; +using EOLib.Domain.Interact.Skill; using EOLib.IO; using Optional; @@ -19,9 +20,11 @@ public class InGameDialogActions : IInGameDialogActions, INPCInteractionNotifier private readonly IActiveDialogRepository _activeDialogRepository; private readonly IShopDataRepository _shopDataRepository; private readonly IQuestDataRepository _questDataRepository; + private readonly ISkillDataRepository _skillDataRepository; private readonly IChestDialogFactory _chestDialogFactory; private readonly ILockerDialogFactory _lockerDialogFactory; private readonly IBankAccountDialogFactory _bankAccountDialogFactory; + private readonly ISkillmasterDialogFactory _skillmasterDialogFactory; private readonly IShopDialogFactory _shopDialogFactory; private readonly IQuestDialogFactory _questDialogFactory; @@ -34,9 +37,11 @@ public InGameDialogActions(IFriendIgnoreListDialogFactory friendIgnoreListDialog IActiveDialogRepository activeDialogRepository, IShopDataRepository shopDataRepository, IQuestDataRepository questDataRepository, + ISkillDataRepository skillDataRepository, IChestDialogFactory chestDialogFactory, ILockerDialogFactory lockerDialogFactory, - IBankAccountDialogFactory bankAccountDialogFactory) + IBankAccountDialogFactory bankAccountDialogFactory, + ISkillmasterDialogFactory skillmasterDialogFactory) { _friendIgnoreListDialogFactory = friendIgnoreListDialogFactory; _paperdollDialogFactory = paperdollDialogFactory; @@ -45,9 +50,11 @@ public InGameDialogActions(IFriendIgnoreListDialogFactory friendIgnoreListDialog _activeDialogRepository = activeDialogRepository; _shopDataRepository = shopDataRepository; _questDataRepository = questDataRepository; + _skillDataRepository = skillDataRepository; _chestDialogFactory = chestDialogFactory; _lockerDialogFactory = lockerDialogFactory; _bankAccountDialogFactory = bankAccountDialogFactory; + _skillmasterDialogFactory = skillmasterDialogFactory; _shopDialogFactory = shopDialogFactory; _questDialogFactory = questDialogFactory; } @@ -122,6 +129,7 @@ public void NotifyInteractionFromNPC(NPCType npcType) { case NPCType.Shop: ShowShopDialog(); break; case NPCType.Quest: ShowQuestDialog(); break; + case NPCType.Skills: ShowSkillmasterDialog(); break; } } @@ -192,6 +200,19 @@ public void ShowBankAccountDialog() dlg.Show(); }); } + + public void ShowSkillmasterDialog() + { + var dlg = _skillmasterDialogFactory.Create(); + dlg.DialogClosed += (_, _) => + { + _activeDialogRepository.SkillmasterDialog = Option.None(); + _skillDataRepository.ResetState(); + }; + _activeDialogRepository.SkillmasterDialog = Option.Some(dlg); + + dlg.Show(); + } } public interface IInGameDialogActions @@ -215,5 +236,7 @@ public interface IInGameDialogActions void ShowLockerDialog(); void ShowBankAccountDialog(); + + void ShowSkillmasterDialog(); } } diff --git a/EndlessClient/Dialogs/ActiveDialogRepository.cs b/EndlessClient/Dialogs/ActiveDialogRepository.cs index 11a7e7436..4cebfbb1b 100644 --- a/EndlessClient/Dialogs/ActiveDialogRepository.cs +++ b/EndlessClient/Dialogs/ActiveDialogRepository.cs @@ -27,6 +27,8 @@ public interface IActiveDialogProvider : IDisposable Option BankAccountDialog { get; } + Option SkillmasterDialog { get; } + IReadOnlyList> ActiveDialogs { get; } } @@ -50,6 +52,8 @@ public interface IActiveDialogRepository : IDisposable Option BankAccountDialog { get; set; } + Option SkillmasterDialog { get; set; } + IReadOnlyList> ActiveDialogs { get; } } @@ -74,6 +78,8 @@ public class ActiveDialogRepository : IActiveDialogRepository, IActiveDialogProv public Option BankAccountDialog { get; set; } + public Option SkillmasterDialog { get; set; } + IReadOnlyList> ActiveDialogs { get @@ -89,6 +95,7 @@ IReadOnlyList> ActiveDialogs ChestDialog.Map(d => (IXNADialog)d), LockerDialog.Map(d => (IXNADialog)d), BankAccountDialog.Map(d => (IXNADialog)d), + SkillmasterDialog.Map(d => (IXNADialog)d), }.ToList(); } } @@ -111,6 +118,7 @@ public void Dispose() ChestDialog = Option.None(); LockerDialog = Option.None(); BankAccountDialog = Option.None(); + SkillmasterDialog = Option.None(); } } } diff --git a/EndlessClient/Dialogs/Factories/SkillmasterDialogFactory.cs b/EndlessClient/Dialogs/Factories/SkillmasterDialogFactory.cs new file mode 100644 index 000000000..3b82b6468 --- /dev/null +++ b/EndlessClient/Dialogs/Factories/SkillmasterDialogFactory.cs @@ -0,0 +1,54 @@ +using AutomaticTypeMapper; +using EndlessClient.Dialogs.Services; +using EOLib.Domain.Character; +using EOLib.Domain.Interact.Skill; +using EOLib.Graphics; +using EOLib.Localization; + +namespace EndlessClient.Dialogs.Factories +{ + [AutoMappedType] + public class SkillmasterDialogFactory : ISkillmasterDialogFactory + { + private readonly INativeGraphicsManager _nativeGraphicsManager; + private readonly IEODialogButtonService _dialogButtonService; + private readonly IEODialogIconService _dialogIconService; + private readonly ILocalizedStringFinder _localizedStringFinder; + private readonly IEOMessageBoxFactory _messageBoxFactory; + private readonly ISkillDataProvider _skillDataProvider; + private readonly ICharacterInventoryProvider _characterInventoryProvider; + + public SkillmasterDialogFactory(INativeGraphicsManager nativeGraphicsManager, + IEODialogButtonService dialogButtonService, + IEODialogIconService dialogIconService, + ILocalizedStringFinder localizedStringFinder, + IEOMessageBoxFactory messageBoxFactory, + ISkillDataProvider skillDataProvider, + ICharacterInventoryProvider characterInventoryProvider) + { + _nativeGraphicsManager = nativeGraphicsManager; + _dialogButtonService = dialogButtonService; + _dialogIconService = dialogIconService; + _localizedStringFinder = localizedStringFinder; + _messageBoxFactory = messageBoxFactory; + _skillDataProvider = skillDataProvider; + _characterInventoryProvider = characterInventoryProvider; + } + + public SkillmasterDialog Create() + { + return new SkillmasterDialog(_nativeGraphicsManager, + _dialogButtonService, + _dialogIconService, + _localizedStringFinder, + _messageBoxFactory, + _skillDataProvider, + _characterInventoryProvider); + } + } + + public interface ISkillmasterDialogFactory + { + SkillmasterDialog Create(); + } +} diff --git a/EndlessClient/Dialogs/Old/OldScrollingListDialog.cs b/EndlessClient/Dialogs/Old/OldScrollingListDialog.cs deleted file mode 100644 index 544561c3d..000000000 --- a/EndlessClient/Dialogs/Old/OldScrollingListDialog.cs +++ /dev/null @@ -1,283 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using EndlessClient.Dialogs.Services; -using EndlessClient.Old; -using EndlessClient.UIControls; -using EOLib; -using EOLib.Graphics; -using EOLib.Net.API; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using XNAControls.Old; - -namespace EndlessClient.Dialogs.Old -{ - public enum ScrollingListDialogButtons - { - AddCancel, - Cancel, - BackCancel, - } - - public class OldScrollingListDialog : EODialogBase - { - //needs: - title label - // - scroll bar - // - lower buttons (configurable) - // - list of items (names, like friend list; items, like shop) - //OldListDialogItem needs way to set width and offsets - - private readonly List m_listItems = new List(); - private readonly object m_listItemLock = new object(); - protected OldScrollBar m_scrollBar; - - /// - /// List of strings containing the primary text field of each child item - /// - public List NamesList - { - get - { - lock (m_listItemLock) - return m_listItems.Select(item => item.Text).ToList(); - } - } - - protected XNALabel m_titleText; - private OldListDialogItem.ListItemStyle _listItemType; - private ScrollingListDialogButtons _buttons; - - public string Title - { - get { return m_titleText.Text; } - set { m_titleText.Text = value; } - } - - /// - /// The number of items to display in the scrolling view at one time when ListItemType is Large - /// - public int LargeItemStyleMaxItemDisplay { get; set; } - - /// - /// The number of items to display in the scrolling view at one time when ListItemType is Small - /// - public int SmallItemStyleMaxItemDisplay { get; set; } - - public OldListDialogItem.ListItemStyle ListItemType - { - get { return _listItemType; } - set - { - _listItemType = value; - m_scrollBar.LinesToRender = ListItemType == OldListDialogItem.ListItemStyle.Small - ? SmallItemStyleMaxItemDisplay - : LargeItemStyleMaxItemDisplay; - } - } - - public ScrollingListDialogButtons Buttons - { - get { return _buttons; } - set - { - _buttons = value; - _setButtons(_buttons); - } - } - - public OldScrollingListDialog(PacketAPI api = null) - : base(api) - { - _setBackgroundTexture(((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 52)); - - //defaults - LargeItemStyleMaxItemDisplay = 5; - SmallItemStyleMaxItemDisplay = 12; - - m_titleText = new XNALabel(new Rectangle(16, 13, 253, 19), Constants.FontSize09) - { - AutoSize = false, - TextAlign = LabelAlignment.MiddleLeft, - ForeColor = ColorConstants.LightGrayText - }; - m_titleText.SetParent(this); - - m_scrollBar = new OldScrollBar(this, new Vector2(252, 44), new Vector2(16, 199), ScrollBarColors.LightOnMed); - - Center(Game.GraphicsDevice); - DrawLocation = new Vector2(DrawLocation.X, 15); - endConstructor(false); - } - - public void SetItemList(List itemList) - { - if (itemList.Count == 0) return; - - if (m_listItems.Count == 0) - m_scrollBar.LinesToRender = itemList[0].Style == OldListDialogItem.ListItemStyle.Large ? 5 : 12; - - m_scrollBar.UpdateDimensions(itemList.Count); - - OldListDialogItem.ListItemStyle firstStyle = itemList[0].Style; - lock (m_listItemLock) - for (int i = 0; i < itemList.Count; ++i) - { - m_listItems.Add(itemList[i]); - m_listItems[i].Style = firstStyle; - m_listItems[i].Index = i; - if (i > m_scrollBar.LinesToRender) - m_listItems[i].Visible = false; - } - } - - public void AddItemToList(OldListDialogItem item, bool sortList) - { - if (m_listItems.Count == 0) - m_scrollBar.LinesToRender = item.Style == OldListDialogItem.ListItemStyle.Large ? LargeItemStyleMaxItemDisplay : SmallItemStyleMaxItemDisplay; - lock (m_listItemLock) - { - m_listItems.Add(item); - if (sortList) - m_listItems.Sort((item1, item2) => item1.Text.CompareTo(item2.Text)); - for (int i = 0; i < m_listItems.Count; ++i) - m_listItems[i].Index = i; - } - m_scrollBar.UpdateDimensions(m_listItems.Count); - } - - public void RemoveFromList(OldListDialogItem item) - { - int ndx; - lock (m_listItemLock) - ndx = m_listItems.FindIndex(_item => _item == item); - if (ndx < 0) return; - - item.Close(); - - lock (m_listItemLock) - { - m_listItems.RemoveAt(ndx); - - m_scrollBar.UpdateDimensions(m_listItems.Count); - if (m_listItems.Count <= m_scrollBar.LinesToRender) - m_scrollBar.ScrollToTop(); - - for (int i = 0; i < m_listItems.Count; ++i) - { - //adjust indices (determines drawing position) - m_listItems[i].Index = i; - } - } - } - - public void SetActiveItemList(List activeLabels) - { - lock (m_listItemLock) - foreach (OldListDialogItem item in m_listItems) - { - if (activeLabels.Select(x => x.ToLower()).Contains(item.Text.ToLower())) - { - item.SetActive(); - } - } - } - - protected void ClearItemList() - { - lock (m_listItemLock) - { - foreach (OldListDialogItem item in m_listItems) - { - item.SetParent(null); - item.Close(); - } - m_listItems.Clear(); - } - m_scrollBar.UpdateDimensions(0); - m_scrollBar.ScrollToTop(); - } - - protected void _setBackgroundTexture(Texture2D text) - { - bgTexture = text; - _setSize(bgTexture.Width, bgTexture.Height); - } - - protected void _setButtons(ScrollingListDialogButtons setButtons) - { - if (dlgButtons.Count > 0) - { - dlgButtons.ForEach(_btn => - { - _btn.SetParent(null); - _btn.Close(); - }); - - dlgButtons.Clear(); - } - - _buttons = setButtons; - switch (setButtons) - { - case ScrollingListDialogButtons.BackCancel: - case ScrollingListDialogButtons.AddCancel: - { - SmallButton which = setButtons == ScrollingListDialogButtons.BackCancel ? SmallButton.Back : SmallButton.Add; - XNAButton add = new XNAButton(smallButtonSheet, new Vector2(48, 252), _getSmallButtonOut(which), _getSmallButtonOver(which)); - add.SetParent(this); - add.OnClick += (o, e) => Close(add, setButtons == ScrollingListDialogButtons.BackCancel ? XNADialogResult.Back : XNADialogResult.Add); - XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(144, 252), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel)); - cancel.SetParent(this); - cancel.OnClick += (o, e) => Close(cancel, XNADialogResult.Cancel); - - dlgButtons.Add(add); - dlgButtons.Add(cancel); - } - break; - case ScrollingListDialogButtons.Cancel: - { - XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(96, 252), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel)); - cancel.SetParent(this); - cancel.OnClick += (o, e) => Close(cancel, XNADialogResult.Cancel); - - dlgButtons.Add(cancel); - } - break; - } - } - - public override void Update(GameTime gt) - { - //which items should we render? - lock (m_listItemLock) - { - if (m_listItems.Count > m_scrollBar.LinesToRender) - { - for (int i = 0; i < m_listItems.Count; ++i) - { - OldListDialogItem curr = m_listItems[i]; - if (i < m_scrollBar.ScrollOffset) - { - curr.Visible = false; - continue; - } - - if (i < m_scrollBar.LinesToRender + m_scrollBar.ScrollOffset) - { - curr.Visible = true; - curr.Index = i - m_scrollBar.ScrollOffset; - } - else - { - curr.Visible = false; - } - } - } - else if (m_listItems.Any(_item => !_item.Visible)) - m_listItems.ForEach(_item => _item.Visible = true); //all items visible if less than # lines to render - } - - base.Update(gt); - } - } -} diff --git a/EndlessClient/Dialogs/Old/SkillmasterDialog.cs b/EndlessClient/Dialogs/Old/SkillmasterDialog.cs deleted file mode 100644 index 3290705fb..000000000 --- a/EndlessClient/Dialogs/Old/SkillmasterDialog.cs +++ /dev/null @@ -1,398 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using EndlessClient.Old; -using EOLib; -using EOLib.Localization; -using EOLib.Net.API; -using Microsoft.Xna.Framework.Graphics; -using XNAControls; -using XNADialogResult = XNAControls.Old.XNADialogResult; - -namespace EndlessClient.Dialogs.Old -{ - public class SkillmasterDialog : OldScrollingListDialog - { - public static SkillmasterDialog Instance { get; private set; } - - public static void Show(PacketAPI api, short npcIndex) - { - if (Instance != null) - return; - - Instance = new SkillmasterDialog(api); - - if (!api.RequestSkillmaster(npcIndex)) - { - Instance.Close(); - Instance = null; - EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu(); - } - } - - private enum SkillState - { - None, - Initial, - Learn, - Forget, - ForgetAll - } - - private SkillState m_state; - private List m_skills; - private bool m_showingRequirements; - - private static Texture2D LearnIcon, ForgetIcon; - - private SkillmasterDialog(PacketAPI api) - : base(api) - { - Buttons = ScrollingListDialogButtons.Cancel; - ListItemType = OldListDialogItem.ListItemStyle.Large; - DialogClosing += (o, e) => - { - if (e.Result == XNADialogResult.Cancel) - { - Instance = null; - } - else if (e.Result == XNADialogResult.Back) - { - e.CancelClose = true; - if (m_state == SkillState.Learn && m_showingRequirements) - { - m_state = SkillState.Initial; //force it to re-generate the list items - _setState(SkillState.Learn); - m_showingRequirements = false; - } - else - _setState(SkillState.Initial); - } - }; - m_state = SkillState.None; - - if (LearnIcon == null || ForgetIcon == null) - { - //getDlgIcon - LearnIcon = _getDlgIcon(ListIcon.Learn); - ForgetIcon = _getDlgIcon(ListIcon.Forget); - } - } - - public void SetSkillmasterData(SkillmasterData data) - { - if (Instance == null || this != Instance) return; - - Title = data.Title; - m_skills = new List(data.Skills); - - _setState(SkillState.Initial); - } - - public void RemoveSkillByIDFromLearnList(short id) - { - if (Instance == null || this != Instance) return; - - OldListDialogItem itemToRemove = children.OfType().FirstOrDefault(_x => _x.ID == id); - if(itemToRemove != null) - RemoveFromList(itemToRemove); - } - - private void _setState(SkillState newState) - { - SkillState old = m_state; - - if (old == newState) return; - - int numToLearn = m_skills.Count(_skill => !OldWorld.Instance.MainPlayer.ActiveCharacter.Spells.Exists(_spell => _spell.ID == _skill.ID)); - int numToForget = OldWorld.Instance.MainPlayer.ActiveCharacter.Spells.Count; - - if (newState == SkillState.Learn && numToLearn == 0) - { - EOMessageBox.Show(DialogResourceID.SKILL_NOTHING_MORE_TO_LEARN, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader); - return; - } - - ClearItemList(); - switch (newState) - { - case SkillState.Initial: - { - string learnNum = $"{numToLearn}{OldWorld.GetString(EOResourceID.SKILLMASTER_ITEMS_TO_LEARN)}"; - string forgetNum = $"{numToForget}{OldWorld.GetString(EOResourceID.SKILLMASTER_ITEMS_LEARNED)}"; - - OldListDialogItem learn = new OldListDialogItem(this, OldListDialogItem.ListItemStyle.Large, 0) - { - Text = OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_LEARN), - SubText = learnNum, - IconGraphic = LearnIcon, - ShowItemBackGround = false, - OffsetY = 45 - }; - learn.OnLeftClick += (o, e) => _setState(SkillState.Learn); - learn.OnRightClick += (o, e) => _setState(SkillState.Learn); - AddItemToList(learn, false); - - OldListDialogItem forget = new OldListDialogItem(this, OldListDialogItem.ListItemStyle.Large, 1) - { - Text = OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_FORGET), - SubText = forgetNum, - IconGraphic = ForgetIcon, - ShowItemBackGround = false, - OffsetY = 45 - }; - forget.OnLeftClick += (o, e) => _setState(SkillState.Forget); - forget.OnRightClick += (o, e) => _setState(SkillState.Forget); - AddItemToList(forget, false); - - OldListDialogItem forgetAll = new OldListDialogItem(this, OldListDialogItem.ListItemStyle.Large, 2) - { - Text = OldWorld.GetString(EOResourceID.SKILLMASTER_FORGET_ALL), - SubText = OldWorld.GetString(EOResourceID.SKILLMASTER_RESET_YOUR_CHARACTER), - IconGraphic = ForgetIcon, - ShowItemBackGround = false, - OffsetY = 45 - }; - forgetAll.OnLeftClick += (o, e) => _setState(SkillState.ForgetAll); - forgetAll.OnRightClick += (o, e) => _setState(SkillState.ForgetAll); - AddItemToList(forgetAll, false); - - _setButtons(ScrollingListDialogButtons.Cancel); - } - break; - case SkillState.Learn: - { - int index = 0; - for (int i = 0; i < m_skills.Count; ++i) - { - if (OldWorld.Instance.MainPlayer.ActiveCharacter.Spells.FindIndex(_sp => m_skills[i].ID == _sp.ID) >= 0) - continue; - int localI = i; - - var spellData = OldWorld.Instance.ESF[m_skills[localI].ID]; - - OldListDialogItem nextListItem = new OldListDialogItem(this, OldListDialogItem.ListItemStyle.Large, index++) - { - Visible = false, - Text = spellData.Name, - SubText = OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_REQUIREMENTS), - IconGraphic = OldWorld.GetSpellIcon(spellData.Icon, false), - ShowItemBackGround = false, - OffsetY = 45, - ID = m_skills[localI].ID - }; - nextListItem.OnLeftClick += (o, e) => _learn(m_skills[localI]); - nextListItem.OnRightClick += (o, e) => _learn(m_skills[localI]); - nextListItem.OnMouseEnter += (o, e) => _showRequirementsLabel(m_skills[localI]); - nextListItem.SetSubtextLink(() => _showRequirements(m_skills[localI])); - AddItemToList(nextListItem, false); - } - - _setButtons(ScrollingListDialogButtons.BackCancel); - } - break; - case SkillState.Forget: - { - TextInputDialog input = new TextInputDialog(OldWorld.GetString(DialogResourceID.SKILL_PROMPT_TO_FORGET, false), 32); - input.SetAsKeyboardSubscriber(); - input.DialogClosing += (sender, args) => - { - if (args.Result == XNADialogResult.Cancel) return; - bool found = - OldWorld.Instance.MainPlayer.ActiveCharacter.Spells.Any( - _spell => OldWorld.Instance.ESF[_spell.ID].Name.ToLower() == input.ResponseText.ToLower()); - - if (!found) - { - args.CancelClose = true; - EOMessageBox.Show(DialogResourceID.SKILL_FORGET_ERROR_NOT_LEARNED, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader); - input.SetAsKeyboardSubscriber(); - } - - if (!m_api.ForgetSpell( - OldWorld.Instance.MainPlayer.ActiveCharacter.Spells.Find( - _spell => OldWorld.Instance.ESF[_spell.ID].Name.ToLower() == input.ResponseText.ToLower()).ID)) - { - Close(); - ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu(); - } - }; - - //should show initial info in the actual dialog since this uses a pop-up input box - // to select a skill to remove - newState = SkillState.Initial; - goto case SkillState.Initial; - } - case SkillState.ForgetAll: - { - _showForgetAllMessage(_forgetAllAction); - _setButtons(ScrollingListDialogButtons.BackCancel); - } - break; - } - - m_state = newState; - } - - private void _learn(Skill skill) - { - OldCharacter c = OldWorld.Instance.MainPlayer.ActiveCharacter; - - bool skillReqsMet = true; - foreach(short x in skill.SkillReq) - if (x != 0 && c.Spells.FindIndex(_sp => _sp.ID == x) < 0) - skillReqsMet = false; - - //check the requirements - if (c.Stats.Str < skill.StrReq || c.Stats.Int < skill.IntReq || c.Stats.Wis < skill.WisReq || - c.Stats.Agi < skill.AgiReq || c.Stats.Con < skill.ConReq || c.Stats.Cha < skill.ChaReq || - c.Stats.Level < skill.LevelReq || c.Inventory.Find(_ii => _ii.ItemID == 1).Amount < skill.GoldReq || !skillReqsMet) - { - EOMessageBox.Show(DialogResourceID.SKILL_LEARN_REQS_NOT_MET, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader); - return; - } - - if (skill.ClassReq > 0 && c.Class != skill.ClassReq) - { - EOMessageBox.Show(DialogResourceID.SKILL_LEARN_WRONG_CLASS, " " + OldWorld.Instance.ECF[skill.ClassReq].Name + "!", EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader); - return; - } - - EOMessageBox.Show(DialogResourceID.SKILL_LEARN_CONFIRMATION, " " + OldWorld.Instance.ESF[skill.ID].Name + "?", EODialogButtons.OkCancel, EOMessageBoxStyle.SmallDialogSmallHeader, - (o, e) => - { - if (e.Result != XNADialogResult.OK) - return; - - if (!m_api.LearnSpell(skill.ID)) - { - Close(); - ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu(); - } - }); - } - - private void _forgetAllAction() - { - EOMessageBox.Show(DialogResourceID.SKILL_RESET_CHARACTER_CONFIRMATION, EODialogButtons.OkCancel, EOMessageBoxStyle.SmallDialogSmallHeader, - (sender, args) => - { - if (args.Result == XNADialogResult.Cancel) return; - - if (!m_api.ResetCharacterStatSkill()) - { - Close(); - ((EOGame) Game).DoShowLostConnectionDialogAndReturnToMainMenu(); - } - }); - } - - private void _showRequirements(Skill skill) - { - m_showingRequirements = true; - ClearItemList(); - - List drawStrings = new List(15) - { - OldWorld.Instance.ESF[skill.ID].Name + (skill.ClassReq > 0 ? " [" + OldWorld.Instance.ECF[skill.ClassReq].Name + "]" : ""), - " " - }; - if (skill.SkillReq.Any(x => x != 0)) - { - drawStrings.AddRange(from req in skill.SkillReq where req != 0 select OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_SKILL) + ": " + OldWorld.Instance.ESF[req].Name); - drawStrings.Add(" "); - } - - if(skill.StrReq > 0) - drawStrings.Add(skill.StrReq + " " + OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_STRENGTH)); - if (skill.IntReq > 0) - drawStrings.Add(skill.IntReq + " " + OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_INTELLIGENCE)); - if (skill.WisReq > 0) - drawStrings.Add(skill.WisReq + " " + OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_WISDOM)); - if (skill.AgiReq > 0) - drawStrings.Add(skill.AgiReq + " " + OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_AGILITY)); - if (skill.ConReq > 0) - drawStrings.Add(skill.ConReq + " " + OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_CONSTITUTION)); - if (skill.ChaReq > 0) - drawStrings.Add(skill.ChaReq + " " + OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_CHARISMA)); - - drawStrings.Add(" "); - drawStrings.Add(skill.LevelReq + " " + OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_LEVEL)); - drawStrings.Add(skill.GoldReq + " " + OldWorld.Instance.EIF[1].Name); - - foreach (string s in drawStrings) - { - OldListDialogItem nextLine = new OldListDialogItem(this, OldListDialogItem.ListItemStyle.Small) { Text = s }; - AddItemToList(nextLine, false); - } - } - - private void _showRequirementsLabel(Skill skill) - { - string full = $"{OldWorld.Instance.ESF[skill.ID].Name} {skill.LevelReq} LVL, "; - if (skill.StrReq > 0) - full += $"{skill.StrReq} STR, "; - if (skill.IntReq > 0) - full += $"{skill.IntReq} INT, "; - if (skill.WisReq > 0) - full += $"{skill.WisReq} WIS, "; - if (skill.AgiReq > 0) - full += $"{skill.AgiReq} AGI, "; - if (skill.ConReq > 0) - full += $"{skill.ConReq} CON, "; - if (skill.ChaReq > 0) - full += $"{skill.ChaReq} CHA, "; - if (skill.GoldReq > 0) - full += $"{skill.GoldReq} Gold"; - if (skill.ClassReq > 0) - full += $", {OldWorld.Instance.ECF[skill.ClassReq].Name}"; - - ((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION, full); - } - - private void _showForgetAllMessage(Action forgetAllAction) - { - List drawStrings = new List(); - - string[] messages = - { - OldWorld.GetString(EOResourceID.SKILLMASTER_FORGET_ALL), - OldWorld.GetString(EOResourceID.SKILLMASTER_FORGET_ALL_MSG_1), - OldWorld.GetString(EOResourceID.SKILLMASTER_FORGET_ALL_MSG_2), - OldWorld.GetString(EOResourceID.SKILLMASTER_FORGET_ALL_MSG_3), - OldWorld.GetString(EOResourceID.SKILLMASTER_CLICK_HERE_TO_FORGET_ALL) - }; - - TextSplitter ts = new TextSplitter("", Game.Content.Load(Constants.FontSize08pt5)) { LineLength = 200 }; - foreach (string s in messages) - { - ts.Text = s; - if (!ts.NeedsProcessing) - { - //no text clipping needed - drawStrings.Add(s); - drawStrings.Add(" "); - continue; - } - - drawStrings.AddRange(ts.SplitIntoLines()); - drawStrings.Add(" "); - } - - //now need to take the processed draw strings and make an OldListDialogItem for each one - foreach (string s in drawStrings) - { - string next = s; - bool link = false; - if (next.Length > 0 && next[0] == '*') - { - next = next.Remove(0, 1); - link = true; - } - OldListDialogItem nextItem = new OldListDialogItem(this, OldListDialogItem.ListItemStyle.Small) { Text = next }; - if (link) nextItem.SetPrimaryTextLink(forgetAllAction); - AddItemToList(nextItem, false); - } - } - } -} diff --git a/EndlessClient/Dialogs/Old/TextInputDialog.cs b/EndlessClient/Dialogs/Old/TextInputDialog.cs deleted file mode 100644 index 7e15569d3..000000000 --- a/EndlessClient/Dialogs/Old/TextInputDialog.cs +++ /dev/null @@ -1,69 +0,0 @@ -using EndlessClient.Dialogs.Services; -using EndlessClient.Old; -using EOLib; -using EOLib.Graphics; -using EOLib.Net.API; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using XNAControls; -using XNAButton = XNAControls.Old.XNAButton; -using XNADialogResult = XNAControls.Old.XNADialogResult; -using XNALabel = XNAControls.Old.XNALabel; -using XNATextBox = XNAControls.Old.XNATextBox; - -namespace EndlessClient.Dialogs.Old -{ - public class TextInputDialog : EODialogBase - { - private readonly XNATextBox m_inputBox; - private readonly IKeyboardSubscriber previousSubscriber; - - public string ResponseText => m_inputBox.Text; - - public TextInputDialog(string prompt, int maxInputChars = 12) - : base((PacketAPI)null) - { - bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 54); - _setSize(bgTexture.Width, bgTexture.Height); - - XNALabel lblPrompt = new XNALabel(new Rectangle(16, 20, 235, 49), Constants.FontSize10) - { - AutoSize = false, - ForeColor = ColorConstants.LightGrayDialogMessage, - TextWidth = 230, - RowSpacing = 3, - Text = prompt - }; - lblPrompt.SetParent(this); - - //set this back once the dialog is closed. - previousSubscriber = ((EOGame)Game).Dispatcher.Subscriber; - DialogClosing += (o, e) => ((EOGame)Game).Dispatcher.Subscriber = previousSubscriber; - - m_inputBox = new XNATextBox(new Rectangle(37, 74, 192, 19), EOGame.Instance.Content.Load("cursor"), Constants.FontSize08) - { - MaxChars = maxInputChars, - LeftPadding = 4, - TextColor = ColorConstants.LightBeigeText - }; - m_inputBox.SetParent(this); - EOGame.Instance.Dispatcher.Subscriber = m_inputBox; - - XNAButton ok = new XNAButton(smallButtonSheet, new Vector2(41, 103), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok)), - cancel = new XNAButton(smallButtonSheet, new Vector2(134, 103), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel)); - ok.OnClick += (o, e) => Close(ok, XNADialogResult.OK); - cancel.OnClick += (o, e) => Close(cancel, XNADialogResult.Cancel); - ok.SetParent(this); - cancel.SetParent(this); - - Center(Game.GraphicsDevice); - DrawLocation = new Vector2(DrawLocation.X, 107); - endConstructor(false); - } - - public void SetAsKeyboardSubscriber() - { - ((EOGame)Game).Dispatcher.Subscriber = m_inputBox; - } - } -} diff --git a/EndlessClient/Dialogs/SkillmasterDialog.cs b/EndlessClient/Dialogs/SkillmasterDialog.cs new file mode 100644 index 000000000..be160ad71 --- /dev/null +++ b/EndlessClient/Dialogs/SkillmasterDialog.cs @@ -0,0 +1,405 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using EndlessClient.Dialogs.Factories; +using EndlessClient.Dialogs.Services; +using EOLib.Domain.Character; +using EOLib.Domain.Interact.Skill; +using EOLib.Graphics; +using EOLib.Localization; +using Microsoft.Xna.Framework; + +namespace EndlessClient.Dialogs +{ + public class SkillmasterDialog : ScrollingListDialog + { + private enum SkillState + { + Initial, + Learn, + Forget, + ForgetAll + } + + private SkillState _state; + + private HashSet _cachedSkills; + private HashSet _cachedSpells; + private string _cachedTitle; + + private bool _showingRequirements; + + private readonly IEODialogIconService _dialogIconService; + private readonly ILocalizedStringFinder _localizedStringFinder; + private readonly IEOMessageBoxFactory _messageBoxFactory; + private readonly ISkillDataProvider _skillDataProvider; + private readonly ICharacterInventoryProvider _characterInventoryProvider; + + public SkillmasterDialog(INativeGraphicsManager nativeGraphicsManager, + IEODialogButtonService dialogButtonService, + IEODialogIconService dialogIconService, + ILocalizedStringFinder localizedStringFinder, + IEOMessageBoxFactory messageBoxFactory, + ISkillDataProvider skillDataProvider, + ICharacterInventoryProvider characterInventoryProvider) + : base(nativeGraphicsManager, dialogButtonService) + { + Buttons = ScrollingListDialogButtons.Cancel; + ListItemType = ListDialogItem.ListItemStyle.Large; + + _cachedSkills = new HashSet(); + _cachedSpells = new HashSet(); + _cachedTitle = string.Empty; + + BackAction += BackClicked; + + _dialogIconService = dialogIconService; + _localizedStringFinder = localizedStringFinder; + _messageBoxFactory = messageBoxFactory; + _skillDataProvider = skillDataProvider; + _characterInventoryProvider = characterInventoryProvider; + + SetState(SkillState.Initial, regen: true); + } + + protected override void OnUpdateControl(GameTime gameTime) + { + if (_cachedTitle != _skillDataProvider.Title) + { + Title = _cachedTitle = _skillDataProvider.Title; + } + + if (!_cachedSkills.SetEquals(_skillDataProvider.Skills)) + { + _cachedSkills = _skillDataProvider.Skills.ToHashSet(); + SetState(_state, regen: true); + } + + if (!_cachedSpells.SetEquals(_characterInventoryProvider.SpellInventory)) + { + _cachedSpells = _characterInventoryProvider.SpellInventory.ToHashSet(); + SetState(_state, regen: true); + } + + base.OnUpdateControl(gameTime); + } + + private void BackClicked(object sender, EventArgs e) + { + if (_state == SkillState.Learn && _showingRequirements) + { + SetState(SkillState.Learn, regen: true); + _showingRequirements = false; + } + else + { + SetState(SkillState.Initial); + } + } + + private void SetState(SkillState newState, bool regen = false) + { + SkillState old = _state; + + if (old == newState && !regen) + return; + + int numToLearn = _cachedSkills.Count(x => !_cachedSpells.Any(si => si.ID == x.Id)); + int numToForget = _cachedSpells.Count; + + if (newState == SkillState.Learn && numToLearn == 0) + { + var dlg = _messageBoxFactory.CreateMessageBox(DialogResourceID.SKILL_NOTHING_MORE_TO_LEARN); + dlg.ShowDialog(); + return; + } + + ClearItemList(); + + switch (newState) + { + case SkillState.Initial: + { + string learnNum = $"{numToLearn}{_localizedStringFinder.GetString(EOResourceID.SKILLMASTER_ITEMS_TO_LEARN)}"; + string forgetNum = $"{numToForget}{_localizedStringFinder.GetString(EOResourceID.SKILLMASTER_ITEMS_LEARNED)}"; + + var learn = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0) + { + PrimaryText = _localizedStringFinder.GetString(EOResourceID.SKILLMASTER_WORD_LEARN), + SubText = learnNum, + IconGraphic = _dialogIconService.IconSheet, + IconGraphicSource = _dialogIconService.GetDialogIconSource(DialogIcon.Learn), + ShowIconBackGround = false, + OffsetY = 45 + }; + learn.LeftClick += (_, _) => SetState(SkillState.Learn); + learn.RightClick += (_, _) => SetState(SkillState.Learn); + learn.SetParentControl(this); + + var forget = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 1) + { + PrimaryText = _localizedStringFinder.GetString(EOResourceID.SKILLMASTER_WORD_FORGET), + SubText = forgetNum, + IconGraphic = _dialogIconService.IconSheet, + IconGraphicSource = _dialogIconService.GetDialogIconSource(DialogIcon.Forget), + ShowIconBackGround = false, + OffsetY = 45 + }; + forget.LeftClick += (_, _) => SetState(SkillState.Forget); + forget.RightClick += (_, _) => SetState(SkillState.Forget); + forget.SetParentControl(this); + + var forgetAll = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 2) + { + PrimaryText = _localizedStringFinder.GetString(EOResourceID.SKILLMASTER_FORGET_ALL), + SubText = _localizedStringFinder.GetString(EOResourceID.SKILLMASTER_RESET_YOUR_CHARACTER), + IconGraphic = _dialogIconService.IconSheet, + IconGraphicSource = _dialogIconService.GetDialogIconSource(DialogIcon.Forget), + ShowIconBackGround = false, + OffsetY = 45 + }; + forgetAll.LeftClick += (_, _) => SetState(SkillState.ForgetAll); + forgetAll.RightClick += (_, _) => SetState(SkillState.ForgetAll); + forgetAll.SetParentControl(this); + + SetItemList(new List { learn, forget, forgetAll }); + + Buttons = ScrollingListDialogButtons.Cancel; + } + break; + case SkillState.Learn: + { + //int index = 0; + //for (int i = 0; i < m_skills.Count; ++i) + //{ + // if (OldWorld.Instance.MainPlayer.ActiveCharacter.Spells.FindIndex(_sp => m_skills[i].ID == _sp.ID) >= 0) + // continue; + // int localI = i; + + // var spellData = OldWorld.Instance.ESF[m_skills[localI].ID]; + + // OldListDialogItem nextListItem = new OldListDialogItem(this, OldListDialogItem.ListItemStyle.Large, index++) + // { + // Visible = false, + // Text = spellData.Name, + // SubText = OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_REQUIREMENTS), + // IconGraphic = OldWorld.GetSpellIcon(spellData.Icon, false), + // ShowItemBackGround = false, + // OffsetY = 45, + // ID = m_skills[localI].ID + // }; + // nextListItem.OnLeftClick += (o, e) => _learn(m_skills[localI]); + // nextListItem.OnRightClick += (o, e) => _learn(m_skills[localI]); + // nextListItem.OnMouseEnter += (o, e) => _showRequirementsLabel(m_skills[localI]); + // nextListItem.SetSubtextLink(() => _showRequirements(m_skills[localI])); + // AddItemToList(nextListItem, false); + //} + + //_setButtons(ScrollingListDialogButtons.BackCancel); + } + break; + case SkillState.Forget: + { + //TextInputDialog input = new TextInputDialog(OldWorld.GetString(DialogResourceID.SKILL_PROMPT_TO_FORGET, false), 32); + //input.SetAsKeyboardSubscriber(); + //input.DialogClosing += (sender, args) => + //{ + // if (args.Result == XNADialogResult.Cancel) return; + // bool found = + // OldWorld.Instance.MainPlayer.ActiveCharacter.Spells.Any( + // _spell => OldWorld.Instance.ESF[_spell.ID].Name.ToLower() == input.ResponseText.ToLower()); + + // if (!found) + // { + // args.CancelClose = true; + // EOMessageBox.Show(DialogResourceID.SKILL_FORGET_ERROR_NOT_LEARNED, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader); + // input.SetAsKeyboardSubscriber(); + // } + + // if (!m_api.ForgetSpell( + // OldWorld.Instance.MainPlayer.ActiveCharacter.Spells.Find( + // _spell => OldWorld.Instance.ESF[_spell.ID].Name.ToLower() == input.ResponseText.ToLower()).ID)) + // { + // Close(); + // ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu(); + // } + //}; + + ////should show initial info in the actual dialog since this uses a pop-up input box + //// to select a skill to remove + //newState = SkillState.Initial; + goto case SkillState.Initial; + } + case SkillState.ForgetAll: + { + //_showForgetAllMessage(_forgetAllAction); + //_setButtons(ScrollingListDialogButtons.BackCancel); + } + break; + } + + _state = newState; + } + + //private void _learn(Skill skill) + //{ + // OldCharacter c = OldWorld.Instance.MainPlayer.ActiveCharacter; + + // bool skillReqsMet = true; + // foreach(short x in skill.SkillReq) + // if (x != 0 && c.Spells.FindIndex(_sp => _sp.ID == x) < 0) + // skillReqsMet = false; + + // //check the requirements + // if (c.Stats.Str < skill.StrReq || c.Stats.Int < skill.IntReq || c.Stats.Wis < skill.WisReq || + // c.Stats.Agi < skill.AgiReq || c.Stats.Con < skill.ConReq || c.Stats.Cha < skill.ChaReq || + // c.Stats.Level < skill.LevelReq || c.Inventory.Find(_ii => _ii.ItemID == 1).Amount < skill.GoldReq || !skillReqsMet) + // { + // EOMessageBox.Show(DialogResourceID.SKILL_LEARN_REQS_NOT_MET, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader); + // return; + // } + + // if (skill.ClassReq > 0 && c.Class != skill.ClassReq) + // { + // EOMessageBox.Show(DialogResourceID.SKILL_LEARN_WRONG_CLASS, " " + OldWorld.Instance.ECF[skill.ClassReq].Name + "!", EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader); + // return; + // } + + // EOMessageBox.Show(DialogResourceID.SKILL_LEARN_CONFIRMATION, " " + OldWorld.Instance.ESF[skill.ID].Name + "?", EODialogButtons.OkCancel, EOMessageBoxStyle.SmallDialogSmallHeader, + // (o, e) => + // { + // if (e.Result != XNADialogResult.OK) + // return; + + // if (!m_api.LearnSpell(skill.ID)) + // { + // Close(); + // ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu(); + // } + // }); + //} + + //private void _forgetAllAction() + //{ + // EOMessageBox.Show(DialogResourceID.SKILL_RESET_CHARACTER_CONFIRMATION, EODialogButtons.OkCancel, EOMessageBoxStyle.SmallDialogSmallHeader, + // (sender, args) => + // { + // if (args.Result == XNADialogResult.Cancel) return; + + // if (!m_api.ResetCharacterStatSkill()) + // { + // Close(); + // ((EOGame) Game).DoShowLostConnectionDialogAndReturnToMainMenu(); + // } + // }); + //} + + //private void _showRequirements(Skill skill) + //{ + // m_showingRequirements = true; + // ClearItemList(); + + // List drawStrings = new List(15) + // { + // OldWorld.Instance.ESF[skill.ID].Name + (skill.ClassReq > 0 ? " [" + OldWorld.Instance.ECF[skill.ClassReq].Name + "]" : ""), + // " " + // }; + // if (skill.SkillReq.Any(x => x != 0)) + // { + // drawStrings.AddRange(from req in skill.SkillReq where req != 0 select OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_SKILL) + ": " + OldWorld.Instance.ESF[req].Name); + // drawStrings.Add(" "); + // } + + // if(skill.StrReq > 0) + // drawStrings.Add(skill.StrReq + " " + OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_STRENGTH)); + // if (skill.IntReq > 0) + // drawStrings.Add(skill.IntReq + " " + OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_INTELLIGENCE)); + // if (skill.WisReq > 0) + // drawStrings.Add(skill.WisReq + " " + OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_WISDOM)); + // if (skill.AgiReq > 0) + // drawStrings.Add(skill.AgiReq + " " + OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_AGILITY)); + // if (skill.ConReq > 0) + // drawStrings.Add(skill.ConReq + " " + OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_CONSTITUTION)); + // if (skill.ChaReq > 0) + // drawStrings.Add(skill.ChaReq + " " + OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_CHARISMA)); + + // drawStrings.Add(" "); + // drawStrings.Add(skill.LevelReq + " " + OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_LEVEL)); + // drawStrings.Add(skill.GoldReq + " " + OldWorld.Instance.EIF[1].Name); + + // foreach (string s in drawStrings) + // { + // OldListDialogItem nextLine = new OldListDialogItem(this, OldListDialogItem.ListItemStyle.Small) { Text = s }; + // AddItemToList(nextLine, false); + // } + //} + + //private void _showRequirementsLabel(Skill skill) + //{ + // string full = $"{OldWorld.Instance.ESF[skill.ID].Name} {skill.LevelReq} LVL, "; + // if (skill.StrReq > 0) + // full += $"{skill.StrReq} STR, "; + // if (skill.IntReq > 0) + // full += $"{skill.IntReq} INT, "; + // if (skill.WisReq > 0) + // full += $"{skill.WisReq} WIS, "; + // if (skill.AgiReq > 0) + // full += $"{skill.AgiReq} AGI, "; + // if (skill.ConReq > 0) + // full += $"{skill.ConReq} CON, "; + // if (skill.ChaReq > 0) + // full += $"{skill.ChaReq} CHA, "; + // if (skill.GoldReq > 0) + // full += $"{skill.GoldReq} Gold"; + // if (skill.ClassReq > 0) + // full += $", {OldWorld.Instance.ECF[skill.ClassReq].Name}"; + + // ((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION, full); + //} + + //private void _showForgetAllMessage(Action forgetAllAction) + //{ + // List drawStrings = new List(); + + // string[] messages = + // { + // OldWorld.GetString(EOResourceID.SKILLMASTER_FORGET_ALL), + // OldWorld.GetString(EOResourceID.SKILLMASTER_FORGET_ALL_MSG_1), + // OldWorld.GetString(EOResourceID.SKILLMASTER_FORGET_ALL_MSG_2), + // OldWorld.GetString(EOResourceID.SKILLMASTER_FORGET_ALL_MSG_3), + // OldWorld.GetString(EOResourceID.SKILLMASTER_CLICK_HERE_TO_FORGET_ALL) + // }; + + // TextSplitter ts = new TextSplitter("", Game.Content.Load(Constants.FontSize08pt5)) { LineLength = 200 }; + // foreach (string s in messages) + // { + // ts.Text = s; + // if (!ts.NeedsProcessing) + // { + // //no text clipping needed + // drawStrings.Add(s); + // drawStrings.Add(" "); + // continue; + // } + + // drawStrings.AddRange(ts.SplitIntoLines()); + // drawStrings.Add(" "); + // } + + // //now need to take the processed draw strings and make an OldListDialogItem for each one + // foreach (string s in drawStrings) + // { + // string next = s; + // bool link = false; + // if (next.Length > 0 && next[0] == '*') + // { + // next = next.Remove(0, 1); + // link = true; + // } + // OldListDialogItem nextItem = new OldListDialogItem(this, OldListDialogItem.ListItemStyle.Small) { Text = next }; + // if (link) nextItem.SetPrimaryTextLink(forgetAllAction); + // AddItemToList(nextItem, false); + // } + //} + } +} diff --git a/EndlessClient/Rendering/OldNPCRenderer.cs b/EndlessClient/Rendering/OldNPCRenderer.cs index bcda918ae..9f5d4e9ea 100644 --- a/EndlessClient/Rendering/OldNPCRenderer.cs +++ b/EndlessClient/Rendering/OldNPCRenderer.cs @@ -308,38 +308,6 @@ private void UpdateMouseoverName() private void HandleLeftClick() { - bool mouseClicked = _currMouseState.LeftButton == ButtonState.Released && - _prevMouseState.LeftButton == ButtonState.Pressed; - - if (mouseClicked && DrawArea.ContainsPoint(_currMouseState.X, _currMouseState.Y)) - { - if (OldWorld.Instance.MainPlayer.ActiveCharacter.NeedsSpellTarget) - { - var data = OldWorld.Instance.ESF[OldWorld.Instance.MainPlayer.ActiveCharacter.SelectedSpell]; - if (data.TargetRestrict != SpellTargetRestrict.Friendly) - { - OldWorld.Instance.ActiveCharacterRenderer.SetSpellTarget(this); - } - else - { - //todo status label message "you cannot attack this NPC" - OldWorld.Instance.MainPlayer.ActiveCharacter.SelectSpell(-1); - } - - return; //don't process regular click on NPC while targeting a spell - } - - PacketAPI api = ((EOGame)Game).API; - switch (NPC.Data.Type) - { - case NPCType.Inn: break; - case NPCType.Barber: break; - case NPCType.Guild: break; - case NPCType.Priest: break; - case NPCType.Law: break; - case NPCType.Skills: SkillmasterDialog.Show(api, NPC.Index); break; - } - } } private void UpdateWalkFrameIfNeeded()