2022-10-26 18:43:24 +00:00
|
|
|
|
using Dalamud.Interface.Windowing;
|
|
|
|
|
using ImGuiNET;
|
|
|
|
|
using Pal.Common;
|
|
|
|
|
using Palace;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Numerics;
|
2023-02-10 19:48:14 +00:00
|
|
|
|
using Pal.Client.Properties;
|
2023-02-12 21:32:22 +00:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
using System.Reflection;
|
2022-10-26 18:43:24 +00:00
|
|
|
|
|
|
|
|
|
namespace Pal.Client.Windows
|
|
|
|
|
{
|
2023-02-15 22:51:35 +00:00
|
|
|
|
internal sealed class StatisticsWindow : Window, IDisposable, ILanguageChanged
|
2022-10-26 18:43:24 +00:00
|
|
|
|
{
|
2023-02-11 13:31:43 +00:00
|
|
|
|
private const string WindowId = "###PalacePalStats";
|
2023-02-15 22:17:19 +00:00
|
|
|
|
private readonly WindowSystem _windowSystem;
|
2023-02-11 20:10:45 +00:00
|
|
|
|
private readonly SortedDictionary<ETerritoryType, TerritoryStatistics> _territoryStatistics = new();
|
2022-10-26 18:43:24 +00:00
|
|
|
|
|
2023-02-15 22:17:19 +00:00
|
|
|
|
public StatisticsWindow(WindowSystem windowSystem)
|
|
|
|
|
: base(WindowId)
|
2022-10-26 18:43:24 +00:00
|
|
|
|
{
|
2023-02-15 22:17:19 +00:00
|
|
|
|
_windowSystem = windowSystem;
|
|
|
|
|
|
2023-02-11 13:31:43 +00:00
|
|
|
|
LanguageChanged();
|
2023-02-11 13:40:22 +00:00
|
|
|
|
|
2022-10-26 18:43:24 +00:00
|
|
|
|
Size = new Vector2(500, 500);
|
|
|
|
|
SizeCondition = ImGuiCond.FirstUseEver;
|
2023-02-04 23:12:24 +00:00
|
|
|
|
Flags = ImGuiWindowFlags.AlwaysAutoResize;
|
2022-10-26 18:43:24 +00:00
|
|
|
|
|
|
|
|
|
foreach (ETerritoryType territory in typeof(ETerritoryType).GetEnumValues())
|
|
|
|
|
{
|
2022-10-30 10:02:49 +00:00
|
|
|
|
_territoryStatistics[territory] = new TerritoryStatistics(territory.ToString());
|
2022-10-26 18:43:24 +00:00
|
|
|
|
}
|
2023-02-15 22:17:19 +00:00
|
|
|
|
|
|
|
|
|
_windowSystem.AddWindow(this);
|
2022-10-26 18:43:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-15 22:17:19 +00:00
|
|
|
|
public void Dispose()
|
|
|
|
|
=> _windowSystem.RemoveWindow(this);
|
|
|
|
|
|
2023-02-11 13:31:43 +00:00
|
|
|
|
public void LanguageChanged()
|
|
|
|
|
=> WindowName = $"{Localization.Palace_Pal} - {Localization.Statistics}{WindowId}";
|
|
|
|
|
|
2022-10-26 18:43:24 +00:00
|
|
|
|
public override void Draw()
|
|
|
|
|
{
|
2023-02-04 23:12:24 +00:00
|
|
|
|
if (ImGui.BeginTabBar("Tabs"))
|
|
|
|
|
{
|
2023-02-15 22:17:19 +00:00
|
|
|
|
DrawDungeonStats("Palace of the Dead", Localization.PalaceOfTheDead, ETerritoryType.Palace_1_10,
|
|
|
|
|
ETerritoryType.Palace_191_200);
|
|
|
|
|
DrawDungeonStats("Heaven on High", Localization.HeavenOnHigh, ETerritoryType.HeavenOnHigh_1_10,
|
|
|
|
|
ETerritoryType.HeavenOnHigh_91_100);
|
2023-02-04 23:12:24 +00:00
|
|
|
|
}
|
2022-11-30 10:39:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-11 13:17:26 +00:00
|
|
|
|
private void DrawDungeonStats(string id, string name, ETerritoryType minTerritory, ETerritoryType maxTerritory)
|
2022-11-30 10:39:40 +00:00
|
|
|
|
{
|
2023-02-11 13:17:26 +00:00
|
|
|
|
if (ImGui.BeginTabItem($"{name}###{id}"))
|
2022-10-26 18:43:24 +00:00
|
|
|
|
{
|
2023-02-15 22:17:19 +00:00
|
|
|
|
if (ImGui.BeginTable($"TrapHoardStatistics{id}", 4,
|
|
|
|
|
ImGuiTableFlags.Borders | ImGuiTableFlags.Resizable))
|
2022-10-26 18:43:24 +00:00
|
|
|
|
{
|
2023-02-10 19:48:14 +00:00
|
|
|
|
ImGui.TableSetupColumn(Localization.Statistics_TerritoryId);
|
|
|
|
|
ImGui.TableSetupColumn(Localization.Statistics_InstanceName);
|
|
|
|
|
ImGui.TableSetupColumn(Localization.Statistics_Traps);
|
|
|
|
|
ImGui.TableSetupColumn(Localization.Statistics_HoardCoffers);
|
2022-10-26 18:43:24 +00:00
|
|
|
|
ImGui.TableHeadersRow();
|
|
|
|
|
|
2023-02-15 22:17:19 +00:00
|
|
|
|
foreach (var (territoryType, stats) in _territoryStatistics
|
|
|
|
|
.Where(x => x.Key >= minTerritory && x.Key <= maxTerritory)
|
|
|
|
|
.OrderBy(x => x.Key.GetOrder() ?? (int)x.Key))
|
2022-10-26 18:43:24 +00:00
|
|
|
|
{
|
|
|
|
|
ImGui.TableNextRow();
|
2022-10-27 14:48:09 +00:00
|
|
|
|
if (ImGui.TableNextColumn())
|
|
|
|
|
ImGui.Text($"{(uint)territoryType}");
|
|
|
|
|
|
2022-10-26 18:43:24 +00:00
|
|
|
|
if (ImGui.TableNextColumn())
|
|
|
|
|
ImGui.Text(stats.TerritoryName);
|
|
|
|
|
|
|
|
|
|
if (ImGui.TableNextColumn())
|
|
|
|
|
ImGui.Text(stats.TrapCount?.ToString() ?? "-");
|
|
|
|
|
|
|
|
|
|
if (ImGui.TableNextColumn())
|
|
|
|
|
ImGui.Text(stats.HoardCofferCount?.ToString() ?? "-");
|
|
|
|
|
}
|
2023-02-15 22:17:19 +00:00
|
|
|
|
|
2022-10-26 18:43:24 +00:00
|
|
|
|
ImGui.EndTable();
|
|
|
|
|
}
|
2023-02-15 22:17:19 +00:00
|
|
|
|
|
2023-02-04 23:12:24 +00:00
|
|
|
|
ImGui.EndTabItem();
|
2022-10-26 18:43:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal void SetFloorData(IEnumerable<FloorStatistics> floorStatistics)
|
|
|
|
|
{
|
|
|
|
|
foreach (var territoryStatistics in _territoryStatistics.Values)
|
|
|
|
|
{
|
|
|
|
|
territoryStatistics.TrapCount = null;
|
|
|
|
|
territoryStatistics.HoardCofferCount = null;
|
|
|
|
|
}
|
2022-12-01 16:56:26 +00:00
|
|
|
|
|
2022-10-26 18:43:24 +00:00
|
|
|
|
foreach (var floor in floorStatistics)
|
|
|
|
|
{
|
2023-02-15 22:17:19 +00:00
|
|
|
|
if (_territoryStatistics.TryGetValue((ETerritoryType)floor.TerritoryType,
|
|
|
|
|
out TerritoryStatistics? territoryStatistics))
|
2022-10-26 18:43:24 +00:00
|
|
|
|
{
|
|
|
|
|
territoryStatistics.TrapCount = floor.TrapCount;
|
|
|
|
|
territoryStatistics.HoardCofferCount = floor.HoardCount;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-15 22:51:35 +00:00
|
|
|
|
private sealed class TerritoryStatistics
|
2022-10-26 18:43:24 +00:00
|
|
|
|
{
|
2023-02-15 22:17:19 +00:00
|
|
|
|
public string TerritoryName { get; }
|
2022-10-26 18:43:24 +00:00
|
|
|
|
public uint? TrapCount { get; set; }
|
|
|
|
|
public uint? HoardCofferCount { get; set; }
|
2022-10-30 10:02:49 +00:00
|
|
|
|
|
|
|
|
|
public TerritoryStatistics(string territoryName)
|
|
|
|
|
{
|
|
|
|
|
TerritoryName = territoryName;
|
|
|
|
|
}
|
2022-10-26 18:43:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|