-
Notifications
You must be signed in to change notification settings - Fork 16
/
SessionExpDialog.cs
126 lines (106 loc) · 5.72 KB
/
SessionExpDialog.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
using System;
using EndlessClient.Dialogs.Services;
using EOLib;
using EOLib.Domain.Character;
using EOLib.Graphics;
using EOLib.Localization;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using XNAControls;
namespace EndlessClient.Dialogs
{
public class SessionExpDialog : BaseEODialog
{
private static readonly Rectangle _signalSource;
private static readonly Rectangle _iconSource;
private readonly Texture2D _icons;
static SessionExpDialog()
{
_signalSource = new Rectangle(0, 15, 15, 15);
_iconSource = new Rectangle(0, 0, 15, 15);
}
public SessionExpDialog(INativeGraphicsManager nativeGraphicsManager,
IEODialogButtonService dialogButtonService,
ILocalizedStringFinder localizedStringFinder,
ICharacterProvider characterProvider,
IExperienceTableProvider expTableProvider,
ICharacterSessionProvider characterSessionProvider)
: base(nativeGraphicsManager, isInGame: true)
{
BackgroundTexture = GraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 61);
_icons = GraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 68, true);
var okButton = new XNAButton(dialogButtonService.SmallButtonSheet,
new Vector2(98, 214),
dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok),
dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Ok));
okButton.OnClick += (_, _) => Close(XNADialogResult.OK);
okButton.SetParentControl(this);
okButton.Initialize();
var title = new XNALabel(Constants.FontSize08pt5)
{
DrawPosition = new Vector2(20, 16),
AutoSize = false,
Text = localizedStringFinder.GetString(EOResourceID.DIALOG_TITLE_PERFORMANCE),
ForeColor = ColorConstants.LightGrayText
};
title.SetParentControl(this);
title.Initialize();
XNALabel[] leftSide = new XNALabel[8], rightSide = new XNALabel[8];
for (int i = 0; i < leftSide.Length; i++)
{
leftSide[i] = new XNALabel(Constants.FontSize08pt5)
{
DrawPosition = new Vector2(38, 48 + 16 * i),
AutoSize = false,
ForeColor = ColorConstants.LightGrayText
};
leftSide[i].SetParentControl(this);
leftSide[i].Initialize();
rightSide[i] = new XNALabel(Constants.FontSize08pt5)
{
DrawPosition = new Vector2(158, 48 + 16 * i),
AutoSize = false,
ForeColor = ColorConstants.LightGrayText
};
rightSide[i].SetParentControl(this);
rightSide[i].Initialize();
}
leftSide[0].Text = localizedStringFinder.GetString(EOResourceID.DIALOG_PERFORMANCE_TOTALEXP);
leftSide[1].Text = localizedStringFinder.GetString(EOResourceID.DIALOG_PERFORMANCE_NEXT_LEVEL);
leftSide[2].Text = localizedStringFinder.GetString(EOResourceID.DIALOG_PERFORMANCE_EXP_NEEDED);
leftSide[3].Text = localizedStringFinder.GetString(EOResourceID.DIALOG_PERFORMANCE_TODAY_EXP);
leftSide[4].Text = localizedStringFinder.GetString(EOResourceID.DIALOG_PERFORMANCE_TOTAL_AVG);
leftSide[5].Text = localizedStringFinder.GetString(EOResourceID.DIALOG_PERFORMANCE_TODAY_AVG);
leftSide[6].Text = localizedStringFinder.GetString(EOResourceID.DIALOG_PERFORMANCE_BEST_KILL);
leftSide[7].Text = localizedStringFinder.GetString(EOResourceID.DIALOG_PERFORMANCE_LAST_KILL);
var c = characterProvider.MainCharacter;
var level = c.Stats[CharacterStat.Level];
var exp = c.Stats[CharacterStat.Experience];
var usage = c.Stats[CharacterStat.Usage];
rightSide[0].Text = $"{exp}";
rightSide[1].Text = $"{expTableProvider.ExperienceByLevel[level + 1]}";
rightSide[2].Text = $"{expTableProvider.ExperienceByLevel[level + 1] - exp}";
rightSide[3].Text = $"{characterSessionProvider.TodayTotalExp}";
rightSide[4].Text = $"{(int)(exp / (usage/60.0))}";
int sessionTimeMinutes = (int)(DateTime.Now - characterSessionProvider.SessionStartTime).TotalMinutes;
rightSide[5].Text = $"{(sessionTimeMinutes > 0 ? (int)(characterSessionProvider.TodayTotalExp / (sessionTimeMinutes/60.0)) : 0)}";
rightSide[6].Text = $"{characterSessionProvider.BestKillExp}";
rightSide[7].Text = $"{characterSessionProvider.LastKillExp}";
Array.ForEach(leftSide, lbl => lbl.ResizeBasedOnText());
Array.ForEach(rightSide, lbl => lbl.ResizeBasedOnText());
CenterInGameView();
if (!Game.Window.AllowUserResizing)
DrawPosition = new Vector2(DrawPosition.X, 15);
}
protected override void OnDrawControl(GameTime gameTime)
{
base.OnDrawControl(gameTime);
_spriteBatch.Begin();
for (int i = 0; i < 8; i++)
_spriteBatch.Draw(_icons, new Vector2(DrawPositionWithParentOffset.X + 18, DrawPositionWithParentOffset.Y + 47 + 16 * i), _iconSource, Color.White);
for(int i = 0; i < 3; i++)
_spriteBatch.Draw(_icons, new Vector2(DrawPositionWithParentOffset.X + 142, DrawPositionWithParentOffset.Y + 48 + 16 * i), _signalSource, Color.White);
_spriteBatch.End();
}
}
}