Skip to content

Commit

Permalink
Show NPC name in status bar when clicking the NPC
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmoffat committed Apr 10, 2022
1 parent 3e0b86e commit a3e4d9f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
8 changes: 8 additions & 0 deletions EndlessClient/Controllers/NPCInteractionController.cs
@@ -1,10 +1,12 @@
using AutomaticTypeMapper;
using EndlessClient.Dialogs;
using EndlessClient.Dialogs.Actions;
using EndlessClient.HUD;
using EndlessClient.Input;
using EOLib.Domain.Interact;
using EOLib.Domain.NPC;
using EOLib.IO.Repositories;
using EOLib.Localization;
using System.Linq;

namespace EndlessClient.Controllers
Expand All @@ -14,18 +16,21 @@ public class NPCInteractionController : INPCInteractionController
{
private readonly IMapNPCActions _mapNpcActions;
private readonly IInGameDialogActions _inGameDialogActions;
private readonly IStatusLabelSetter _statusLabelSetter;
private readonly IENFFileProvider _enfFileProvider;
private readonly IActiveDialogProvider _activeDialogProvider;
private readonly IUserInputRepository _userInputRepository;

public NPCInteractionController(IMapNPCActions mapNpcActions,
IInGameDialogActions inGameDialogActions,
IStatusLabelSetter statusLabelSetter,
IENFFileProvider enfFileProvider,
IActiveDialogProvider activeDialogProvider,
IUserInputRepository userInputRepository)
{
_mapNpcActions = mapNpcActions;
_inGameDialogActions = inGameDialogActions;
_statusLabelSetter = statusLabelSetter;
_enfFileProvider = enfFileProvider;
_activeDialogProvider = activeDialogProvider;
_userInputRepository = userInputRepository;
Expand All @@ -38,6 +43,9 @@ public void ShowNPCDialog(INPC npc)

var data = _enfFileProvider.ENFFile[npc.ID];

// there is no "NPC" text in the localized files
_statusLabelSetter.SetStatusLabel($"[ NPC ] {data.Name}");

switch(data.Type)
{
case EOLib.IO.NPCType.Shop:
Expand Down
7 changes: 5 additions & 2 deletions EndlessClient/HUD/IStatusLabelSetter.cs
@@ -1,13 +1,16 @@
using EOLib.Localization;
using EOLib.Domain.Interact.Quest;
using EOLib.Localization;

namespace EndlessClient.HUD
{
public interface IStatusLabelSetter
public interface IStatusLabelSetter : IStatusLabelNotifier
{
void SetStatusLabel(EOResourceID type, EOResourceID text, string appended = "");

void SetStatusLabel(EOResourceID type, string prepended, EOResourceID text);

void SetStatusLabel(EOResourceID type, string text);

void SetStatusLabel(string text);
}
}
9 changes: 7 additions & 2 deletions EndlessClient/HUD/StatusLabelSetter.cs
@@ -1,12 +1,11 @@
using System;
using AutomaticTypeMapper;
using EOLib.Domain.Interact.Quest;
using EOLib.Localization;

namespace EndlessClient.HUD
{
[AutoMappedType]
public class StatusLabelSetter : IStatusLabelSetter, IStatusLabelNotifier
public class StatusLabelSetter : IStatusLabelSetter
{
private readonly IStatusLabelTextRepository _statusLabelTextRepository;
private readonly ILocalizedStringFinder _localizedStringFinder;
Expand Down Expand Up @@ -41,6 +40,12 @@ public void SetStatusLabel(EOResourceID type, string text)
SetStatusLabelText(_localizedStringFinder.GetString(type), text);
}

public void SetStatusLabel(string text)
{
_statusLabelTextRepository.StatusText = text;
_statusLabelTextRepository.SetTime = DateTime.Now;
}

public void ShowWarning(string message)
{
SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, message);
Expand Down

0 comments on commit a3e4d9f

Please sign in to comment.