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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
using System;
using System.Numerics;
using Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
using Dalamud.Game.Addon.Lifecycle;
using Dalamud.Interface.Windowing;
using ImGuiNET;
using Malmstone.Services;
using Malmstone.Utils;
namespace Malmstone.Windows
{
public class MainWindow : Window, IDisposable
{
private Plugin Plugin;
private PvPService PvPService;
private int TargetSeriesRank;
// Cache-related fields
private int _lastSeriesRank;
private int _lastTargetSeriesRank;
private int _lastSeriesExperience;
private MalmstoneXPCalculator.XpCalculationResult _cachedXpResult;
public MainWindow(Plugin plugin)
: base("Malmstone")
{
SizeConstraints = new WindowSizeConstraints
{
MinimumSize = new Vector2(460, 510),
MaximumSize = new Vector2(float.MaxValue, float.MaxValue)
};
Plugin = plugin;
PvPService = new PvPService();
TargetSeriesRank = Plugin.Configuration.DefaultTargetRankProperty;
}
public void Dispose() { }
public override void Draw()
{
if (!IsOpen) return;
var pvpInfo = PvPService.GetPvPSeriesInfo();
if (pvpInfo != null)
{
ImGui.Text($"Current Series Level: {pvpInfo.CurrentSeriesRank}");
ImGui.Text($"Current Level Experience Progress: {pvpInfo.SeriesExperience} XP");
ImGui.Spacing();
ImGui.Text("Target Series Level:");
ImGui.InputInt("##TargetSeriesRank", ref TargetSeriesRank, 1);
// Bounds checking to ensure no overflows
if (TargetSeriesRank < 1) TargetSeriesRank = 1;
if (TargetSeriesRank > 107397) TargetSeriesRank = 107397;
if (TargetSeriesRank <= pvpInfo.CurrentSeriesRank) TargetSeriesRank = pvpInfo.CurrentSeriesRank + 1;
ImGui.Spacing();
ImGui.Separator();
// Only recalculate if the relevant data has changed
if (pvpInfo.CurrentSeriesRank != _lastSeriesRank ||
TargetSeriesRank != _lastTargetSeriesRank ||
pvpInfo.SeriesExperience != _lastSeriesExperience)
{
_cachedXpResult = MalmstoneXPCalculator.CalculateXp(pvpInfo.CurrentSeriesRank, TargetSeriesRank, pvpInfo.SeriesExperience);
_lastSeriesRank = pvpInfo.CurrentSeriesRank;
_lastTargetSeriesRank = TargetSeriesRank;
_lastSeriesExperience = pvpInfo.SeriesExperience;
}
var xpResult = _cachedXpResult;
ImGui.Spacing();
ImGui.Text($"You have {xpResult.RemainingXp} remaining series EXP to go until you reach level {xpResult.TargetLevel}");
ImGui.Spacing();
ImGui.Separator();
// Crystalline Conflict Section
ImGui.TextColored(new Vector4(0.6f, 0.8f, 1f, 1f), "Crystalline Conflict");
ImGui.Spacing();
ImGui.BulletText($"Win: {xpResult.CrystallineConflictWin} " + (xpResult.CrystallineConflictWin == 1 ? "time" : "times"));
ImGui.BulletText($"Lose: {xpResult.CrystallineConflictLose} " + (xpResult.CrystallineConflictLose == 1 ? "time" : "times"));
ImGui.Spacing();
ImGui.Separator();
// Frontlines Section
ImGui.TextColored(new Vector4(0.8f, 0.6f, 0.6f, 1f), "Frontlines");
ImGui.Spacing();
ImGui.BulletText($"Take 1st Place: {xpResult.FrontlineWin} " + (xpResult.FrontlineWin == 1 ? "time" : "times"));
ImGui.BulletText($"Take 2nd Place: {xpResult.FrontlineLose2nd} " + (xpResult.FrontlineLose2nd == 1 ? "time" : "times"));
ImGui.BulletText($"Take 3rd Place: {xpResult.FrontlineLose3rd} " + (xpResult.FrontlineLose3rd == 1 ? "time" : "times"));
// Frontlines Roulette Section
ImGui.TextColored(new Vector4(0.8f, 0.6f, 0.6f, 1f), "Frontlines (Roulette)");
ImGui.Spacing();
ImGui.BulletText($"Take 1st Place: {xpResult.FrontlineDailyWin} " + (xpResult.FrontlineDailyWin == 1 ? "time" : "times"));
ImGui.BulletText($"Take 2nd Place: {xpResult.FrontlineDailyLose2nd} " + (xpResult.FrontlineDailyLose2nd == 1 ? "time" : "times"));
ImGui.BulletText($"Take 3rd Place: {xpResult.FrontlineDailyLose3rd} " + (xpResult.FrontlineDailyLose3rd == 1 ? "time" : "times"));
ImGui.Spacing();
ImGui.Separator();
// Rival Wings Section
ImGui.TextColored(new Vector4(0.6f, 0.8f, 0.6f, 1f), "Rival Wings");
ImGui.Spacing();
ImGui.BulletText($"Win: {xpResult.RivalWingsWin} " + (xpResult.RivalWingsWin == 1 ? "time" : "times"));
ImGui.BulletText($"Lose: {xpResult.RivalWingsLose} " + (xpResult.RivalWingsLose == 1 ? "time" : "times"));
ImGui.Separator();
ImGui.Spacing();
if (ImGui.Button("Settings"))
Plugin.ToggleConfigUI();
ImGui.SameLine();
if (pvpInfo.CurrentSeriesRank != pvpInfo.ClaimedSeriesRank)
{
ImGui.Text("Don't forget to claim your Series Malmstone rewards!");
}
}
else
{
ImGui.Text("PvP Profile is not loaded.");
}
}
public void OnOpenPVPRewardWindow(AddonEvent eventType, AddonArgs addonInfo)
{
IsOpen = true;
}
public void OnClosePVPRewardWindow(AddonEvent eventType, AddonArgs addonInfo)
{
IsOpen = false;
}
}
}
|