-
Notifications
You must be signed in to change notification settings - Fork 16
/
StatusLabelSetter.cs
75 lines (65 loc) · 2.72 KB
/
StatusLabelSetter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System;
using AutomaticTypeMapper;
using EOLib.Localization;
namespace EndlessClient.HUD
{
[AutoMappedType]
public class StatusLabelSetter : IStatusLabelSetter
{
private readonly IStatusLabelTextRepository _statusLabelTextRepository;
private readonly ILocalizedStringFinder _localizedStringFinder;
public StatusLabelSetter(IStatusLabelTextRepository statusLabelTextRepository,
ILocalizedStringFinder localizedStringFinder)
{
_statusLabelTextRepository = statusLabelTextRepository;
_localizedStringFinder = localizedStringFinder;
}
public void SetStatusLabel(EOResourceID type, EOResourceID text, string appended = "")
{
CheckStatusLabelType(type);
SetStatusLabelText(_localizedStringFinder.GetString(type),
_localizedStringFinder.GetString(text),
appended);
}
public void SetStatusLabel(EOResourceID type, string prepended, EOResourceID text)
{
CheckStatusLabelType(type);
SetStatusLabelText(_localizedStringFinder.GetString(type),
prepended,
_localizedStringFinder.GetString(text));
}
public void SetStatusLabel(EOResourceID type, string text)
{
CheckStatusLabelType(type);
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);
}
private void SetStatusLabelText(string type, string text, string extra = "")
{
_statusLabelTextRepository.StatusText = $"[ {type} ] {text}{extra}";
_statusLabelTextRepository.SetTime = DateTime.Now;
}
private void CheckStatusLabelType(EOResourceID type)
{
switch (type)
{
case EOResourceID.STATUS_LABEL_TYPE_ACTION:
case EOResourceID.STATUS_LABEL_TYPE_BUTTON:
case EOResourceID.STATUS_LABEL_TYPE_INFORMATION:
case EOResourceID.STATUS_LABEL_TYPE_WARNING:
case EOResourceID.STATUS_LABEL_TYPE_ITEM:
case EOResourceID.SKILLMASTER_WORD_SPELL:
break;
default: throw new ArgumentOutOfRangeException(nameof(type), "Use either ACTION, BUTTION, INFORMATION, WARNING, ITEM, or SPELL for this.");
}
}
}
}