Skip to content

Commit

Permalink
- The craft overlay has arrived, this collapsable overlay will show y…
Browse files Browse the repository at this point in the history
…ou the next steps in your current craft project.

  - Has a menu for each item for buying/gathering/crafting
  - Is retainer aware, so it'll only show you what you need to extract from each retainer while it's open
  - Provides quick switching between active craft list
- Item icons within the AT interface can now be hovered and a tooltip will show, this can be configured to show never/on icon hover/row hover
- Right clicking on any item within AT will now provide a Gather/Buy/Craft menu with the ability to teleport to specific nodes/shops
- Fishing/Spearfishing items should show more accurate locations
- New filter called "Glamour Ready Combined", shows if an item is part of a set that gets combined in the glamour chest
- Certain vendors were not showing due to having no name will now show their NPCs name instead
- Extra vendors have been included
- Housing vendors have been de-deduplicated
- The item window will show if an item has been combined into a glamour ready set
- Initial 7.11 data
  • Loading branch information
Critical-Impact committed Dec 17, 2024
1 parent 131e700 commit 9e68e4d
Show file tree
Hide file tree
Showing 78 changed files with 2,532 additions and 703 deletions.
53 changes: 53 additions & 0 deletions InventoryTools/Converters/EnumDictionaryConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace InventoryTools.Converters;

public class EnumDictionaryConverter : JsonConverter<Dictionary<string, Enum>>
{
public override void WriteJson(JsonWriter writer, Dictionary<string, Enum> value, JsonSerializer serializer)
{
writer.WriteStartObject();
foreach (var kvp in value)
{
writer.WritePropertyName(kvp.Key);
writer.WriteStartObject();
writer.WritePropertyName("Type");
writer.WriteValue(kvp.Value.GetType().FullName);
writer.WritePropertyName("Assembly");
writer.WriteValue(kvp.Value.GetType().Assembly.GetName().Name);
writer.WritePropertyName("Value");
writer.WriteValue(kvp.Value.ToString());
writer.WriteEndObject();
}
writer.WriteEndObject();
}

public override Dictionary<string, Enum> ReadJson(JsonReader reader, Type objectType, Dictionary<string, Enum> existingValue, bool hasExistingValue, JsonSerializer serializer)
{
var result = new Dictionary<string, Enum>();
var jsonObject = JObject.Load(reader);

foreach (var property in jsonObject.Properties())
{
string key = property.Name;
var typeString = property.Value["Type"]?.ToString();
var assemblyString = property.Value["Assembly"]?.ToString();
var valueString = property.Value["Value"]?.ToString();

Type enumType = AppDomain.CurrentDomain.GetAssemblies().First(c => c.GetName().Name == assemblyString).GetType(typeString);
if (enumType == null)
{
throw new JsonSerializationException($"Unknown type: {typeString}");
}

var enumValue = Enum.Parse(enumType, valueString);
result[key] = (Enum)enumValue;
}

return result;
}
}
9 changes: 9 additions & 0 deletions InventoryTools/Extensions/ITextureProviderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.IO;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;

namespace InventoryTools.Extensions
Expand All @@ -10,5 +12,12 @@ public static class ITextureProviderExtensions
{
return textureProvider.GetFromGame(string.Format("ui/uld/{0}.tex", iconName));
}

public static ISharedImmediateTexture GetPluginImageTexture(this ITextureProvider textureProvider, IDalamudPluginInterface pluginInterface, string imageName)
{
var assemblyLocation = pluginInterface.AssemblyLocation.DirectoryName!;
var imagePath = Path.Combine(assemblyLocation, Path.Combine("Images", $"{imageName}.png"));
return textureProvider.GetFromFile(new FileInfo(imagePath));
}
}
}
2 changes: 2 additions & 0 deletions InventoryTools/Extensions/SettingCategoryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public static string FormattedName(this SettingCategory settingCategory)
return "Visuals";
case SettingCategory.MarketBoard:
return "Marketboard";
case SettingCategory.CraftOverlay:
return "Craft Overlay";
case SettingCategory.ToolTips:
return "Tooltips";
case SettingCategory.Hotkeys:
Expand Down
81 changes: 80 additions & 1 deletion InventoryTools/InventoryToolsConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Dalamud.Configuration;
using Dalamud.Interface.Colors;
using InventoryTools.Attributes;
using InventoryTools.Converters;
using InventoryTools.Logic;
using InventoryTools.Logic.Editors;
using InventoryTools.Logic.Settings;
Expand All @@ -18,7 +19,7 @@
namespace InventoryTools
{
[Serializable]
public class InventoryToolsConfiguration : IPluginConfiguration
public class InventoryToolsConfiguration : IPluginConfiguration, IConfigurable<bool?>, IConfigurable<int?>, IConfigurable<Enum?>
{
[JsonIgnore]
public bool IsDirty { get; set; }
Expand Down Expand Up @@ -78,6 +79,9 @@ public class InventoryToolsConfiguration : IPluginConfiguration
private HashSet<string>? _windowsIgnoreEscape = new HashSet<string>();
private HashSet<uint>? _favouriteItemsList = new HashSet<uint>();
private TooltipAmountOwnedSort _tooltipAmountOwnedSort = TooltipAmountOwnedSort.Alphabetically;
private Dictionary<string, bool>? _booleanSettings = new();
private Dictionary<string, int>? _integerSettings = new();
private Dictionary<string, Enum>? _enumSettings = new();

[JsonProperty] [DefaultValue(300)] public int CraftWindowSplitterPosition { get; set; } = 300;

Expand Down Expand Up @@ -906,6 +910,25 @@ public int TooltipFooterLines

public LogLevel LogLevel { get; set; } = LogLevel.Information;

public Dictionary<string, bool> BooleanSettings
{
get => _booleanSettings ??= new Dictionary<string, bool>();
set => _booleanSettings = value;
}

public Dictionary<string, int> IntegerSettings
{
get => _integerSettings ??= new Dictionary<string, int>();
set => _integerSettings = value;
}

[JsonConverter(typeof(EnumDictionaryConverter))]
public Dictionary<string, Enum> EnumSettings
{
get => _enumSettings ??= new Dictionary<string, Enum>();
set => _enumSettings = value;
}


//Configuration Helpers

Expand Down Expand Up @@ -948,5 +971,61 @@ public bool HasList(string name)
}


public bool? Get(string key, bool? defaultValue)
{
return this.BooleanSettings.TryGetValue(key, out var value) ? value : defaultValue;
}

public void Set(string key, int? newValue)
{
if (newValue == null)
{
this.IntegerSettings.Remove(key);
}
else
{
this.IntegerSettings[key] = newValue.Value;
}

this.IsDirty = true;
}

public void Set(string key, bool? newValue)
{
if (newValue == null)
{
this.BooleanSettings.Remove(key);
}
else
{
this.BooleanSettings[key] = newValue.Value;
}

this.IsDirty = true;
}

public int? Get(string key, int? defaultValue)
{
return this.IntegerSettings.TryGetValue(key, out var value) ? value : defaultValue;
}

public Enum? Get(string key, Enum? defaultValue)
{
return this.EnumSettings.GetValueOrDefault(key);
}

public void Set(string key, Enum? newValue)
{
if (newValue == null)
{
this.EnumSettings.Remove(key);
}
else
{
this.EnumSettings[key] = newValue;
}

this.IsDirty = true;
}
}
}
12 changes: 10 additions & 2 deletions InventoryTools/InventoryToolsPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
using InventoryTools.Logic.Editors;
using InventoryTools.Logic.Features;
using InventoryTools.Logic.Filters;
using InventoryTools.Logic.GenericFilters;
using InventoryTools.Logic.ItemRenderers;
using InventoryTools.Logic.Settings.Abstract;
using InventoryTools.Misc;
Expand Down Expand Up @@ -87,13 +88,15 @@ public InventoryToolsPlugin(IDalamudPluginInterface pluginInterface, IPluginLog
_framework = framework;
PluginInterface = pluginInterface;
_service = PluginInterface.Create<Service>()!;
CreateHost();
this.Host = CreateHost();

Start();
loadConfigStopwatch.Stop();
pluginLog.Verbose("Took " + loadConfigStopwatch.Elapsed.TotalSeconds + " to start Allagan Tools.");
}

public IHost Host { get; set; }

private List<Type> HostedServices { get; } = new()
{
typeof(ConfigurationManagerService),
Expand Down Expand Up @@ -264,6 +267,10 @@ public override void PreBuild(IHostBuilder hostBuilder)
builder
.RegisterType(typeof(GenericHasUseCategoryFilter))
.AsSelf();

builder
.RegisterType(typeof(GenericBooleanFilter))
.AsSelf();
});

hostBuilder.ConfigureContainer<ContainerBuilder>(builder =>
Expand Down Expand Up @@ -336,7 +343,8 @@ public override void PreBuild(IHostBuilder hostBuilder)
});

builder.RegisterType<PluginCommands>().SingleInstance();
builder.RegisterType<RightClickService>().SingleInstance();
builder.RegisterType<ImGuiMenuService>().SingleInstance();
builder.RegisterType<ImGuiTooltipService>().SingleInstance();
builder.RegisterType<TryOn>().SingleInstance();
builder.RegisterType<TetrisGame>().SingleInstance();
builder.RegisterType<WotsitIpc>().As<IWotsitIpc>().SingleInstance();
Expand Down
4 changes: 2 additions & 2 deletions InventoryTools/Logic/Columns/Buttons/CraftBuyColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void DrawSupplierRow(ItemRow item,(IShop shop, ENpcBaseRow? npc, ILocation? loca
messages.Add(new RequestTeleportMessage(nearestAetheryte.Value.RowId));
}

_chatUtilities.PrintFullMapLink(tuple.location, item.NameString);
_chatUtilities.PrintFullMapLink(tuple.location, tuple.npc.ENpcResidentRow.Base.Singular.ExtractText());
ImGui.CloseCurrentPopup();
}
}
Expand Down Expand Up @@ -146,7 +146,7 @@ private bool DrawVendorButton(ItemRow item, int rowIndex, List<MessageBase> mess
messages.Add(new RequestTeleportMessage(nearestAetheryte.Value.RowId));
}

_chatUtilities.PrintFullMapLink(vendor.location, vendor.location.ToString());
_chatUtilities.PrintFullMapLink(vendor.location, vendor.npc?.ENpcResidentRow.Base.Singular.ExtractText() ?? vendor.location.ToString());
}
else
{
Expand Down
27 changes: 24 additions & 3 deletions InventoryTools/Logic/Columns/IconColumn.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Collections.Generic;
using System.Numerics;
using CriticalCommonLib.Services.Mediator;

using Dalamud.Game.ClientState.Keys;
using Dalamud.Plugin.Services;
using ImGuiNET;
using InventoryTools.Logic.Columns.Abstract;
using InventoryTools.Logic.Settings;
using InventoryTools.Mediator;
using InventoryTools.Services;
using InventoryTools.Ui;
Expand All @@ -14,8 +16,17 @@ namespace InventoryTools.Logic.Columns
{
public class IconColumn : GameIconColumn
{
public IconColumn(ILogger<IconColumn> logger, ImGuiService imGuiService) : base(logger, imGuiService)
private readonly ImGuiTooltipService _tooltipService;
private readonly ImGuiTooltipModeSetting _tooltipModeSetting;
private readonly InventoryToolsConfiguration _configuration;
private readonly IKeyState _keyState;

public IconColumn(ILogger<IconColumn> logger, ImGuiTooltipService tooltipService, ImGuiService imGuiService, ImGuiTooltipModeSetting tooltipModeSetting, InventoryToolsConfiguration configuration, IKeyState keyState) : base(logger, imGuiService)
{
_tooltipService = tooltipService;
_tooltipModeSetting = tooltipModeSetting;
_configuration = configuration;
_keyState = keyState;
}
public override ColumnCategory ColumnCategory => ColumnCategory.Basic;
public override (ushort, bool)? CurrentValue(ColumnConfiguration columnConfiguration, SearchResult searchResult)
Expand Down Expand Up @@ -49,7 +60,17 @@ public override IEnumerable<SearchResult> Sort(ColumnConfiguration columnConfigu
if (ImGui.ImageButton(ImGuiService.GetIconTexture(currentValue.Value.Item1, currentValue.Value.Item2).ImGuiHandle, new Vector2(filterConfiguration.TableHeight - 1, filterConfiguration.TableHeight - 1) * ImGui.GetIO().FontGlobalScale,new Vector2(0,0), new Vector2(1,1), 2))
{
ImGui.PopID();
messages.Add(new OpenUintWindowMessage(typeof(ItemWindow), searchResult.Item.RowId));
if (!this._keyState[VirtualKey.CONTROL] && !this._keyState[VirtualKey.SHIFT] && !this._keyState[VirtualKey.MENU])
{
messages.Add(new OpenUintWindowMessage(typeof(ItemWindow), searchResult.Item.RowId));
}
}
if (_tooltipModeSetting.CurrentValue(_configuration) == ImGuiTooltipMode.Icons)
{
if (ImGui.IsItemHovered())
{
_tooltipService.DrawItemTooltip(searchResult);
}
}
ImGui.PopID();
}
Expand Down
17 changes: 16 additions & 1 deletion InventoryTools/Logic/Columns/NameIconColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@
using ImGuiNET;
using InventoryTools.Logic.Columns.Abstract;
using Dalamud.Interface.Utility.Raii;
using InventoryTools.Logic.Settings;
using InventoryTools.Services;
using Microsoft.Extensions.Logging;

namespace InventoryTools.Logic.Columns;

public class NameIconColumn : TextIconColumn
{
private readonly ImGuiTooltipService _tooltipService;
private readonly ImGuiTooltipModeSetting _tooltipModeSetting;
private readonly InventoryToolsConfiguration _configuration;

public NameIconColumn(ILogger<NameIconColumn> logger, ImGuiService imGuiService) : base(logger, imGuiService)
public NameIconColumn(ILogger<NameIconColumn> logger, ImGuiTooltipService tooltipService, ImGuiTooltipModeSetting tooltipModeSetting, ImGuiService imGuiService, InventoryToolsConfiguration configuration) : base(logger, imGuiService)
{
_tooltipService = tooltipService;
_tooltipModeSetting = tooltipModeSetting;
_configuration = configuration;
}
public override ColumnCategory ColumnCategory => ColumnCategory.Basic;
public override (string, ushort, bool)? CurrentValue(ColumnConfiguration columnConfiguration, SearchResult searchResult)
Expand All @@ -35,6 +42,14 @@ public override (string, ushort, bool)? CurrentValue(ColumnConfiguration columnC
SearchResult searchResult, int rowIndex, int columnIndex)
{
base.Draw(configuration, columnConfiguration, searchResult, rowIndex, columnIndex);
_tooltipService.DrawItemTooltip(searchResult);
if (_tooltipModeSetting.CurrentValue(_configuration) == ImGuiTooltipMode.Icons)
{
if (ImGui.IsItemHovered())
{
_tooltipService.DrawItemTooltip(searchResult);
}
}
if (searchResult.CraftItem != null && searchResult.CraftItem.IsOutputItem)
{
var itemRecipes = searchResult.Item.Recipes
Expand Down
3 changes: 2 additions & 1 deletion InventoryTools/Logic/CraftItemTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
using Newtonsoft.Json.Converters;
using OtterGui;
using Dalamud.Interface.Utility.Raii;
using InventoryTools.Logic.Settings;
using InventoryTools.Services;

namespace InventoryTools.Logic
{
public class CraftItemTable : RenderTableBase
{
public CraftItemTable(RightClickService rightClickService, InventoryToolsConfiguration configuration) : base(rightClickService, configuration)
public CraftItemTable(ImGuiMenuService imGuiMenuService, ImGuiTooltipService imGuiTooltipService, InventoryToolsConfiguration configuration, ImGuiTooltipModeSetting tooltipModeSetting) : base(imGuiMenuService, imGuiTooltipService, tooltipModeSetting, configuration)
{
_tableFlags = ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersV |
ImGuiTableFlags.BordersOuterV | ImGuiTableFlags.BordersInnerV |
Expand Down
3 changes: 2 additions & 1 deletion InventoryTools/Logic/FilterTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
using Newtonsoft.Json.Converters;
using OtterGui;
using Dalamud.Interface.Utility.Raii;
using InventoryTools.Logic.Settings;
using InventoryTools.Services;

namespace InventoryTools.Logic
{
public class FilterTable : RenderTableBase
{
public FilterTable(RightClickService rightClickService, InventoryToolsConfiguration configuration) : base(rightClickService, configuration)
public FilterTable(ImGuiMenuService imGuiMenuService, ImGuiTooltipService imGuiTooltipService, InventoryToolsConfiguration configuration, ImGuiTooltipModeSetting tooltipModeSetting) : base(imGuiMenuService, imGuiTooltipService, tooltipModeSetting, configuration)
{

}
Expand Down
Loading

0 comments on commit 9e68e4d

Please sign in to comment.