From 1773afea46e09f56ab6da65035985a429c4ee535 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Thu, 9 Jan 2025 19:34:16 +0100 Subject: [PATCH] GatheringPathRenderer: minor updates --- Directory.Build.targets | 2 +- GatheringPathRenderer/.gitignore | 1 + GatheringPathRenderer/DalamudPackager.targets | 21 +++ .../GatheringPathRenderer.csproj | 8 + .../GatheringPathRenderer.json | 5 +- GatheringPathRenderer/RendererPlugin.cs | 22 ++- GatheringPathRenderer/Windows/ConfigWindow.cs | 33 +++++ GatheringPathRenderer/Windows/EditorWindow.cs | 19 ++- .../1002_Yawtanane Grasslands_BTN.json | 138 ++++++++++++++++++ 9 files changed, 241 insertions(+), 8 deletions(-) create mode 100644 GatheringPathRenderer/.gitignore create mode 100644 GatheringPathRenderer/DalamudPackager.targets create mode 100644 GatheringPathRenderer/Windows/ConfigWindow.cs create mode 100644 GatheringPaths/7.x - Dawntrail/Shaaloani/1002_Yawtanane Grasslands_BTN.json diff --git a/Directory.Build.targets b/Directory.Build.targets index 9c7a8c24..58a5fad2 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,5 +1,5 @@ - + 4.13 diff --git a/GatheringPathRenderer/.gitignore b/GatheringPathRenderer/.gitignore new file mode 100644 index 00000000..a60a458a --- /dev/null +++ b/GatheringPathRenderer/.gitignore @@ -0,0 +1 @@ +/dist diff --git a/GatheringPathRenderer/DalamudPackager.targets b/GatheringPathRenderer/DalamudPackager.targets new file mode 100644 index 00000000..7f129a87 --- /dev/null +++ b/GatheringPathRenderer/DalamudPackager.targets @@ -0,0 +1,21 @@ + + + + + + + + + + diff --git a/GatheringPathRenderer/GatheringPathRenderer.csproj b/GatheringPathRenderer/GatheringPathRenderer.csproj index 6009a518..73d05cbe 100644 --- a/GatheringPathRenderer/GatheringPathRenderer.csproj +++ b/GatheringPathRenderer/GatheringPathRenderer.csproj @@ -1,4 +1,11 @@ + + 0.1 + dist + $(SolutionDir)=X:\ + x64 + + @@ -6,4 +13,5 @@ + diff --git a/GatheringPathRenderer/GatheringPathRenderer.json b/GatheringPathRenderer/GatheringPathRenderer.json index 8d68d1d8..56f91709 100644 --- a/GatheringPathRenderer/GatheringPathRenderer.json +++ b/GatheringPathRenderer/GatheringPathRenderer.json @@ -1,6 +1,7 @@ { "Name": "GatheringPathRenderer", "Author": "Liza Carvelli", - "Punchline": "dev only plugin: Renders gathering location.", - "Description": "dev only plugin: Renders gathering location (without ECommons polluting the entire normal project)." + "Punchline": "[Questionable dev plugin]: Renders gathering location.", + "Description": "[Questionable dev plugin]: Renders gathering location using Splatoon.", + "RepoUrl": "https://git.carvel.li/liza/Questionable/src/branch/master/GatheringPathRenderer" } diff --git a/GatheringPathRenderer/RendererPlugin.cs b/GatheringPathRenderer/RendererPlugin.cs index 5ef430ea..02e01bb7 100644 --- a/GatheringPathRenderer/RendererPlugin.cs +++ b/GatheringPathRenderer/RendererPlugin.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Text.Encodings.Web; @@ -17,11 +18,11 @@ using ECommons.Schedulers; using ECommons.SplatoonAPI; using GatheringPathRenderer.Windows; using LLib.GameData; -using Questionable.Model; using Questionable.Model.Gathering; namespace GatheringPathRenderer; +[SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")] public sealed class RendererPlugin : IDalamudPlugin { private const long OnTerritoryChange = -2; @@ -56,8 +57,10 @@ public sealed class RendererPlugin : IDalamudPlugin _editorCommands = new EditorCommands(this, dataManager, commandManager, targetManager, clientState, chatGui, configuration); - _editorWindow = new EditorWindow(this, _editorCommands, dataManager, targetManager, clientState, objectTable) + var configWindow = new ConfigWindow(pluginInterface, configuration); + _editorWindow = new EditorWindow(this, _editorCommands, dataManager, targetManager, clientState, objectTable, configWindow) { IsOpen = true }; + _windowSystem.AddWindow(configWindow); _windowSystem.AddWindow(_editorWindow); _currentClassJob = (EClassJob?)_clientState.LocalPlayer?.ClassJob.RowId ?? EClassJob.Adventurer; @@ -78,6 +81,7 @@ public sealed class RendererPlugin : IDalamudPlugin { get { +#if DEBUG DirectoryInfo? solutionDirectory = _pluginInterface.AssemblyLocation.Directory?.Parent?.Parent?.Parent; if (solutionDirectory != null) { @@ -88,6 +92,12 @@ public sealed class RendererPlugin : IDalamudPlugin } throw new Exception("Unable to resolve project path"); +#else + var allPluginsDirectory = _pluginInterface.ConfigFile.Directory ?? throw new Exception("Unknown directory for plugin configs"); + return allPluginsDirectory + .CreateSubdirectory("Questionable") + .CreateSubdirectory("GatheringPaths"); +#endif } } @@ -103,12 +113,18 @@ public sealed class RendererPlugin : IDalamudPlugin try { +#if DEBUG foreach (var expansionFolder in ExpansionData.ExpansionFolders.Values) LoadFromDirectory( new DirectoryInfo(Path.Combine(PathsDirectory.FullName, expansionFolder))); - _pluginLog.Information( $"Loaded {_gatheringLocations.Count} gathering root locations from project directory"); +#else + LoadFromDirectory(PathsDirectory); + _pluginLog.Information( + $"Loaded {_gatheringLocations.Count} gathering root locations from {PathsDirectory.FullName} directory"); +#endif + } catch (Exception e) { diff --git a/GatheringPathRenderer/Windows/ConfigWindow.cs b/GatheringPathRenderer/Windows/ConfigWindow.cs new file mode 100644 index 00000000..0e9ba04c --- /dev/null +++ b/GatheringPathRenderer/Windows/ConfigWindow.cs @@ -0,0 +1,33 @@ +using Dalamud.Interface.Windowing; +using Dalamud.Plugin; +using ImGuiNET; + +namespace GatheringPathRenderer.Windows; + +internal sealed class ConfigWindow : Window +{ + private readonly IDalamudPluginInterface _pluginInterface; + private readonly Configuration _configuration; + + public ConfigWindow(IDalamudPluginInterface pluginInterface, Configuration configuration) + : base("Gathering Path Config", ImGuiWindowFlags.AlwaysAutoResize) + { + _pluginInterface = pluginInterface; + _configuration = configuration; + + AllowPinning = false; + AllowClickthrough = false; + } + + public override void Draw() + { + string authorName = _configuration.AuthorName; + if (ImGui.InputText("Author name for new files", ref authorName, 256)) + { + _configuration.AuthorName = authorName; + Save(); + } + } + + private void Save() => _pluginInterface.SavePluginConfig(_configuration); +} diff --git a/GatheringPathRenderer/Windows/EditorWindow.cs b/GatheringPathRenderer/Windows/EditorWindow.cs index 1150558f..c117f4a9 100644 --- a/GatheringPathRenderer/Windows/EditorWindow.cs +++ b/GatheringPathRenderer/Windows/EditorWindow.cs @@ -6,6 +6,7 @@ using System.Numerics; using Dalamud.Game.ClientState.Objects; using Dalamud.Game.ClientState.Objects.Enums; using Dalamud.Game.ClientState.Objects.Types; +using Dalamud.Interface; using Dalamud.Interface.Colors; using Dalamud.Interface.Windowing; using Dalamud.Plugin.Services; @@ -32,8 +33,8 @@ internal sealed class EditorWindow : Window _targetLocation; public EditorWindow(RendererPlugin plugin, EditorCommands editorCommands, IDataManager dataManager, - ITargetManager targetManager, IClientState clientState, IObjectTable objectTable) - : base("Gathering Path Editor###QuestionableGatheringPathEditor", + ITargetManager targetManager, IClientState clientState, IObjectTable objectTable, ConfigWindow configWindow) + : base($"Gathering Path Editor {typeof(EditorWindow).Assembly.GetName().Version!.ToString(2)}###QuestionableGatheringPathEditor", ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoNavFocus | ImGuiWindowFlags.AlwaysAutoResize) { _plugin = plugin; @@ -48,6 +49,20 @@ internal sealed class EditorWindow : Window MinimumSize = new Vector2(300, 100), }; + TitleBarButtons.Add(new TitleBarButton + { + Icon = FontAwesomeIcon.Cog, + IconOffset = new Vector2(1.5f, 1), + Click = _ => configWindow.IsOpen = true, + Priority = int.MinValue, + ShowTooltip = () => + { + ImGui.BeginTooltip(); + ImGui.Text("Open Configuration"); + ImGui.EndTooltip(); + } + }); + RespectCloseHotkey = false; ShowCloseButton = false; AllowPinning = false; diff --git a/GatheringPaths/7.x - Dawntrail/Shaaloani/1002_Yawtanane Grasslands_BTN.json b/GatheringPaths/7.x - Dawntrail/Shaaloani/1002_Yawtanane Grasslands_BTN.json new file mode 100644 index 00000000..44d84892 --- /dev/null +++ b/GatheringPaths/7.x - Dawntrail/Shaaloani/1002_Yawtanane Grasslands_BTN.json @@ -0,0 +1,138 @@ +{ + "$schema": "https://git.carvel.li/liza/Questionable/raw/branch/master/GatheringPaths/gatheringlocation-v1.json", + "Author": "liza", + "Steps": [ + { + "TerritoryId": 1190, + "InteractionType": "None" + } + ], + "Groups": [ + { + "Nodes": [ + { + "DataId": 34920, + "Locations": [ + { + "Position": { + "X": 192.6021, + "Y": 12.31054, + "Z": 631.2545 + } + }, + { + "Position": { + "X": 194.8373, + "Y": 12.50387, + "Z": 646.5401 + } + }, + { + "Position": { + "X": 180.8447, + "Y": 12.43262, + "Z": 610.7131 + } + } + ] + }, + { + "DataId": 34919, + "Locations": [ + { + "Position": { + "X": 186.171, + "Y": 12.54104, + "Z": 634.9042 + } + } + ] + } + ] + }, + { + "Nodes": [ + { + "DataId": 34917, + "Locations": [ + { + "Position": { + "X": 39.45634, + "Y": -0.06042051, + "Z": 502.3853 + } + } + ] + }, + { + "DataId": 34918, + "Locations": [ + { + "Position": { + "X": 46.03248, + "Y": -0.7049216, + "Z": 491.6059 + } + }, + { + "Position": { + "X": 36.15481, + "Y": -0.0501074, + "Z": 505.9388 + } + }, + { + "Position": { + "X": 24.72226, + "Y": 0.5922582, + "Z": 528.0809 + } + } + ] + } + ] + }, + { + "Nodes": [ + { + "DataId": 34922, + "Locations": [ + { + "Position": { + "X": 2.302937, + "Y": -4.586716, + "Z": 687.4797 + } + }, + { + "Position": { + "X": 30.02284, + "Y": -2.447479, + "Z": 704.4326 + } + }, + { + "Position": { + "X": 41.59287, + "Y": -0.8454803, + "Z": 692.0099 + } + } + ] + }, + { + "DataId": 34921, + "Locations": [ + { + "Position": { + "X": 18.47237, + "Y": -2.987581, + "Z": 690.8011 + } + } + ] + } + ] + } + ] +} \ No newline at end of file