Skip to content

Commit

Permalink
Gil Icon Shown option added + default setting window size adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
Pythyu committed Aug 27, 2022
1 parent cea7aae commit 2ca9d7c
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 5 deletions.
63 changes: 58 additions & 5 deletions MarketBoardPlugin/GUI/MarketBoardWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Copyright (c) Florian Maunier. All rights reserved.
// </copyright>

using System.Data.SqlTypes;

namespace MarketBoardPlugin.GUI
{
using System;
Expand Down Expand Up @@ -72,6 +74,8 @@ public class MarketBoardWindow : IDisposable

private bool watchingForHoveredItem = true;

private bool priceIconShown = true;

private ulong playerId;

private int selectedWorld = -1;
Expand Down Expand Up @@ -468,11 +472,27 @@ public bool Draw()
}

ImGui.NextColumn();
ImGui.Text(listing.PricePerUnit.ToString("C", this.numberFormatInfo));
if (this.priceIconShown)
{
ImGui.Text(listing.PricePerUnit.ToString("C", this.numberFormatInfo));
}
else
{
ImGui.Text(listing.PricePerUnit.ToString("N0", CultureInfo.CreateSpecificCulture("sv-SE")));
}

ImGui.NextColumn();
ImGui.Text($"{listing.Quantity:##,###}");
ImGui.NextColumn();
ImGui.Text(listing.Total.ToString("C", this.numberFormatInfo));
if (this.priceIconShown)
{
ImGui.Text(listing.Total.ToString("C", this.numberFormatInfo));
}
else
{
ImGui.Text(listing.Total.ToString("N0", CultureInfo.CreateSpecificCulture("sv-SE")));
}

ImGui.NextColumn();
ImGui.Text($"{listing.RetainerName} {SeIconChar.CrossWorld.ToChar()} {(this.selectedWorld <= 1 ? listing.WorldName : this.worldList[this.selectedWorld].Item1)}");
ImGui.NextColumn();
Expand Down Expand Up @@ -528,11 +548,27 @@ public bool Draw()
}

ImGui.NextColumn();
ImGui.Text(history.PricePerUnit.ToString("C", this.numberFormatInfo));
if (this.priceIconShown)
{
ImGui.Text(history.PricePerUnit.ToString("C", this.numberFormatInfo));
}
else
{
ImGui.Text(history.PricePerUnit.ToString("N0", CultureInfo.CreateSpecificCulture("sv-SE")));
}

ImGui.NextColumn();
ImGui.Text($"{history.Quantity:##,###}");
ImGui.NextColumn();
ImGui.Text(history.Total.ToString("C", this.numberFormatInfo));
if (this.priceIconShown)
{
ImGui.Text(history.Total.ToString("C", this.numberFormatInfo));
}
else
{
ImGui.Text(history.PricePerUnit.ToString("N0", CultureInfo.CreateSpecificCulture("sv-SE")));
}

ImGui.NextColumn();
ImGui.Text($"{DateTimeOffset.FromUnixTimeSeconds(history.Timestamp).LocalDateTime:G}");
ImGui.NextColumn();
Expand Down Expand Up @@ -684,6 +720,9 @@ protected virtual void Dispose(bool disposing)

private void OpenSettingMenu()
{
var scale = ImGui.GetIO().FontGlobalScale;
ImGui.SetNextWindowSize(new Vector2(150, 75) * scale, ImGuiCond.FirstUseEver);

ImGui.Begin("Settings");
var contextMenuIntegration = this.config.ContextMenuIntegration;
if (ImGui.Checkbox("Context menu integration", ref contextMenuIntegration))
Expand All @@ -692,6 +731,12 @@ private void OpenSettingMenu()
MBPlugin.PluginInterface.SavePluginConfig(this.config);
}

if (ImGui.Checkbox("Gil Icon Shown", ref this.priceIconShown))
{
this.config.PriceIconShown = this.priceIconShown;
MBPlugin.PluginInterface.SavePluginConfig(this.config);
}

if (ImGui.Checkbox("Watch for hovered item", ref this.watchingForHoveredItem))
{
this.config.WatchForHovered = this.watchingForHoveredItem;
Expand Down Expand Up @@ -741,7 +786,15 @@ private void ShowShoppingListMenu()
{
ImGui.Text(item.SourceItem.Name);
ImGui.NextColumn();
ImGui.Text(item.Price.ToString("C", this.numberFormatInfo));
if (this.priceIconShown)
{
ImGui.Text(item.Price.ToString("C", this.numberFormatInfo));
}
else
{
ImGui.Text(item.Price.ToString("N0", CultureInfo.CreateSpecificCulture("sv-SE")));
}

ImGui.NextColumn();
ImGui.Text(item.World);
ImGui.NextColumn();
Expand Down
5 changes: 5 additions & 0 deletions MarketBoardPlugin/MBPluginConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,10 @@ public class MBPluginConfig : IPluginConfiguration
/// Gets or sets a value indicating whether the 'Search with Market Board Plugin' is added to game context menus.
/// </summary>
public bool ContextMenuIntegration { get; set; } = true;

/// <summary>
/// Gets or sets a value indicating whether 'PriceIconShown' is enabled.
/// </summary>
public bool PriceIconShown { get; set; } = true;
}
}

0 comments on commit 2ca9d7c

Please sign in to comment.