Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add management menu #365

Merged
merged 8 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion EOLib.Localization/EOResourceID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions EOLib/Domain/Character/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
34 changes: 10 additions & 24 deletions EndlessClient/Dialogs/Factories/GuildDialogFactory.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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()
Expand All @@ -49,11 +37,9 @@ public GuildDialog Create()
_dialogButtonService,
_dialogIconService,
_localizedStringFinder,
_textInputDialogFactory,
_GuildActions,
_contentProvider,
_currentMapStateProvider,
_enfFileProvider);
_characterProvider,
_messageBoxFactory
);
}
}

Expand Down
141 changes: 116 additions & 25 deletions EndlessClient/Dialogs/GuildDialog.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -22,42 +16,48 @@ 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;

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);
Expand Down Expand Up @@ -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);

Expand All @@ -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),
ethanmoffat marked this conversation as resolved.
Show resolved Hide resolved
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);
}
}
}
4 changes: 4 additions & 0 deletions EndlessClient/Dialogs/Services/EODialogIconService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down