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/Pal.Client.csproj b/Pal.Client/Pal.Client.csproj index b423f52..10baf2e 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 win-x64 @@ -18,6 +17,10 @@ true portable $(SolutionDir)=X:\ + false + false + false + false @@ -36,6 +39,9 @@ + + all + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -108,6 +114,13 @@ + + + $(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)] diff --git a/Pal.Client/Windows/AgreementWindow.cs b/Pal.Client/Windows/AgreementWindow.cs index 316ee49..6442805 100644 --- a/Pal.Client/Windows/AgreementWindow.cs +++ b/Pal.Client/Windows/AgreementWindow.cs @@ -5,6 +5,7 @@ using ECommons; using ImGuiNET; using System.Numerics; using Pal.Client.Configuration; +using Pal.Client.Extensions; using Pal.Client.Properties; namespace Pal.Client.Windows @@ -66,8 +67,10 @@ namespace Pal.Client.Windows ImGui.TextWrapped(Localization.Explanation_3); ImGui.TextWrapped(Localization.Explanation_4); - ImGui.RadioButton(Localization.Config_UploadMyDiscoveries_ShowOtherTraps, ref _choice, (int)EMode.Online); - ImGui.RadioButton(Localization.Config_NeverUploadDiscoveries_ShowMyTraps, ref _choice, (int)EMode.Offline); + PalImGui.RadioButtonWrapped(Localization.Config_UploadMyDiscoveries_ShowOtherTraps, ref _choice, + (int)EMode.Online); + PalImGui.RadioButtonWrapped(Localization.Config_NeverUploadDiscoveries_ShowMyTraps, ref _choice, + (int)EMode.Offline); ImGui.Separator(); diff --git a/Pal.Client/Windows/ConfigWindow.cs b/Pal.Client/Windows/ConfigWindow.cs index 5c7c44e..9c81c23 100644 --- a/Pal.Client/Windows/ConfigWindow.cs +++ b/Pal.Client/Windows/ConfigWindow.cs @@ -20,6 +20,7 @@ using System.Threading; using System.Threading.Tasks; using Dalamud.Game.Gui; using Microsoft.Extensions.Logging; +using Pal.Client.Extensions; using Pal.Client.Properties; using Pal.Client.Configuration; using Pal.Client.Database; @@ -229,7 +230,7 @@ namespace Pal.Client.Windows private void DrawCommunityTab(ref bool saveAndClose) { - if (BeginTabItemEx($"{Localization.ConfigTab_Community}###TabCommunity", + if (PalImGui.BeginTabItemWithFlags($"{Localization.ConfigTab_Community}###TabCommunity", _switchToCommunityTab ? ImGuiTabItemFlags.SetSelected : ImGuiTabItemFlags.None)) { _switchToCommunityTab = false; @@ -237,8 +238,9 @@ namespace Pal.Client.Windows ImGui.TextWrapped(Localization.Explanation_3); ImGui.TextWrapped(Localization.Explanation_4); - ImGui.RadioButton(Localization.Config_UploadMyDiscoveries_ShowOtherTraps, ref _mode, (int)EMode.Online); - ImGui.RadioButton(Localization.Config_NeverUploadDiscoveries_ShowMyTraps, ref _mode, + PalImGui.RadioButtonWrapped(Localization.Config_UploadMyDiscoveries_ShowOtherTraps, ref _mode, + (int)EMode.Online); + PalImGui.RadioButtonWrapped(Localization.Config_NeverUploadDiscoveries_ShowMyTraps, ref _mode, (int)EMode.Offline); saveAndClose = ImGui.Button(Localization.SaveAndClose); @@ -394,14 +396,16 @@ namespace Pal.Client.Windows if (_hoardConfig.Show) { - int hoardCoffers = memoryTerritory.Locations.Count(x => x.Type == MemoryLocation.EType.Hoard); + int hoardCoffers = + memoryTerritory.Locations.Count(x => x.Type == MemoryLocation.EType.Hoard); ImGui.Text($"{hoardCoffers} known hoard coffer{(hoardCoffers == 1 ? "" : "s")}"); } if (_silverConfig.Show) { int silverCoffers = - _floorService.EphemeralLocations.Count(x => x.Type == MemoryLocation.EType.SilverCoffer); + _floorService.EphemeralLocations.Count(x => + x.Type == MemoryLocation.EType.SilverCoffer); ImGui.Text( $"{silverCoffers} silver coffer{(silverCoffers == 1 ? "" : "s")} visible on current floor"); } @@ -423,21 +427,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 () => @@ -485,10 +474,7 @@ namespace Pal.Client.Windows CancellationTokenSource cts = new CancellationTokenSource(); _lastImportCts = cts; - Task.Run(async () => - { - _lastImport = await _importService.FindLast(cts.Token); - }, cts.Token); + Task.Run(async () => { _lastImport = await _importService.FindLast(cts.Token); }, cts.Token); } private void DoExport(string destinationPath) 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).