From f9cbf0494abd83e63b25ca1607fd063488829d99 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Sun, 12 Feb 2023 22:32:22 +0100 Subject: [PATCH] Fix HoH 31-90 display names --- .github/workflows/build.yml | 2 ++ Pal.Client/Windows/StatisticsWindow.cs | 9 ++++---- Pal.Common/ETerritoryType.cs | 32 ++++++++++++++++++-------- Pal.Common/EnumExtensions.cs | 16 +++++++++++++ 4 files changed, 44 insertions(+), 15 deletions(-) create mode 100644 Pal.Common/EnumExtensions.cs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b02bd02..dcba9a3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,6 +11,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + with: + submodules: true - name: Setup .NET SDK uses: actions/setup-dotnet@v3 diff --git a/Pal.Client/Windows/StatisticsWindow.cs b/Pal.Client/Windows/StatisticsWindow.cs index 7aed58e..03eabdc 100644 --- a/Pal.Client/Windows/StatisticsWindow.cs +++ b/Pal.Client/Windows/StatisticsWindow.cs @@ -1,16 +1,15 @@ using Dalamud.Interface.Windowing; using ImGuiNET; -using Lumina.Excel.GeneratedSheets; using Pal.Common; using Palace; using System; using System.Collections.Generic; -using System.Data.Common; using System.Linq; using System.Numerics; -using System.Text; -using System.Threading.Tasks; using Pal.Client.Properties; +using System.ComponentModel.DataAnnotations; +using System.Runtime.CompilerServices; +using System.Reflection; namespace Pal.Client.Windows { @@ -57,7 +56,7 @@ namespace Pal.Client.Windows ImGui.TableSetupColumn(Localization.Statistics_HoardCoffers); ImGui.TableHeadersRow(); - foreach (var (territoryType, stats) in _territoryStatistics.Where(x => x.Key >= minTerritory && x.Key <= maxTerritory)) + foreach (var (territoryType, stats) in _territoryStatistics.Where(x => x.Key >= minTerritory && x.Key <= maxTerritory).OrderBy(x => x.Key.GetOrder() ?? (int)x.Key)) { ImGui.TableNextRow(); if (ImGui.TableNextColumn()) diff --git a/Pal.Common/ETerritoryType.cs b/Pal.Common/ETerritoryType.cs index 674a4cc..9796f86 100644 --- a/Pal.Common/ETerritoryType.cs +++ b/Pal.Common/ETerritoryType.cs @@ -1,4 +1,6 @@ -namespace Pal.Common +using System.ComponentModel.DataAnnotations; + +namespace Pal.Common { public enum ETerritoryType : ushort { @@ -23,15 +25,25 @@ Palace_181_190, Palace_191_200, + [Display(Order = 1)] HeavenOnHigh_1_10 = 770, - HeavenOnHigh_11_20, - HeavenOnHigh_21_30, - HeavenOnHigh_31_40, - HeavenOnHigh_41_50, - HeavenOnHigh_51_60, - HeavenOnHigh_61_70 = 782, - HeavenOnHigh_71_80, - HeavenOnHigh_81_90, - HeavenOnHigh_91_100 + [Display(Order = 2)] + HeavenOnHigh_11_20 = 771, + [Display(Order = 3)] + HeavenOnHigh_21_30 = 772, + [Display(Order = 4)] + HeavenOnHigh_31_40 = 782, + [Display(Order = 5)] + HeavenOnHigh_41_50 = 773, + [Display(Order = 6)] + HeavenOnHigh_51_60 = 783, + [Display(Order = 7)] + HeavenOnHigh_61_70 = 774, + [Display(Order = 8)] + HeavenOnHigh_71_80 = 784, + [Display(Order = 9)] + HeavenOnHigh_81_90 = 775, + [Display(Order = 10)] + HeavenOnHigh_91_100 = 785 } } diff --git a/Pal.Common/EnumExtensions.cs b/Pal.Common/EnumExtensions.cs new file mode 100644 index 0000000..e978d8e --- /dev/null +++ b/Pal.Common/EnumExtensions.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations; +using System.Reflection; + +namespace Pal.Common +{ + public static class EnumExtensions + { + public static int? GetOrder(this Enum e) + { + Type type = e.GetType(); + MemberInfo field = type.GetMember(e.ToString()).Single(); + DisplayAttribute? attribute = field.GetCustomAttributes(typeof(DisplayAttribute), false).Cast().FirstOrDefault(); + return attribute?.Order; + } + } +}