Skip to content

Commit e10117d

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents a837998 + ef4f92b commit e10117d

File tree

265 files changed

+5046
-5637
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

265 files changed

+5046
-5637
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using InventoryTools.Logic;
3+
4+
namespace InventoryTools.Extensions;
5+
6+
public static class FilterTypeExtensions
7+
{
8+
public static string FormattedName(this FilterType filterType)
9+
{
10+
return filterType switch
11+
{
12+
FilterType.None => "None",
13+
FilterType.SearchFilter => "Search List",
14+
FilterType.SortingFilter => "Sort List",
15+
FilterType.GameItemFilter => "Game Item List",
16+
FilterType.CraftFilter => "Craft List",
17+
FilterType.HistoryFilter => "History List",
18+
FilterType.CuratedList => "Curated List",
19+
_ => "Unknown"
20+
};
21+
}
22+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using FFXIVClientStructs.FFXIV.Client.Game;
3+
4+
namespace InventoryTools.Extensions;
5+
6+
public static class ItemFlagsExtensions
7+
{
8+
public static string FormattedName(this InventoryItem.ItemFlags flags)
9+
{
10+
return flags switch
11+
{
12+
InventoryItem.ItemFlags.None => "None",
13+
InventoryItem.ItemFlags.HighQuality => "High Quality",
14+
InventoryItem.ItemFlags.CompanyCrestApplied => "Company Crest Applied",
15+
InventoryItem.ItemFlags.Relic => "Relic",
16+
InventoryItem.ItemFlags.Collectable => "Collectable",
17+
_ => "None"
18+
};
19+
}
20+
}

InventoryTools/Extensions/StringExtensions.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,12 @@ public static class StringExtensions
1010
public static void OpenBrowser(this string url) {
1111
Process.Start(new ProcessStartInfo {FileName = url, UseShellExecute = true});
1212
}
13-
13+
1414
public static string ToTitleCase(this string title)
1515
{
16-
return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(title.ToLower());
17-
}
18-
19-
public static void ToClipboard(this string text)
20-
{
21-
ImGui.SetClipboardText(text);
16+
return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(title.ToLower());
2217
}
23-
18+
2419
public static string ToSentence( this string input )
2520
{
2621
return new string(input.SelectMany((c, i) => i > 0 && char.IsUpper(c) ? new[] { ' ', c } : new[] { c }).ToArray());

InventoryTools/IPC/IPCService.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -264,30 +264,33 @@ private Dictionary<uint, uint> GetFilterItems(string filterKey)
264264
if (filter.FilterType == FilterType.SearchFilter || filter.FilterType == FilterType.SortingFilter)
265265
{
266266
var filterResult = _listFilterService.RefreshList(filter);
267-
foreach (var sortedItem in filterResult.SortedItems)
267+
foreach (var sortedItem in filterResult)
268268
{
269-
if (filterItems.ContainsKey(sortedItem.InventoryItem.ItemId))
269+
if (sortedItem.InventoryItem != null)
270270
{
271-
filterItems[sortedItem.InventoryItem.ItemId] += sortedItem.InventoryItem.Quantity;
272-
}
273-
else
274-
{
275-
filterItems.Add(sortedItem.InventoryItem.ItemId, sortedItem.InventoryItem.Quantity);
271+
if (filterItems.ContainsKey(sortedItem.InventoryItem.ItemId))
272+
{
273+
filterItems[sortedItem.InventoryItem.ItemId] += sortedItem.InventoryItem.Quantity;
274+
}
275+
else
276+
{
277+
filterItems.Add(sortedItem.InventoryItem.ItemId, sortedItem.InventoryItem.Quantity);
278+
}
276279
}
277280
}
278281
}
279282
if (filter.FilterType == FilterType.GameItemFilter)
280283
{
281284
var filterResult = _listFilterService.RefreshList(filter);
282-
foreach (var sortedItem in filterResult.AllItems)
285+
foreach (var sortedItem in filterResult)
283286
{
284-
if (filterItems.ContainsKey(sortedItem.RowId))
287+
if (filterItems.ContainsKey(sortedItem.Item.RowId))
285288
{
286-
filterItems[sortedItem.RowId] += 0;
289+
filterItems[sortedItem.Item.RowId] += 0;
287290
}
288291
else
289292
{
290-
filterItems.Add(sortedItem.RowId, 0);
293+
filterItems.Add(sortedItem.Item.RowId, 0);
291294
}
292295
}
293296
}

InventoryTools/InventoryTools.csproj

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,28 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<Import Project="Dalamud.Plugin.Bootstrap.targets"/>
3-
3+
44
<PropertyGroup>
5-
<LangVersion>12</LangVersion>
65
<Version>1.7.0.20</Version>
76
<AssemblyName>InventoryTools</AssemblyName>
8-
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
9-
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
10-
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
11-
<NoWarn>IDE0003</NoWarn>
7+
<NoWarn>IDE0003</NoWarn>
128
<OutputType>Library</OutputType>
139
<OutputPath>bin\$(Configuration)\</OutputPath>
14-
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
1510
<Configurations>Debug;Release;FullDebug</Configurations>
16-
<Platforms>AnyCPU</Platforms>
17-
<Nullable>enable</Nullable>
18-
<TargetFramework>net8.0-windows</TargetFramework>
1911
</PropertyGroup>
2012

21-
<PropertyGroup>
22-
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
23-
</PropertyGroup>
24-
2513
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
2614
<PlatformTarget>x64</PlatformTarget>
2715
</PropertyGroup>
2816

2917
<ItemGroup>
3018
<PackageReference Include="Autofac" Version="8.0.0" />
3119
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="9.0.0" />
32-
<PackageReference Include="DalaMock.Host" Version="2.0.23" />
20+
<PackageReference Include="DalaMock.Host" Version="2.0.28" />
3321
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
3422
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.11" />
3523
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="7.0.11" />
3624
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
3725
<PackageReference Include="CsvHelper" Version="30.0.1" />
38-
<PackageReference Include="DalamudPackager" Version="2.1.12" />
3926
<PackageReference Include="SerialQueue" Version="2.1.0" />
4027
<PackageReference Include="System.Reactive" Version="5.0.0" />
4128
<ProjectReference Include="..\CriticalCommonLib\CriticalCommonLib.csproj" />

InventoryTools/InventoryToolsPlugin.cs

Lines changed: 65 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class InventoryToolsPlugin : HostedPlugin
5656
private readonly IPluginLog _pluginLog;
5757
private Service? _service;
5858
private IDalamudPluginInterface PluginInterface { get; set; }
59-
59+
6060
public InventoryToolsPlugin(IDalamudPluginInterface pluginInterface, IPluginLog pluginLog,
6161
IAddonLifecycle addonLifecycle, IChatGui chatGui, IClientState clientState, ICommandManager commandManager,
6262
ICondition condition, IDataManager dataManager, IFramework framework, IGameGui gameGui,
@@ -73,9 +73,57 @@ public InventoryToolsPlugin(IDalamudPluginInterface pluginInterface, IPluginLog
7373
PluginInterface = pluginInterface;
7474
_service = PluginInterface.Create<Service>()!;
7575
CreateHost();
76-
76+
7777
Start();
78-
78+
79+
}
80+
81+
private List<Type> HostedServices { get; } = new()
82+
{
83+
typeof(ExcelCache),
84+
typeof(ConfigurationManagerService),
85+
typeof(ContextMenuService),
86+
typeof(ListService),
87+
typeof(OverlayService),
88+
typeof(HostedUniversalis),
89+
typeof(WotsitIpc),
90+
typeof(ListFilterService),
91+
typeof(MediatorService),
92+
typeof(MigrationManagerService),
93+
typeof(PluginCommandManager<PluginCommands>),
94+
typeof(PluginLogic),
95+
typeof(BootService),
96+
typeof(ServiceConfigurator),
97+
typeof(WindowService),
98+
typeof(TableService),
99+
typeof(InventoryToolsUi),
100+
typeof(TeleporterService),
101+
typeof(LaunchButtonService),
102+
typeof(HostedInventoryHistory),
103+
typeof(OdrScanner),
104+
typeof(IPCService),
105+
typeof(HostedCraftMonitor),
106+
typeof(ItemSearchService),
107+
108+
};
109+
110+
public List<Type> GetHostedServices()
111+
{
112+
var hostedServices = HostedServices.ToList();
113+
Dictionary<Type, Type> replacements = new();
114+
ReplaceHostedServices(replacements);
115+
foreach (var replacement in replacements)
116+
{
117+
hostedServices.Remove(replacement.Key);
118+
hostedServices.Add(replacement.Value);
119+
}
120+
121+
return hostedServices;
122+
}
123+
124+
public virtual void ReplaceHostedServices(Dictionary<Type,Type> replacements)
125+
{
126+
79127
}
80128

81129
public override void PreBuild(IHostBuilder hostBuilder)
@@ -140,7 +188,7 @@ public override void PreBuild(IHostBuilder hostBuilder)
140188
{
141189
if (pair.Key.IsAssignableFrom(type))
142190
{
143-
builder.RegisterType(type).As(pair.Value).As(pair.Key).As(type).ExternallyOwned();
191+
builder.RegisterType(type).As(pair.Value).AsImplementedInterfaces().As(pair.Key).As(type).ExternallyOwned();
144192
}
145193
}
146194

@@ -191,29 +239,12 @@ public override void PreBuild(IHostBuilder hostBuilder)
191239
//Hosted service registrations
192240
hostBuilder.ConfigureContainer<ContainerBuilder>(builder =>
193241
{
194-
//Needs to be externally owned as the hosted service causes a second registration in the container which causes it to dispose twice even though it's only constructed once
195-
builder.RegisterType<ExcelCache>().SingleInstance().ExternallyOwned();
196-
builder.RegisterType<ConfigurationManagerService>().SingleInstance().ExternallyOwned();
197-
builder.RegisterType<ContextMenuService>().SingleInstance().ExternallyOwned();
198-
builder.RegisterType<ListService>().As<IListService>().SingleInstance().ExternallyOwned();
199-
builder.RegisterType<OverlayService>().As<IOverlayService>().SingleInstance().ExternallyOwned();
200-
builder.RegisterType<HostedUniversalis>().AsSelf().As<IUniversalis>().SingleInstance()
201-
.ExternallyOwned();
202-
builder.RegisterType<WotsitIpc>().As<IWotsitIpc>().SingleInstance().ExternallyOwned();
203-
builder.RegisterType<ListFilterService>().SingleInstance().ExternallyOwned();
204-
builder.RegisterType<MediatorService>().SingleInstance().ExternallyOwned();
205-
builder.RegisterType<MigrationManagerService>().SingleInstance().ExternallyOwned();
206-
builder.RegisterType<PluginCommandManager<PluginCommands>>().SingleInstance().ExternallyOwned();
207-
builder.RegisterType<PluginLogic>().SingleInstance().ExternallyOwned();
208-
builder.RegisterType<BootService>().SingleInstance().ExternallyOwned();
209-
builder.RegisterType<ServiceConfigurator>().ExternallyOwned().SingleInstance();
210-
builder.RegisterType<WindowService>().SingleInstance().ExternallyOwned();
211-
builder.RegisterType<TableService>().SingleInstance().ExternallyOwned();
212-
builder.RegisterType<InventoryToolsUi>().SingleInstance().ExternallyOwned();
213-
builder.RegisterType<TeleporterService>().SingleInstance().ExternallyOwned();
214-
builder.RegisterType<LaunchButtonService>().SingleInstance().ExternallyOwned();
215-
builder.RegisterType<HostedInventoryHistory>().SingleInstance().ExternallyOwned();
216-
builder.RegisterType<ItemSearchService>().SingleInstance().ExternallyOwned();
242+
foreach (var hostedService in GetHostedServices())
243+
{
244+
builder.RegisterType(hostedService).AsSelf().AsImplementedInterfaces().As<IHostedService>().SingleInstance();
245+
}
246+
247+
builder.RegisterType<QuestManagerService>().AsImplementedInterfaces().AsSelf().SingleInstance();
217248
});
218249

219250
hostBuilder.ConfigureContainer<ContainerBuilder>(builder =>
@@ -222,11 +253,11 @@ public override void PreBuild(IHostBuilder hostBuilder)
222253
builder.RegisterType<SeTime>().As<ISeTime>().SingleInstance();
223254
builder.RegisterType<ConfigurationWizardService>().SingleInstance();
224255
builder.RegisterType<FileDialogManager>().SingleInstance();
256+
builder.RegisterType<DalamudFileDialogManager>().As<IFileDialogManager>().SingleInstance();
225257
builder.RegisterType<BackgroundTaskQueue>().As<IBackgroundTaskQueue>();
226258
builder.RegisterType<CharacterMonitor>().As<ICharacterMonitor>().SingleInstance();
227259
builder.RegisterType<ChatUtilities>().As<IChatUtilities>().SingleInstance();
228260
builder.RegisterType<ConfigurationWizardService>().As<IConfigurationWizardService>().SingleInstance();
229-
builder.RegisterType<HostedCraftMonitor>().AsSelf().As<ICraftMonitor>().SingleInstance();
230261
builder.RegisterType<FilterService>().As<IFilterService>().SingleInstance();
231262
builder.RegisterType<Font>().As<IFont>().SingleInstance();
232263
builder.RegisterType<GameInterface>().As<IGameInterface>().SingleInstance();
@@ -237,6 +268,7 @@ public override void PreBuild(IHostBuilder hostBuilder)
237268
builder.RegisterType<MarketBoardService>().As<IMarketBoardService>().SingleInstance();
238269
builder.RegisterType<MarketCache>().As<IMarketCache>().SingleInstance();
239270
builder.RegisterType<MobTracker>().As<IMobTracker>().SingleInstance();
271+
builder.RegisterType<ClipboardService>().As<IClipboardService>().SingleInstance();
240272
builder.RegisterType<IPCService>().SingleInstance();
241273
builder.RegisterType<TeleporterIpc>().As<ITeleporterIpc>().SingleInstance();
242274
builder.RegisterType<TooltipService>().As<ITooltipService>().SingleInstance();
@@ -245,7 +277,8 @@ public override void PreBuild(IHostBuilder hostBuilder)
245277
builder.RegisterType<InventoryHistory>().SingleInstance();
246278
builder.RegisterType<ListCategoryService>().SingleInstance();
247279
builder.RegisterType<Logger>().SingleInstance();
248-
builder.RegisterType<OdrScanner>().SingleInstance();
280+
builder.RegisterType<PopupService>().SingleInstance();
281+
249282
builder.RegisterType<PluginCommands>().SingleInstance();
250283
builder.RegisterType<RightClickService>().SingleInstance();
251284
builder.RegisterType<TryOn>().SingleInstance();
@@ -257,7 +290,7 @@ public override void PreBuild(IHostBuilder hostBuilder)
257290
builder.RegisterType<VersionInfo>().SingleInstance();
258291
builder.RegisterType<CraftPricer>().SingleInstance();
259292
builder.RegisterType<InventoryScopePicker>();
260-
builder.RegisterType<InventoryScopeCalculator>().SingleInstance();
293+
builder.RegisterType<InventoryScopeCalculator>().SingleInstance();
261294
builder.RegisterType<GameInteropService>().As<IGameInteropService>().SingleInstance();
262295
builder.RegisterType<WindowSystemFactory>().As<IWindowSystemFactory>().SingleInstance();
263296
builder.RegisterType<DalamudWindowSystem>().As<IWindowSystem>();
@@ -426,43 +459,16 @@ public override void PreBuild(IHostBuilder hostBuilder)
426459
};
427460
});
428461
});
429-
hostBuilder
430-
.ConfigureServices(collection =>
431-
{
432-
collection.AddHostedService(p => p.GetRequiredService<ExcelCache>());
433-
collection.AddHostedService(p => p.GetRequiredService<MigrationManagerService>());
434-
collection.AddHostedService(p => p.GetRequiredService<ServiceConfigurator>());
435-
collection.AddHostedService(p => p.GetRequiredService<IListService>());
436-
collection.AddHostedService(p => p.GetRequiredService<ListFilterService>());
437-
collection.AddHostedService(p => p.GetRequiredService<MediatorService>());
438-
collection.AddHostedService(p => p.GetRequiredService<PluginLogic>());
439-
collection.AddHostedService(p => p.GetRequiredService<WindowService>());
440-
collection.AddHostedService(p => p.GetRequiredService<TableService>());
441-
collection.AddHostedService(p => p.GetRequiredService<IOverlayService>());
442-
collection.AddHostedService(p => p.GetRequiredService<IWotsitIpc>());
443-
collection.AddHostedService(p => p.GetRequiredService<TeleporterService>());
444-
collection.AddHostedService(p => p.GetRequiredService<ContextMenuService>());
445-
collection.AddHostedService(p => p.GetRequiredService<PluginCommandManager<PluginCommands>>());
446-
collection.AddHostedService(p => p.GetRequiredService<BootService>());
447-
collection.AddHostedService(p => p.GetRequiredService<ConfigurationManagerService>());
448-
collection.AddHostedService(p => p.GetRequiredService<InventoryToolsUi>());
449-
collection.AddHostedService(p => p.GetRequiredService<HostedUniversalis>());
450-
collection.AddHostedService(p => p.GetRequiredService<LaunchButtonService>());
451-
collection.AddHostedService(p => p.GetRequiredService<HostedInventoryHistory>());
452-
collection.AddHostedService(p => p.GetRequiredService<IPCService>());
453-
collection.AddHostedService(p => p.GetRequiredService<HostedCraftMonitor>());
454-
collection.AddHostedService(p => p.GetRequiredService<ItemSearchService>());
455-
});
456462
}
457463

458464
public override void ConfigureContainer(ContainerBuilder containerBuilder)
459465
{
460-
466+
461467
}
462468

463469
public override void ConfigureServices(IServiceCollection serviceCollection)
464470
{
465-
471+
466472
}
467473

468474
protected virtual void Dispose(bool disposing)

0 commit comments

Comments
 (0)