mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Merge pull request #1 from goaaats/deduplicate
Add error message on failed import
This commit is contained in:
commit
54d8a3e330
2 changed files with 29 additions and 9 deletions
|
|
@ -58,7 +58,10 @@ namespace Penumbra.Importer
|
|||
|
||||
case ".ttmp2":
|
||||
ImportV2ModPack( modPackFile );
|
||||
return;
|
||||
return;
|
||||
|
||||
default:
|
||||
throw new ArgumentException( $"Unrecognized modpack format: {modPackFile.Extension}", nameof(modPackFile) );
|
||||
}
|
||||
|
||||
State = ImporterState.Done;
|
||||
|
|
|
|||
|
|
@ -19,10 +19,14 @@ namespace Penumbra.UI
|
|||
private const string LabelFileDialog = "Pick one or more modpacks.";
|
||||
private const string LabelFileImportRunning = "Import in progress...";
|
||||
private const string TooltipModpack1 = "Writing modpack to disk before extracting...";
|
||||
private const string FailedImport = "One or more of your modpacks failed to import.\nPlease submit a bug report.";
|
||||
|
||||
private const uint ColorRed = 0xFF0000C8;
|
||||
|
||||
private static readonly Vector2 ImportBarSize = new( -1, 0 );
|
||||
|
||||
private bool _isImportRunning = false;
|
||||
private bool _isImportRunning = false;
|
||||
private bool _hasError = false;
|
||||
private TexToolsImport _texToolsImport = null!;
|
||||
private readonly SettingsInterface _base;
|
||||
|
||||
|
|
@ -47,6 +51,8 @@ namespace Penumbra.UI
|
|||
|
||||
if( result == DialogResult.OK )
|
||||
{
|
||||
_hasError = false;
|
||||
|
||||
foreach( var fileName in picker.FileNames )
|
||||
{
|
||||
PluginLog.Log( $"-> {fileName} START");
|
||||
|
|
@ -55,13 +61,14 @@ namespace Penumbra.UI
|
|||
{
|
||||
_texToolsImport = new TexToolsImport( new DirectoryInfo( _base._plugin.Configuration.CurrentCollection ) );
|
||||
_texToolsImport.ImportModPack( new FileInfo( fileName ) );
|
||||
|
||||
PluginLog.Log( $"-> {fileName} OK!" );
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
PluginLog.LogError( ex, "Could not import one or more modpacks." );
|
||||
PluginLog.LogError( ex, "Failed to import modpack at {0}", fileName );
|
||||
_hasError = true;
|
||||
}
|
||||
|
||||
PluginLog.Log( $"-> {fileName} OK!");
|
||||
}
|
||||
|
||||
_texToolsImport = null;
|
||||
|
|
@ -79,8 +86,8 @@ namespace Penumbra.UI
|
|||
}
|
||||
}
|
||||
|
||||
private void DrawImportProgress()
|
||||
{
|
||||
private void DrawImportProgress()
|
||||
{
|
||||
ImGui.Button( LabelFileImportRunning );
|
||||
|
||||
if( _texToolsImport != null )
|
||||
|
|
@ -105,7 +112,14 @@ namespace Penumbra.UI
|
|||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawFailedImportMessage()
|
||||
{
|
||||
ImGui.PushStyleColor( ImGuiCol.Text, ColorRed );
|
||||
ImGui.Text( FailedImport );
|
||||
ImGui.PopStyleColor();
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
|
|
@ -117,7 +131,10 @@ namespace Penumbra.UI
|
|||
if( !_isImportRunning )
|
||||
DrawImportButton();
|
||||
else
|
||||
DrawImportProgress();
|
||||
DrawImportProgress();
|
||||
|
||||
if (_hasError)
|
||||
DrawFailedImportMessage();
|
||||
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue