Fix weapon meta changes.

This commit is contained in:
Ottermandias 2021-06-04 13:05:46 +02:00
parent 6a1ae4f317
commit db4942224e
4 changed files with 38 additions and 28 deletions

View file

@ -46,6 +46,7 @@ namespace Penumbra.Importer
ObjectType.DemiHuman => true,
ObjectType.Housing => true,
ObjectType.Monster => true,
ObjectType.Weapon => true,
ObjectType.Icon => false,
ObjectType.Font => false,
ObjectType.Interface => false,
@ -53,7 +54,6 @@ namespace Penumbra.Importer
ObjectType.Map => false,
ObjectType.Vfx => false,
ObjectType.Unknown => false,
ObjectType.Weapon => false,
ObjectType.World => false,
_ => false,
};
@ -149,7 +149,7 @@ namespace Penumbra.Importer
}
catch( Exception e )
{
PluginLog.Debug("Skipped {Type}-manipulation:\n{e:l}", manipulation.Type, e );
PluginLog.Debug( "Skipped {Type}-manipulation:\n{e:l}", manipulation.Type, e );
}
}

View file

@ -98,7 +98,6 @@ namespace Penumbra.MetaData
public ImcFile? GetNewImcFile( ObjectType type, ushort primarySetId, ushort secondarySetId = 0 )
=> GetDefaultImcFile( type, primarySetId, secondarySetId )?.Clone();
public MetaDefaults( DalamudPluginInterface pi )
=> _pi = pi;

View file

@ -1,13 +1,17 @@
using System;
using Penumbra.Game;
using Penumbra.Mods;
using Penumbra.Util;
namespace Penumbra.MetaData
{
public static class MetaFileNames
{
public static GamePath Eqp() => GamePath.GenerateUnchecked( "chara/xls/equipmentparameter/equipmentparameter.eqp" );
public static GamePath Gmp() => GamePath.GenerateUnchecked( "chara/xls/equipmentparameter/gimmickparameter.gmp" );
public static GamePath Eqp()
=> GamePath.GenerateUnchecked( "chara/xls/equipmentparameter/equipmentparameter.eqp" );
public static GamePath Gmp()
=> GamePath.GenerateUnchecked( "chara/xls/equipmentparameter/gimmickparameter.gmp" );
public static GamePath Est( ObjectType type, EquipSlot equip, BodySlot slot )
{
@ -17,15 +21,15 @@ namespace Penumbra.MetaData
{
EquipSlot.Body => GamePath.GenerateUnchecked( "chara/xls/charadb/extra_top.est" ),
EquipSlot.Head => GamePath.GenerateUnchecked( "chara/xls/charadb/extra_met.est" ),
_ => throw new NotImplementedException()
_ => throw new NotImplementedException(),
},
ObjectType.Character => slot switch
{
BodySlot.Hair => GamePath.GenerateUnchecked( "chara/xls/charadb/hairskeletontemplate.est" ),
BodySlot.Face => GamePath.GenerateUnchecked( "chara/xls/charadb/faceskeletontemplate.est" ),
_ => throw new NotImplementedException()
_ => throw new NotImplementedException(),
},
_ => throw new NotImplementedException()
_ => throw new NotImplementedException(),
};
}
@ -41,7 +45,7 @@ namespace Penumbra.MetaData
$"chara/monster/m{primaryId:D4}/obj/body/b{secondaryId:D4}/b{secondaryId:D4}.imc" ),
ObjectType.Weapon => GamePath.GenerateUnchecked(
$"chara/weapon/w{primaryId:D4}/obj/body/b{secondaryId:D4}/b{secondaryId:D4}.imc" ),
_ => throw new NotImplementedException()
_ => throw new NotImplementedException(),
};
}
@ -51,7 +55,7 @@ namespace Penumbra.MetaData
{
ObjectType.Accessory => GamePath.GenerateUnchecked( $"chara/xls/charadb/accessorydeformerparameter/c{gr.ToRaceCode()}.eqdp" ),
ObjectType.Equipment => GamePath.GenerateUnchecked( $"chara/xls/charadb/equipmentdeformerparameter/c{gr.ToRaceCode()}.eqdp" ),
_ => throw new NotImplementedException()
_ => throw new NotImplementedException(),
};
}
@ -69,7 +73,7 @@ namespace Penumbra.MetaData
EquipSlot.Wrists => Eqdp( ObjectType.Accessory, gr ),
EquipSlot.RingL => Eqdp( ObjectType.Accessory, gr ),
EquipSlot.RingR => Eqdp( ObjectType.Accessory, gr ),
_ => throw new NotImplementedException()
_ => throw new NotImplementedException(),
};
}
}

View file

@ -30,7 +30,7 @@ namespace Penumbra.Mods
GmpFile gmp => gmp.WriteBytes(),
EstFile est => est.WriteBytes(),
ImcFile imc => imc.WriteBytes(),
_ => throw new NotImplementedException()
_ => throw new NotImplementedException(),
};
DisposeFile( CurrentFile );
CurrentFile = TempFile.WriteNew( dir, data );
@ -123,27 +123,34 @@ namespace Penumbra.Mods
}
var gamePath = m.CorrespondingFilename();
if( !_currentFiles.TryGetValue( gamePath, out var file ) )
try
{
file = new FileInformation( _default.CreateNewFile( m ) ?? throw new IOException() )
if( !_currentFiles.TryGetValue( gamePath, out var file ) )
{
Changed = true,
CurrentFile = null
file = new FileInformation( _default.CreateNewFile( m ) ?? throw new IOException() )
{
Changed = true,
CurrentFile = null,
};
_currentFiles[ gamePath ] = file;
}
file.Changed |= m.Type switch
{
MetaType.Eqp => m.Apply( ( EqpFile )file.Data ),
MetaType.Eqdp => m.Apply( ( EqdpFile )file.Data ),
MetaType.Gmp => m.Apply( ( GmpFile )file.Data ),
MetaType.Est => m.Apply( ( EstFile )file.Data ),
MetaType.Imc => m.Apply( ( ImcFile )file.Data ),
_ => throw new NotImplementedException(),
};
_currentFiles[ gamePath ] = file;
return true;
}
file.Changed |= m.Type switch
catch( Exception e )
{
MetaType.Eqp => m.Apply( ( EqpFile )file.Data ),
MetaType.Eqdp => m.Apply( ( EqdpFile )file.Data ),
MetaType.Gmp => m.Apply( ( GmpFile )file.Data ),
MetaType.Est => m.Apply( ( EstFile )file.Data ),
MetaType.Imc => m.Apply( ( ImcFile )file.Data ),
_ => throw new NotImplementedException()
};
return true;
PluginLog.Error( $"Could not obtain default file for manipulation {m.CorrespondingFilename()}:\n{e}" );
return false;
}
}
}
}