Code cleanup bits
This commit is contained in:
parent
12de110b04
commit
2bfcfee753
@ -38,15 +38,15 @@ namespace Pal.Client
|
||||
public List<ImportHistoryEntry> ImportHistory { get; set; } = new();
|
||||
|
||||
public bool ShowTraps { get; set; } = true;
|
||||
public Vector4 TrapColor { get; set; } = new Vector4(1, 0, 0, 0.4f);
|
||||
public Vector4 TrapColor { get; set; } = new(1, 0, 0, 0.4f);
|
||||
public bool OnlyVisibleTrapsAfterPomander { get; set; } = true;
|
||||
|
||||
public bool ShowHoard { get; set; } = true;
|
||||
public Vector4 HoardColor { get; set; } = new Vector4(0, 1, 1, 0.4f);
|
||||
public Vector4 HoardColor { get; set; } = new(0, 1, 1, 0.4f);
|
||||
public bool OnlyVisibleHoardAfterPomander { get; set; } = true;
|
||||
|
||||
public bool ShowSilverCoffers { get; set; } = false;
|
||||
public Vector4 SilverCofferColor { get; set; } = new Vector4(1, 1, 1, 0.4f);
|
||||
public bool ShowSilverCoffers { get; set; }
|
||||
public Vector4 SilverCofferColor { get; set; } = new(1, 1, 1, 0.4f);
|
||||
public bool FillSilverCoffers { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
@ -120,7 +120,7 @@ namespace Pal.Client
|
||||
// Only notify offline users - we can just re-download the backup markers from the server seamlessly.
|
||||
if (Mode == EMode.Offline && changedAnyFile)
|
||||
{
|
||||
new TickScheduler(delegate
|
||||
_ = new TickScheduler(delegate
|
||||
{
|
||||
Service.Chat.PalError("Due to a bug, some coffers were accidentally saved as traps. To fix the related display issue, locally cached data was cleaned up.");
|
||||
Service.Chat.PrintError($"If you have any backup tools installed, please restore the contents of '{Service.PluginInterface.GetPluginConfigDirectory()}' to any backup from February 2, 2023 or before.");
|
||||
|
@ -1,10 +1,11 @@
|
||||
using Dalamud.Game.Gui;
|
||||
using Pal.Client.Properties;
|
||||
|
||||
namespace Pal.Client.Extensions;
|
||||
|
||||
public static class ChatExtensions
|
||||
namespace Pal.Client.Extensions
|
||||
{
|
||||
public static void PalError(this ChatGui chat, string e)
|
||||
=> chat.PrintError($"[{Localization.Palace_Pal}] {e}");
|
||||
public static class ChatExtensions
|
||||
{
|
||||
public static void PalError(this ChatGui chat, string e)
|
||||
=> chat.PrintError($"[{Localization.Palace_Pal}] {e}");
|
||||
}
|
||||
}
|
||||
|
13
Pal.Client/Extensions/GuidExtensions.cs
Normal file
13
Pal.Client/Extensions/GuidExtensions.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace Pal.Client.Extensions
|
||||
{
|
||||
public static class GuidExtensions
|
||||
{
|
||||
public static string ToPartialId(this Guid g, int length = 13)
|
||||
=> g.ToString().ToPartialId();
|
||||
|
||||
public static string ToPartialId(this string s, int length = 13)
|
||||
=> s.PadRight(length + 1).Substring(0, length);
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using Pal.Client.Extensions;
|
||||
|
||||
namespace Pal.Client
|
||||
{
|
||||
@ -72,7 +73,7 @@ namespace Pal.Client
|
||||
if (version <= 3)
|
||||
{
|
||||
foreach (var marker in localState.Markers)
|
||||
marker.RemoteSeenOn = marker.RemoteSeenOn.Select(x => x.PadRight(14).Substring(0, 13)).ToList();
|
||||
marker.RemoteSeenOn = marker.RemoteSeenOn.Select(x => x.ToPartialId()).ToList();
|
||||
}
|
||||
|
||||
if (version < CurrentVersion)
|
||||
|
@ -65,7 +65,7 @@ namespace Pal.Client.Net
|
||||
|
||||
private class NullScope : IDisposable
|
||||
{
|
||||
public static NullScope Instance { get; } = new NullScope();
|
||||
public static NullScope Instance { get; } = new();
|
||||
|
||||
private NullScope()
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ namespace Pal.Client.Net
|
||||
|
||||
internal class JwtRoleConverter : JsonConverter<List<string>>
|
||||
{
|
||||
public override List<string>? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
public override List<string> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.String)
|
||||
return new List<string> { reader.GetString() ?? throw new JsonException("no value present") };
|
||||
|
@ -88,7 +88,7 @@ namespace Pal.Client.Net
|
||||
var account = Account;
|
||||
if (account != null)
|
||||
{
|
||||
account.CachedRoles = _loginInfo.Claims?.Roles?.ToList() ?? new List<string>();
|
||||
account.CachedRoles = _loginInfo.Claims?.Roles.ToList() ?? new List<string>();
|
||||
Service.Configuration.Save();
|
||||
}
|
||||
}
|
||||
@ -156,7 +156,7 @@ namespace Pal.Client.Net
|
||||
{
|
||||
IsLoggedIn = true;
|
||||
AuthToken = authToken;
|
||||
Claims = JwtClaims.FromAuthToken(authToken!);
|
||||
Claims = JwtClaims.FromAuthToken(authToken);
|
||||
}
|
||||
else
|
||||
IsLoggedIn = false;
|
||||
|
@ -18,7 +18,7 @@ namespace Pal.Client.Net
|
||||
|
||||
var palaceClient = new PalaceService.PalaceServiceClient(_channel);
|
||||
var downloadReply = await palaceClient.DownloadFloorsAsync(new DownloadFloorsRequest { TerritoryType = territoryId }, headers: AuthorizedHeaders(), cancellationToken: cancellationToken);
|
||||
return (downloadReply.Success, downloadReply.Objects.Select(o => CreateMarkerFromNetworkObject(o)).ToList());
|
||||
return (downloadReply.Success, downloadReply.Objects.Select(CreateMarkerFromNetworkObject).ToList());
|
||||
}
|
||||
|
||||
public async Task<(bool, List<Marker>)> UploadMarker(ushort territoryType, IList<Marker> markers, CancellationToken cancellationToken = default)
|
||||
@ -42,7 +42,7 @@ namespace Pal.Client.Net
|
||||
Z = m.Position.Z
|
||||
}));
|
||||
var uploadReply = await palaceClient.UploadFloorsAsync(uploadRequest, headers: AuthorizedHeaders(), cancellationToken: cancellationToken);
|
||||
return (uploadReply.Success, uploadReply.Objects.Select(o => CreateMarkerFromNetworkObject(o)).ToList());
|
||||
return (uploadReply.Success, uploadReply.Objects.Select(CreateMarkerFromNetworkObject).ToList());
|
||||
}
|
||||
|
||||
public async Task<bool> MarkAsSeen(ushort territoryType, IList<Marker> markers, CancellationToken cancellationToken = default)
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Dalamud.Logging;
|
||||
using System;
|
||||
using Dalamud.Logging;
|
||||
using Grpc.Core;
|
||||
using System.Net.Security;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
@ -7,14 +8,14 @@ namespace Pal.Client.Net
|
||||
{
|
||||
internal partial class RemoteApi
|
||||
{
|
||||
private Metadata UnauthorizedHeaders() => new Metadata
|
||||
private Metadata UnauthorizedHeaders() => new()
|
||||
{
|
||||
{ "User-Agent", _userAgent },
|
||||
};
|
||||
|
||||
private Metadata AuthorizedHeaders() => new Metadata
|
||||
private Metadata AuthorizedHeaders() => new()
|
||||
{
|
||||
{ "Authorization", $"Bearer {_loginInfo?.AuthToken}" },
|
||||
{ "Authorization", $"Bearer {_loginInfo.AuthToken}" },
|
||||
{ "User-Agent", _userAgent },
|
||||
};
|
||||
|
||||
@ -34,7 +35,9 @@ namespace Pal.Client.Net
|
||||
return null;
|
||||
|
||||
var bytes = new byte[manifestResourceStream.Length];
|
||||
manifestResourceStream.Read(bytes, 0, bytes.Length);
|
||||
int read = manifestResourceStream.Read(bytes, 0, bytes.Length);
|
||||
if (read != bytes.Length)
|
||||
throw new InvalidOperationException();
|
||||
|
||||
var certificate = new X509Certificate2(bytes, pass, X509KeyStorageFlags.DefaultKeySet);
|
||||
PluginLog.Debug($"Using client certificate {certificate.GetCertHashString()}");
|
||||
|
@ -2,6 +2,7 @@
|
||||
using Grpc.Net.Client;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using Pal.Client.Extensions;
|
||||
|
||||
namespace Pal.Client.Net
|
||||
{
|
||||
@ -18,7 +19,7 @@ namespace Pal.Client.Net
|
||||
|
||||
private GrpcChannel? _channel;
|
||||
private LoginInfo _loginInfo = new(null);
|
||||
private bool _warnedAboutUpgrade = false;
|
||||
private bool _warnedAboutUpgrade;
|
||||
|
||||
public Configuration.AccountInfo? Account
|
||||
{
|
||||
@ -34,7 +35,7 @@ namespace Pal.Client.Net
|
||||
|
||||
public Guid? AccountId => Account?.Id;
|
||||
|
||||
public string? PartialAccountId => Account?.Id?.ToString()?.PadRight(14).Substring(0, 13);
|
||||
public string? PartialAccountId => Account?.Id?.ToPartialId();
|
||||
|
||||
private string FormattedPartialAccountId => PartialAccountId ?? "[no account id]";
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
"Name": "Palace Pal",
|
||||
"Author": "Liza Carvelli",
|
||||
"Punchline": "Shows possible trap & hoard coffer locations in Palace of the Dead & Heaven on High.",
|
||||
"Description": "Shows possible trap & hoard coffer locations in Palace of the Dead & Heaven on High. Requires Splatoon to be installed.",
|
||||
"Description": "Shows possible trap & hoard coffer locations in Palace of the Dead & Heaven on High.\n\nThe default configuration requires Splatoon to be installed. If you do not wish to install Splatoon, you can switch to the experimental 'Simple' renderer in the configuration.",
|
||||
"RepoUrl": "https://github.com/carvelli/PalacePal",
|
||||
"IconUrl": "https://raw.githubusercontent.com/carvelli/Dalamud-Plugins/master/dist/Palace Pal.png",
|
||||
"Tags": [ "potd", "palace", "hoh", "splatoon" ]
|
||||
|
@ -39,10 +39,10 @@ namespace Pal.Client
|
||||
internal ConcurrentDictionary<ushort, LocalState> FloorMarkers { get; } = new();
|
||||
internal ConcurrentBag<Marker> EphemeralMarkers { get; set; } = new();
|
||||
internal ushort LastTerritory { get; set; }
|
||||
public SyncState TerritorySyncState { get; set; }
|
||||
public PomanderState PomanderOfSight { get; set; } = PomanderState.Inactive;
|
||||
public PomanderState PomanderOfIntuition { get; set; } = PomanderState.Inactive;
|
||||
public string? DebugMessage { get; set; }
|
||||
internal SyncState TerritorySyncState { get; set; }
|
||||
internal PomanderState PomanderOfSight { get; private set; } = PomanderState.Inactive;
|
||||
internal PomanderState PomanderOfIntuition { get; private set; } = PomanderState.Inactive;
|
||||
internal string? DebugMessage { get; set; }
|
||||
internal Queue<IQueueOnFrameworkThread> EarlyEventQueue { get; } = new();
|
||||
internal Queue<IQueueOnFrameworkThread> LateEventQueue { get; } = new();
|
||||
internal ConcurrentQueue<nint> NextUpdateObjects { get; } = new();
|
||||
@ -98,7 +98,7 @@ namespace Pal.Client
|
||||
}
|
||||
|
||||
pluginInterface.UiBuilder.Draw += Draw;
|
||||
pluginInterface.UiBuilder.OpenConfigUi += OnOpenConfigUi;
|
||||
pluginInterface.UiBuilder.OpenConfigUi += OpenConfigUi;
|
||||
pluginInterface.LanguageChanged += LanguageChanged;
|
||||
Service.Framework.Update += OnFrameworkUpdate;
|
||||
Service.Chat.ChatMessage += OnChatMessage;
|
||||
@ -110,7 +110,7 @@ namespace Pal.Client
|
||||
ReloadLanguageStrings();
|
||||
}
|
||||
|
||||
public void OnOpenConfigUi()
|
||||
private void OpenConfigUi()
|
||||
{
|
||||
Window? configWindow;
|
||||
if (Service.Configuration.FirstUse)
|
||||
@ -162,7 +162,7 @@ namespace Pal.Client
|
||||
break;
|
||||
|
||||
case "near":
|
||||
DebugNearest(m => true);
|
||||
DebugNearest(_ => true);
|
||||
break;
|
||||
|
||||
case "tnear":
|
||||
@ -191,7 +191,7 @@ namespace Pal.Client
|
||||
|
||||
Service.CommandManager.RemoveHandler("/pal");
|
||||
Service.PluginInterface.UiBuilder.Draw -= Draw;
|
||||
Service.PluginInterface.UiBuilder.OpenConfigUi -= OnOpenConfigUi;
|
||||
Service.PluginInterface.UiBuilder.OpenConfigUi -= OpenConfigUi;
|
||||
Service.PluginInterface.LanguageChanged -= LanguageChanged;
|
||||
Service.Framework.Update -= OnFrameworkUpdate;
|
||||
Service.Chat.ChatMessage -= OnChatMessage;
|
||||
@ -246,14 +246,12 @@ namespace Pal.Client
|
||||
{
|
||||
PomanderOfIntuition = PomanderState.FoundOnCurrentFloor;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
private void LanguageChanged(string langcode)
|
||||
{
|
||||
Localization.Culture = new CultureInfo(langcode);
|
||||
Service.WindowSystem?.Windows.OfType<ILanguageChanged>().Each(w => w.LanguageChanged());
|
||||
Service.WindowSystem.Windows.OfType<ILanguageChanged>().Each(w => w.LanguageChanged());
|
||||
}
|
||||
|
||||
private void OnFrameworkUpdate(Framework framework)
|
||||
@ -267,7 +265,7 @@ namespace Pal.Client
|
||||
bool saveMarkers = false;
|
||||
|
||||
while (EarlyEventQueue.TryDequeue(out IQueueOnFrameworkThread? queued))
|
||||
queued?.Run(this, ref recreateLayout, ref saveMarkers);
|
||||
queued.Run(this, ref recreateLayout, ref saveMarkers);
|
||||
|
||||
if (LastTerritory != Service.ClientState.TerritoryType)
|
||||
{
|
||||
@ -294,7 +292,7 @@ namespace Pal.Client
|
||||
}
|
||||
|
||||
while (LateEventQueue.TryDequeue(out IQueueOnFrameworkThread? queued))
|
||||
queued?.Run(this, ref recreateLayout, ref saveMarkers);
|
||||
queued.Run(this, ref recreateLayout, ref saveMarkers);
|
||||
|
||||
var currentFloor = GetFloorMarkers(LastTerritory);
|
||||
|
||||
@ -334,7 +332,7 @@ namespace Pal.Client
|
||||
|
||||
// This requires you to have seen a trap/hoard marker once per floor to synchronize this for older local states,
|
||||
// markers discovered afterwards are automatically marked seen.
|
||||
if (partialAccountId != null && knownMarker.NetworkId != null && !knownMarker.RemoteSeenRequested && !knownMarker.RemoteSeenOn.Contains(partialAccountId))
|
||||
if (partialAccountId != null && knownMarker is { NetworkId: { }, RemoteSeenRequested: false } && !knownMarker.RemoteSeenOn.Contains(partialAccountId))
|
||||
updateSeenMarkers = true;
|
||||
|
||||
continue;
|
||||
@ -372,7 +370,7 @@ namespace Pal.Client
|
||||
|
||||
if (updateSeenMarkers && partialAccountId != null)
|
||||
{
|
||||
var markersToUpdate = currentFloorMarkers.Where(x => x.Seen && x.NetworkId != null && !x.RemoteSeenRequested && !x.RemoteSeenOn.Contains(partialAccountId)).ToList();
|
||||
var markersToUpdate = currentFloorMarkers.Where(x => x is { Seen: true, NetworkId: { }, RemoteSeenRequested: false } && !x.RemoteSeenOn.Contains(partialAccountId)).ToList();
|
||||
foreach (var marker in markersToUpdate)
|
||||
marker.RemoteSeenRequested = true;
|
||||
Task.Run(async () => await SyncSeenMarkersForTerritory(LastTerritory, markersToUpdate));
|
||||
@ -401,7 +399,7 @@ namespace Pal.Client
|
||||
List<IRenderElement> elements = new();
|
||||
foreach (var marker in currentFloorMarkers)
|
||||
{
|
||||
if (marker.Seen || config.Mode == Configuration.EMode.Online || (marker.WasImported && marker.Imports.Count > 0))
|
||||
if (marker.Seen || config.Mode == Configuration.EMode.Online || marker is { WasImported: true, Imports.Count: > 0 })
|
||||
{
|
||||
if (marker.Type == Marker.EType.Trap && config.ShowTraps)
|
||||
{
|
||||
@ -583,12 +581,12 @@ namespace Pal.Client
|
||||
var nearbyMarkers = state.Markers
|
||||
.Where(m => predicate(m))
|
||||
.Where(m => m.RenderElement != null && m.RenderElement.Color != ColorInvisible)
|
||||
.Select(m => new { m = m, distance = (playerPosition - m.Position)?.Length() ?? float.MaxValue })
|
||||
.Select(m => new { m, distance = (playerPosition - m.Position)?.Length() ?? float.MaxValue })
|
||||
.OrderBy(m => m.distance)
|
||||
.Take(5)
|
||||
.ToList();
|
||||
foreach (var nearbyMarker in nearbyMarkers)
|
||||
Service.Chat.Print($"{nearbyMarker.distance:F2} - {nearbyMarker.m.Type} {nearbyMarker.m.NetworkId?.ToString()?.Substring(0, 8)} - {nearbyMarker.m.Position}");
|
||||
Service.Chat.Print($"{nearbyMarker.distance:F2} - {nearbyMarker.m.Type} {nearbyMarker.m.NetworkId?.ToPartialId(length: 8)} - {nearbyMarker.m.Position}");
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -690,12 +688,12 @@ namespace Pal.Client
|
||||
|
||||
private class LocalizedChatMessages
|
||||
{
|
||||
public string MapRevealed { get; set; } = "???"; //"The map for this floor has been revealed!";
|
||||
public string AllTrapsRemoved { get; set; } = "???"; // "All the traps on this floor have disappeared!";
|
||||
public string HoardOnCurrentFloor { get; set; } = "???"; // "You sense the Accursed Hoard calling you...";
|
||||
public string HoardNotOnCurrentFloor { get; set; } = "???"; // "You do not sense the call of the Accursed Hoard on this floor...";
|
||||
public string HoardCofferOpened { get; set; } = "???"; // "You discover a piece of the Accursed Hoard!";
|
||||
public Regex FloorChanged { get; set; } = new Regex(@"This isn't a game message, but will be replaced"); // new Regex(@"^Floor (\d+)$");
|
||||
public string MapRevealed { get; init; } = "???"; //"The map for this floor has been revealed!";
|
||||
public string AllTrapsRemoved { get; init; } = "???"; // "All the traps on this floor have disappeared!";
|
||||
public string HoardOnCurrentFloor { get; init; } = "???"; // "You sense the Accursed Hoard calling you...";
|
||||
public string HoardNotOnCurrentFloor { get; init; } = "???"; // "You do not sense the call of the Accursed Hoard on this floor...";
|
||||
public string HoardCofferOpened { get; init; } = "???"; // "You discover a piece of the Accursed Hoard!";
|
||||
public Regex FloorChanged { get; init; } = new(@"This isn't a game message, but will be replaced"); // new Regex(@"^Floor (\d+)$");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,17 +4,17 @@ namespace Pal.Client.Rendering
|
||||
{
|
||||
internal class MarkerConfig
|
||||
{
|
||||
|
||||
private readonly static Dictionary<Marker.EType, MarkerConfig> _markerConfig = new Dictionary<Marker.EType, MarkerConfig>
|
||||
private static readonly MarkerConfig EmptyConfig = new();
|
||||
private static readonly Dictionary<Marker.EType, MarkerConfig> MarkerConfigs = new()
|
||||
{
|
||||
{ Marker.EType.Trap, new MarkerConfig { Radius = 1.7f } },
|
||||
{ Marker.EType.Hoard, new MarkerConfig { Radius = 1.7f, OffsetY = -0.03f } },
|
||||
{ Marker.EType.SilverCoffer, new MarkerConfig { Radius = 1f } },
|
||||
};
|
||||
|
||||
public float OffsetY { get; set; } = 0;
|
||||
public float OffsetY { get; set; }
|
||||
public float Radius { get; set; } = 0.25f;
|
||||
|
||||
public static MarkerConfig ForType(Marker.EType type) => _markerConfig[type] ?? new MarkerConfig();
|
||||
public static MarkerConfig ForType(Marker.EType type) => MarkerConfigs.GetValueOrDefault(type, EmptyConfig);
|
||||
}
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ namespace Pal.Client.Rendering
|
||||
/// </summary>
|
||||
internal class SimpleRenderer : IRenderer, IDisposable
|
||||
{
|
||||
private ConcurrentDictionary<ELayer, SimpleLayer> layers = new();
|
||||
private readonly ConcurrentDictionary<ELayer, SimpleLayer> _layers = new();
|
||||
|
||||
public void SetLayer(ELayer layer, IReadOnlyList<IRenderElement> elements)
|
||||
{
|
||||
layers[layer] = new SimpleLayer
|
||||
_layers[layer] = new SimpleLayer
|
||||
{
|
||||
TerritoryType = Service.ClientState.TerritoryType,
|
||||
Elements = elements.Cast<SimpleElement>().ToList()
|
||||
@ -35,7 +35,7 @@ namespace Pal.Client.Rendering
|
||||
|
||||
public void ResetLayer(ELayer layer)
|
||||
{
|
||||
if (layers.Remove(layer, out var l))
|
||||
if (_layers.Remove(layer, out var l))
|
||||
l.Dispose();
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ namespace Pal.Client.Rendering
|
||||
|
||||
public void DrawLayers()
|
||||
{
|
||||
if (layers.Count == 0)
|
||||
if (_layers.Count == 0)
|
||||
return;
|
||||
|
||||
ImGuiHelpers.ForceNextWindowMainViewport();
|
||||
@ -65,10 +65,10 @@ namespace Pal.Client.Rendering
|
||||
{
|
||||
ushort territoryType = Service.ClientState.TerritoryType;
|
||||
|
||||
foreach (var layer in layers.Values.Where(l => l.TerritoryType == territoryType))
|
||||
foreach (var layer in _layers.Values.Where(l => l.TerritoryType == territoryType))
|
||||
layer.Draw();
|
||||
|
||||
foreach (var key in layers.Where(l => l.Value.TerritoryType != territoryType).Select(l => l.Key).ToList())
|
||||
foreach (var key in _layers.Where(l => l.Value.TerritoryType != territoryType).Select(l => l.Key).ToList())
|
||||
ResetLayer(key);
|
||||
|
||||
ImGui.End();
|
||||
@ -78,14 +78,14 @@ namespace Pal.Client.Rendering
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var l in layers.Values)
|
||||
foreach (var l in _layers.Values)
|
||||
l.Dispose();
|
||||
}
|
||||
|
||||
public class SimpleLayer : IDisposable
|
||||
{
|
||||
public required ushort TerritoryType { get; init; }
|
||||
public required IReadOnlyList<SimpleElement> Elements { get; set; }
|
||||
public required IReadOnlyList<SimpleElement> Elements { get; init; }
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
@ -102,14 +102,14 @@ namespace Pal.Client.Rendering
|
||||
|
||||
public class SimpleElement : IRenderElement
|
||||
{
|
||||
private const int segmentCount = 20;
|
||||
private const int SegmentCount = 20;
|
||||
|
||||
public bool IsValid { get; set; } = true;
|
||||
public required Marker.EType Type { get; set; }
|
||||
public required Vector3 Position { get; set; }
|
||||
public required Marker.EType Type { get; init; }
|
||||
public required Vector3 Position { get; init; }
|
||||
public required uint Color { get; set; }
|
||||
public required float Radius { get; set; }
|
||||
public required bool Fill { get; set; }
|
||||
public required float Radius { get; init; }
|
||||
public required bool Fill { get; init; }
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
@ -136,12 +136,12 @@ namespace Pal.Client.Rendering
|
||||
}
|
||||
|
||||
bool onScreen = false;
|
||||
for (int index = 0; index < 2 * segmentCount; ++index)
|
||||
for (int index = 0; index < 2 * SegmentCount; ++index)
|
||||
{
|
||||
onScreen |= Service.GameGui.WorldToScreen(new Vector3(
|
||||
Position.X + Radius * (float)Math.Sin(Math.PI / segmentCount * index),
|
||||
Position.X + Radius * (float)Math.Sin(Math.PI / SegmentCount * index),
|
||||
Position.Y,
|
||||
Position.Z + Radius * (float)Math.Cos(Math.PI / segmentCount * index)),
|
||||
Position.Z + Radius * (float)Math.Cos(Math.PI / SegmentCount * index)),
|
||||
out Vector2 vector2);
|
||||
|
||||
ImGui.GetWindowDrawList().PathLineTo(vector2);
|
||||
|
@ -18,8 +18,8 @@ namespace Pal.Client.Rendering
|
||||
{
|
||||
internal class SplatoonRenderer : IRenderer, IDrawDebugItems, IDisposable
|
||||
{
|
||||
private const long ON_TERRITORY_CHANGE = -2;
|
||||
private bool IsDisposed { get; set; } = false;
|
||||
private const long OnTerritoryChange = -2;
|
||||
private bool IsDisposed { get; set; }
|
||||
|
||||
public SplatoonRenderer(DalamudPluginInterface pluginInterface, IDalamudPlugin plugin)
|
||||
{
|
||||
@ -29,11 +29,11 @@ namespace Pal.Client.Rendering
|
||||
public void SetLayer(ELayer layer, IReadOnlyList<IRenderElement> elements)
|
||||
{
|
||||
// we need to delay this, as the current framework update could be before splatoon's, in which case it would immediately delete the layout
|
||||
new TickScheduler(delegate
|
||||
_ = new TickScheduler(delegate
|
||||
{
|
||||
try
|
||||
{
|
||||
Splatoon.AddDynamicElements(ToLayerName(layer), elements.Cast<SplatoonElement>().Select(x => x.Delegate).ToArray(), new long[] { Environment.TickCount64 + 60 * 60 * 1000, ON_TERRITORY_CHANGE });
|
||||
Splatoon.AddDynamicElements(ToLayerName(layer), elements.Cast<SplatoonElement>().Select(x => x.Delegate).ToArray(), new[] { Environment.TickCount64 + 60 * 60 * 1000, OnTerritoryChange });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -91,7 +91,7 @@ namespace Pal.Client.Rendering
|
||||
CreateElement(Marker.EType.Hoard, pos.Value, ImGui.ColorConvertFloat4ToU32(hoardColor)),
|
||||
};
|
||||
|
||||
if (!Splatoon.AddDynamicElements("PalacePal.Test", elements.Cast<SplatoonElement>().Select(x => x.Delegate).ToArray(), new long[] { Environment.TickCount64 + 10000 }))
|
||||
if (!Splatoon.AddDynamicElements("PalacePal.Test", elements.Cast<SplatoonElement>().Select(x => x.Delegate).ToArray(), new[] { Environment.TickCount64 + 10000 }))
|
||||
{
|
||||
Service.Chat.PrintError("Could not draw markers :(");
|
||||
}
|
||||
@ -134,17 +134,17 @@ namespace Pal.Client.Rendering
|
||||
|
||||
public class SplatoonElement : IRenderElement
|
||||
{
|
||||
private readonly SplatoonRenderer renderer;
|
||||
private readonly SplatoonRenderer _renderer;
|
||||
|
||||
public SplatoonElement(SplatoonRenderer renderer, Element element)
|
||||
{
|
||||
this.renderer = renderer;
|
||||
_renderer = renderer;
|
||||
Delegate = element;
|
||||
}
|
||||
|
||||
public Element Delegate { get; }
|
||||
|
||||
public bool IsValid => !renderer.IsDisposed && Delegate.IsValid();
|
||||
public bool IsValid => !_renderer.IsDisposed && Delegate.IsValid();
|
||||
public uint Color
|
||||
{
|
||||
get => Delegate.color;
|
||||
|
@ -15,13 +15,13 @@ namespace Pal.Client.Scheduled
|
||||
{
|
||||
private readonly ExportRoot _export;
|
||||
private Guid _exportId;
|
||||
private int importedTraps;
|
||||
private int importedHoardCoffers;
|
||||
private int _importedTraps;
|
||||
private int _importedHoardCoffers;
|
||||
|
||||
public QueuedImport(string sourcePath)
|
||||
{
|
||||
using (var input = File.OpenRead(sourcePath))
|
||||
_export = ExportRoot.Parser.ParseFrom(input);
|
||||
using var input = File.OpenRead(sourcePath);
|
||||
_export = ExportRoot.Parser.ParseFrom(input);
|
||||
}
|
||||
|
||||
public void Run(Plugin plugin, ref bool recreateLayout, ref bool saveMarkers)
|
||||
@ -58,7 +58,7 @@ namespace Pal.Client.Scheduled
|
||||
recreateLayout = true;
|
||||
saveMarkers = true;
|
||||
|
||||
Service.Chat.Print(string.Format(Localization.ImportCompleteStatistics, importedTraps, importedHoardCoffers));
|
||||
Service.Chat.Print(string.Format(Localization.ImportCompleteStatistics, _importedTraps, _importedHoardCoffers));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -103,9 +103,9 @@ namespace Pal.Client.Scheduled
|
||||
localMarker = remoteMarker;
|
||||
|
||||
if (localMarker.Type == Marker.EType.Trap)
|
||||
importedTraps++;
|
||||
_importedTraps++;
|
||||
else if (localMarker.Type == Marker.EType.Hoard)
|
||||
importedHoardCoffers++;
|
||||
_importedHoardCoffers++;
|
||||
}
|
||||
|
||||
remoteMarker.Imports.Add(_exportId);
|
||||
|
@ -9,10 +9,10 @@ namespace Pal.Client.Scheduled
|
||||
{
|
||||
internal class QueuedSyncResponse : IQueueOnFrameworkThread
|
||||
{
|
||||
public SyncType Type { get; set; }
|
||||
public ushort TerritoryType { get; set; }
|
||||
public bool Success { get; set; }
|
||||
public List<Marker> Markers { get; set; } = new();
|
||||
public required SyncType Type { get; init; }
|
||||
public required ushort TerritoryType { get; init; }
|
||||
public required bool Success { get; init; }
|
||||
public required List<Marker> Markers { get; init; }
|
||||
|
||||
public void Run(Plugin plugin, ref bool recreateLayout, ref bool saveMarkers)
|
||||
{
|
||||
|
@ -24,10 +24,10 @@ namespace Pal.Client
|
||||
[PluginService] public static DataManager DataManager { get; set; } = null!;
|
||||
[PluginService] public static GameGui GameGui { get; set; } = null!;
|
||||
|
||||
public static Plugin Plugin { get; set; } = null!;
|
||||
public static WindowSystem WindowSystem { get; set; } = new(typeof(Service).AssemblyQualifiedName);
|
||||
internal static RemoteApi RemoteApi { get; set; } = new RemoteApi();
|
||||
public static Configuration Configuration { get; set; } = null!;
|
||||
internal static Plugin Plugin { get; set; } = null!;
|
||||
internal static WindowSystem WindowSystem { get; } = new(typeof(Service).AssemblyQualifiedName);
|
||||
internal static RemoteApi RemoteApi { get; } = new();
|
||||
internal static Configuration Configuration { get; set; } = null!;
|
||||
internal static Hooks Hooks { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ using Pal.Client.Properties;
|
||||
|
||||
namespace Pal.Client.Windows
|
||||
{
|
||||
internal class ConfigWindow : Window
|
||||
internal class ConfigWindow : Window, ILanguageChanged
|
||||
{
|
||||
private const string WindowId = "###PalPalaceConfig";
|
||||
private int _mode;
|
||||
@ -43,8 +43,8 @@ namespace Pal.Client.Windows
|
||||
private string _saveExportPath = string.Empty;
|
||||
private string? _openImportDialogStartPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
||||
private string? _saveExportDialogStartPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
||||
private FileDialogManager _importDialog;
|
||||
private FileDialogManager _exportDialog;
|
||||
private readonly FileDialogManager _importDialog;
|
||||
private readonly FileDialogManager _exportDialog;
|
||||
|
||||
public ConfigWindow() : base(WindowId)
|
||||
{
|
||||
@ -358,7 +358,7 @@ 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 unsafe static bool BeginTabItemEx(string label, ImGuiTabItemFlags flags)
|
||||
private static unsafe bool BeginTabItemEx(string label, ImGuiTabItemFlags flags)
|
||||
{
|
||||
int labelLength = Encoding.UTF8.GetByteCount(label);
|
||||
byte* labelPtr = stackalloc byte[labelLength + 1];
|
||||
@ -392,17 +392,17 @@ namespace Pal.Client.Windows
|
||||
});
|
||||
}
|
||||
|
||||
internal void DoImport(string sourcePath)
|
||||
private void DoImport(string sourcePath)
|
||||
{
|
||||
Service.Plugin.EarlyEventQueue.Enqueue(new QueuedImport(sourcePath));
|
||||
}
|
||||
|
||||
internal void UndoImport(Guid importId)
|
||||
private void UndoImport(Guid importId)
|
||||
{
|
||||
Service.Plugin.EarlyEventQueue.Enqueue(new QueuedUndoImport(importId));
|
||||
}
|
||||
|
||||
internal void DoExport(string destinationPath)
|
||||
private void DoExport(string destinationPath)
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
@ -411,7 +411,7 @@ namespace Pal.Client.Windows
|
||||
(bool success, ExportRoot export) = await Service.RemoteApi.DoExport();
|
||||
if (success)
|
||||
{
|
||||
using var output = File.Create(destinationPath);
|
||||
await using var output = File.Create(destinationPath);
|
||||
export.WriteTo(output);
|
||||
|
||||
Service.Chat.Print($"Export saved as {destinationPath}.");
|
||||
|
@ -17,7 +17,7 @@ namespace Pal.Client.Windows
|
||||
internal class StatisticsWindow : Window, ILanguageChanged
|
||||
{
|
||||
private const string WindowId = "###PalacePalStats";
|
||||
private SortedDictionary<ETerritoryType, TerritoryStatistics> _territoryStatistics = new();
|
||||
private readonly SortedDictionary<ETerritoryType, TerritoryStatistics> _territoryStatistics = new();
|
||||
|
||||
public StatisticsWindow() : base(WindowId)
|
||||
{
|
||||
|
@ -8,6 +8,6 @@ namespace Pal.Common
|
||||
{
|
||||
public static class ExportConfig
|
||||
{
|
||||
public static int ExportVersion { get; } = 1;
|
||||
public static int ExportVersion => 1;
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ namespace Pal.Common
|
||||
{
|
||||
public class PalaceMath
|
||||
{
|
||||
private static readonly Vector3 ScaleFactor = new Vector3(5);
|
||||
private static readonly Vector3 ScaleFactor = new(5);
|
||||
|
||||
public static bool IsNearlySamePosition(Vector3 a, Vector3 b)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user