Skip to content

Commit

Permalink
7.1 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
PassiveModding committed Nov 14, 2024
1 parent d974a34 commit 6bbc602
Show file tree
Hide file tree
Showing 12 changed files with 235 additions and 114 deletions.
2 changes: 1 addition & 1 deletion Meddle/Meddle.Plugin/Meddle.Plugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.13"/>
<PackageReference Include="DalamudPackager" Version="11.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0"/>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0"/>
<PackageReference Include="Vortice.Direct3D11" Version="3.5.0"/>
Expand Down
10 changes: 6 additions & 4 deletions Meddle/Meddle.Plugin/Models/Layout/ParsedInstance.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Numerics;
using FFXIVClientStructs.FFXIV.Client.Game.Object;
using FFXIVClientStructs.FFXIV.Client.LayoutEngine;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

Check failure on line 4 in Meddle/Meddle.Plugin/Models/Layout/ParsedInstance.cs

View workflow job for this annotation

GitHub Actions / Build (7.0.x, latest)

The type or namespace name 'Sheets' does not exist in the namespace 'Lumina.Excel' (are you missing an assembly reference?)
using Meddle.Plugin.Models.Skeletons;
using Meddle.Plugin.Models.Structs;
using Meddle.Plugin.Services;
Expand Down Expand Up @@ -168,18 +168,20 @@ private bool SearchInternal(string query, HashSet<ParsedInstance> visited)
public class ParsedHousingInstance : ParsedSharedInstance, ISearchableInstance
{
public ParsedHousingInstance(nint id, Transform transform, string path, string name,
ObjectKind kind, Stain? stain, Stain defaultStain, Item? item, IReadOnlyList<ParsedInstance> children) : base(id, ParsedInstanceType.Housing, transform, path, children)
ObjectKind kind, Stain? stain, Stain defaultStain,

Check failure on line 171 in Meddle/Meddle.Plugin/Models/Layout/ParsedInstance.cs

View workflow job for this annotation

GitHub Actions / Build (7.0.x, latest)

The type or namespace name 'Stain' could not be found (are you missing a using directive or an assembly reference?)
/*Item? item,*/
IReadOnlyList<ParsedInstance> children) : base(id, ParsedInstanceType.Housing, transform, path, children)
{
Name = name;
Kind = kind;
Stain = stain;
DefaultStain = defaultStain;
Item = item;
//Item = item;
}

public Stain? Stain { get; }

Check failure on line 182 in Meddle/Meddle.Plugin/Models/Layout/ParsedInstance.cs

View workflow job for this annotation

GitHub Actions / Build (7.0.x, latest)

The type or namespace name 'Stain' could not be found (are you missing a using directive or an assembly reference?)
public Stain DefaultStain { get; }

Check failure on line 183 in Meddle/Meddle.Plugin/Models/Layout/ParsedInstance.cs

View workflow job for this annotation

GitHub Actions / Build (7.0.x, latest)

The type or namespace name 'Stain' could not be found (are you missing a using directive or an assembly reference?)
public Item? Item { get; }
// public Item? Item { get; }
public string Name { get; }
public ObjectKind Kind { get; }

Expand Down
33 changes: 17 additions & 16 deletions Meddle/Meddle.Plugin/Models/StructExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ namespace Meddle.Plugin.Models;
public static class StructExtensions
{
public const int CharacterBaseAttachOffset = 0xD0; // CharacterBase + 0xD0 -> Attach

public const int ModelEnabledAttributeIndexMaskOffset = 0xAC; // Model + 0xAC -> EnabledAttributeIndexMask
public const int ModelEnabledShapeKeyIndexMaskOffset = 0xC8; // Model + 0xC8 -> EnabledShapeKeyIndexMask
//
// public const int ModelEnabledAttributeIndexMaskOffset = 0xAC; // Model + 0xAC -> EnabledAttributeIndexMask
// public const int ModelEnabledShapeKeyIndexMaskOffset = 0xC8; // Model + 0xC8 -> EnabledShapeKeyIndexMask

public const int PartialSkeletonFlagsOffset = 0x8; // PartialSkeleton + 0x8 -> Flags

Expand Down Expand Up @@ -69,25 +69,25 @@ private static unsafe ParsedSkeleton GetParsedSkeleton(this Pointer<Skeleton> sk
return new ParsedSkeleton(skeleton.Value);
}

public static unsafe (uint EnabledAttributeIndexMask, uint EnabledShapeKeyIndexMask) GetModelMasks(
this Pointer<Model> model)
{
if (model == null) throw new ArgumentNullException(nameof(model));
if (model.Value == null) throw new ArgumentNullException(nameof(model));

var modelBase = model.Value;
var enabledAttributeIndexMask = *(uint*)((nint)modelBase + ModelEnabledAttributeIndexMaskOffset);
var enabledShapeKeyIndexMask = *(uint*)((nint)modelBase + ModelEnabledShapeKeyIndexMaskOffset);
return (enabledAttributeIndexMask, enabledShapeKeyIndexMask);
}
// public static unsafe (uint EnabledAttributeIndexMask, uint EnabledShapeKeyIndexMask) GetModelMasks(
// this Pointer<Model> model)
// {
// if (model == null) throw new ArgumentNullException(nameof(model));
// if (model.Value == null) throw new ArgumentNullException(nameof(model));
//
// var modelBase = model.Value;
// var enabledAttributeIndexMask = *(uint*)((nint)modelBase + ModelEnabledAttributeIndexMaskOffset);
// var enabledShapeKeyIndexMask = *(uint*)((nint)modelBase + ModelEnabledShapeKeyIndexMaskOffset);
// return (enabledAttributeIndexMask, enabledShapeKeyIndexMask);
// }

public static unsafe Meddle.Utils.Export.Model.ShapeAttributeGroup ParseModelShapeAttributes(
Pointer<Model> modelPointer)
{
if (modelPointer == null) throw new ArgumentNullException(nameof(modelPointer));
if (modelPointer.Value == null) throw new ArgumentNullException(nameof(modelPointer));
var model = modelPointer.Value;
var (enabledAttributeIndexMask, enabledShapeKeyIndexMask) = modelPointer.GetModelMasks();
// var (enabledAttributeIndexMask, enabledShapeKeyIndexMask) = modelPointer.GetModelMasks();
var shapes = new List<(string, short)>();
foreach (var shape in model->ModelResourceHandle->Shapes)
{
Expand All @@ -101,7 +101,8 @@ public static unsafe Meddle.Utils.Export.Model.ShapeAttributeGroup ParseModelSha
}

var shapeAttributeGroup = new Meddle.Utils.Export.Model.ShapeAttributeGroup(
enabledShapeKeyIndexMask, enabledAttributeIndexMask, shapes.ToArray(), attributes.ToArray());
model->EnabledShapeKeyIndexMask, model->EnabledAttributeIndexMask,
shapes.ToArray(), attributes.ToArray());

return shapeAttributeGroup;
}
Expand Down
5 changes: 5 additions & 0 deletions Meddle/Meddle.Plugin/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Dalamud.Configuration;
using Dalamud.IoC;
using Dalamud.Plugin;
//using InteropGenerator.Runtime;
using Meddle.Plugin.Models;
using Meddle.Plugin.Services;
using Meddle.Plugin.UI.Layout;
Expand All @@ -26,6 +27,10 @@ public Plugin(IDalamudPluginInterface pluginInterface)
{
try
{
// FFXIVClientStructs.Interop.Generated.Addresses.Register();
// Resolver.GetInstance.Setup();
// Resolver.GetInstance.Resolve();

var config = pluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
pluginInterface.Inject(config);
config.Migrate();
Expand Down
23 changes: 10 additions & 13 deletions Meddle/Meddle.Plugin/Services/LayoutService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Numerics;
using System.Numerics;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.Object;
Expand All @@ -9,8 +7,7 @@
using FFXIVClientStructs.FFXIV.Client.LayoutEngine.Layer;
using FFXIVClientStructs.FFXIV.Client.LayoutEngine.Terrain;
using FFXIVClientStructs.Interop;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

Check failure on line 10 in Meddle/Meddle.Plugin/Services/LayoutService.cs

View workflow job for this annotation

GitHub Actions / Build (7.0.x, latest)

The type or namespace name 'Sheets' does not exist in the namespace 'Lumina.Excel' (are you missing an assembly reference?)
using Meddle.Plugin.Models.Layout;
using Meddle.Plugin.Models.Structs;
using Meddle.Plugin.Utils;
Expand All @@ -22,7 +19,7 @@ namespace Meddle.Plugin.Services;

public class LayoutService : IService, IDisposable
{
private readonly Dictionary<uint, Item> itemDict;
// private readonly Dictionary<uint, Item> itemDict;
private readonly Dictionary<uint, Stain> stainDict;

Check failure on line 23 in Meddle/Meddle.Plugin/Services/LayoutService.cs

View workflow job for this annotation

GitHub Actions / Build (7.0.x, latest)

The type or namespace name 'Stain' could not be found (are you missing a using directive or an assembly reference?)
private readonly ILogger<LayoutService> logger;
private readonly IFramework framework;
Expand All @@ -38,9 +35,9 @@ public LayoutService(
this.logger = logger;
this.framework = framework;
stainDict = dataManager.GetExcelSheet<Stain>()!.ToDictionary(row => row.RowId, row => row);
itemDict = dataManager.GetExcelSheet<Item>()!
.Where(item => item.AdditionalData != 0 && item.ItemSearchCategory.Row is 65 or 66)
.ToDictionary(row => row.AdditionalData, row => row);
// itemDict = dataManager.GetExcelSheet<Item>()!
// .Where(item => item.AdditionalData.RowId != 0 && item.ItemSearchCategory.Value.RowId is 65 or 66)
// .ToDictionary(row => row.AdditionalData.RowId, row => row);
this.framework.Update += Update;
}

Expand Down Expand Up @@ -264,13 +261,13 @@ private unsafe ParsedInstanceSet[] ParseLayout(LayoutManager* activeLayout, Pars
furnitureMatch.GameObject->ObjectKind,
furnitureMatch.Stain,
furnitureMatch.DefaultStain,
furnitureMatch.Item, children);
/*furnitureMatch.Item,*/ children);
foreach (var child in housing.Flatten())
{
if (child is ParsedBgPartsInstance parsedBgPartsInstance)
{
parsedBgPartsInstance.StainColor = furnitureMatch.Stain != null ?
UiUtil.ConvertU32ColorToVector4(furnitureMatch.Stain.Color) :
UiUtil.ConvertU32ColorToVector4(furnitureMatch.Stain.Value.Color) :
UiUtil.ConvertU32ColorToVector4(furnitureMatch.DefaultStain.Color);
}
}
Expand Down Expand Up @@ -395,7 +392,7 @@ private unsafe Furniture[] ParseTerritoryFurniture(HousingTerritory* territory)
HousingFurniture = item,
Stain = item.Stain != 0 ? stainDict[item.Stain] : null,
DefaultStain = stainDict[housingSettings.Value->DefaultColorId],
Item = itemDict.GetValueOrDefault(item.Id)
//Item = itemDict.GetValueOrDefault(item.Id)
});
}

Expand All @@ -416,7 +413,7 @@ public unsafe class Furniture
{
public HousingObject* GameObject;
public HousingFurniture HousingFurniture;
public Item? Item;
//public Item? Item;
public SharedGroupLayoutInstance* LayoutInstance;
public Stain? Stain;

Check failure on line 418 in Meddle/Meddle.Plugin/Services/LayoutService.cs

View workflow job for this annotation

GitHub Actions / Build (7.0.x, latest)

The type or namespace name 'Stain' could not be found (are you missing a using directive or an assembly reference?)
public Stain DefaultStain;

Check failure on line 419 in Meddle/Meddle.Plugin/Services/LayoutService.cs

View workflow job for this annotation

GitHub Actions / Build (7.0.x, latest)

The type or namespace name 'Stain' could not be found (are you missing a using directive or an assembly reference?)
Expand Down
14 changes: 7 additions & 7 deletions Meddle/Meddle.Plugin/Services/ParseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,23 @@ public unsafe IColorTableSet ParseColorTableTexture(Texture* colorTableTexture)
$"Color table is not R16G16B16A16F ({(TexFile.TextureFormat)colorTableTexture->TextureFormat})");
}

if (colorTableTexture->Width == 4 && colorTableTexture->Height == 16)
if (colorTableTexture->ActualWidth == 4 && colorTableTexture->ActualHeight == 16)
{
// legacy table
var stridedData = ImageUtils.AdjustStride(stride, (int)colorTableTexture->Width * 8,
(int)colorTableTexture->Height, colorTableRes.Data);
var stridedData = ImageUtils.AdjustStride(stride, (int)colorTableTexture->ActualWidth * 8,
(int)colorTableTexture->ActualHeight, colorTableRes.Data);
var reader = new SpanBinaryReader(stridedData);
return new LegacyColorTableSet
{
ColorTable = new LegacyColorTable(ref reader)
};
}

if (colorTableTexture->Width == 8 && colorTableTexture->Height == 32)
if (colorTableTexture->ActualWidth == 8 && colorTableTexture->ActualHeight == 32)
{
// new table
var stridedData = ImageUtils.AdjustStride(stride, (int)colorTableTexture->Width * 8,
(int)colorTableTexture->Height, colorTableRes.Data);
var stridedData = ImageUtils.AdjustStride(stride, (int)colorTableTexture->ActualWidth * 8,
(int)colorTableTexture->ActualHeight, colorTableRes.Data);
var reader = new SpanBinaryReader(stridedData);
return new ColorTableSet
{
Expand All @@ -111,6 +111,6 @@ public unsafe IColorTableSet ParseColorTableTexture(Texture* colorTableTexture)
}

throw new ArgumentException(
$"Color table is not 4x16 or 8x32 ({colorTableTexture->Width}x{colorTableTexture->Height})");
$"Color table is not 4x16 or 8x32 ({colorTableTexture->ActualWidth}x{colorTableTexture->ActualHeight})");
}
}
Loading

0 comments on commit 6bbc602

Please sign in to comment.