mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 10:17:22 +01:00
feat: add error message on failed import
This commit is contained in:
parent
bea196e4b6
commit
4346efa881
1 changed files with 25 additions and 8 deletions
|
|
@ -19,10 +19,14 @@ namespace Penumbra.UI
|
||||||
private const string LabelFileDialog = "Pick one or more modpacks.";
|
private const string LabelFileDialog = "Pick one or more modpacks.";
|
||||||
private const string LabelFileImportRunning = "Import in progress...";
|
private const string LabelFileImportRunning = "Import in progress...";
|
||||||
private const string TooltipModpack1 = "Writing modpack to disk before extracting...";
|
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 static readonly Vector2 ImportBarSize = new( -1, 0 );
|
||||||
|
|
||||||
private bool _isImportRunning = false;
|
private bool _isImportRunning = false;
|
||||||
|
private bool _hasError = false;
|
||||||
private TexToolsImport _texToolsImport = null!;
|
private TexToolsImport _texToolsImport = null!;
|
||||||
private readonly SettingsInterface _base;
|
private readonly SettingsInterface _base;
|
||||||
|
|
||||||
|
|
@ -47,6 +51,8 @@ namespace Penumbra.UI
|
||||||
|
|
||||||
if( result == DialogResult.OK )
|
if( result == DialogResult.OK )
|
||||||
{
|
{
|
||||||
|
_hasError = false;
|
||||||
|
|
||||||
foreach( var fileName in picker.FileNames )
|
foreach( var fileName in picker.FileNames )
|
||||||
{
|
{
|
||||||
PluginLog.Log( $"-> {fileName} START");
|
PluginLog.Log( $"-> {fileName} START");
|
||||||
|
|
@ -55,13 +61,14 @@ namespace Penumbra.UI
|
||||||
{
|
{
|
||||||
_texToolsImport = new TexToolsImport( new DirectoryInfo( _base._plugin.Configuration.CurrentCollection ) );
|
_texToolsImport = new TexToolsImport( new DirectoryInfo( _base._plugin.Configuration.CurrentCollection ) );
|
||||||
_texToolsImport.ImportModPack( new FileInfo( fileName ) );
|
_texToolsImport.ImportModPack( new FileInfo( fileName ) );
|
||||||
|
|
||||||
|
PluginLog.Log( $"-> {fileName} OK!" );
|
||||||
}
|
}
|
||||||
catch( Exception ex )
|
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;
|
_texToolsImport = null;
|
||||||
|
|
@ -79,8 +86,8 @@ namespace Penumbra.UI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawImportProgress()
|
private void DrawImportProgress()
|
||||||
{
|
{
|
||||||
ImGui.Button( LabelFileImportRunning );
|
ImGui.Button( LabelFileImportRunning );
|
||||||
|
|
||||||
if( _texToolsImport != null )
|
if( _texToolsImport != null )
|
||||||
|
|
@ -105,7 +112,14 @@ namespace Penumbra.UI
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawFailedImportMessage()
|
||||||
|
{
|
||||||
|
ImGui.PushStyleColor( ImGuiCol.Text, ColorRed );
|
||||||
|
ImGui.Text( FailedImport );
|
||||||
|
ImGui.PopStyleColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw()
|
public void Draw()
|
||||||
|
|
@ -117,7 +131,10 @@ namespace Penumbra.UI
|
||||||
if( !_isImportRunning )
|
if( !_isImportRunning )
|
||||||
DrawImportButton();
|
DrawImportButton();
|
||||||
else
|
else
|
||||||
DrawImportProgress();
|
DrawImportProgress();
|
||||||
|
|
||||||
|
if (_hasError)
|
||||||
|
DrawFailedImportMessage();
|
||||||
|
|
||||||
ImGui.EndTabItem();
|
ImGui.EndTabItem();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue