diff --git a/EOLib.Localization/EOResourceID.cs b/EOLib.Localization/EOResourceID.cs index 95250f2fc..0a1dffcea 100644 --- a/EOLib.Localization/EOResourceID.cs +++ b/EOLib.Localization/EOResourceID.cs @@ -185,7 +185,7 @@ public enum EOResourceID GUILD_RANKING = 193, GUILD_DISBAND = 194, GUILD_CHANGE_YOUR_GUILD_DETAILS = 195, - GUILD_CHANGE_MEMBER_RANKINGS = 196, + GUILD_MANAGE_MEMBER_RANKINGS = 196, GUILD_DISBAND_YOUR_GUILD = 197, GUILD_DEPOSIT = 198, GUILD_WITHDRAW = 199, @@ -196,6 +196,7 @@ public enum EOResourceID GUILD_JOINING_A_GUILD_IS_FREE = 205, GUILD_PLEASE_CONSIDER_CAREFULLY = 207, GUILD_DO_YOU_ACCEPT = 223, + GUILD_ASSIGN_RANK_TO_MEMBER = 233, SETTING_KEYBOARD_ENGLISH = 253, SETTING_KEYBOARD_DUTCH = 254, diff --git a/EOLib/Domain/Character/Character.cs b/EOLib/Domain/Character/Character.cs index a78bf49cf..713cb3f1f 100644 --- a/EOLib/Domain/Character/Character.cs +++ b/EOLib/Domain/Character/Character.cs @@ -39,6 +39,8 @@ public sealed partial class Character : ISpellTargetable public string GuildTag { get; } + public bool InGuild => GuildTag != " "; + public int ClassID { get; } public AdminLevel AdminLevel { get; } diff --git a/EndlessClient/Dialogs/Factories/GuildDialogFactory.cs b/EndlessClient/Dialogs/Factories/GuildDialogFactory.cs index 459794505..a01d47c04 100644 --- a/EndlessClient/Dialogs/Factories/GuildDialogFactory.cs +++ b/EndlessClient/Dialogs/Factories/GuildDialogFactory.cs @@ -1,10 +1,7 @@ using AutomaticTypeMapper; -using EndlessClient.Content; using EndlessClient.Dialogs.Services; -using EOLib.Domain.Interact.Guild; -using EOLib.Domain.Map; +using EOLib.Domain.Character; using EOLib.Graphics; -using EOLib.IO.Repositories; using EOLib.Localization; namespace EndlessClient.Dialogs.Factories @@ -16,31 +13,22 @@ public class GuildDialogFactory : IGuildDialogFactory private readonly IEODialogButtonService _dialogButtonService; private readonly IEODialogIconService _dialogIconService; private readonly ILocalizedStringFinder _localizedStringFinder; - private readonly ITextInputDialogFactory _textInputDialogFactory; - private readonly IGuildActions _GuildActions; - private readonly IContentProvider _contentProvider; - private readonly ICurrentMapStateProvider _currentMapStateProvider; - private readonly IENFFileProvider _enfFileProvider; + private readonly ICharacterProvider _characterProvider; + private readonly IEOMessageBoxFactory _messageBoxFactory; public GuildDialogFactory(INativeGraphicsManager nativeGraphicsManager, IEODialogButtonService dialogButtonService, IEODialogIconService dialogIconService, ILocalizedStringFinder localizedStringFinder, - ITextInputDialogFactory textInputDialogFactory, - IGuildActions GuildActions, - IContentProvider contentProvider, - ICurrentMapStateProvider currentMapStateProvider, - IENFFileProvider enfFileProvider) + ICharacterProvider characterProvider, + IEOMessageBoxFactory messageBoxFactory) { _nativeGraphicsManager = nativeGraphicsManager; _dialogButtonService = dialogButtonService; _dialogIconService = dialogIconService; _localizedStringFinder = localizedStringFinder; - _textInputDialogFactory = textInputDialogFactory; - _GuildActions = GuildActions; - _contentProvider = contentProvider; - _currentMapStateProvider = currentMapStateProvider; - _enfFileProvider = enfFileProvider; + _characterProvider = characterProvider; + _messageBoxFactory = messageBoxFactory; } public GuildDialog Create() @@ -49,11 +37,9 @@ public GuildDialog Create() _dialogButtonService, _dialogIconService, _localizedStringFinder, - _textInputDialogFactory, - _GuildActions, - _contentProvider, - _currentMapStateProvider, - _enfFileProvider); + _characterProvider, + _messageBoxFactory + ); } } diff --git a/EndlessClient/Dialogs/GuildDialog.cs b/EndlessClient/Dialogs/GuildDialog.cs index af6415df6..9d835d349 100644 --- a/EndlessClient/Dialogs/GuildDialog.cs +++ b/EndlessClient/Dialogs/GuildDialog.cs @@ -1,18 +1,12 @@ using EndlessClient.Content; using EndlessClient.Dialogs.Factories; using EndlessClient.Dialogs.Services; -using EOLib; +using EOLib.Domain.Character; using EOLib.Domain.Interact.Guild; using EOLib.Domain.Map; using EOLib.Graphics; -using EOLib.IO; using EOLib.IO.Repositories; using EOLib.Localization; -using Optional.Collections; -using System; -using System.Collections.Generic; -using System.Linq; -using XNAControls; namespace EndlessClient.Dialogs { @@ -22,15 +16,19 @@ private enum GuildDialogState { // initial menu Initial, + Management, + Modify, + ManageRankings, + AssignRank, + RemoveMember, + Disband, + } private readonly IEODialogIconService _dialogIconService; private readonly ILocalizedStringFinder _localizedStringFinder; - private readonly ITextInputDialogFactory _textInputDialogFactory; - private readonly IGuildActions _GuildActions; - private readonly IContentProvider _contentProvider; - private readonly ICurrentMapStateProvider _currentMapStateProvider; - private readonly IENFFileProvider _enfFileProvider; + private readonly ICharacterProvider _characterProvider; + private readonly IEOMessageBoxFactory _messageBoxFactory; private GuildDialogState _state; @@ -38,26 +36,28 @@ public GuildDialog(INativeGraphicsManager nativeGraphicsManager, IEODialogButtonService dialogButtonService, IEODialogIconService dialogIconService, ILocalizedStringFinder localizedStringFinder, - ITextInputDialogFactory textInputDialogFactory, - IGuildActions GuildActions, - IContentProvider contentProvider, - ICurrentMapStateProvider currentMapStateProvider, - IENFFileProvider enfFileProvider) + ICharacterProvider characterProvider, + IEOMessageBoxFactory messageBoxFactory) : base(nativeGraphicsManager, dialogButtonService, DialogType.Guild) { _dialogIconService = dialogIconService; _localizedStringFinder = localizedStringFinder; - _textInputDialogFactory = textInputDialogFactory; - _GuildActions = GuildActions; - _contentProvider = contentProvider; - _currentMapStateProvider = currentMapStateProvider; - _enfFileProvider = enfFileProvider; + _characterProvider = characterProvider; + _messageBoxFactory = messageBoxFactory; SetState(GuildDialogState.Initial); BackAction += (_, _) => { - + switch (_state) + { + case GuildDialogState.Management: + SetState(GuildDialogState.Initial); + break; + default: + // no-op + break; + } }; Title = _localizedStringFinder.GetString(EOResourceID.GUILD_GUILD_MASTER); @@ -116,8 +116,8 @@ private void SetState(GuildDialogState state) SubText = _localizedStringFinder.GetString(EOResourceID.GUILD_MODIFY_RANKING_DISBAND), OffsetY = 45, }; - //registrationItem.LeftClick += (_, _) => SetState(GuildDialogState.Registration); - //registrationItem.RightClick += (_, _) => SetState(GuildDialogState.Registration); + managementItem.LeftClick += (_, _) => SetState(GuildDialogState.Management); + managementItem.RightClick += (_, _) => SetState(GuildDialogState.Management); AddItemToList(managementItem, sortList: false); @@ -136,7 +136,98 @@ private void SetState(GuildDialogState state) AddItemToList(bankAccountItem, sortList: false); } break; + + case GuildDialogState.Management: + { + ListItemType = ListDialogItem.ListItemStyle.Large; + Buttons = ScrollingListDialogButtons.BackCancel; + + var modifyGuildItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0) + { + ShowIconBackGround = false, + IconGraphic = _dialogIconService.IconSheet, + IconGraphicSource = _dialogIconService.GetDialogIconSource(DialogIcon.GuildModify), + PrimaryText = _localizedStringFinder.GetString(EOResourceID.GUILD_MODIFY_GUILD), + SubText = _localizedStringFinder.GetString(EOResourceID.GUILD_CHANGE_YOUR_GUILD_DETAILS), + OffsetY = 45, + }; + modifyGuildItem.LeftClick += (_, _) => SetStateIfGuildMember(GuildDialogState.Modify); + modifyGuildItem.RightClick += (_, _) => SetStateIfGuildMember(GuildDialogState.Modify); + + AddItemToList(modifyGuildItem, sortList: false); + + var manageRankingItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0) + { + ShowIconBackGround = false, + IconGraphic = _dialogIconService.IconSheet, + IconGraphicSource = _dialogIconService.GetDialogIconSource(DialogIcon.GuildRanking), + PrimaryText = _localizedStringFinder.GetString(EOResourceID.GUILD_RANKING), + SubText = _localizedStringFinder.GetString(EOResourceID.GUILD_MANAGE_MEMBER_RANKINGS), + OffsetY = 45, + }; + manageRankingItem.LeftClick += (_, _) => SetStateIfGuildMember(GuildDialogState.ManageRankings); + manageRankingItem.RightClick += (_, _) => SetStateIfGuildMember(GuildDialogState.ManageRankings); + + AddItemToList(manageRankingItem, sortList: false); + + var assignRankItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0) + { + ShowIconBackGround = false, + IconGraphic = _dialogIconService.IconSheet, + IconGraphicSource = _dialogIconService.GetDialogIconSource(DialogIcon.GuildRanking), + PrimaryText = _localizedStringFinder.GetString(EOResourceID.GUILD_RANKING), + SubText = _localizedStringFinder.GetString(EOResourceID.GUILD_ASSIGN_RANK_TO_MEMBER), + OffsetY = 45, + }; + assignRankItem.LeftClick += (_, _) => SetStateIfGuildMember(GuildDialogState.AssignRank); + assignRankItem.RightClick += (_, _) => SetStateIfGuildMember(GuildDialogState.AssignRank); + + AddItemToList(assignRankItem, sortList: false); + + var removeMemberItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0) + { + ShowIconBackGround = false, + IconGraphic = _dialogIconService.IconSheet, + IconGraphicSource = _dialogIconService.GetDialogIconSource(DialogIcon.GuildRemoveMember), + PrimaryText = _localizedStringFinder.GetString(EOResourceID.GUILD_REMOVE_MEMBER), + SubText = _localizedStringFinder.GetString(EOResourceID.GUILD_REMOVE_A_MEMBER_FROM_GUILD), + OffsetY = 45, + }; + removeMemberItem.LeftClick += (_, _) => SetStateIfGuildMember(GuildDialogState.RemoveMember); + removeMemberItem.RightClick += (_, _) => SetStateIfGuildMember(GuildDialogState.RemoveMember); + + AddItemToList(removeMemberItem, sortList: false); + + var disbandItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0) + { + ShowIconBackGround = false, + IconGraphic = _dialogIconService.IconSheet, + IconGraphicSource = _dialogIconService.GetDialogIconSource(DialogIcon.GuildDisband), + PrimaryText = _localizedStringFinder.GetString(EOResourceID.GUILD_DISBAND), + SubText = _localizedStringFinder.GetString(EOResourceID.GUILD_DISBAND_YOUR_GUILD), + OffsetY = 45, + }; + disbandItem.LeftClick += (_, _) => SetStateIfGuildMember(GuildDialogState.Disband); + disbandItem.RightClick += (_, _) => SetStateIfGuildMember(GuildDialogState.Disband); + + AddItemToList(disbandItem, sortList: false); + } + break; + } + + } + + private void SetStateIfGuildMember(GuildDialogState state) + { + if (!_characterProvider.MainCharacter.InGuild) + { + var dlg = _messageBoxFactory.CreateMessageBox(DialogResourceID.GUILD_NOT_IN_GUILD); + dlg.ShowDialog(); + return; + } + + SetState(state); } } } diff --git a/EndlessClient/Dialogs/Services/EODialogIconService.cs b/EndlessClient/Dialogs/Services/EODialogIconService.cs index 426d16eac..90a638e05 100644 --- a/EndlessClient/Dialogs/Services/EODialogIconService.cs +++ b/EndlessClient/Dialogs/Services/EODialogIconService.cs @@ -30,6 +30,10 @@ public enum DialogIcon GuildRegister = 15, GuildLookup = GuildRegister, GuildMemberlist = GuildRegister, + GuildModify = 16, + GuildRanking = 17, + GuildRemoveMember = 18, + GuildDisband = 19, Learn = 20, Forget = 21,