Skip to content

Commit

Permalink
Implement Board dialog in UI. Add property for detecting if any of a …
Browse files Browse the repository at this point in the history
…logged in user's characters have admin permissions.
  • Loading branch information
ethanmoffat committed May 18, 2023
1 parent e277af5 commit 83325cd
Show file tree
Hide file tree
Showing 13 changed files with 484 additions and 94 deletions.
5 changes: 5 additions & 0 deletions EOLib.Localization/EOResourceID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ public enum EOResourceID
SETTING_KEYBOARD_SWEDISH = 255,
SETTING_KEYBOARD_AZERTY = 256,

BOARD_TOWN_BOARD = 271,
BOARD_TOWN_BOARD_NOW_VIEWED = 272,
BOARD_LOADING_MESSAGE = 273,
BOARD_POSTING_NEW_MESSAGE = 274,

JAIL_WARNING_CANNOT_DROP_ITEMS = 275,
JAIL_WARNING_CANNOT_TRADE = 276,
JAIL_WARNING_CANNOT_USE_GLOBAL = 277,
Expand Down
2 changes: 2 additions & 0 deletions EOLib/Domain/Login/LoginActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ public async Task<int> RequestCharacterLogin(Character.Character character)
.WithStats(data.CharacterStats);

_playerInfoRepository.IsFirstTimePlayer = data.FirstTimePlayer;
_playerInfoRepository.PlayerHasAdminCharacter = _characterSelectorRepository.Characters.Any(x => x.AdminLevel > 0);

_currentMapStateRepository.CurrentMapID = data.MapID;
_currentMapStateRepository.JailMapID = data.JailMap;

Expand Down
7 changes: 7 additions & 0 deletions EOLib/Domain/Login/PlayerInfoRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public interface IPlayerInfoRepository
bool IsFirstTimePlayer { get; set; }

bool PlayerIsInGame { get; set; }

bool PlayerHasAdminCharacter { get; set; }
}

public interface IPlayerInfoProvider
Expand All @@ -26,6 +28,8 @@ public interface IPlayerInfoProvider
bool IsFirstTimePlayer { get; }

bool PlayerIsInGame { get; }

bool PlayerHasAdminCharacter { get; }
}

[AutoMappedType(IsSingleton = true)]
Expand All @@ -41,13 +45,16 @@ public sealed class PlayerInfoRepository : IPlayerInfoRepository, IPlayerInfoPro

public bool PlayerIsInGame { get; set; }

public bool PlayerHasAdminCharacter { get; set; }

public void ResetState()
{
LoggedInAccountName = "";
PlayerPassword = "";
PlayerID = 0;
IsFirstTimePlayer = false;
PlayerIsInGame = false;
PlayerHasAdminCharacter = false;
}
}
}
28 changes: 19 additions & 9 deletions EndlessClient/Dialogs/Actions/InGameDialogActions.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
using AutomaticTypeMapper;
using EndlessClient.Audio;
using EndlessClient.Dialogs.Factories;
using EndlessClient.HUD;
using EOLib.Domain.Character;
using EOLib.Domain.Interact.Quest;
using EOLib.Domain.Interact.Shop;
using EOLib.Domain.Interact.Skill;
using EOLib.Localization;
using Optional;
using System;
using System.Collections.Generic;
using System.Linq;
using XNAControls;

namespace EndlessClient.Dialogs.Actions
{
Expand All @@ -32,6 +35,7 @@ public class InGameDialogActions : IInGameDialogActions
private readonly ITradeDialogFactory _tradeDialogFactory;
private readonly IBoardDialogFactory _boardDialogFactory;
private readonly ISfxPlayer _sfxPlayer;
private readonly IStatusLabelSetter _statusLabelSetter;
private readonly IShopDialogFactory _shopDialogFactory;
private readonly IQuestDialogFactory _questDialogFactory;

Expand All @@ -53,7 +57,8 @@ public InGameDialogActions(IFriendIgnoreListDialogFactory friendIgnoreListDialog
IScrollingListDialogFactory scrollingListDialogFactory,
ITradeDialogFactory tradeDialogFactory,
IBoardDialogFactory boardDialogFactory,
ISfxPlayer sfxPlayer)
ISfxPlayer sfxPlayer,
IStatusLabelSetter statusLabelSetter)
{
_friendIgnoreListDialogFactory = friendIgnoreListDialogFactory;
_paperdollDialogFactory = paperdollDialogFactory;
Expand All @@ -72,6 +77,7 @@ public InGameDialogActions(IFriendIgnoreListDialogFactory friendIgnoreListDialog
_tradeDialogFactory = tradeDialogFactory;
_boardDialogFactory = boardDialogFactory;
_sfxPlayer = sfxPlayer;
_statusLabelSetter = statusLabelSetter;
_shopDialogFactory = shopDialogFactory;
_questDialogFactory = questDialogFactory;
}
Expand Down Expand Up @@ -314,27 +320,31 @@ public void ShowBoardDialog()
dlg.DialogClosed += (_, _) => _activeDialogRepository.BoardDialog = Option.None<BoardDialog>();
_activeDialogRepository.BoardDialog = Option.Some(dlg);

UseDefaultDialogSounds(dlg);

dlg.Show();

UseDefaultDialogSounds(dlg);
});

// the vanilla client shows the status label any time the server sends the BOARD_OPEN packet
_statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, EOResourceID.BOARD_TOWN_BOARD_NOW_VIEWED);
}

private void UseDefaultDialogSounds(ScrollingListDialog dialog)
{
UseDefaultDialogSounds((BaseEODialog)dialog);

EventHandler handler = (_, _) => _sfxPlayer.PlaySfx(SoundEffectID.DialogButtonClick);
dialog.AddAction += handler;
dialog.BackAction += handler;
dialog.NextAction += handler;
dialog.HistoryAction += handler;
dialog.ProgressAction += handler;
foreach (var button in dialog.ChildControls.OfType<IXNAButton>())
button.OnClick += Handler;

void Handler(object sender, EventArgs e) => _sfxPlayer.PlaySfx(SoundEffectID.DialogButtonClick);
}

private void UseDefaultDialogSounds(BaseEODialog dialog)
{
dialog.DialogClosing += (_, _) => _sfxPlayer.PlaySfx(SoundEffectID.DialogButtonClick);

foreach (var textbox in dialog.ChildControls.OfType<IXNATextBox>())
textbox.OnGotFocus += (_, _) => _sfxPlayer.PlaySfx(SoundEffectID.TextBoxFocus);
}

private void UseQuestDialogSounds(QuestDialog dialog)
Expand Down
Loading

0 comments on commit 83325cd

Please sign in to comment.