Skip to content

Commit

Permalink
# This is a combination of 105 commits.
Browse files Browse the repository at this point in the history
^ This is the 1st commit message:

Add support for the DalamudSubstitutionProvider for textures.

^ The commit message xivdev#2 will be skipped:

^ Cleanup.

^ The commit message xivdev#3 will be skipped:

^ Add drag & drop to texture import.

^ The commit message xivdev#4 will be skipped:

^ 0.7.3.0

^ The commit message xivdev#5 will be skipped:

^ [CI] Updating repo.json for 0.7.3.0

^ The commit message xivdev#6 will be skipped:

^ Temporarily not use dalamud function because it is not available in release yet.

^ The commit message xivdev#7 will be skipped:

^ [CI] Updating repo.json for 0.7.3.1

^ The commit message xivdev#8 will be skipped:

^ Add Asset Compiler tab
^
^ Add Loose Texture Compiler Core
^
^ Submodule changes
^
^ Correct text
^
^ Add custom path function.
^
^ Refactor name to asset compiler
^
^ Right align buttons. Store project files outside of the folder of the currently selected mod.
^
^ Add Simple Mode
^
^ Fix issue with simple mode not clearing itself.
^
^ Update constructors
^
^ Add modifier keys to filepicker clearing buttons.
^
^ Submodule changes
^
^ Minor cleanup
^
^ Adjust event names
^
^ Fix project persistence.
^
^ Add a cap to how many texture sets can exist.
^
^ Only save project if asset compiler tab is actually used.
^
^ Submodule updates
^
^ Remove incomplete class.
^
^ Add Drag And Drop, add bulk name replacement.

# The commit message xivdev#9 will be skipped:

# Attempt to fix some texture errors.

# The commit message xivdev#10 will be skipped:

# Get penumbra to compile again.

# The commit message xivdev#11 will be skipped:

# Submodule update

# The commit message xivdev#12 will be skipped:

# Disable UI for textures when converting.

# The commit message xivdev#13 will be skipped:

# Update DirectXTex/OtterTex

# The commit message xivdev#14 will be skipped:

# Keep the texture alive during write.

# The commit message xivdev#15 will be skipped:

# [CI] Updating repo.json for 0.7.3.2

# The commit message xivdev#16 will be skipped:

# Explain comment.

# The commit message xivdev#17 will be skipped:

# Add some unnamed mounts to actor identification.

# The commit message xivdev#18 will be skipped:

# Material editor: improve color accuracy

# The commit message xivdev#19 will be skipped:

# Material editor: live-preview changes

# The commit message xivdev#20 will be skipped:

# Material editor 2099

# The commit message xivdev#21 will be skipped:

# Material editor: better color constants

# The commit message xivdev#22 will be skipped:

# Update GameData

# The commit message xivdev#23 will be skipped:

# Material editor: Allow negatives again with R²G²B²
#
# There seems to be people using it.

# The commit message xivdev#24 will be skipped:

# Material editor: tweak colorset highlighting
#
# Make the frequency framerate-independent, set it to 1 Hz, and decrease the dynamic range.
#
# Thanks @StoiaCode for feedback!

# The commit message xivdev#25 will be skipped:

# Material editor: tear down previewers bound to a CharacterBase that goes away

# The commit message xivdev#26 will be skipped:

# Add a few texture manipulation tools.

# The commit message xivdev#27 will be skipped:

# Small cleanup, auto-formatting.

# The commit message xivdev#28 will be skipped:

# Textures: Un-merge save buttons, make ignore unselectable

# The commit message xivdev#29 will be skipped:

# Textures: Renumber CombineOps.
#
# Positive values in this enum also double as indices into the labels and tooltip arrays.
#
# (confirmed skill issue moment)

# The commit message xivdev#30 will be skipped:

# Textures: Automatic resizing

# The commit message xivdev#31 will be skipped:

# Textures: Add a matrix preset that drops alpha

# The commit message xivdev#32 will be skipped:

# Textures: PR xivdev#327 feedback

# The commit message xivdev#33 will be skipped:

# Textures: PR xivdev#327 feedback

# The commit message xivdev#34 will be skipped:

# Textures: Refactor resizing code

# The commit message xivdev#35 will be skipped:

# Textures: Simplify away _targetPixels

# The commit message xivdev#36 will be skipped:

# Slight restructuring.

# The commit message xivdev#37 will be skipped:

#  Skin Fixer (fixes modding of skin.shpk)

# The commit message xivdev#38 will be skipped:

# Skin Fixer: Make resolving skin.shpk for new draw objects async

# The commit message xivdev#39 will be skipped:

# Skin Fixer: Fix potential ref leak + add SRH
#
# `SafeResourceHandle` wraps a `ResourceHandle*` with auto `IncRef` / `DecRef`, to further help prevent leaks.

# The commit message xivdev#40 will be skipped:

# Use better event in SkinFixer and some cleanup.

# The commit message xivdev#41 will be skipped:

# Remove Finalize from FileEditor.

# The commit message xivdev#42 will be skipped:

# Some formatting in Materials.Shpk.

# The commit message xivdev#43 will be skipped:

# Small cleanup in ResolveContext.

# The commit message xivdev#44 will be skipped:

# Auto-formatting and some cleanup.

# The commit message xivdev#45 will be skipped:

# Restructure Live Preview.

# The commit message xivdev#46 will be skipped:

# Fix slash direction in material path.

# The commit message xivdev#47 will be skipped:

# [CI] Updating repo.json for testing_0.7.3.3

# The commit message xivdev#48 will be skipped:

# Fix newtonsoft not playing well with records with strings.

# The commit message xivdev#49 will be skipped:

# Cleanup

# The commit message xivdev#50 will be skipped:

# Check for drawObject != null before invoking draw object created event.

# The commit message xivdev#51 will be skipped:

# Fix variant gamepath.

# The commit message xivdev#52 will be skipped:

# Material editor: use a SafeHandle for texture swapping

# The commit message #53 will be skipped:

# Material editor: Customizable highlight color

# The commit message xivdev#54 will be skipped:

# Material editor: Vector field spacing

# The commit message xivdev#55 will be skipped:

# Fix compiler warning

# The commit message xivdev#56 will be skipped:

# [CI] Updating repo.json for testing_0.7.3.4

# The commit message xivdev#57 will be skipped:

# Resource Tree: Improve mtrl and sklb support

# The commit message xivdev#58 will be skipped:

# Resource Tree: Deduplicate nodes, add skp

# The commit message xivdev#59 will be skipped:

# Resource Tree: Add ChangedItem-like icons, make UI prettier

# The commit message xivdev#60 will be skipped:

# Resource Tree: Make skp child of sklb

# The commit message xivdev#61 will be skipped:

# Resource Tree: Fix shared model fold state

# The commit message xivdev#62 will be skipped:

# Some auto-formatting and ROS iteration for lookups.

# The commit message #63 will be skipped:

# Resource Tree: Use `/`s for game actual paths

# The commit message xivdev#64 will be skipped:

# Skin Fixer: Switch to a passive approach.
#
# Do not load skin.shpk for ourselves as it causes a race condition.
# Instead, inspect the materials' ShPk names.

# The commit message xivdev#65 will be skipped:

# Some formatting, use ConcurrentSet explicitly for clarity.

# The commit message xivdev#66 will be skipped:

# [CI] Updating repo.json for testing_0.7.3.5

# The commit message xivdev#67 will be skipped:

# Add Emotes to Changed Items.

# The commit message xivdev#68 will be skipped:

# [CI] Updating repo.json for testing_0.7.3.6

# The commit message xivdev#69 will be skipped:

# Fix changed item flags for emotes.

# The commit message #70 will be skipped:

# Update GameData for new parsing.

# The commit message xivdev#71 will be skipped:

# Fix CS update creating ambiguous reference.

# The commit message xivdev#72 will be skipped:

# Add Player and Interface to quick select collections and rework their tooltips and names slightly.

# The commit message xivdev#73 will be skipped:

# [CI] Updating repo.json for testing_0.7.3.7

# The commit message xivdev#74 will be skipped:

# Allow drag & drop of multiple mods or folders with Control.

# The commit message xivdev#75 will be skipped:

# [CI] Updating repo.json for testing_0.7.3.8

# The commit message xivdev#76 will be skipped:

# Fix click check for selectables.

# The commit message xivdev#77 will be skipped:

# [CI] Updating repo.json for testing_0.7.3.9

# The commit message xivdev#78 will be skipped:

# Add Filesystem Compression as a toggle and button. Also some auto-formatting.

# The commit message xivdev#79 will be skipped:

# [CI] Updating repo.json for testing_0.7.3.10

# The commit message xivdev#80 will be skipped:

# Add Compacting to API AddMod.

# The commit message xivdev#81 will be skipped:

# Add key checks to restoring from backup or deleting backups.

# The commit message xivdev#82 will be skipped:

# Material Editor: Split ColorTable apart from ColorSet

# The commit message xivdev#83 will be skipped:

# GameData Commit.

# The commit message xivdev#84 will be skipped:

# Auto Formatting.

# The commit message xivdev#85 will be skipped:

# Use System global usings.

# The commit message xivdev#86 will be skipped:

# Make line endings explicit in editorconfig and share in sub projects, also apply editorconfig everywhere and move some namespaces.

# The commit message xivdev#87 will be skipped:

# ResourceTree improvements + IPC
#
# - Moves ResourceType enum out of GameData as discussed on Discord ;
# - Adds new color coding for local player and non-networked objects on On-Screen ;
# - Adds ResourceTree-related IPC ;
# - Fixes xivdev#342.

# The commit message xivdev#88 will be skipped:

# ResourceTree IPC: Remove mergeSameCollection.

# The commit message xivdev#89 will be skipped:

# ResourceTree: Avoid enumerating the whole object table in some cases

# The commit message #90 will be skipped:

# Move IPC Arguments around.

# The commit message xivdev#91 will be skipped:

# Rename ResourceType file.

# The commit message xivdev#92 will be skipped:

# Remove enums folder from csproj?!

# The commit message xivdev#93 will be skipped:

# Fix params bug.

# The commit message #94 will be skipped:

# Api nuget version.

# The commit message xivdev#95 will be skipped:

# Add load state to resource watcher.

# The commit message xivdev#96 will be skipped:

# [CI] Updating repo.json for testing_0.7.3.11

# The commit message xivdev#97 will be skipped:

# Add CalculateHeight Hook

# The commit message xivdev#98 will be skipped:

# ResourceTree: Reverse-resolve in bulk

# The commit message xivdev#99 will be skipped:

# Remove some allocations from resource tree.

# The commit message xivdev#100 will be skipped:

# Update OtterGui.

# The commit message xivdev#101 will be skipped:

# Fix ambiguous reference for no fucking reason.

# The commit message xivdev#102 will be skipped:

# [CI] Updating repo.json for testing_0.7.3.12

# The commit message xivdev#103 will be skipped:

# Add automatic restore from backup for sort_order and active_collections for now.

# The commit message xivdev#104 will be skipped:

# Material Editor: Extend live preview.

# The commit message xivdev#105 will be skipped:

# Optimize ResourceTree somewhat.
  • Loading branch information
Ottermandias authored and Sebane1 committed Sep 22, 2023
1 parent d3bc3f4 commit 547eccd
Show file tree
Hide file tree
Showing 264 changed files with 8,081 additions and 4,923 deletions.
82 changes: 42 additions & 40 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@

[*.proto]
indent_style=tab
indent_size=tab
tab_width=4

[*.{asax,ascx,aspx,axaml,cs,cshtml,css,htm,html,js,jsx,master,paml,razor,skin,ts,tsx,vb,xaml,xamlx,xoml}]
indent_style=space
indent_size=4
tab_width=4

[*.{appxmanifest,axml,build,config,csproj,dbml,discomap,dtd,json,jsproj,lsproj,njsproj,nuspec,proj,props,resjson,resw,resx,StyleCop,targets,tasks,vbproj,xml,xsd}]
indent_style=space
indent_size=2
tab_width=2
# Standard properties
charset = utf-8
end_of_line = lf
insert_final_newline = true
csharp_indent_labels = one_less_than_current
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_throw_expression = true:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_prefer_tuple_swap = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_prefer_top_level_statements = true:silent

[*]

# Microsoft .NET properties
csharp_indent_braces=false
csharp_indent_switch_labels=true
Expand Down Expand Up @@ -3567,30 +3577,6 @@ resharper_xaml_x_key_attribute_disallowed_highlighting=error
resharper_xml_doc_comment_syntax_problem_highlighting=warning
resharper_xunit_xunit_test_with_console_output_highlighting=warning

# Standard properties
end_of_line= crlf
csharp_indent_labels = one_less_than_current
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_throw_expression = true:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_prefer_tuple_swap = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion

[*.{cshtml,htm,html,proto,razor}]
indent_style=tab
indent_size=tab
Expand All @@ -3601,6 +3587,21 @@ indent_style=space
indent_size=4
tab_width=4

[ "*.proto" ]
indent_style=tab
indent_size=tab
tab_width=4

[*.{asax,ascx,aspx,axaml,cs,cshtml,css,htm,html,js,jsx,master,paml,razor,skin,ts,tsx,vb,xaml,xamlx,xoml}]
indent_style=space
indent_size=4
tab_width=4

[*.{appxmanifest,axml,build,config,csproj,dbml,discomap,dtd,json,jsproj,lsproj,njsproj,nuspec,proj,props,resjson,resw,resx,StyleCop,targets,tasks,vbproj,xml,xsd}]
indent_style=space
indent_size=2
tab_width=2

[*.{appxmanifest,asax,ascx,aspx,axaml,axml,build,c,c++,cc,cginc,compute,config,cp,cpp,cs,cshtml,csproj,css,cu,cuh,cxx,dbml,discomap,dtd,h,hh,hlsl,hlsli,hlslinc,hpp,htm,html,hxx,inc,inl,ino,ipp,js,json,jsproj,jsx,lsproj,master,mpp,mq4,mq5,mqh,njsproj,nuspec,paml,proj,props,proto,razor,resjson,resw,resx,skin,StyleCop,targets,tasks,tpp,ts,tsx,usf,ush,vb,vbproj,xaml,xamlx,xml,xoml,xsd}]
indent_style=space
indent_size= 4
Expand All @@ -3621,3 +3622,4 @@ dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_namespace_match_folder = true:suggestion
insert_final_newline = true
2 changes: 1 addition & 1 deletion OtterGui
Submodule OtterGui updated 85 files
+19 −7 ArrayExtensions.cs
+63 −12 Classes/Backup.cs
+0 −1 Classes/ChatService.cs
+47 −0 Classes/ConcurrentSet.cs
+33 −0 Classes/DayChangeTracker.cs
+0 −4 Classes/DisposableContainer.cs
+0 −1 Classes/DoubleModifier.cs
+0 −3 Classes/EventWrapper.cs
+0 −4 Classes/FrameworkManager.cs
+0 −2 Classes/IconStorage.cs
+45 −10 Classes/IndexSet.cs
+0 −4 Classes/LazyList.cs
+0 −1 Classes/LowerString.cs
+0 −3 Classes/ModifiableHotkey.cs
+0 −2 Classes/ModifierHotkey.cs
+0 −3 Classes/OptionalBool.cs
+0 −6 Classes/PerformanceTracker.cs
+0 −3 Classes/SaveService.cs
+0 −5 Classes/SingleArray.cs
+0 −6 Classes/StartTimeTracker.cs
+0 −5 Classes/SubList.cs
+0 −4 Classes/TemporaryList.cs
+1 −3 Classes/TextureCache.cs
+0 −5 Classes/TransformList.cs
+0 −4 Classes/ZipList.cs
+12 −0 Compression/CompressionAlgorithm.cs
+201 −0 Compression/FileCompactor.cs
+84 −0 Compression/Interop.cs
+0 −2 Custom/CustomGui.cs
+0 −1 Custom/IndividualHelpers.cs
+0 −3 Custom/NpcCombo.cs
+0 −2 Custom/WorldCombo.cs
+0 −4 FileExtensions.cs
+0 −5 Filesystem/Extensions.cs
+18 −7 Filesystem/FileSystem.File.cs
+0 −3 Filesystem/FileSystem.Internals.cs
+0 −3 Filesystem/FileSystem.cs
+0 −4 Filesystem/Folder.cs
+0 −2 Filesystem/NameComparer.cs
+0 −3 Filesystem/Path.cs
+0 −3 Filesystem/Selector/FileSystemSelector.Buttons.cs
+0 −3 Filesystem/Selector/FileSystemSelector.Context.cs
+54 −9 Filesystem/Selector/FileSystemSelector.DragDrop.cs
+12 −10 Filesystem/Selector/FileSystemSelector.Draw.cs
+1 −5 Filesystem/Selector/FileSystemSelector.State.cs
+0 −3 Filesystem/Selector/FileSystemSelector.Utility.cs
+49 −14 Filesystem/Selector/FileSystemSelector.cs
+0 −3 Filesystem/SortMode.cs
+0 −8 Functions.cs
+21 −0 GlobalUsings.cs
+0 −4 ImGuiClip.cs
+0 −3 ImGuiPie.cs
+0 −2 ImGuiTable.cs
+0 −4 ItemSelector.cs
+0 −4 Log/Logger.cs
+0 −4 Raii/Color.cs
+0 −2 Raii/EndObjects.cs
+0 −1 Raii/Font.cs
+0 −1 Raii/Id.cs
+0 −1 Raii/Indent.cs
+0 −4 Raii/Style.cs
+0 −5 StableInsertionSortExtension.cs
+0 −2 Table/ColumnFlags.cs
+0 −2 Table/ColumnSelect.cs
+0 −2 Table/ColumnString.cs
+0 −4 Table/Table.cs
+0 −3 Tasks/IAction.cs
+0 −4 Tasks/SingleTaskQueue.cs
+0 −4 Tasks/TaskWrap.cs
+36 −9 Util.cs
+5 −13 Widgets/Changelog.cs
+0 −1 Widgets/ChatTypeSelector.cs
+0 −4 Widgets/ClippedSelectableCombo.cs
+0 −2 Widgets/ColorPicker.cs
+0 −2 Widgets/FilterComboCache.cs
+0 −2 Widgets/FilterComboColors.cs
+0 −4 Widgets/FilteredCombo.cs
+0 −3 Widgets/ImGuiFramedGroup.cs
+0 −1 Widgets/ImGuiResizingTextInput.cs
+0 −2 Widgets/KeySelectors.cs
+0 −2 Widgets/PaletteColorPicker.cs
+0 −2 Widgets/TabBar.cs
+0 −2 Widgets/TagButtons.cs
+0 −4 Widgets/Tutorial.cs
+0 −1 Widgets/WidgetUtil.cs
2 changes: 1 addition & 1 deletion Penumbra.GameData
Submodule Penumbra.GameData updated 65 files
+42 −40 .editorconfig
+0 −3 Actors/ActorIdentifier.cs
+25 −8 Actors/ActorManager.Data.cs
+0 −3 Actors/ActorManager.Identifiers.cs
+3 −3 Actors/IdentifierType.cs
+1 −1 Actors/ScreenActor.cs
+124 −125 Data/BNpcNames.cs
+6 −7 Data/DataSharer.cs
+0 −5 Data/DisassembledShader.cs
+5 −2 Data/EquipmentIdentificationList.cs
+0 −4 Data/GamePathParser.cs
+8 −3 Data/GamePaths.cs
+0 −2 Data/HumanModelList.cs
+1 −5 Data/ItemData.cs
+0 −2 Data/KeyList.cs
+0 −1 Data/ModelIdentificationList.cs
+123 −13 Data/ObjectIdentification.cs
+0 −3 Data/RestrictedGear.cs
+0 −4 Data/StainData.cs
+0 −2 Data/WeaponIdentificationList.cs
+0 −4 Enums/BodySlot.cs
+0 −1 Enums/ChangedItemExtensions.cs
+0 −3 Enums/CustomizationType.cs
+0 −4 Enums/EquipSlot.cs
+0 −2 Enums/FileType.cs
+21 −3 Enums/FullEquipType.cs
+0 −4 Enums/Race.cs
+0 −319 Enums/ResourceType.cs
+0 −2 Enums/RspAttribute.cs
+0 −5 Files/AvfxFile.cs
+0 −4 Files/AvfxMagic.cs
+0 −5 Files/MdlFile.Write.cs
+0 −4 Files/MdlFile.cs
+205 −0 Files/MtrlFile.AddRemove.cs
+22 −31 Files/MtrlFile.ColorDyeTable.cs
+0 −135 Files/MtrlFile.ColorSet.cs
+193 −0 Files/MtrlFile.ColorTable.cs
+16 −26 Files/MtrlFile.Write.cs
+106 −106 Files/MtrlFile.cs
+0 −4 Files/ShpkFile.Shader.cs
+0 −79 Files/ShpkFile.StringPool.cs
+12 −8 Files/ShpkFile.Write.cs
+153 −66 Files/ShpkFile.cs
+1 −6 Files/StmFile.StainingTemplateEntry.cs
+0 −4 Files/StmFile.cs
+813 −0 Files/TmbFile.cs
+167 −0 Files/Utility/SpanBinaryReader.cs
+89 −0 Files/Utility/StringPool.cs
+6 −3 GameData.cs
+18 −0 GlobalUsings.cs
+0 −3 Interop/D3DCompiler.cs
+1 −0 Signatures.cs
+0 −3 Structs/CharacterArmor.cs
+0 −3 Structs/CharacterWeapon.cs
+0 −5 Structs/CustomizeData.cs
+0 −2 Structs/EqdpEntry.cs
+0 −4 Structs/EqpEntry.cs
+1 −2 Structs/EquipItem.cs
+0 −2 Structs/GameObjectInfo.cs
+0 −3 Structs/GmpEntry.cs
+0 −2 Structs/IdTypes.cs
+0 −1 Structs/ImcEntry.cs
+0 −4 Structs/RspEntry.cs
+0 −5 Structs/TransformList.cs
+19 −5 UtilityFunctions.cs
126 changes: 119 additions & 7 deletions Penumbra/Api/DalamudSubstitutionProvider.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System;
using Dalamud.Plugin.Services;
using Penumbra.Collections;
using Penumbra.Collections.Manager;
using Penumbra.Communication;
using Penumbra.Mods;
using Penumbra.Services;
using Penumbra.String.Classes;

namespace Penumbra.Api;
Expand All @@ -9,19 +12,110 @@ public class DalamudSubstitutionProvider : IDisposable
{
private readonly ITextureSubstitutionProvider _substitution;
private readonly ActiveCollectionData _activeCollectionData;
private readonly Configuration _config;
private readonly CommunicatorService _communicator;

public DalamudSubstitutionProvider(ITextureSubstitutionProvider substitution, ActiveCollectionData activeCollectionData)
public bool Enabled
=> _config.UseDalamudUiTextureRedirection;

public DalamudSubstitutionProvider(ITextureSubstitutionProvider substitution, ActiveCollectionData activeCollectionData,
Configuration config, CommunicatorService communicator)
{
_substitution = substitution;
_activeCollectionData = activeCollectionData;
_substitution.InterceptTexDataLoad += Substitute;
_substitution = substitution;
_activeCollectionData = activeCollectionData;
_config = config;
_communicator = communicator;
if (Enabled)
Subscribe();
}

public void Set(bool value)
{
if (value)
Enable();
else
Disable();
}

public void ResetSubstitutions(IEnumerable<Utf8GamePath> paths)
{
// TODO fix
//var transformed = paths
// .Where(p => (p.Path.StartsWith("ui/"u8) || p.Path.StartsWith("common/font/"u8)) && p.Path.EndsWith(".tex"u8))
// .Select(p => p.ToString());
//_substitution.InvalidatePaths(transformed);
}

public void Enable()
{
if (Enabled)
return;

_config.UseDalamudUiTextureRedirection = true;
_config.Save();
Subscribe();
}

public void Disable()
{
if (!Enabled)
return;

Unsubscribe();
_config.UseDalamudUiTextureRedirection = false;
_config.Save();
}

public void Dispose()
=> _substitution.InterceptTexDataLoad -= Substitute;
=> Unsubscribe();

private void OnCollectionChange(CollectionType type, ModCollection? oldCollection, ModCollection? newCollection, string _)
{
if (type is not CollectionType.Interface)
return;

var enumerable = oldCollection?.ResolvedFiles.Keys ?? Array.Empty<Utf8GamePath>().AsEnumerable();
enumerable = enumerable.Concat(newCollection?.ResolvedFiles.Keys ?? Array.Empty<Utf8GamePath>().AsEnumerable());
ResetSubstitutions(enumerable);
}

private void OnResolvedFileChange(ModCollection collection, ResolvedFileChanged.Type type, Utf8GamePath key, FullPath _1, FullPath _2,
IMod? _3)
{
if (_activeCollectionData.Interface != collection)
return;

switch (type)
{
case ResolvedFileChanged.Type.Added:
case ResolvedFileChanged.Type.Removed:
case ResolvedFileChanged.Type.Replaced:
ResetSubstitutions(new[]
{
key,
});
break;
case ResolvedFileChanged.Type.FullRecomputeStart:
case ResolvedFileChanged.Type.FullRecomputeFinished:
ResetSubstitutions(collection.ResolvedFiles.Keys);
break;
}
}

private void OnEnabledChange(bool state)
{
if (state)
OnCollectionChange(CollectionType.Interface, null, _activeCollectionData.Interface, string.Empty);
else
OnCollectionChange(CollectionType.Interface, _activeCollectionData.Interface, null, string.Empty);
}

private void Substitute(string path, ref string? replacementPath)
{
// Do not replace when not enabled.
if (!_config.EnableMods)
return;

// Let other plugins prioritize replacement paths.
if (replacementPath != null)
return;
Expand All @@ -43,4 +137,22 @@ private void Substitute(string path, ref string? replacementPath)
// ignored
}
}
}

private void Subscribe()
{
_substitution.InterceptTexDataLoad += Substitute;
_communicator.CollectionChange.Subscribe(OnCollectionChange, CollectionChange.Priority.DalamudSubstitutionProvider);
_communicator.ResolvedFileChanged.Subscribe(OnResolvedFileChange, ResolvedFileChanged.Priority.DalamudSubstitutionProvider);
_communicator.EnabledChanged.Subscribe(OnEnabledChange, EnabledChanged.Priority.DalamudSubstitutionProvider);
OnCollectionChange(CollectionType.Interface, null, _activeCollectionData.Interface, string.Empty);
}

private void Unsubscribe()
{
_substitution.InterceptTexDataLoad -= Substitute;
_communicator.CollectionChange.Unsubscribe(OnCollectionChange);
_communicator.ResolvedFileChanged.Unsubscribe(OnResolvedFileChange);
_communicator.EnabledChanged.Unsubscribe(OnEnabledChange);
OnCollectionChange(CollectionType.Interface, _activeCollectionData.Interface, null, string.Empty);
}
}
2 changes: 0 additions & 2 deletions Penumbra/Api/HttpApi.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;
using System.Threading.Tasks;
using EmbedIO;
using EmbedIO.Routing;
using EmbedIO.WebApi;
Expand Down
Loading

0 comments on commit 547eccd

Please sign in to comment.