From b8fadc086c76e3827b4e7ab811a49090b6fe0749 Mon Sep 17 00:00:00 2001 From: Florian Maunier Date: Fri, 28 Jun 2024 23:53:18 +0200 Subject: [PATCH 1/4] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20(deps)=20upgrade=20all?= =?UTF-8?q?=20deps?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MarketBoardPlugin/MarketBoardPlugin.csproj | 5 ++--- MarketBoardPlugin/packages.lock.json | 24 +++++++++++----------- OtterGui | 2 +- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/MarketBoardPlugin/MarketBoardPlugin.csproj b/MarketBoardPlugin/MarketBoardPlugin.csproj index 154d480..9320702 100644 --- a/MarketBoardPlugin/MarketBoardPlugin.csproj +++ b/MarketBoardPlugin/MarketBoardPlugin.csproj @@ -51,9 +51,8 @@ - - - + + all diff --git a/MarketBoardPlugin/packages.lock.json b/MarketBoardPlugin/packages.lock.json index 8093649..bc75bf6 100644 --- a/MarketBoardPlugin/packages.lock.json +++ b/MarketBoardPlugin/packages.lock.json @@ -2,17 +2,11 @@ "version": 1, "dependencies": { "net8.0-windows7.0": { - "Dalamud.ContextMenu": { - "type": "Direct", - "requested": "[1.3.1, )", - "resolved": "1.3.1", - "contentHash": "ptAxut5PiLnzZ4G/KQdHJVcyklC/BF3otHJ7zYVUPiKBjsOCoF0n/6h2jK7e+8ev2Y1yAY3Wtx2GuXLFQgt9Uw==" - }, "Dalamud.DrunkenToad": { "type": "Direct", - "requested": "[1.8.15, )", - "resolved": "1.8.15", - "contentHash": "biuHkQR0qmIMWEsa14CcWtUH4f6G7sOTQMDZZKws2MhzTYl/3sw2lDS3z6bBOPd17I1UPtmkFBBn0QbQEpO4PA==", + "requested": "[1.9.2, )", + "resolved": "1.9.2", + "contentHash": "fT7ntQ1swV+U9H9I1TI6hJVXVSKxifzXex9D5EOdxqk3ZoHDwTLaKjKxWBrGOI+NI12UjgYWC7DPW39oJfqIfg==", "dependencies": { "Dalamud.Loc": "1.1.2", "Microsoft.Extensions.DependencyInjection": "7.0.0" @@ -20,9 +14,15 @@ }, "DalamudPackager": { "type": "Direct", - "requested": "[2.1.12, )", - "resolved": "2.1.12", - "contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg==" + "requested": "[2.1.13, )", + "resolved": "2.1.13", + "contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ==" + }, + "MSBuildGitHash": { + "type": "Direct", + "requested": "[2.0.2, )", + "resolved": "2.0.2", + "contentHash": "1gA7vw5Wc4w6/H2IDVFx69LGQndIyTSsBOTL1BO1lAjzyWl6LUi24gtST8Bh5yd/793patMZyO7Ym4Kg19p+VA==" }, "StyleCop.Analyzers": { "type": "Direct", diff --git a/OtterGui b/OtterGui index 1d93651..93cbd4d 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 1d9365164655a7cb38172e1311e15e19b1def6db +Subproject commit 93cbd4de0432e4afbb088c81835f048b41bf8c1d From 2663842f2f959d5fdca2a208c8a1ab73f2a982c8 Mon Sep 17 00:00:00 2001 From: Florian Maunier Date: Sat, 29 Jun 2024 12:32:28 +0200 Subject: [PATCH 2/4] =?UTF-8?q?=E2=9C=A8=20(apiX)=20upgrade=20to=20apiX=20?= =?UTF-8?q?/=20Dawntrail?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GUI/MarketBoardConfigWindow.cs | 8 +- .../GUI/MarketBoardShoppingListWindow.cs | 2 +- MarketBoardPlugin/GUI/MarketBoardWindow.cs | 91 ++++----- .../Helpers/UniversalisClient.cs | 26 ++- MarketBoardPlugin/MBPlugin.cs | 175 ++++++++++++------ 5 files changed, 188 insertions(+), 114 deletions(-) diff --git a/MarketBoardPlugin/GUI/MarketBoardConfigWindow.cs b/MarketBoardPlugin/GUI/MarketBoardConfigWindow.cs index f07a5d4..9c974a4 100644 --- a/MarketBoardPlugin/GUI/MarketBoardConfigWindow.cs +++ b/MarketBoardPlugin/GUI/MarketBoardConfigWindow.cs @@ -40,7 +40,7 @@ public override void Draw() this.Checkbox("No Gil Sales Tax", "Toggles whether the Gil Sales Tax is included", this.Plugin.Config.NoGilSalesTax, (v) => { this.Plugin.Config.NoGilSalesTax = v; - MBPlugin.PluginInterface.SavePluginConfig(this.Plugin.Config); + this.Plugin.PluginInterface.SavePluginConfig(this.Plugin.Config); this.Plugin.ResetMarketData(); }); @@ -56,7 +56,7 @@ public override void Draw() if (this.Plugin.Config.MarketBufferSize != marketBufferSize) { this.Plugin.Config.MarketBufferSize = marketBufferSize; - MBPlugin.PluginInterface.SavePluginConfig(this.Plugin.Config); + this.Plugin.PluginInterface.SavePluginConfig(this.Plugin.Config); } var itemRefreshTimeout = this.Plugin.Config.ItemRefreshTimeout; @@ -65,7 +65,7 @@ public override void Draw() if (this.Plugin.Config.ItemRefreshTimeout != itemRefreshTimeout) { this.Plugin.Config.ItemRefreshTimeout = itemRefreshTimeout; - MBPlugin.PluginInterface.SavePluginConfig(this.Plugin.Config); + this.Plugin.PluginInterface.SavePluginConfig(this.Plugin.Config); } } @@ -73,7 +73,7 @@ private void Checkbox(string label, string description, bool oldValue, Action(); - this.items = MBPlugin.Data.GetExcelSheet(); - this.classJobs = MBPlugin.Data.GetExcelSheet()? + this.items = plugin.DataManager.GetExcelSheet(); + this.classJobs = plugin.DataManager.GetExcelSheet()? .Where(cj => cj.RowId != 0) .OrderBy(cj => { @@ -141,13 +139,12 @@ public MarketBoardWindow(MBPlugin plugin) _ => 4, }; }).ToList(); - this.plugin = plugin ?? throw new ArgumentNullException(nameof(plugin)); this.sortedCategoriesAndItems = this.SortCategoriesAndItems(); - MBPlugin.Framework.Update += this.HandleFrameworkUpdateEvent; - MBPlugin.GameGui.HoveredItemChanged += this.HandleHoveredItemChange; + this.plugin.Framework.Update += this.HandleFrameworkUpdateEvent; + this.plugin.GameGui.HoveredItemChanged += this.HandleHoveredItemChange; - this.defaultFontHandle = MBPlugin.PluginInterface.UiBuilder.FontAtlas.NewDelegateFontHandle(e => + this.defaultFontHandle = this.plugin.PluginInterface.UiBuilder.FontAtlas.NewDelegateFontHandle(e => e.OnPreBuild(toolkit => toolkit.AddFontFromStream( this.GetType().Assembly.GetManifestResourceStream("MarketBoardPlugin.Resources.NotoSans-Medium-NNBSP.otf"), @@ -160,11 +157,9 @@ public MarketBoardWindow(MBPlugin plugin) false, "NNBSP"))); - this.titleFontHandle = MBPlugin.PluginInterface.UiBuilder.FontAtlas.NewDelegateFontHandle(e => + this.titleFontHandle = this.plugin.PluginInterface.UiBuilder.FontAtlas.NewDelegateFontHandle(e => e.OnPreBuild(toolkit => - toolkit.AddDalamudDefaultFont(MBPlugin.PluginInterface.UiBuilder.DefaultFontSpec.SizePx * 1.5f))); - - MBPlugin.PluginInterface.UiBuilder.RebuildFonts(); + toolkit.AddDalamudDefaultFont(this.plugin.PluginInterface.UiBuilder.DefaultFontSpec.SizePx * 1.5f))); var imPlotStylePtr = ImPlot.GetStyle(); @@ -347,7 +342,7 @@ void SelectClassJob(ClassJob classJob) { ImGui.Text("History"); ImGui.Separator(); - var sheet = MBPlugin.Data.Excel.GetSheet(); + var sheet = this.plugin.DataManager.Excel.GetSheet(); foreach (var id in this.plugin.Config.History.ToArray()) { var item = sheet.GetRow(id); @@ -366,7 +361,7 @@ void SelectClassJob(ClassJob classJob) { ImGui.Text("Favorites"); ImGui.Separator(); - var sheet = MBPlugin.Data.Excel.GetSheet(); + var sheet = this.plugin.DataManager.Excel.GetSheet(); foreach (var id in this.plugin.Config.Favorites.ToArray()) { var item = sheet.GetRow(id); @@ -477,7 +472,7 @@ void SelectClassJob(ClassJob classJob) else { this.progressPosition = 0; - var itemId = MBPlugin.GameGui.HoveredItem; + var itemId = this.plugin.GameGui.HoveredItem; this.ChangeSelectedItem(Convert.ToUInt32(itemId % 500000)); this.itemBeingHovered = 0; } @@ -505,18 +500,26 @@ void SelectClassJob(ClassJob classJob) if (this.selectedItem?.RowId > 0) { - if (this.selectedItemIcon != null) + var couldGetIcon = this.plugin.TextureProvider.GetFromGameIcon(new GameIconLookup { - if (ImGui.ImageButton(this.selectedItemIcon.ImGuiHandle, new Vector2(40, 40))) + IconId = this.selectedItem.Icon, + }).TryGetWrap(out var selectedItemIcon, out _); + + using (selectedItemIcon) + { + if (couldGetIcon) { - ImGui.LogToClipboard(); - ImGui.LogText(this.selectedItem.Name); - ImGui.LogFinish(); + if (ImGui.ImageButton(selectedItemIcon.ImGuiHandle, new Vector2(40, 40))) + { + ImGui.LogToClipboard(); + ImGui.LogText(this.selectedItem.Name); + ImGui.LogFinish(); + } + } + else + { + ImGui.SetCursorPos(new Vector2(40, 40)); } - } - else - { - ImGui.SetCursorPos(new Vector2(40, 40)); } this.titleFontHandle.Push(); @@ -848,8 +851,7 @@ internal void ChangeSelectedItem(uint itemId, bool noHistory = false) this.selectedItem = this.items.Single(i => i.RowId == itemId); var iconId = this.selectedItem.Icon; - this.selectedItemIcon?.Dispose(); - this.selectedItemIcon = MBPlugin.TextureProvider.GetIcon(iconId); + this.plugin.Log.Verbose("Selected item: {0} ({1}), icon: {2}", this.selectedItem.Name, this.selectedItem.RowId, iconId); this.RefreshMarketData(); if (!noHistory) @@ -861,7 +863,7 @@ internal void ChangeSelectedItem(uint itemId, bool noHistory = false) this.plugin.Config.History.RemoveRange(100, this.plugin.Config.History.Count - 100); } - MBPlugin.PluginInterface.SavePluginConfig(this.plugin.Config); + this.plugin.PluginInterface.SavePluginConfig(this.plugin.Config); } } @@ -878,9 +880,8 @@ protected virtual void Dispose(bool disposing) if (disposing) { - MBPlugin.Framework.Update -= this.HandleFrameworkUpdateEvent; - MBPlugin.GameGui.HoveredItemChanged -= this.HandleHoveredItemChange; - this.selectedItemIcon?.Dispose(); + this.plugin.Framework.Update -= this.HandleFrameworkUpdateEvent; + this.plugin.GameGui.HoveredItemChanged -= this.HandleHoveredItemChange; this.defaultFontHandle?.Dispose(); this.titleFontHandle?.Dispose(); } @@ -919,13 +920,13 @@ private static string ConvertItemNameToSortableFormat(string itemName) /// Function used for debug purposes : Log every attributes of an Item. /// /// Item class to show in logs. - private static void LogItemInfo(Item itm) + private void LogItemInfo(Item itm) { foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(itm)) { string name = descriptor.Name; object value = descriptor.GetValue(itm); - MBPlugin.Log.Information("{0}={1}", name, value); + this.plugin.Log.Information("{0}={1}", name, value); } } @@ -972,7 +973,7 @@ private Dictionary> SortCategoriesAndItems() { try { - var itemSearchCategories = MBPlugin.Data.GetExcelSheet(); + var itemSearchCategories = this.plugin.DataManager.GetExcelSheet(); var sortedCategories = itemSearchCategories.Where(c => c.Category > 0).OrderBy(c => c.Category).ThenBy(c => c.Order); @@ -992,23 +993,23 @@ private Dictionary> SortCategoriesAndItems() } catch (Exception ex) { - MBPlugin.Log.Error(ex, $"Error loading category list."); + this.plugin.Log.Error(ex, $"Error loading category list."); return null; } } private void HandleFrameworkUpdateEvent(IFramework framework) { - if (MBPlugin.ClientState.LocalContentId != 0 && this.playerId != MBPlugin.ClientState.LocalContentId) + if (this.plugin.ClientState.LocalContentId != 0 && this.playerId != this.plugin.ClientState.LocalContentId) { - var localPlayer = MBPlugin.ClientState.LocalPlayer; + var localPlayer = this.plugin.ClientState.LocalPlayer; if (localPlayer == null) { return; } var currentDc = localPlayer.CurrentWorld.GameData.DataCenter; - var dcWorlds = MBPlugin.Data.GetExcelSheet() + var dcWorlds = this.plugin.DataManager.GetExcelSheet() .Where(w => w.DataCenter.Row == currentDc.Row && w.IsPublic) .OrderBy(w => w.Name.ToString()) .Select(w => @@ -1052,11 +1053,11 @@ private void HandleFrameworkUpdateEvent(IFramework framework) if (this.worldList.Count > 1) { - this.playerId = MBPlugin.ClientState.LocalContentId; + this.playerId = this.plugin.ClientState.LocalContentId; } } - if (MBPlugin.ClientState.LocalContentId == 0) + if (this.plugin.ClientState.LocalContentId == 0) { this.playerId = 0; } @@ -1077,7 +1078,7 @@ private void HandleHoveredItemChange(object sender, ulong itemId) return; } - var item = MBPlugin.Data.Excel.GetSheet().GetRow((uint)itemId % 500000); + var item = this.plugin.DataManager.Excel.GetSheet().GetRow((uint)itemId % 500000); if (item != null && this.enumerableCategoriesAndItems != null && this.sortedCategoriesAndItems.Any(i => i.Value != null && i.Value.Any(k => k.ToString() == item.ToString()))) { @@ -1119,7 +1120,7 @@ private void RefreshMarketData() try { - this.marketData = await UniversalisClient + this.marketData = await this.plugin.UniversalisClient .GetMarketData( this.selectedItem.RowId, this.worldList[this.selectedWorld].Item1, @@ -1129,7 +1130,7 @@ private void RefreshMarketData() } catch (Exception) { - MBPlugin.Log.Warning($"Failed to fetch market data for item {this.selectedItem.RowId} from Universalis."); + this.plugin.Log.Warning($"Failed to fetch market data for item {this.selectedItem.RowId} from Universalis."); this.marketData = null; } diff --git a/MarketBoardPlugin/Helpers/UniversalisClient.cs b/MarketBoardPlugin/Helpers/UniversalisClient.cs index df92077..8e92330 100644 --- a/MarketBoardPlugin/Helpers/UniversalisClient.cs +++ b/MarketBoardPlugin/Helpers/UniversalisClient.cs @@ -16,17 +16,23 @@ namespace MarketBoardPlugin.Helpers /// /// Universalis API Client. /// - public static class UniversalisClient + /// + /// Initializes a new instance of the class. + /// + /// The plugin instance. + public class UniversalisClient(MBPlugin plugin) { + private readonly MBPlugin plugin = plugin ?? throw new ArgumentNullException(nameof(plugin)); + /// - /// Gets market data of an item for a specific world. + /// Retrieves market data for a specific item from the Universalis API. /// - /// The item ID. - /// The world's name. - /// Number of entries to fetch from the history. - /// A . - /// The market data. - public static async Task GetMarketData(uint itemId, string worldName, int historyCount, CancellationToken cancellationToken) + /// The ID of the item to retrieve market data for. + /// The name of the world to retrieve market data from. + /// The number of historical entries to retrieve. + /// A cancellation token to cancel the operation. + /// A object containing the retrieved market data, or null if the operation fails. + public async Task GetMarketData(uint itemId, string worldName, int historyCount, CancellationToken cancellationToken) { var uriBuilder = new UriBuilder($"https://universalis.app/api/{worldName}/{itemId}?entries={historyCount}"); @@ -44,7 +50,7 @@ public static async Task GetMarketData(uint itemId, string w } catch (HttpRequestException) { - MBPlugin.Log.Warning($"Failed to fetch market data for item {itemId} on world {worldName}."); + this.plugin.Log.Warning($"Fai /// to fetch market data for item {itemId} on world {worldName}."); return null; } @@ -60,7 +66,7 @@ public static async Task GetMarketData(uint itemId, string w } catch (JsonException) { - MBPlugin.Log.Warning($"Failed to parse market data for item {itemId} on world {worldName}."); + this.plugin.Log.Warning($"Failed to parse market data for item {itemId} on world {worldName}."); return null; } diff --git a/MarketBoardPlugin/MBPlugin.cs b/MarketBoardPlugin/MBPlugin.cs index 8589ac5..416ef77 100644 --- a/MarketBoardPlugin/MBPlugin.cs +++ b/MarketBoardPlugin/MBPlugin.cs @@ -8,18 +8,16 @@ namespace MarketBoardPlugin using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Globalization; - using Dalamud.ContextMenu; using Dalamud.Game.Command; + using Dalamud.Game.Gui.ContextMenu; using Dalamud.Game.Text; - using Dalamud.Game.Text.SeStringHandling; - using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Interface.Windowing; - using Dalamud.IoC; using Dalamud.Plugin; using Dalamud.Plugin.Services; using Lumina.Excel.GeneratedSheets; using MarketBoardPlugin.GUI; + using MarketBoardPlugin.Helpers; using MarketBoardPlugin.Models.ShoppingList; /// @@ -28,16 +26,14 @@ namespace MarketBoardPlugin [SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Plugin entry point")] public class MBPlugin : IDalamudPlugin { - private readonly DalamudContextMenu contextMenuBase; - - private readonly InventoryContextMenuItem inventoryContextMenuItem; - private readonly MarketBoardWindow marketBoardWindow; private readonly MarketBoardConfigWindow marketBoardConfigWindow; private readonly MarketBoardShoppingListWindow marketBoardShoppingListWindow; + private readonly MenuItem inventoryContextMenuItem; + /// /// Gets the window system. /// @@ -49,9 +45,39 @@ public class MBPlugin : IDalamudPlugin /// Initializes a new instance of the class. /// This is the plugin's entry point. /// - public MBPlugin() + /// The Dalamud plugin interface. + /// The data manager. + /// The command manager. + /// The framework. + /// The client state. + /// The game GUI. + /// The texture provider. + /// The plugin log. + /// The context menu. + public MBPlugin( + IDalamudPluginInterface pluginInterface, + IDataManager dataManager, + ICommandManager commandManager, + IFramework framework, + IClientState clientState, + IGameGui gameGui, + ITextureProvider textureProvider, + IPluginLog log, + IContextMenu contextMenu) { - this.Config = PluginInterface.GetPluginConfig() as MBPluginConfig ?? new MBPluginConfig(); + this.PluginInterface = pluginInterface; + this.DataManager = dataManager; + this.CommandManager = commandManager; + this.Framework = framework; + this.ClientState = clientState; + this.GameGui = gameGui; + this.TextureProvider = textureProvider; + this.Log = log; + this.ContextMenu = contextMenu; + + this.UniversalisClient = new UniversalisClient(this); + + this.Config = this.PluginInterface.GetPluginConfig() as MBPluginConfig ?? new MBPluginConfig(); this.marketBoardWindow = new MarketBoardWindow(this); this.marketBoardConfigWindow = new MarketBoardConfigWindow(this); @@ -62,20 +88,24 @@ public MBPlugin() this.windowSystem.AddWindow(this.marketBoardShoppingListWindow); // Set up command handlers - CommandManager.AddHandler("/pmb", new CommandInfo(this.OnOpenMarketBoardCommand) + this.CommandManager.AddHandler("/pmb", new CommandInfo(this.OnOpenMarketBoardCommand) { HelpMessage = "Open the market board window.", }); - PluginInterface.UiBuilder.Draw += this.DrawUi; - PluginInterface.UiBuilder.OpenConfigUi += this.OpenConfigUi; - PluginInterface.UiBuilder.OpenMainUi += this.OpenMainUi; + this.PluginInterface.UiBuilder.Draw += this.DrawUi; + this.PluginInterface.UiBuilder.OpenConfigUi += this.OpenConfigUi; + this.PluginInterface.UiBuilder.OpenMainUi += this.OpenMainUi; // Set up context menu - this.contextMenuBase = new DalamudContextMenu(PluginInterface); - this.inventoryContextMenuItem = new InventoryContextMenuItem( - new SeString(new TextPayload("Search with Market Board Plugin")), this.OnSelectContextMenuItem, true); - this.contextMenuBase.OnOpenInventoryContextMenu += this.OnContextMenuOpened; + this.inventoryContextMenuItem = new MenuItem + { + Name = "Search with Market Board Plugin", + OnClicked = this.OnSelectContextMenuItem, + Prefix = SeIconChar.Gil, + PrefixColor = 48, + }; + this.ContextMenu.OnMenuOpened += this.OnContextMenuOpened; // Set up number format this.NumberFormatInfo.CurrencySymbol = SeIconChar.Gil.ToIconString(); @@ -106,29 +136,52 @@ public MBPlugin() /// public NumberFormatInfo NumberFormatInfo { get; init; } = CultureInfo.CurrentCulture.NumberFormat.Clone() as NumberFormatInfo; - [PluginService] - internal static DalamudPluginInterface PluginInterface { get; private set; } = null!; + /// + /// Gets the Dalamud plugin interface. + /// + public IDalamudPluginInterface PluginInterface { get; init; } - [PluginService] - internal static IDataManager Data { get; private set; } = null!; + /// + /// Gets the data manager. + /// + public IDataManager DataManager { get; init; } - [PluginService] - internal static ICommandManager CommandManager { get; private set; } = null!; + /// + /// Gets the command manager. + /// + public ICommandManager CommandManager { get; init; } - [PluginService] - internal static IFramework Framework { get; private set; } = null!; + /// + /// Gets the framework. + /// + public IFramework Framework { get; init; } - [PluginService] - internal static IClientState ClientState { get; private set; } = null!; + /// + /// Gets the client state. + /// + public IClientState ClientState { get; init; } - [PluginService] - internal static IGameGui GameGui { get; private set; } = null!; + /// + /// Gets the game GUI. + /// + public IGameGui GameGui { get; init; } - [PluginService] - internal static ITextureProvider TextureProvider { get; private set; } = null!; + /// + /// Gets the texture provider. + /// + public ITextureProvider TextureProvider { get; init; } - [PluginService] - internal static IPluginLog Log { get; private set; } = null!; + /// + /// Gets the plugin log. + /// + public IPluginLog Log { get; init; } + + /// + /// Gets the context menu. + /// + public IContextMenu ContextMenu { get; init; } + + public UniversalisClient UniversalisClient { get; init; } /// public void Dispose() @@ -138,7 +191,7 @@ public void Dispose() } /// - /// Reset the market data. + /// Resets the market data. /// public void ResetMarketData() { @@ -146,7 +199,7 @@ public void ResetMarketData() } /// - /// Open the main UI. + /// Opens the main UI. /// public void OpenMainUi() { @@ -154,7 +207,7 @@ public void OpenMainUi() } /// - /// Open the config UI. + /// Opens the config UI. /// public void OpenConfigUi() { @@ -175,61 +228,75 @@ protected virtual void Dispose(bool disposing) if (disposing) { // Save config - PluginInterface.SavePluginConfig(this.Config); + this.PluginInterface.SavePluginConfig(this.Config); // Remove windows this.windowSystem.RemoveAllWindows(); this.marketBoardWindow.Dispose(); // Remove command handlers - CommandManager.RemoveHandler("/pmb"); + this.CommandManager.RemoveHandler("/pmb"); // Remove context menu handler - this.contextMenuBase.OnOpenInventoryContextMenu -= this.OnContextMenuOpened; - this.contextMenuBase.Dispose(); + this.ContextMenu.OnMenuOpened -= this.OnContextMenuOpened; } this.isDisposed = true; } - private void OnContextMenuOpened(InventoryContextMenuOpenArgs args) + private void OnContextMenuOpened(IMenuOpenedArgs args) { + if (args.MenuType != ContextMenuType.Inventory) + { + return; + } + if (!this.Config.ContextMenuIntegration) { return; } - var i = (uint)(GameGui.HoveredItem % 500000); + this.inventoryContextMenuItem.IsEnabled = true; + + var target = args.Target as MenuTargetInventory; - var item = Data.Excel.GetSheet()?.GetRow(i); - if (item == null) + if (!target.TargetItem.HasValue || target.TargetItem.Value.ItemId == 0) { - return; + this.inventoryContextMenuItem.IsEnabled = false; } + var item = this.DataManager.Excel.GetSheet().GetRow(target.TargetItem.Value.ItemId); + if (item.IsUntradable) { - return; + this.inventoryContextMenuItem.IsEnabled = false; } - if (args.ItemId == 0) + args.AddMenuItem(this.inventoryContextMenuItem); + } + + private void OnSelectContextMenuItem(IMenuItemClickedArgs args) + { + if (args.MenuType != ContextMenuType.Inventory) { return; } - args.AddCustomItem(this.inventoryContextMenuItem); - } + var target = args.Target as MenuTargetInventory; + + if (!target.TargetItem.HasValue || target.TargetItem.Value.ItemId == 0) + { + return; + } - private void OnSelectContextMenuItem(InventoryContextMenuItemSelectedArgs args) - { try { this.marketBoardWindow.IsOpen = true; - this.marketBoardWindow.ChangeSelectedItem(args.ItemId); + this.marketBoardWindow.ChangeSelectedItem(target.TargetItem.Value.ItemId); } catch (Exception ex) { - Log.Error(ex, "Failed on context menu for itemId" + args.ItemId); + this.Log.Error(ex, "Failed on context menu for itemId" + target.TargetItem.Value.ItemId); } } From be538af0e58da5efac2e3427eddca6198b433af2 Mon Sep 17 00:00:00 2001 From: Florian Maunier Date: Sun, 30 Jun 2024 15:06:21 +0200 Subject: [PATCH 3/4] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20(ottergui)=20bump=20Ot?= =?UTF-8?q?terGui?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OtterGui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OtterGui b/OtterGui index 93cbd4d..c5f3ef9 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 93cbd4de0432e4afbb088c81835f048b41bf8c1d +Subproject commit c5f3ef9343d2943dfaefa7a7eefe1bc09d4b8f01 From 2cb59e28bd865c5b85102a9748d9cdd19de9f3be Mon Sep 17 00:00:00 2001 From: Florian Maunier Date: Sun, 30 Jun 2024 15:13:07 +0200 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=94=96=20bump=20version=20to=201.6.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MarketBoardPlugin/MarketBoardPlugin.csproj | 6 +++--- MarketBoardPlugin/packages.lock.json | 6 ------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/MarketBoardPlugin/MarketBoardPlugin.csproj b/MarketBoardPlugin/MarketBoardPlugin.csproj index 9320702..4fc0db3 100644 --- a/MarketBoardPlugin/MarketBoardPlugin.csproj +++ b/MarketBoardPlugin/MarketBoardPlugin.csproj @@ -11,9 +11,9 @@ PdbOnly true git rev-parse --short HEAD - 1.5.0 - 1.5.0 - 1.5.0 + 1.6.0 + 1.6.0 + 1.6.0 Florian Maunier Market board plugin for Dalamud. Copyright (c) Florian Maunier. All rights reserved. diff --git a/MarketBoardPlugin/packages.lock.json b/MarketBoardPlugin/packages.lock.json index bc75bf6..11f396d 100644 --- a/MarketBoardPlugin/packages.lock.json +++ b/MarketBoardPlugin/packages.lock.json @@ -18,12 +18,6 @@ "resolved": "2.1.13", "contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ==" }, - "MSBuildGitHash": { - "type": "Direct", - "requested": "[2.0.2, )", - "resolved": "2.0.2", - "contentHash": "1gA7vw5Wc4w6/H2IDVFx69LGQndIyTSsBOTL1BO1lAjzyWl6LUi24gtST8Bh5yd/793patMZyO7Ym4Kg19p+VA==" - }, "StyleCop.Analyzers": { "type": "Direct", "requested": "[1.2.0-beta.556, )",