Merge branch 'master' into new-config-and-data

# Conflicts:
#	Pal.Client/Pal.Client.csproj
#	Pal.Client/Windows/AgreementWindow.cs
#	Pal.Client/Windows/ConfigWindow.cs
rendering
Liza 2023-02-21 16:30:16 +01:00
commit 810aa30cf9
6 changed files with 76 additions and 27 deletions

View File

@ -0,0 +1,36 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
using ImGuiNET;
namespace Pal.Client.Extensions
{
internal static class PalImGui
{
/// <summary>
/// None of the default BeginTabItem methods allow using flags without making the tab have a close button for some reason.
/// </summary>
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;
}
}
}

View File

@ -3,7 +3,6 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework> <TargetFramework>net7.0-windows</TargetFramework>
<LangVersion>11.0</LangVersion> <LangVersion>11.0</LangVersion>
<Version>2.16</Version>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<RuntimeIdentifier>win-x64</RuntimeIdentifier> <RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup> </PropertyGroup>
@ -18,6 +17,10 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>portable</DebugType> <DebugType>portable</DebugType>
<PathMap Condition="$(SolutionDir) != ''">$(SolutionDir)=X:\</PathMap> <PathMap Condition="$(SolutionDir) != ''">$(SolutionDir)=X:\</PathMap>
<GitVersion>false</GitVersion>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'"> <PropertyGroup Condition="'$(Configuration)' == 'Release'">
@ -36,6 +39,9 @@
<PackageReference Include="DalamudPackager" Version="2.1.10" /> <PackageReference Include="DalamudPackager" Version="2.1.10" />
<PackageReference Include="Google.Protobuf" Version="3.21.12" /> <PackageReference Include="Google.Protobuf" Version="3.21.12" />
<PackageReference Include="Grpc.Net.Client" Version="2.51.0" /> <PackageReference Include="Grpc.Net.Client" Version="2.51.0" />
<PackageReference Include="GitInfo" Version="2.3.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Grpc.Tools" Version="2.51.0"> <PackageReference Include="Grpc.Tools" Version="2.51.0">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@ -108,6 +114,13 @@
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<Target Name="PopulateInfo" DependsOnTargets="GitVersion" BeforeTargets="GetAssemblyVersion;GenerateNuspec;GetPackageContents">
<PropertyGroup>
<Version>$(GitSemVerMajor).$(GitSemVerMinor)</Version>
<PackageVersion>$(Version)</PackageVersion>
</PropertyGroup>
</Target>
<Target Name="RenameLatestZip" AfterTargets="PackagePlugin" Condition="'$(Configuration)' == 'Release'"> <Target Name="RenameLatestZip" AfterTargets="PackagePlugin" Condition="'$(Configuration)' == 'Release'">
<Exec Command="rename &quot;$(OutDir)$(AssemblyName)\latest.zip&quot; &quot;$(AssemblyName)-$(Version).zip&quot;" /> <Exec Command="rename &quot;$(OutDir)$(AssemblyName)\latest.zip&quot; &quot;$(AssemblyName)-$(Version).zip&quot;" />
</Target> </Target>

View File

@ -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)]

View File

@ -5,6 +5,7 @@ using ECommons;
using ImGuiNET; using ImGuiNET;
using System.Numerics; using System.Numerics;
using Pal.Client.Configuration; using Pal.Client.Configuration;
using Pal.Client.Extensions;
using Pal.Client.Properties; using Pal.Client.Properties;
namespace Pal.Client.Windows namespace Pal.Client.Windows
@ -66,8 +67,10 @@ namespace Pal.Client.Windows
ImGui.TextWrapped(Localization.Explanation_3); ImGui.TextWrapped(Localization.Explanation_3);
ImGui.TextWrapped(Localization.Explanation_4); ImGui.TextWrapped(Localization.Explanation_4);
ImGui.RadioButton(Localization.Config_UploadMyDiscoveries_ShowOtherTraps, ref _choice, (int)EMode.Online); PalImGui.RadioButtonWrapped(Localization.Config_UploadMyDiscoveries_ShowOtherTraps, ref _choice,
ImGui.RadioButton(Localization.Config_NeverUploadDiscoveries_ShowMyTraps, ref _choice, (int)EMode.Offline); (int)EMode.Online);
PalImGui.RadioButtonWrapped(Localization.Config_NeverUploadDiscoveries_ShowMyTraps, ref _choice,
(int)EMode.Offline);
ImGui.Separator(); ImGui.Separator();

View File

@ -20,6 +20,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Dalamud.Game.Gui; using Dalamud.Game.Gui;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Pal.Client.Extensions;
using Pal.Client.Properties; using Pal.Client.Properties;
using Pal.Client.Configuration; using Pal.Client.Configuration;
using Pal.Client.Database; using Pal.Client.Database;
@ -229,7 +230,7 @@ namespace Pal.Client.Windows
private void DrawCommunityTab(ref bool saveAndClose) 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 ? ImGuiTabItemFlags.SetSelected : ImGuiTabItemFlags.None))
{ {
_switchToCommunityTab = false; _switchToCommunityTab = false;
@ -237,8 +238,9 @@ namespace Pal.Client.Windows
ImGui.TextWrapped(Localization.Explanation_3); ImGui.TextWrapped(Localization.Explanation_3);
ImGui.TextWrapped(Localization.Explanation_4); ImGui.TextWrapped(Localization.Explanation_4);
ImGui.RadioButton(Localization.Config_UploadMyDiscoveries_ShowOtherTraps, ref _mode, (int)EMode.Online); PalImGui.RadioButtonWrapped(Localization.Config_UploadMyDiscoveries_ShowOtherTraps, ref _mode,
ImGui.RadioButton(Localization.Config_NeverUploadDiscoveries_ShowMyTraps, ref _mode, (int)EMode.Online);
PalImGui.RadioButtonWrapped(Localization.Config_NeverUploadDiscoveries_ShowMyTraps, ref _mode,
(int)EMode.Offline); (int)EMode.Offline);
saveAndClose = ImGui.Button(Localization.SaveAndClose); saveAndClose = ImGui.Button(Localization.SaveAndClose);
@ -394,14 +396,16 @@ namespace Pal.Client.Windows
if (_hoardConfig.Show) 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")}"); ImGui.Text($"{hoardCoffers} known hoard coffer{(hoardCoffers == 1 ? "" : "s")}");
} }
if (_silverConfig.Show) if (_silverConfig.Show)
{ {
int silverCoffers = int silverCoffers =
_floorService.EphemeralLocations.Count(x => x.Type == MemoryLocation.EType.SilverCoffer); _floorService.EphemeralLocations.Count(x =>
x.Type == MemoryLocation.EType.SilverCoffer);
ImGui.Text( ImGui.Text(
$"{silverCoffers} silver coffer{(silverCoffers == 1 ? "" : "s")} visible on current floor"); $"{silverCoffers} silver coffer{(silverCoffers == 1 ? "" : "s")} visible on current floor");
} }
@ -423,21 +427,6 @@ namespace Pal.Client.Windows
} }
} }
/// <summary>
/// None of the default BeginTabItem methods allow using flags without making the tab have a close button for some reason.
/// </summary>
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() internal void TestConnection()
{ {
Task.Run(async () => Task.Run(async () =>
@ -485,10 +474,7 @@ namespace Pal.Client.Windows
CancellationTokenSource cts = new CancellationTokenSource(); CancellationTokenSource cts = new CancellationTokenSource();
_lastImportCts = cts; _lastImportCts = cts;
Task.Run(async () => Task.Run(async () => { _lastImport = await _importService.FindLast(cts.Token); }, cts.Token);
{
_lastImport = await _importService.FindLast(cts.Token);
}, cts.Token);
} }
private void DoExport(string destinationPath) private void DoExport(string destinationPath)

View File

@ -14,3 +14,6 @@ Please check [Splatoon's Installation Instructions](https://github.com/Nightmare
## Translation ## Translation
Please feel free to help by [translating this plugin into your language](https://crowdin.com/project/palace-pal). 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).