From d46bad5af0e0fb96ef2688eefa12a808723c9750 Mon Sep 17 00:00:00 2001 From: Florian Maunier Date: Sat, 25 May 2024 21:30:04 +0200 Subject: [PATCH 1/5] =?UTF-8?q?=F0=9F=92=9A=20(build)=20disable=20MSBuildG?= =?UTF-8?q?itHash=20on=20release=20builds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MarketBoardPlugin/MarketBoardPlugin.csproj | 3 ++- MarketBoardPlugin/packages.lock.json | 6 ------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/MarketBoardPlugin/MarketBoardPlugin.csproj b/MarketBoardPlugin/MarketBoardPlugin.csproj index a55c45d..f33aad2 100644 --- a/MarketBoardPlugin/MarketBoardPlugin.csproj +++ b/MarketBoardPlugin/MarketBoardPlugin.csproj @@ -54,7 +54,8 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/MarketBoardPlugin/packages.lock.json b/MarketBoardPlugin/packages.lock.json index e408eae..8093649 100644 --- a/MarketBoardPlugin/packages.lock.json +++ b/MarketBoardPlugin/packages.lock.json @@ -24,12 +24,6 @@ "resolved": "2.1.12", "contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg==" }, - "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, )", From f9ebe15fdacc42016f15b6b4748e4b5dd1412d9f Mon Sep 17 00:00:00 2001 From: Florian Maunier Date: Fri, 17 Dec 2021 17:05:59 +0100 Subject: [PATCH 2/5] =?UTF-8?q?=E2=9C=A8=20=20(config)=20add=20favorite=20?= =?UTF-8?q?item=20list=20to=20the=20config=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MarketBoardPlugin/MBPluginConfig.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MarketBoardPlugin/MBPluginConfig.cs b/MarketBoardPlugin/MBPluginConfig.cs index 43ce047..649e9a5 100644 --- a/MarketBoardPlugin/MBPluginConfig.cs +++ b/MarketBoardPlugin/MBPluginConfig.cs @@ -73,5 +73,10 @@ public class MBPluginConfig : IPluginConfiguration /// Gets or sets a value indicating whether the recent history menu is disabled or not. /// public bool RecentHistoryDisabled { get; set; } + + /// + /// Gets the favorite items. + /// + public IEnumerable Favorites { get; } } } From d14132a3012794c715c0b3462c77ce23874363c8 Mon Sep 17 00:00:00 2001 From: Florian Maunier Date: Sun, 26 May 2024 14:25:36 +0200 Subject: [PATCH 3/5] =?UTF-8?q?=E2=9C=A8=20(favorites)=20implement=20favor?= =?UTF-8?q?ite=20items?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MarketBoardPlugin/GUI/MarketBoardWindow.cs | 58 ++++++++++++++++++++-- MarketBoardPlugin/MBPluginConfig.cs | 2 +- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/MarketBoardPlugin/GUI/MarketBoardWindow.cs b/MarketBoardPlugin/GUI/MarketBoardWindow.cs index 716a9a0..d04ce63 100644 --- a/MarketBoardPlugin/GUI/MarketBoardWindow.cs +++ b/MarketBoardPlugin/GUI/MarketBoardWindow.cs @@ -15,8 +15,10 @@ namespace MarketBoardPlugin.GUI using System.Threading.Tasks; using Dalamud.Game.Text; using Dalamud.Interface; + using Dalamud.Interface.Components; using Dalamud.Interface.Internal; using Dalamud.Interface.ManagedFontAtlas; + using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Windowing; using Dalamud.Plugin.Services; using ImGuiNET; @@ -61,6 +63,8 @@ public class MarketBoardWindow : Window, IDisposable private bool advancedSearchMenuOpen; + private bool favoritesOpen; + private float progressPosition; private string searchString = string.Empty; @@ -221,6 +225,9 @@ public override void Draw() this.UpdateCategoriesAndItems(); } + var defaultButtonColor = ImGui.GetColorU32(ImGuiCol.Button); + var defaultButtonHoveredColor = ImGui.GetColorU32(ImGuiCol.ButtonHovered); + var scale = ImGui.GetIO().FontGlobalScale; using var fontDispose = this.defaultFontHandle.Push(); @@ -228,18 +235,35 @@ public override void Draw() // Item List Column Setup ImGui.BeginChild("itemListColumn", new Vector2(267, 0) * scale, true); - ImGui.SetNextItemWidth((-32 * ImGui.GetIO().FontGlobalScale) - ImGui.GetStyle().ItemSpacing.X); + ImGui.SetNextItemWidth((-64 * ImGui.GetIO().FontGlobalScale) - (ImGui.GetStyle().ItemSpacing.X * 2)); ImGuiOverrides.InputTextWithHint("##searchString", "Search for item", ref this.searchString, 256); - ImGui.SameLine(); ImGui.PushFont(UiBuilder.IconFont); - ImGui.PushStyleColor(ImGuiCol.Text, this.searchHistoryOpen ? 0xFF0000FF : 0xFFFFFFFF); + ImGui.PushStyleVar(ImGuiStyleVar.ButtonTextAlign, new Vector2(0.5f, 0.5f)); + + ImGui.SameLine(); + ImGui.PushStyleColor(ImGuiCol.Button, this.searchHistoryOpen ? 0xFF5CB85C : defaultButtonColor); + ImGui.PushStyleColor(ImGuiCol.ButtonHovered, this.searchHistoryOpen ? 0x885CB85C : defaultButtonHoveredColor); if (ImGui.Button($"{(char)FontAwesomeIcon.History}", new Vector2(32 * ImGui.GetIO().FontGlobalScale, ImGui.GetItemRectSize().Y))) { this.searchHistoryOpen = !this.searchHistoryOpen; } ImGui.PopStyleColor(); + ImGui.PopStyleColor(); + + ImGui.SameLine(); + ImGui.PushStyleColor(ImGuiCol.Button, this.favoritesOpen ? 0xFF5CB85C : defaultButtonColor); + ImGui.PushStyleColor(ImGuiCol.ButtonHovered, this.favoritesOpen ? 0x885CB85C : defaultButtonHoveredColor); + if (ImGui.Button($"{(char)FontAwesomeIcon.Star}", new Vector2(32 * ImGui.GetIO().FontGlobalScale, ImGui.GetItemRectSize().Y))) + { + this.favoritesOpen = !this.favoritesOpen; + } + + ImGui.PopStyleColor(); + ImGui.PopStyleColor(); + + ImGui.PopStyleVar(); ImGui.PopFont(); var previousYCursor = ImGui.GetCursorPosY(); @@ -338,6 +362,25 @@ void SelectClassJob(ClassJob classJob) } } } + else if (this.favoritesOpen) + { + ImGui.Text("Favorites"); + ImGui.Separator(); + var sheet = MBPlugin.Data.Excel.GetSheet(); + foreach (var id in this.plugin.Config.Favorites.ToArray()) + { + var item = sheet.GetRow(id); + if (item == null) + { + continue; + } + + if (ImGui.Selectable($"{item.Name}", this.selectedItem == item)) + { + this.ChangeSelectedItem(id, true); + } + } + } else { foreach (var category in this.enumerableCategoriesAndItems) @@ -390,7 +433,7 @@ void SelectClassJob(ClassJob classJob) this.ChangeSelectedItem(item.RowId); } - if (ImGui.BeginPopupContextItem("shoplist" + category.Key.Name + i)) + if (ImGui.BeginPopupContextItem("itemContextMenu" + category.Key.Name + i)) { if (this.selectedItem != null && item != null && this.selectedItem.RowId != item.RowId) { @@ -406,10 +449,15 @@ void SelectClassJob(ClassJob classJob) this.plugin.ShoppingList.Add(new SavedItem(item, price, itm.WorldName)); } + if (ImGui.Selectable("Add to the favorites")) + { + this.plugin.Config.Favorites.Add(item.RowId); + } + ImGui.EndPopup(); } - ImGui.OpenPopupOnItemClick("shoplist" + category.Key.Name + i, ImGuiPopupFlags.MouseButtonRight); + ImGui.OpenPopupOnItemClick("itemContextMenu" + category.Key.Name + i, ImGuiPopupFlags.MouseButtonRight); } ImGui.Indent(ImGui.GetTreeNodeToLabelSpacing()); diff --git a/MarketBoardPlugin/MBPluginConfig.cs b/MarketBoardPlugin/MBPluginConfig.cs index 649e9a5..52ea2c6 100644 --- a/MarketBoardPlugin/MBPluginConfig.cs +++ b/MarketBoardPlugin/MBPluginConfig.cs @@ -77,6 +77,6 @@ public class MBPluginConfig : IPluginConfiguration /// /// Gets the favorite items. /// - public IEnumerable Favorites { get; } + public ICollection Favorites { get; } = new List(); } } From 85588323369dd843f93bbc51ad64a331b6193e82 Mon Sep 17 00:00:00 2001 From: Florian Maunier Date: Sun, 26 May 2024 18:05:55 +0200 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=90=9B=20(universalis)=20handle=20pot?= =?UTF-8?q?ential=20errors=20while=20fetching=20market=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MarketBoardPlugin/GUI/MarketBoardWindow.cs | 22 ++++++++---- .../Helpers/UniversalisClient.cs | 35 +++++++++++++++---- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/MarketBoardPlugin/GUI/MarketBoardWindow.cs b/MarketBoardPlugin/GUI/MarketBoardWindow.cs index d04ce63..2cd1329 100644 --- a/MarketBoardPlugin/GUI/MarketBoardWindow.cs +++ b/MarketBoardPlugin/GUI/MarketBoardWindow.cs @@ -1117,13 +1117,21 @@ private void RefreshMarketData() this.marketData = null; } - this.marketData = await UniversalisClient - .GetMarketData( - this.selectedItem.RowId, - this.worldList[this.selectedWorld].Item1, - 50, - CancellationToken.None) - .ConfigureAwait(false); + try + { + this.marketData = await UniversalisClient + .GetMarketData( + this.selectedItem.RowId, + this.worldList[this.selectedWorld].Item1, + 50, + CancellationToken.None) + .ConfigureAwait(false); + } + catch (Exception) + { + MBPlugin.Log.Warning($"Failed to fetch market data for item {this.selectedItem.RowId} from Universalis."); + this.marketData = null; + } if (cachedItem != null) { diff --git a/MarketBoardPlugin/Helpers/UniversalisClient.cs b/MarketBoardPlugin/Helpers/UniversalisClient.cs index 802b47c..df92077 100644 --- a/MarketBoardPlugin/Helpers/UniversalisClient.cs +++ b/MarketBoardPlugin/Helpers/UniversalisClient.cs @@ -5,6 +5,7 @@ namespace MarketBoardPlugin.Helpers { using System; + using System.IO; using System.Net.Http; using System.Text.Json; using System.Threading; @@ -32,15 +33,37 @@ public static async Task GetMarketData(uint itemId, string w cancellationToken.ThrowIfCancellationRequested(); using var client = new HttpClient(); - var res = await client - .GetStreamAsync(uriBuilder.Uri, cancellationToken) - .ConfigureAwait(false); + + Stream res; + + try + { + res = await client + .GetStreamAsync(uriBuilder.Uri, cancellationToken) + .ConfigureAwait(false); + } + catch (HttpRequestException) + { + MBPlugin.Log.Warning($"Failed to fetch market data for item {itemId} on world {worldName}."); + return null; + } cancellationToken.ThrowIfCancellationRequested(); - var parsedRes = await JsonSerializer - .DeserializeAsync(res, cancellationToken: cancellationToken) - .ConfigureAwait(false); + MarketDataResponse parsedRes; + + try + { + parsedRes = await JsonSerializer + .DeserializeAsync(res, cancellationToken: cancellationToken) + .ConfigureAwait(false); + } + catch (JsonException) + { + MBPlugin.Log.Warning($"Failed to parse market data for item {itemId} on world {worldName}."); + return null; + } + if (parsedRes != null) { parsedRes.FetchTimestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds(); From ae6c955510d470861eb7a24da9dfdf48d3f54052 Mon Sep 17 00:00:00 2001 From: Florian Maunier Date: Sun, 26 May 2024 18:36:01 +0200 Subject: [PATCH 5/5] =?UTF-8?q?=F0=9F=94=96=20bump=20version=20to=201.5.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MarketBoardPlugin/MarketBoardPlugin.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MarketBoardPlugin/MarketBoardPlugin.csproj b/MarketBoardPlugin/MarketBoardPlugin.csproj index f33aad2..154d480 100644 --- a/MarketBoardPlugin/MarketBoardPlugin.csproj +++ b/MarketBoardPlugin/MarketBoardPlugin.csproj @@ -1,4 +1,4 @@ - + net8.0-windows @@ -11,9 +11,9 @@ PdbOnly true git rev-parse --short HEAD - 1.4.0 - 1.4.0 - 1.4.0 + 1.5.0 + 1.5.0 + 1.5.0 Florian Maunier Market board plugin for Dalamud. Copyright (c) Florian Maunier. All rights reserved.