Give error information on IMC problems.

This commit is contained in:
Ottermandias 2022-06-08 15:22:10 +02:00
parent a37a8eb5aa
commit 35cff163f8
4 changed files with 76 additions and 33 deletions

View file

@ -70,24 +70,33 @@ public partial class MetaManager
#if USE_IMC
Manipulations[ m ] = mod;
var path = m.GamePath();
if( !Files.TryGetValue( path, out var file ) )
try
{
file = new ImcFile( path );
}
if( !Files.TryGetValue( path, out var file ) )
{
file = new ImcFile( path );
}
if( !m.Apply( file ) )
if( !m.Apply( file ) )
{
return false;
}
Files[ path ] = file;
var fullPath = CreateImcPath( path );
if( _collection.HasCache )
{
_collection.ForceFile( path, fullPath );
}
return true;
}
catch( Exception e )
{
++Penumbra.ImcExceptions;
PluginLog.Error( $"Could not apply IMC Manipulation:\n{e}" );
return false;
}
Files[ path ] = file;
var fullPath = CreateImcPath( path );
if( _collection.HasCache )
{
_collection.ForceFile( path, fullPath );
}
return true;
#else
return false;
#endif

View file

@ -69,6 +69,7 @@ public class Penumbra : IDisposable
public static SimpleRedirectManager Redirects { get; private set; } = null!;
public static ResourceLoader ResourceLoader { get; private set; } = null!;
public static FrameworkManager Framework { get; private set; } = null!;
public static int ImcExceptions = 0;
public readonly ResourceLogger ResourceLogger;
@ -147,6 +148,10 @@ public class Penumbra : IDisposable
Api = new PenumbraApi( this );
Ipc = new PenumbraIpc( Dalamud.PluginInterface, Api );
SubscribeItemLinks();
if( ImcExceptions > 0 )
{
PluginLog.Error( $"{ImcExceptions} IMC Exceptions thrown. Please repair your game files." );
}
}
private void SetupInterface( out ConfigWindow cfg, out LaunchButton btn, out WindowSystem system )
@ -429,6 +434,7 @@ public class Penumbra : IDisposable
ModManager.Sum( m => m.TotalSwapCount ) );
sb.AppendFormat( "> **`Mods with Meta Manipulations:`** {0}, Total {1}\n", ModManager.Count( m => m.TotalManipulations > 0 ),
ModManager.Sum( m => m.TotalManipulations ) );
sb.AppendFormat( "> **`IMC Exceptions Thrown: `** {0}\n", ImcExceptions );
string CollectionName( ModCollection c )
=> c == ModCollection.Empty ? ModCollection.Empty.Name : c.Name.Length >= 2 ? c.Name[ ..2 ] : c.Name;

View file

@ -55,7 +55,7 @@ public partial class ConfigWindow
DrawAdvancedSettings();
_dialogManager.Draw();
DrawDiscordButton();
DrawSupportButtons();
}
// Changing the base mod directory.
@ -209,26 +209,11 @@ public partial class ConfigWindow
ImGui.NewLine();
}
private static void DrawDiscordButton()
public static void DrawDiscordButton( float width )
{
const string help = "Copy Support Info to Clipboard";
const string discord = "Join Discord for Support";
const string address = @"https://discord.gg/kVva7DHV4r";
var width = ImGui.CalcTextSize( help ).X + ImGui.GetStyle().FramePadding.X * 2;
if( ImGui.GetScrollMaxY() > 0 )
{
width += ImGui.GetStyle().ScrollbarSize + ImGui.GetStyle().ItemSpacing.X;
}
ImGui.SetCursorPos( new Vector2( ImGui.GetWindowWidth() - width, ImGui.GetFrameHeightWithSpacing() ) );
if( ImGui.Button( help ) )
{
var text = Penumbra.GatherSupportInformation();
ImGui.SetClipboardText( text );
}
ImGui.SetCursorPos( new Vector2( ImGui.GetWindowWidth() - width, 0 ) );
using var color = ImRaii.PushColor( ImGuiCol.Button, Colors.DiscordColor );
using var color = ImRaii.PushColor( ImGuiCol.Button, Colors.DiscordColor );
if( ImGui.Button( discord, new Vector2( width, 0 ) ) )
{
try
@ -247,5 +232,31 @@ public partial class ConfigWindow
ImGuiUtil.HoverTooltip( $"Open {address}" );
}
private const string SupportInfoButtonText = "Copy Support Info to Clipboard";
public static void DrawSupportButton()
{
if( ImGui.Button( SupportInfoButtonText ) )
{
var text = Penumbra.GatherSupportInformation();
ImGui.SetClipboardText( text );
}
}
private static void DrawSupportButtons()
{
var width = ImGui.CalcTextSize( SupportInfoButtonText ).X + ImGui.GetStyle().FramePadding.X * 2;
if( ImGui.GetScrollMaxY() > 0 )
{
width += ImGui.GetStyle().ScrollbarSize + ImGui.GetStyle().ItemSpacing.X;
}
ImGui.SetCursorPos( new Vector2( ImGui.GetWindowWidth() - width, ImGui.GetFrameHeightWithSpacing() ) );
DrawSupportButton();
ImGui.SetCursorPos( new Vector2( ImGui.GetWindowWidth() - width, 0 ) );
DrawDiscordButton( width );
}
}
}

View file

@ -1,12 +1,10 @@
using System;
using System.Collections.Generic;
using System.Numerics;
using Dalamud.Interface;
using Dalamud.Interface.Windowing;
using Dalamud.Logging;
using ImGuiNET;
using OtterGui.Raii;
using Penumbra.Mods;
using Penumbra.UI.Classes;
namespace Penumbra.UI;
@ -56,6 +54,25 @@ public sealed partial class ConfigWindow : Window, IDisposable
{
try
{
if( Penumbra.ImcExceptions > 0 )
{
using var color = ImRaii.PushColor( ImGuiCol.Text, Colors.RegexWarningBorder );
ImGui.NewLine();
ImGui.NewLine();
ImGui.TextWrapped( $"There were {Penumbra.ImcExceptions} errors while trying to load IMC files from the game data.\n"
+ "This usually means that your game installation was corrupted by updating the game while having TexTools mods still active.\n"
+ "It is recommended to not use TexTools and Penumbra (or other Lumina-based tools) at the same time.\n\n"
+ "Please use the Launcher's Repair Game Files function to repair your client installation." );
color.Pop();
ImGui.NewLine();
ImGui.NewLine();
SettingsTab.DrawDiscordButton( 0 );
ImGui.SameLine();
SettingsTab.DrawSupportButton();
return;
}
using var bar = ImRaii.TabBar( string.Empty, ImGuiTabBarFlags.NoTooltip );
SetupSizes();
_settingsTab.Draw();