mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 10:17:22 +01:00
Slightly improve error message when importing wrongly named atch files.
This commit is contained in:
parent
ebe45c6a47
commit
2c115eda94
1 changed files with 16 additions and 6 deletions
|
|
@ -34,6 +34,7 @@ public sealed class AtchMetaDrawer : MetaDrawer<AtchIdentifier, AtchEntry>, ISer
|
||||||
private AtchFile? _currentBaseAtchFile;
|
private AtchFile? _currentBaseAtchFile;
|
||||||
private AtchPoint? _currentBaseAtchPoint;
|
private AtchPoint? _currentBaseAtchPoint;
|
||||||
private readonly AtchPointCombo _combo;
|
private readonly AtchPointCombo _combo;
|
||||||
|
private string _fileImport = string.Empty;
|
||||||
|
|
||||||
public AtchMetaDrawer(ModMetaEditor editor, MetaFileManager metaFiles)
|
public AtchMetaDrawer(ModMetaEditor editor, MetaFileManager metaFiles)
|
||||||
: base(editor, metaFiles)
|
: base(editor, metaFiles)
|
||||||
|
|
@ -48,6 +49,8 @@ public sealed class AtchMetaDrawer : MetaDrawer<AtchIdentifier, AtchEntry>, ISer
|
||||||
=> obj.ToName();
|
=> obj.ToName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private sealed class RaceCodeException(string filePath) : Exception($"Could not identify race code from path {filePath}.");
|
||||||
|
|
||||||
public void ImportFile(string filePath)
|
public void ImportFile(string filePath)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -57,14 +60,15 @@ public sealed class AtchMetaDrawer : MetaDrawer<AtchIdentifier, AtchEntry>, ISer
|
||||||
|
|
||||||
var gr = Parser.ParseRaceCode(filePath);
|
var gr = Parser.ParseRaceCode(filePath);
|
||||||
if (gr is GenderRace.Unknown)
|
if (gr is GenderRace.Unknown)
|
||||||
throw new Exception($"Could not identify race code from path {filePath}.");
|
throw new RaceCodeException(filePath);
|
||||||
|
|
||||||
var text = File.ReadAllBytes(filePath);
|
var text = File.ReadAllBytes(filePath);
|
||||||
var file = new AtchFile(text);
|
var file = new AtchFile(text);
|
||||||
foreach (var point in file.Points)
|
foreach (var point in file.Points)
|
||||||
{
|
{
|
||||||
foreach (var (entry, index) in point.Entries.WithIndex())
|
foreach (var (entry, index) in point.Entries.WithIndex())
|
||||||
{
|
{
|
||||||
var identifier = new AtchIdentifier(point.Type, gr, (ushort) index);
|
var identifier = new AtchIdentifier(point.Type, gr, (ushort)index);
|
||||||
var defaultValue = AtchCache.GetDefault(MetaFiles, identifier);
|
var defaultValue = AtchCache.GetDefault(MetaFiles, identifier);
|
||||||
if (defaultValue == null)
|
if (defaultValue == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -76,6 +80,12 @@ public sealed class AtchMetaDrawer : MetaDrawer<AtchIdentifier, AtchEntry>, ISer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (RaceCodeException ex)
|
||||||
|
{
|
||||||
|
Penumbra.Messager.AddMessage(new Notification(ex, "The imported .atch file does not contain a race code (cXXXX) in its name.",
|
||||||
|
"Could not import .atch file:",
|
||||||
|
NotificationType.Warning));
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Penumbra.Messager.AddMessage(new Notification(ex, "Unable to import .atch file.", "Could not import .atch file:",
|
Penumbra.Messager.AddMessage(new Notification(ex, "Unable to import .atch file.", "Could not import .atch file:",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue