More fixes, some cleanup.

This commit is contained in:
Ottermandias 2022-03-17 14:03:57 +01:00
parent 581b91b337
commit e6752ade04
20 changed files with 193 additions and 361 deletions

View file

@ -169,7 +169,7 @@ public partial class SettingsInterface
return;
}
Penumbra.ModManager.Collections.SetCurrentCollection( _collections[ idx + 1 ] );
Penumbra.ModManager.Collections.SetCollection( _collections[ idx + 1 ], CollectionType.Current );
_currentCollectionIndex = idx;
_selector.Cache.TriggerListReset();
if( _selector.Mod != null )
@ -208,7 +208,7 @@ public partial class SettingsInterface
ImGui.SetNextItemWidth( SettingsMenu.InputTextWidth );
if( ImGui.Combo( "##Default Collection", ref index, _collectionNamesWithNone ) && index != _currentDefaultIndex )
{
Penumbra.ModManager.Collections.SetDefaultCollection( _collections[ index ] );
Penumbra.ModManager.Collections.SetCollection( _collections[ index ], CollectionType.Default );
_currentDefaultIndex = index;
}
@ -231,7 +231,7 @@ public partial class SettingsInterface
&& index != _currentForcedIndex
&& manager.Collections.CharacterCollection.Count > 0 )
{
manager.Collections.SetForcedCollection( _collections[ index ] );
manager.Collections.SetCollection( _collections[ index ], CollectionType.Forced );
_currentForcedIndex = index;
}
@ -352,7 +352,7 @@ public partial class SettingsInterface
ImGui.SetNextItemWidth( SettingsMenu.InputTextWidth );
if( ImGui.Combo( $"##{name}collection", ref tmp, _collectionNamesWithNone ) && idx != tmp )
{
manager.Collections.SetCharacterCollection( name, _collections[ tmp ] );
manager.Collections.SetCollection( _collections[ tmp ], CollectionType.Character, name );
_currentCharacterIndices[ name ] = tmp;
}

View file

@ -22,104 +22,6 @@ namespace Penumbra.UI;
public partial class SettingsInterface
{
private static void DrawDebugTabPlayers()
{
if( !ImGui.CollapsingHeader( "Players##Debug" ) )
{
return;
}
var players = Penumbra.PlayerWatcher.WatchedPlayers().ToArray();
var count = players.Sum( s => Math.Max( 1, s.Item2.Length ) );
if( count == 0 )
{
return;
}
if( !ImGui.BeginTable( "##ObjectTable", 13, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.ScrollX,
new Vector2( -1, ImGui.GetTextLineHeightWithSpacing() * 4 * count ) ) )
{
return;
}
using var raii = ImGuiRaii.DeferredEnd( ImGui.EndTable );
var identifier = GameData.GameData.GetIdentifier();
foreach( var (actor, equip) in players.SelectMany( kvp => kvp.Item2.Any()
? kvp.Item2
.Select( x => ( $"{kvp.Item1} ({x.Item1})", x.Item2 ) )
: new[] { ( kvp.Item1, new CharacterEquipment() ) } ) )
{
// @formatter:off
ImGui.TableNextRow();
ImGui.TableNextColumn();
ImGui.Text( actor );
ImGui.TableNextColumn();
ImGui.Text( $"{equip.MainHand}" );
ImGui.TableNextColumn();
ImGui.Text( $"{equip.Head}" );
ImGui.TableNextColumn();
ImGui.Text( $"{equip.Body}" );
ImGui.TableNextColumn();
ImGui.Text( $"{equip.Hands}" );
ImGui.TableNextColumn();
ImGui.Text( $"{equip.Legs}" );
ImGui.TableNextColumn();
ImGui.Text( $"{equip.Feet}" );
ImGui.TableNextRow();
ImGui.TableNextColumn();
if (equip.IsSet == 0)
{
ImGui.Text( "(not set)" );
}
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( equip.MainHand.Set, equip.MainHand.Type, equip.MainHand.Variant, EquipSlot.MainHand )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( equip.Head.Set, 0, equip.Head.Variant, EquipSlot.Head )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( equip.Body.Set, 0, equip.Body.Variant, EquipSlot.Body )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( equip.Hands.Set, 0, equip.Hands.Variant, EquipSlot.Hands )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( equip.Legs.Set, 0, equip.Legs.Variant, EquipSlot.Legs )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( equip.Feet.Set, 0, equip.Feet.Variant, EquipSlot.Feet )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextRow();
ImGui.TableNextColumn();
ImGui.TableNextColumn();
ImGui.Text( $"{equip.OffHand}" );
ImGui.TableNextColumn();
ImGui.Text( $"{equip.Ears}" );
ImGui.TableNextColumn();
ImGui.Text( $"{equip.Neck}" );
ImGui.TableNextColumn();
ImGui.Text( $"{equip.Wrists}" );
ImGui.TableNextColumn();
ImGui.Text( $"{equip.LFinger}" );
ImGui.TableNextColumn();
ImGui.Text( $"{equip.RFinger}" );
ImGui.TableNextRow();
ImGui.TableNextColumn();
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( equip.OffHand.Set, equip.OffHand.Type, equip.OffHand.Variant, EquipSlot.OffHand )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( equip.Ears.Set, 0, equip.Ears.Variant, EquipSlot.Ears )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( equip.Neck.Set, 0, equip.Neck.Variant, EquipSlot.Neck )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( equip.Wrists.Set, 0, equip.Wrists.Variant, EquipSlot.Wrists )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( equip.LFinger.Set, 0, equip.LFinger.Variant, EquipSlot.LFinger )?.Name.ToString() ?? "Unknown" );
ImGui.TableNextColumn();
ImGui.Text( identifier.Identify( equip.RFinger.Set, 0, equip.RFinger.Variant, EquipSlot.LFinger )?.Name.ToString() ?? "Unknown" );
// @formatter:on
}
}
private static void PrintValue( string name, string value )
{
ImGui.TableNextRow();
@ -431,8 +333,8 @@ public partial class SettingsInterface
{
var def = ExpandedGmpFile.GetDefault( gmp );
var val = Penumbra.ModManager.Collections.ActiveCollection.Cache?.MetaManipulations.Gmp.File?[ gmp ] ?? def;
ImGui.Text( def.Value.ToString("X") );
ImGui.Text( val.Value.ToString("X") );
ImGui.Text( def.Value.ToString( "X" ) );
ImGui.Text( val.Value.ToString( "X" ) );
}
catch
{ }
@ -557,8 +459,6 @@ public partial class SettingsInterface
ImGui.NewLine();
DrawDebugTabRedraw();
ImGui.NewLine();
DrawDebugTabPlayers();
ImGui.NewLine();
DrawDebugTabIpc();
ImGui.NewLine();
}

View file

@ -1,12 +1,10 @@
using System;
using System.Collections.Generic;
using System.Drawing.Text;
using System.ComponentModel;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using Dalamud.Interface;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
using Penumbra.Meta.Files;
@ -77,22 +75,12 @@ public partial class SettingsInterface
( Gender.FemaleNpc.ToName(), Gender.FemaleNpc ),
};
private static readonly (string, ObjectType)[] ObjectTypes =
private static readonly (string, EstManipulation.EstType)[] EstTypes =
{
( "Equipment", ObjectType.Equipment ),
( "Customization", ObjectType.Character ),
};
private static readonly (string, EquipSlot)[] EstEquipSlots =
{
EqpEquipSlots[ 0 ],
EqpEquipSlots[ 1 ],
};
private static readonly (string, BodySlot)[] EstBodySlots =
{
( "Hair", BodySlot.Hair ),
( "Face", BodySlot.Face ),
( "Hair", EstManipulation.EstType.Hair ),
( "Face", EstManipulation.EstType.Face ),
( "Body", EstManipulation.EstType.Body ),
( "Head", EstManipulation.EstType.Head ),
};
private static readonly (string, SubRace)[] Subraces =
@ -133,9 +121,11 @@ public partial class SettingsInterface
( RspAttribute.FemaleMaxTail.ToFullString(), RspAttribute.FemaleMaxTail ),
};
private static readonly (string, ObjectType)[] ImcObjectType =
{
ObjectTypes[ 0 ],
( "Equipment", ObjectType.Equipment ),
( "Customization", ObjectType.Character ),
( "Weapon", ObjectType.Weapon ),
( "Demihuman", ObjectType.DemiHuman ),
( "Monster", ObjectType.Monster ),
@ -143,8 +133,8 @@ public partial class SettingsInterface
private static readonly (string, BodySlot)[] ImcBodySlots =
{
EstBodySlots[ 0 ],
EstBodySlots[ 1 ],
( "Hair", BodySlot.Hair ),
( "Face", BodySlot.Face ),
( "Body", BodySlot.Body ),
( "Tail", BodySlot.Tail ),
( "Ears", BodySlot.Zear ),
@ -646,24 +636,26 @@ public partial class SettingsInterface
RestrictedInputInt( "Set Id##newManipImc", ref _newManipSetId, 0, ushort.MaxValue );
RestrictedInputInt( "Variant##newManipImc", ref _newManipVariant, 0, byte.MaxValue );
CustomCombo( "Object Type", ImcObjectType, out var objectType, ref _newManipObjectType );
EquipSlot equipSlot = default;
ImcManipulation imc = new();
switch( objectType )
{
case ObjectType.Equipment:
CustomCombo( "Equipment Slot", EqdpEquipSlots, out equipSlot, ref _newManipEquipSlot );
//newManip = MetaManipulation.Imc( equipSlot, _newManipSetId, _newManipVariant,
// new ImcFile.ImageChangeData() );
CustomCombo( "Equipment Slot", EqdpEquipSlots, out var equipSlot, ref _newManipEquipSlot );
imc = new ImcManipulation( equipSlot, _newManipVariant, _newManipSetId, new ImcEntry() );
break;
case ObjectType.DemiHuman:
case ObjectType.Weapon:
case ObjectType.Monster:
RestrictedInputInt( "Secondary Id##newManipImc", ref _newManipSecondaryId, 0, ushort.MaxValue );
CustomCombo( "Body Slot", ImcBodySlots, out var bodySlot, ref _newManipBodySlot );
//newManip = MetaManipulation.Imc( objectType, bodySlot, _newManipSetId, _newManipSecondaryId,
// _newManipVariant, new ImcFile.ImageChangeData() );
imc = new ImcManipulation( objectType, bodySlot, _newManipSetId, _newManipSecondaryId,
_newManipVariant, new ImcEntry() );
break;
}
newManip = new MetaManipulation( new ImcManipulation( imc.ObjectType, imc.BodySlot, imc.PrimaryId, imc.SecondaryId,
imc.Variant, imc.EquipSlot, ImcFile.GetDefault( imc.GamePath(), imc.EquipSlot, imc.Variant ) ) );
break;
}
case MetaManipulation.Type.Eqdp:
@ -672,76 +664,50 @@ public partial class SettingsInterface
CustomCombo( "Equipment Slot", EqdpEquipSlots, out var equipSlot, ref _newManipEquipSlot );
CustomCombo( "Race", Races, out var race, ref _newManipRace );
CustomCombo( "Gender", Genders, out var gender, ref _newManipGender );
//newManip = MetaManipulation.Eqdp( equipSlot, Names.CombinedRace( gender, race ), ( ushort )_newManipSetId,
// new EqdpEntry() );
var eqdp = new EqdpManipulation( new EqdpEntry(), equipSlot, gender, race, _newManipSetId );
newManip = new MetaManipulation( new EqdpManipulation( ExpandedEqdpFile.GetDefault( eqdp.FileIndex(), eqdp.SetId ),
equipSlot, gender, race, _newManipSetId ) );
break;
}
case MetaManipulation.Type.Eqp:
{
RestrictedInputInt( "Set Id##newManipEqp", ref _newManipSetId, 0, ushort.MaxValue );
CustomCombo( "Equipment Slot", EqpEquipSlots, out var equipSlot, ref _newManipEquipSlot );
//newManip = MetaManipulation.Eqp( equipSlot, ( ushort )_newManipSetId, 0 );
newManip = new MetaManipulation( new EqpManipulation( ExpandedEqpFile.GetDefault( _newManipSetId ) & Eqp.Mask( equipSlot ),
equipSlot, _newManipSetId ) );
break;
}
case MetaManipulation.Type.Est:
{
RestrictedInputInt( "Set Id##newManipEst", ref _newManipSetId, 0, ushort.MaxValue );
CustomCombo( "Object Type", ObjectTypes, out var objectType, ref _newManipObjectType );
EquipSlot equipSlot = default;
BodySlot bodySlot = default;
switch( ( ObjectType )_newManipObjectType )
{
case ObjectType.Equipment:
CustomCombo( "Equipment Slot", EstEquipSlots, out equipSlot, ref _newManipEquipSlot );
break;
case ObjectType.Character:
CustomCombo( "Body Slot", EstBodySlots, out bodySlot, ref _newManipBodySlot );
break;
}
CustomCombo( "Est Type", EstTypes, out var estType, ref _newManipObjectType );
CustomCombo( "Race", Races, out var race, ref _newManipRace );
CustomCombo( "Gender", Genders, out var gender, ref _newManipGender );
//newManip = MetaManipulation.Est( objectType, equipSlot, Names.CombinedRace( gender, race ), bodySlot,
// ( ushort )_newManipSetId, 0 );
newManip = new MetaManipulation( new EstManipulation( gender, race, estType, _newManipSetId,
EstFile.GetDefault( estType, Names.CombinedRace( gender, race ), _newManipSetId ) ) );
break;
}
case MetaManipulation.Type.Gmp:
RestrictedInputInt( "Set Id##newManipGmp", ref _newManipSetId, 0, ushort.MaxValue );
//newManip = MetaManipulation.Gmp( ( ushort )_newManipSetId, new GmpEntry() );
newManip = new MetaManipulation( new GmpManipulation( ExpandedGmpFile.GetDefault( _newManipSetId ), _newManipSetId ) );
break;
case MetaManipulation.Type.Rsp:
CustomCombo( "Subrace", Subraces, out var subRace, ref _newManipSubrace );
CustomCombo( "Attribute", RspAttributes, out var rspAttribute, ref _newManipAttribute );
//newManip = MetaManipulation.Rsp( subRace, rspAttribute, 1f );
newManip = new MetaManipulation( new RspManipulation( subRace, rspAttribute,
CmpFile.GetDefault( subRace, rspAttribute ) ) );
break;
}
//if( ImGui.Button( "Create Manipulation##newManip", Vector2.UnitX * -1 )
// && newManip != null
// && list.All( m => m.Identifier != newManip.Value.Identifier ) )
//{
// var def = Penumbra.MetaDefaults.GetDefaultValue( newManip.Value );
// if( def != null )
// {
// var manip = newManip.Value.Type switch
// {
// MetaType.Est => new MetaManipulation( newManip.Value.Identifier, ( ulong )def ),
// MetaType.Eqp => new MetaManipulation( newManip.Value.Identifier, ( ulong )def ),
// MetaType.Eqdp => new MetaManipulation( newManip.Value.Identifier, (ushort) def ),
// MetaType.Gmp => new MetaManipulation( newManip.Value.Identifier, ( ulong )def ),
// MetaType.Imc => new MetaManipulation( newManip.Value.Identifier,
// ( ( ImcFile.ImageChangeData )def ).ToInteger() ),
// MetaType.Rsp => MetaManipulation.Rsp( newManip.Value.RspIdentifier.SubRace,
// newManip.Value.RspIdentifier.Attribute, ( float )def ),
// _ => throw new InvalidEnumArgumentException(),
// };
// list.Add( manip );
// change = true;
// ++count;
// }
//
// ImGui.CloseCurrentPopup();
//}
if( ImGui.Button( "Create Manipulation##newManip", Vector2.UnitX * -1 )
&& newManip != null
&& list.All( m => !m.Equals( newManip ) ) )
{
list.Add( newManip.Value );
change = true;
++count;
ImGui.CloseCurrentPopup();
}
return change;
}

View file

@ -87,9 +87,10 @@ public partial class SettingsInterface
if( ImGui.IsItemClicked() )
{
var data = ( ( Interop.Structs.ResourceHandle* )r )->GetData();
var data = Interop.Structs.ResourceHandle.GetData( ( Interop.Structs.ResourceHandle* )r );
var length = ( int )Interop.Structs.ResourceHandle.GetLength( ( Interop.Structs.ResourceHandle* )r );
ImGui.SetClipboardText( string.Join( " ",
new ReadOnlySpan< byte >( ( byte* )data.Data, data.Length ).ToArray().Select( b => b.ToString( "X2" ) ) ) );
new ReadOnlySpan< byte >( data, length ).ToArray().Select( b => b.ToString( "X2" ) ) ) );
//ImGuiNative.igSetClipboardText( ( byte* )Structs.ResourceHandle.GetData( ( IntPtr )r ) );
}

View file

@ -27,10 +27,10 @@ public partial class SettingsInterface
public TabSettings( SettingsInterface ui )
{
_base = ui;
_config = Penumbra.Config;
_configChanged = false;
_newModDirectory = _config.ModDirectory;
_base = ui;
_config = Penumbra.Config;
_configChanged = false;
_newModDirectory = _config.ModDirectory;
}
private static bool DrawPressEnterWarning( string old )
@ -239,44 +239,6 @@ public partial class SettingsInterface
ImGuiComponents.HelpMarker( "Enables other applications, e.g. Anamnesis, to use some Penumbra functions, like requesting redraws." );
}
private void DrawEnabledPlayerWatcher()
{
var enabled = _config.EnablePlayerWatch;
if( ImGui.Checkbox( "Enable Automatic Character Redraws", ref enabled ) )
{
_config.EnablePlayerWatch = enabled;
_configChanged = true;
Penumbra.PlayerWatcher.SetStatus( enabled );
}
ImGui.SameLine();
ImGuiComponents.HelpMarker(
"If this setting is enabled, Penumbra will keep tabs on characters that have a corresponding character collection setup in the Collections tab.\n"
+ "Penumbra will try to automatically redraw those characters using their collection when they first appear in an instance, or when they change their current equip.\n" );
if( !_config.EnablePlayerWatch || !_config.ShowAdvanced )
{
return;
}
var waitFrames = _config.WaitFrames;
ImGui.SameLine();
ImGui.SetNextItemWidth( 50 * ImGuiHelpers.GlobalScale );
if( ImGui.InputInt( "Wait Frames", ref waitFrames, 0, 0 )
&& waitFrames != _config.WaitFrames
&& waitFrames is > 0 and < 3000 )
{
_base._penumbra.ObjectReloader.DefaultWaitFrames = waitFrames;
_config.WaitFrames = waitFrames;
_configChanged = true;
}
ImGui.SameLine();
ImGuiComponents.HelpMarker(
"The number of frames penumbra waits after some events (like zone changes) until it starts trying to redraw actors again, in a range of [1, 3001].\n"
+ "Keep this as low as possible while producing stable results." );
}
private static void DrawReloadResourceButton()
{
if( ImGui.Button( "Reload Resident Resources" ) )
@ -388,7 +350,6 @@ public partial class SettingsInterface
ImGuiCustom.VerticalDistance( DefaultVerticalSpace );
DrawEnabledBox();
DrawEnabledPlayerWatcher();
ImGuiCustom.VerticalDistance( DefaultVerticalSpace );
DrawScaleModSelectorBox();