Disable material migration for now

This commit is contained in:
Ottermandias 2024-07-16 22:04:36 +02:00
parent 07c3be641d
commit 9c781f8563
3 changed files with 31 additions and 21 deletions

@ -1 +1 @@
Subproject commit 2c067b4f3c1d84888c2b961a93fe2de01fffe5f1 Subproject commit c2a4c4ee7470c5afbd3dd7731697ab49c055d1e3

View file

@ -233,6 +233,8 @@ public class MigrationManager(Configuration config) : IService
/// <summary> Writes or migrates a .mdl file during extraction from a regular archive. </summary> /// <summary> Writes or migrates a .mdl file during extraction from a regular archive. </summary>
public void MigrateMdlDuringExtraction(IReader reader, string directory, ExtractionOptions options) public void MigrateMdlDuringExtraction(IReader reader, string directory, ExtractionOptions options)
{ {
// TODO reactivate when this works.
return;
if (!config.MigrateImportedModelsToV6) if (!config.MigrateImportedModelsToV6)
{ {
reader.WriteEntryToDirectory(directory, options); reader.WriteEntryToDirectory(directory, options);
@ -265,6 +267,8 @@ public class MigrationManager(Configuration config) : IService
public void MigrateMtrlDuringExtraction(IReader reader, string directory, ExtractionOptions options) public void MigrateMtrlDuringExtraction(IReader reader, string directory, ExtractionOptions options)
{ {
// TODO reactivate when this works.
return;
if (!config.MigrateImportedMaterialsToLegacy) if (!config.MigrateImportedMaterialsToLegacy)
{ {
reader.WriteEntryToDirectory(directory, options); reader.WriteEntryToDirectory(directory, options);
@ -276,17 +280,21 @@ public class MigrationManager(Configuration config) : IService
using var e = reader.OpenEntryStream(); using var e = reader.OpenEntryStream();
e.CopyTo(s); e.CopyTo(s);
var file = new MtrlFile(s.GetBuffer()); var file = new MtrlFile(s.GetBuffer());
if (!file.IsDawnTrail)
{
file.MigrateToDawntrail();
Penumbra.Log.Debug($"Migrated material {reader.Entry.Key} to Dawntrail during import.");
}
Directory.CreateDirectory(Path.GetDirectoryName(path)!); Directory.CreateDirectory(Path.GetDirectoryName(path)!);
using var f = File.Open(path, FileMode.Create, FileAccess.Write); using var f = File.Open(path, FileMode.Create, FileAccess.Write);
if (file.IsDawnTrail)
{
file.MigrateToDawntrail();
Penumbra.Log.Debug($"Migrated material {reader.Entry.Key} to Dawntrail during import.");
f.Write(file.Write());
}
else
{
s.Seek(0, SeekOrigin.Begin); s.Seek(0, SeekOrigin.Begin);
s.WriteTo(f); s.WriteTo(f);
} }
}
/// <summary> Update the data of a .mdl file during TTMP extraction. Returns either the existing array or a new one. </summary> /// <summary> Update the data of a .mdl file during TTMP extraction. Returns either the existing array or a new one. </summary>
public byte[] MigrateTtmpModel(string path, byte[] data) public byte[] MigrateTtmpModel(string path, byte[] data)

View file

@ -22,10 +22,11 @@ public class MigrationSectionDrawer(MigrationManager migrationManager, Configura
DrawMdlMigration(); DrawMdlMigration();
DrawMdlRestore(); DrawMdlRestore();
DrawMdlCleanup(); DrawMdlCleanup();
ImGui.Separator(); // TODO enable when this works
DrawMtrlMigration(); //ImGui.Separator();
DrawMtrlRestore(); //DrawMtrlMigration();
DrawMtrlCleanup(); //DrawMtrlRestore();
//DrawMtrlCleanup();
} }
private void DrawSettings() private void DrawSettings()
@ -39,15 +40,16 @@ public class MigrationSectionDrawer(MigrationManager migrationManager, Configura
ImUtf8.HoverTooltip("This increments the version marker and restructures the bone table to the new version."u8); ImUtf8.HoverTooltip("This increments the version marker and restructures the bone table to the new version."u8);
value = config.MigrateImportedMaterialsToLegacy; // TODO enable when this works
if (ImUtf8.Checkbox("Automatically Migrate Materials to Dawntrail on Import"u8, ref value)) //value = config.MigrateImportedMaterialsToLegacy;
{ //if (ImUtf8.Checkbox("Automatically Migrate Materials to Dawntrail on Import"u8, ref value))
config.MigrateImportedMaterialsToLegacy = value; //{
config.Save(); // config.MigrateImportedMaterialsToLegacy = value;
} // config.Save();
//}
ImUtf8.HoverTooltip( //
"This currently only increases the color-table size and switches the shader from 'character.shpk' to 'characterlegacy.shpk', if the former is used."u8); //ImUtf8.HoverTooltip(
// "This currently only increases the color-table size and switches the shader from 'character.shpk' to 'characterlegacy.shpk', if the former is used."u8);
ImUtf8.Checkbox("Create Backups During Manual Migration", ref _createBackups); ImUtf8.Checkbox("Create Backups During Manual Migration", ref _createBackups);
} }