From 7c968fa9d46bc6344133fc80ce5df2111b629208 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Tue, 21 Feb 2023 14:07:52 +0100 Subject: [PATCH 1/4] Update README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index a7730e2..43b6136 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,6 @@ Please check [Splatoon's Installation Instructions](https://github.com/Nightmare ## Translation Please feel free to help by [translating this plugin into your language](https://crowdin.com/project/palace-pal). + +If you want to translate the plugin into a language that is currently not enabled, +[please create a new issue](https://github.com/carvelli/PalacePal/issues/new). From 7b5bb3ee3af61a1724f9a89f65e1a9e4d43d3554 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Tue, 21 Feb 2023 14:58:30 +0100 Subject: [PATCH 2/4] Use textwrap for radio buttons --- Pal.Client/Extensions/PalImGui.cs | 36 +++++++++++++++++++++++++++ Pal.Client/Windows/AgreementWindow.cs | 5 ++-- Pal.Client/Windows/ConfigWindow.cs | 22 +++------------- 3 files changed, 43 insertions(+), 20 deletions(-) create mode 100644 Pal.Client/Extensions/PalImGui.cs diff --git a/Pal.Client/Extensions/PalImGui.cs b/Pal.Client/Extensions/PalImGui.cs new file mode 100644 index 0000000..e6215c8 --- /dev/null +++ b/Pal.Client/Extensions/PalImGui.cs @@ -0,0 +1,36 @@ +using System; +using System.Runtime.InteropServices; +using System.Text; +using ImGuiNET; + +namespace Pal.Client.Extensions +{ + internal static class PalImGui + { + /// + /// None of the default BeginTabItem methods allow using flags without making the tab have a close button for some reason. + /// + internal static unsafe bool BeginTabItemWithFlags(string label, ImGuiTabItemFlags flags) + { + int labelLength = Encoding.UTF8.GetByteCount(label); + byte* labelPtr = stackalloc byte[labelLength + 1]; + byte[] labelBytes = Encoding.UTF8.GetBytes(label); + + Marshal.Copy(labelBytes, 0, (IntPtr)labelPtr, labelLength); + labelPtr[labelLength] = 0; + + return ImGuiNative.igBeginTabItem(labelPtr, null, flags) != 0; + } + + public static void RadioButtonWrapped(string label, ref int choice, int value) + { + ImGui.BeginGroup(); + ImGui.RadioButton($"##radio{value}", value == choice); + ImGui.SameLine(); + ImGui.TextWrapped(label); + ImGui.EndGroup(); + if (ImGui.IsItemClicked()) + choice = value; + } + } +} diff --git a/Pal.Client/Windows/AgreementWindow.cs b/Pal.Client/Windows/AgreementWindow.cs index 3cd3a29..377ac64 100644 --- a/Pal.Client/Windows/AgreementWindow.cs +++ b/Pal.Client/Windows/AgreementWindow.cs @@ -3,6 +3,7 @@ using Dalamud.Interface.Windowing; using ECommons; using ImGuiNET; using System.Numerics; +using Pal.Client.Extensions; using Pal.Client.Properties; namespace Pal.Client.Windows @@ -49,8 +50,8 @@ namespace Pal.Client.Windows ImGui.TextWrapped(Localization.Explanation_3); ImGui.TextWrapped(Localization.Explanation_4); - ImGui.RadioButton(Localization.Config_UploadMyDiscoveries_ShowOtherTraps, ref _choice, (int)Configuration.EMode.Online); - ImGui.RadioButton(Localization.Config_NeverUploadDiscoveries_ShowMyTraps, ref _choice, (int)Configuration.EMode.Offline); + PalImGui.RadioButtonWrapped(Localization.Config_UploadMyDiscoveries_ShowOtherTraps, ref _choice, (int)Configuration.EMode.Online); + PalImGui.RadioButtonWrapped(Localization.Config_NeverUploadDiscoveries_ShowMyTraps, ref _choice, (int)Configuration.EMode.Offline); ImGui.Separator(); diff --git a/Pal.Client/Windows/ConfigWindow.cs b/Pal.Client/Windows/ConfigWindow.cs index 7787296..dbf0623 100644 --- a/Pal.Client/Windows/ConfigWindow.cs +++ b/Pal.Client/Windows/ConfigWindow.cs @@ -18,6 +18,7 @@ using System.Runtime.InteropServices; using System.Text; using System.Threading; using System.Threading.Tasks; +using Pal.Client.Extensions; using Pal.Client.Properties; namespace Pal.Client.Windows @@ -183,15 +184,15 @@ namespace Pal.Client.Windows private void DrawCommunityTab(ref bool saveAndClose) { - if (BeginTabItemEx($"{Localization.ConfigTab_Community}###TabCommunity", _switchToCommunityTab ? ImGuiTabItemFlags.SetSelected : ImGuiTabItemFlags.None)) + if (PalImGui.BeginTabItemWithFlags($"{Localization.ConfigTab_Community}###TabCommunity", _switchToCommunityTab ? ImGuiTabItemFlags.SetSelected : ImGuiTabItemFlags.None)) { _switchToCommunityTab = false; ImGui.TextWrapped(Localization.Explanation_3); ImGui.TextWrapped(Localization.Explanation_4); - ImGui.RadioButton(Localization.Config_UploadMyDiscoveries_ShowOtherTraps, ref _mode, (int)Configuration.EMode.Online); - ImGui.RadioButton(Localization.Config_NeverUploadDiscoveries_ShowMyTraps, ref _mode, (int)Configuration.EMode.Offline); + PalImGui.RadioButtonWrapped(Localization.Config_UploadMyDiscoveries_ShowOtherTraps, ref _mode, (int)Configuration.EMode.Online); + PalImGui.RadioButtonWrapped(Localization.Config_NeverUploadDiscoveries_ShowMyTraps, ref _mode, (int)Configuration.EMode.Offline); saveAndClose = ImGui.Button(Localization.SaveAndClose); ImGui.Separator(); @@ -359,21 +360,6 @@ namespace Pal.Client.Windows } } - /// - /// None of the default BeginTabItem methods allow using flags without making the tab have a close button for some reason. - /// - private static unsafe bool BeginTabItemEx(string label, ImGuiTabItemFlags flags) - { - int labelLength = Encoding.UTF8.GetByteCount(label); - byte* labelPtr = stackalloc byte[labelLength + 1]; - byte[] labelBytes = Encoding.UTF8.GetBytes(label); - - Marshal.Copy(labelBytes, 0, (IntPtr)labelPtr, labelLength); - labelPtr[labelLength] = 0; - - return ImGuiNative.igBeginTabItem(labelPtr, null, flags) != 0; - } - internal void TestConnection() { Task.Run(async () => From d1fdd1ce12f52c272b5c791a673e458c70916ab1 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Tue, 21 Feb 2023 16:04:51 +0100 Subject: [PATCH 3/4] Determine client build version automatically from git tag --- Pal.Client/Pal.Client.csproj | 15 +++++++++++++-- Pal.Client/Properties/AssemblyInfo.cs | 8 ++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 Pal.Client/Properties/AssemblyInfo.cs diff --git a/Pal.Client/Pal.Client.csproj b/Pal.Client/Pal.Client.csproj index 86feeac..990d0aa 100644 --- a/Pal.Client/Pal.Client.csproj +++ b/Pal.Client/Pal.Client.csproj @@ -3,7 +3,6 @@ net7.0-windows 11.0 - 2.16 enable @@ -14,6 +13,10 @@ true false true + false + false + false + false @@ -38,6 +41,7 @@ + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -96,7 +100,14 @@ Localization.resx - + + + + $(GitSemVerMajor).$(GitSemVerMinor) + $(Version) + + + diff --git a/Pal.Client/Properties/AssemblyInfo.cs b/Pal.Client/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..4b66f84 --- /dev/null +++ b/Pal.Client/Properties/AssemblyInfo.cs @@ -0,0 +1,8 @@ +using System.Reflection; + +[assembly: AssemblyVersion(ThisAssembly.Git.SemVer.Major + "." + ThisAssembly.Git.SemVer.Minor)] +[assembly: AssemblyFileVersion(ThisAssembly.Git.SemVer.Major + "." + ThisAssembly.Git.SemVer.Minor)] +[assembly: AssemblyInformationalVersion( + ThisAssembly.Git.SemVer.Major + "." + + ThisAssembly.Git.SemVer.Minor + "+" + + ThisAssembly.Git.Commit)] From ff02b1f03c473dc2d71433353e5b38ec5add24ec Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Tue, 21 Feb 2023 16:14:56 +0100 Subject: [PATCH 4/4] Downgrade GitInfo to avoid extra dependency dll in dist --- Pal.Client/Pal.Client.csproj | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Pal.Client/Pal.Client.csproj b/Pal.Client/Pal.Client.csproj index 990d0aa..717eaa7 100644 --- a/Pal.Client/Pal.Client.csproj +++ b/Pal.Client/Pal.Client.csproj @@ -41,7 +41,9 @@ - + + all + all runtime; build; native; contentfiles; analyzers; buildtransitive