Skip to content

Commit

Permalink
Update v3.0.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunaretic committed Jul 24, 2024
2 parents f759501 + df00d62 commit b737e18
Show file tree
Hide file tree
Showing 8 changed files with 406 additions and 77 deletions.
23 changes: 22 additions & 1 deletion ConsoleTools/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Threading.Tasks;
using System.Windows;
using xivModdingFramework.Cache;
using xivModdingFramework.Helpers;
using xivModdingFramework.Models.DataContainers;
using xivModdingFramework.Models.FileTypes;
using xivModdingFramework.Mods;
Expand Down Expand Up @@ -40,7 +41,27 @@ public static int Main(string[] args)
return null;
};

return Run(args).GetAwaiter().GetResult();
int res = -1;
try
{
res = Run(args).GetAwaiter().GetResult();
}
catch(Exception ex)
{
Console.WriteLine(ex);
}

try
{
// Always clear the temp folder, or try to.
IOUtil.ClearTempFolder();
}
catch
{

}

return res;
}


Expand Down
6 changes: 3 additions & 3 deletions FFXIV_TexTools/FFXIV_TexTools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
<Product>FFXIV_TexTools</Product>
<Copyright>Copyright © 2024</Copyright>

<ApplicationVersion>3.0.8.0</ApplicationVersion>
<AssemblyVersion>3.0.8.0</AssemblyVersion>
<FileVersion>3.0.8.0</FileVersion>
<ApplicationVersion>3.0.8.1</ApplicationVersion>
<AssemblyVersion>3.0.8.1</AssemblyVersion>
<FileVersion>3.0.8.1</FileVersion>

<LangVersion>9.0</LangVersion>
<UseWPF>true</UseWPF>
Expand Down
30 changes: 19 additions & 11 deletions FFXIV_TexTools/Helpers/ModpackUpgraderWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,31 @@ namespace FFXIV_TexTools.Helpers
{
internal class ModpackUpgraderWrapper
{
public static async Task UpgradeModpackPrompted(bool includePartials = true)
public static async Task UpgradeModpackPrompted(bool includePartials = true, string initialPath = null)
{
var mw = MainWindow.GetMainWindow();
var ofd = new OpenFileDialog()
{
Filter = ViewHelpers.LoadModpackFilter,
InitialDirectory = Path.GetFullPath(Settings.Default.ModPack_Directory),
};

ofd.Multiselect = true;
if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
string[] paths = new string[0];
if (initialPath == null)
{
return;
}
var ofd = new OpenFileDialog()
{
Filter = ViewHelpers.LoadModpackFilter,
InitialDirectory = Path.GetFullPath(Settings.Default.ModPack_Directory),
};

ofd.Multiselect = true;
if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
{
return;
}


var paths = ofd.FileNames;
paths = ofd.FileNames;
} else
{
paths = new string[1] { initialPath };
}


await mw.LockUi("Upgrading Modpack", "Please Wait...\n\nIf this takes more than 3-5 minutes, please close TexTools and retry with \nOptions => Settings => 'Compress Upgrade Textures' turned off.");
Expand Down
86 changes: 29 additions & 57 deletions FFXIV_TexTools/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,19 @@ public MainWindow(string[] args)

private async Task HandleArgs(string[] args)
{
OnlyImport(args[0]);
try
{
var gameDir = new DirectoryInfo(Properties.Settings.Default.FFXIV_Directory);
var lang = XivLanguages.GetXivLanguage(Properties.Settings.Default.Application_Language);
await XivCache.SetGameInfo(gameDir, lang, false);
}
catch (Exception ex)
{
FlexibleMessageBox.Show("An error occurred while initializing:\n\n" + ex.Message, "Init Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

ImportOnlyWindow.ShowImportDialog(args[0]);
Application.Current.Shutdown();
}

private void OnKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
Expand All @@ -414,28 +426,6 @@ private void OnKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
}
}

private void LanguageSelection()
{
var lang = Properties.Settings.Default.Application_Language;

if (lang.Equals(string.Empty))
{
var langSelectView = new LanguageSelectView();
langSelectView.ShowDialog();

var langCode = langSelectView.LanguageCode;

Properties.Settings.Default.Application_Language = langCode;
Properties.Settings.Default.Save();
} else if (lang != Properties.Settings.Default.Application_Language)
{
// We shouldn't evet actually get here, as this function is only called on
// first time installs, where lang would be empty, and other calls force-restart the application.
// But doesn't hurt to have a safety check here anyways.
_ = InitializeCache();
}
}

private bool _FFXIV_PATCHED = false;
private bool _NEW_INSTALL = false;
private async void OnCacheRebuild(object sender, CacheRebuildReason reason)
Expand Down Expand Up @@ -856,15 +846,24 @@ public static bool CheckForUpdates()

private void CheckForSettingsUpdate()
{
if (Settings.Default.UpgradeRequired)
try
{
if (Settings.Default.UpgradeRequired)
{
Settings.Default.Upgrade();
Settings.Default.UpgradeRequired = false;
Settings.Default.Save();

// Set theme according to settings now that the settings have been upgraded to the new version
var appStyle = ThemeManager.DetectAppStyle(Application.Current);
ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(appStyle.Item2.Name), ThemeManager.GetAppTheme(Settings.Default.Application_Theme));
}
}
catch(Exception ex)
{
Settings.Default.Upgrade();
Settings.Default.UpgradeRequired = false;
ViewHelpers.ShowError("Corrupt Settings File", "User settings file is corrupt or invalid. Settings will be reset.");
Settings.Default.Reset();
Settings.Default.Save();

// Set theme according to settings now that the settings have been upgraded to the new version
var appStyle = ThemeManager.DetectAppStyle(Application.Current);
ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(appStyle.Item2.Name), ThemeManager.GetAppTheme(Settings.Default.Application_Theme));
}
}

Expand Down Expand Up @@ -905,33 +904,6 @@ public static void MakeHighlander()
}
}

private async void OnlyImport(string modpack)
{

try
{

var gameDir = new DirectoryInfo(Properties.Settings.Default.FFXIV_Directory);
var lang = XivLanguages.GetXivLanguage(Properties.Settings.Default.Application_Language);
await XivCache.SetGameInfo(gameDir, lang, false);
if (!ViewHelpers.ShowConfirmation(this, "Import Confirmation", "This will install the modpack to your live FFXIV files.\n\nAre you sure you wish to continue?"))
{
Application.Current.Shutdown();
}

XivCache.GameWriteEnabled = true;

await ImportModpack(modpack, true);
}
catch(Exception ex)
{
FlexibleMessageBox.Show("An error occurred while initializing or importing the mod:\n\n" + ex.Message, "Import Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
throw;
}

Application.Current.Shutdown();
}

/// <summary>
/// Event handler for the language button clicked
/// </summary>
Expand Down
38 changes: 38 additions & 0 deletions FFXIV_TexTools/Views/ModPack/ImportOnlyWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<mah:MetroWindow x:Class="FFXIV_TexTools.Views.ImportOnlyWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="Importing Modpack" Width="460" SizeToContent="Height" ResizeMode="NoResize">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>

<Label Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0" FontWeight="Bold" Content="{Binding Path=ImportText}"/>

<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>

<Label HorizontalAlignment="Right" VerticalAlignment="Center" Content="Action:" Margin="10,0"/>
<ComboBox Grid.Column="1" Margin="10,0" VerticalAlignment="Center" ItemsSource="{Binding Path=Actions}" DisplayMemberPath="Key" SelectedValuePath="Value" SelectedValue="{Binding Path=SelectedAction}"></ComboBox>

</Grid>

<Grid Grid.Row="2">
<Button VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0" Content="Cancel" Width="150" Click="Cancel_Click"/>
<Button VerticalAlignment="Center" HorizontalAlignment="Right" Margin="10,0" Content="Continue" Width="150" Click="Continue_Click"/>
</Grid>

</Grid>
</mah:MetroWindow>
Loading

0 comments on commit b737e18

Please sign in to comment.