Skip to content

Commit 41a780c

Browse files
Merge pull request #39 from PassiveModding/feature/various-fixes
Various fixes
2 parents 8c21763 + 188077c commit 41a780c

File tree

5 files changed

+37
-24
lines changed

5 files changed

+37
-24
lines changed

Meddle/Meddle.Plugin/Services/LayoutService.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,9 @@ public unsafe ParsedInstance[] ParseObjects()
358358

359359
var objects = new Dictionary<nint, ParsedInstance>();
360360
var mounts = new Dictionary<nint, ParsedCharacterInstance>();
361-
foreach (var objectPtr in gameObjectManager->Objects.GameObjectIdSorted)
361+
for (var idx = 0; idx < gameObjectManager->Objects.GameObjectIdSorted.Length; idx++)
362362
{
363+
var objectPtr = gameObjectManager->Objects.GameObjectIdSorted[idx];
363364
if (objectPtr == null || objectPtr.Value == null)
364365
continue;
365366

@@ -371,10 +372,10 @@ public unsafe ParsedInstance[] ParseObjects()
371372
var drawObject = obj->DrawObject;
372373
if (drawObject == null)
373374
continue;
374-
375+
375376
if (IsObjectPlaceHolder(drawObject))
376377
continue;
377-
378+
378379
var anyVisible = drawObject->IsVisible;
379380

380381
void AddObject(ParsedCharacterInstance instance)
@@ -388,11 +389,12 @@ void AddObject(ParsedCharacterInstance instance)
388389
objects.TryAdd(instance.Id, instance);
389390
}
390391
}
391-
392+
392393
var transform = new Transform(drawObject->Position, drawObject->Rotation, drawObject->Scale);
393-
var instance = new ParsedCharacterInstance((nint)obj, obj->NameString, type, transform, anyVisible);
394+
var name = obj->NameString.GetCharacterName(config, type, idx.ToString());
395+
var instance = new ParsedCharacterInstance((nint)obj, name, type, transform, anyVisible);
394396
AddObject(instance);
395-
397+
396398
if (drawObject->IsVisible == false)
397399
{
398400
// want to list children which are visible even if the parent is not.
@@ -406,25 +408,25 @@ void HandleRecursiveVisibility(Object* childObject)
406408
{
407409
if (IsCharacterPlaceholder(cBase))
408410
return;
409-
411+
410412
var cTransform = new Transform(cBase->DrawObject.Position, cBase->DrawObject.Rotation, cBase->DrawObject.Scale);
411-
var cInstance = new ParsedCharacterInstance((nint)childObject, $"Child of {obj->NameString}", type, cTransform, true,
412-
ParsedCharacterInstance.ParsedCharacterInstanceIdType.CharacterBase)
413+
var cInstance = new ParsedCharacterInstance((nint)childObject, $"Child of {name}", type, cTransform, true,
414+
ParsedCharacterInstance.ParsedCharacterInstanceIdType.CharacterBase)
413415
{
414416
Parent = instance
415417
};
416418
AddObject(cInstance);
417419
return; // skip parsing if visible as item should be covered under attaches to parent
418420
}
419421
}
420-
422+
421423
foreach (var childOfChild in childObject->ChildObjects)
422424
{
423425
if (childOfChild == null) continue;
424426
HandleRecursiveVisibility(childOfChild);
425427
}
426428
}
427-
429+
428430
foreach (var childObject in drawObject->ChildObjects.GetEnumerator())
429431
{
430432
HandleRecursiveVisibility(childObject);

Meddle/Meddle.Plugin/UI/Layout/Instance.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,7 @@ private void DrawInstance(ParsedInstance instance, Stack<ParsedInstance> stack,
6565

6666
if (instance is ParsedCharacterInstance ci)
6767
{
68-
if (!string.IsNullOrWhiteSpace(config.PlayerNameOverride) && ci.Kind == ObjectKind.Pc)
69-
{
70-
infoHeader += $" - {config.PlayerNameOverride}";
71-
}
72-
else
73-
{
74-
infoHeader += $" - {ci.Name}";
75-
}
68+
infoHeader += $" - {ci.Name}";
7669
}
7770

7871
if (instance is ParsedSharedInstance {Children.Count: > 0} shared)

Meddle/Meddle.Plugin/UI/LiveCharacterTab.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ private void DrawCharacter(CSCharacter* character, string name, int depth = 0)
205205
}
206206

207207
return info;
208-
}, $"{character->NameString}");
208+
}, character->NameString.GetCharacterName(config, character->ObjectKind));
209209
}
210210
else
211211
{
@@ -214,7 +214,7 @@ private void DrawCharacter(CSCharacter* character, string name, int depth = 0)
214214
genderRace = GenderRace.Unknown;
215215
}
216216

217-
DrawDrawObject(drawObject, $"{character->NameString}", customizeData, customizeParams, genderRace);
217+
DrawDrawObject(drawObject, character->NameString.GetCharacterName(config, character->ObjectKind), customizeData, customizeParams, genderRace);
218218

219219
try
220220
{
@@ -243,7 +243,7 @@ private void DrawCharacter(CSCharacter* character, string name, int depth = 0)
243243
{
244244
ImGui.Separator();
245245
ImGui.Text($"Weapon {weaponIdx}");
246-
DrawDrawObject(weaponData.DrawObject, $"{character->NameString}_Weapon", null, null, GenderRace.Unknown);
246+
DrawDrawObject(weaponData.DrawObject, $"{character->NameString.GetCharacterName(config, character->ObjectKind)}_Weapon", null, null, GenderRace.Unknown);
247247
}
248248
}
249249
}
@@ -285,7 +285,7 @@ private void DrawExportSettings(ParsedCharacterInfo characterInfo, string name)
285285
if (!ImGui.BeginPopup("ExportSettingsPopup", ImGuiWindowFlags.AlwaysAutoResize)) return;
286286
try
287287
{
288-
if (UiUtil.DrawExportConfig(config.ExportConfig))
288+
if (UiUtil.DrawExportConfig(config.ExportConfig, UiUtil.ExportConfigDrawFlags.HideLayoutOptions))
289289
{
290290
config.Save();
291291
}

Meddle/Meddle.Plugin/Utils/ExportUtil.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ public static void SaveAsType(this ModelRoot? gltf, ExportType typeFlags, string
2828

2929
if (typeFlags.HasFlag(ExportType.OBJ))
3030
{
31-
gltf?.SaveAsWavefront(Path.Combine(path, name + ".obj"));
31+
// sanitize obj name
32+
var objName = name.Replace(" ", "_");
33+
gltf?.SaveAsWavefront(Path.Combine(path, objName + ".obj"));
3234
}
3335
}
3436

Meddle/Meddle.Plugin/Utils/UIUtil.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Dalamud.Interface;
33
using Dalamud.Interface.Utility.Raii;
44
using FFXIVClientStructs.FFXIV.Client.Game.Character;
5+
using FFXIVClientStructs.FFXIV.Client.Game.Object;
56
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
67
using FFXIVClientStructs.Interop;
78
using ImGuiNET;
@@ -640,4 +641,19 @@ private static void DrawBoneTree(ParsedPartialSkeleton partial, ParsedHkaPose po
640641
/// <summary> Square stores its colors as BGR values so R and B need to be shuffled and Alpha set to max. </summary>
641642
public static uint SeColorToRgba(uint color)
642643
=> ((color & 0xFF) << 16) | ((color >> 16) & 0xFF) | (color & 0xFF00) | 0xFF000000;
644+
645+
public static string GetCharacterName(this string? name, Configuration config, ObjectKind kind, string? suffix = null)
646+
{
647+
if (string.IsNullOrWhiteSpace(name))
648+
{
649+
return $"Unknown{suffix}";
650+
}
651+
652+
if (!string.IsNullOrWhiteSpace(config.PlayerNameOverride) && kind == ObjectKind.Pc)
653+
{
654+
return $"{config.PlayerNameOverride}{suffix}";
655+
}
656+
657+
return name;
658+
}
643659
}

0 commit comments

Comments
 (0)