Skip to content

Commit

Permalink
Update 2.2.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
KoraLyn committed Aug 13, 2020
2 parents 9fd08b4 + af2bc4e commit d525fed
Show file tree
Hide file tree
Showing 16 changed files with 533 additions and 60 deletions.
12 changes: 12 additions & 0 deletions FFXIV_TexTools/Helpers/FlexibleMessageBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,18 @@ void FlexibleMessageBoxForm_KeyUp(object sender, KeyEventArgs e)
/// <returns>The dialog result.</returns>
public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
{
if(owner == null)
{
try
{
var mainWindow = MainWindow.GetMainWindow();
owner = mainWindow.Win32Window;
} catch
{
// No-Op.
}
}

//Create a new instance of the FlexibleMessageBox form
var flexibleMessageBoxForm = new FlexibleMessageBoxForm();
flexibleMessageBoxForm.ShowInTaskbar = false;
Expand Down
1 change: 1 addition & 0 deletions FFXIV_TexTools/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
</MenuItem>
<MenuItem Header="{Binding Source={x:Static resx:UIStrings.Help}}">
<MenuItem x:Name="Menu_Backup" Header="{Binding Source={x:Static resx:UIStrings.Backup_Index_Files}}" Click="Menu_Backup_Click"/>
<MenuItem x:Name="Menu_WebBackups" Header="{Binding Source={x:Static resx:UIStrings.Download_Backups}}" Click="Menu_WebBackups_Click" />
<MenuItem x:Name="Menu_ProblemCheck" Header="{Binding Source={x:Static resx:UIStrings.Check_For_Problems}}" Click="Menu_ProblemCheck_Click"/>
<MenuItem x:Name="Menu_StartOver" Header="{Binding Source={x:Static resx:UIStrings.Start_Over}}" Click="Menu_StartOver_Click" />
<MenuItem x:Name="Menu_BugReport" Header="{Binding Source={x:Static resx:UIStrings.Report_Bug}}" Click="Menu_BugReport_Click"/>
Expand Down
115 changes: 111 additions & 4 deletions FFXIV_TexTools/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using FFXIV_TexTools.ViewModels;
using FFXIV_TexTools.Views;
using FFXIV_TexTools.Views.Models;
using FolderSelect;
using MahApps.Metro;
using MahApps.Metro.Controls.Dialogs;
using SixLabors.ImageSharp;
Expand All @@ -28,10 +29,13 @@
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Interop;
using System.Windows.Threading;
using xivModdingFramework.Cache;
using xivModdingFramework.General.Enums;
Expand All @@ -53,6 +57,7 @@ public partial class MainWindow
private string _startupArgs;
private static MainWindow _mainWindow;
private FullModelView _fmv;
public readonly System.Windows.Forms.IWin32Window Win32Window;


/// <summary>
Expand Down Expand Up @@ -125,6 +130,7 @@ private void AutoUpdater_ApplicationExitEvent()
public MainWindow(string[] args)
{
_mainWindow = this;

AutoUpdater.ApplicationExitEvent += AutoUpdater_ApplicationExitEvent;

// Forcefully assign the correct working directory. This helps keep the
Expand Down Expand Up @@ -207,6 +213,9 @@ public MainWindow(string[] args)
{
this.Show();

// Can set this now that we're open.
Win32Window = new WindowWrapper(new WindowInteropHelper(this).Handle);


var textureView = TextureTabItem.Content as TextureView;
var textureViewModel = textureView.DataContext as TextureViewModel;
Expand Down Expand Up @@ -1142,16 +1151,19 @@ private async void Menu_Backup_Click(object sender, RoutedEventArgs e)
var gameDirectory = new DirectoryInfo(Settings.Default.FFXIV_Directory);
var problemChecker = new ProblemChecker(gameDirectory);
var backupsDirectory = new DirectoryInfo(Properties.Settings.Default.Backup_Directory);
await LockUi("Backing Up Indexes", "If you have many mods enabled, this may take some time...");
try
{
await problemChecker.BackupIndexFiles(backupsDirectory);
await this.ShowMessageAsync(UIMessages.BackupCompleteTitle, UIMessages.BackupCompleteMessage);
}
catch(Exception ex)
{
FlexibleMessageBox.Show(string.Format(UIMessages.BackupFailedErrorMessage, ex.Message), UIMessages.BackupFailedTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}

await this.ShowMessageAsync(UIMessages.BackupCompleteTitle, UIMessages.BackupCompleteMessage);
FlexibleMessageBox.Show(string.Format(UIMessages.BackupFailedErrorMessage, ex.Message), UIMessages.BackupFailedTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
} finally
{
await UnlockUi();
}
}
}

Expand Down Expand Up @@ -1233,5 +1245,100 @@ private void FullModelViewer_Click(object sender, RoutedEventArgs e)

fmv.Show();
}


private void Menu_WebBackups_Click(object sender, RoutedEventArgs e)
{
DownloadIndexBackups();
}
private async Task DownloadIndexBackups()
{
var url = UIStrings.Index_Backups_Url;
if (url == "INVALID" || String.IsNullOrWhiteSpace(url))
{
FlexibleMessageBox.Show("Index backup download is not currently supported for your client language.", "Web Download Error", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
return;
}

var result = FlexibleMessageBox.Show("This will download index backups from the internet. Proceed?", "Web Download Confirmation",MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);

if (result != System.Windows.Forms.DialogResult.OK) return;

await LockUi("Downloading Backups");
try
{
await Task.Run(async () =>
{
_lockProgress.Report("Downloading Indexes...");
var localPath = Path.GetTempFileName();
using (var client = new WebClient())
{
client.DownloadFile(url, localPath);
}

var tempDir = Path.GetTempPath();
tempDir += "/index_backup";
var tempDi = new DirectoryInfo(tempDir);
foreach (FileInfo file in tempDi.GetFiles())
{
file.Delete();
}


Directory.CreateDirectory(tempDir);

_lockProgress.Report("Unzipping new Indexes...");
ZipFile.ExtractToDirectory(localPath, tempDir);

_lockProgress.Report("Checking downloaded index version...");
var versionRaw = File.ReadAllText(tempDir + "/ffxivgame.ver");

Version version = new Version(versionRaw.Substring(0, versionRaw.LastIndexOf(".", StringComparison.Ordinal)));

if (version != XivCache.GameInfo.GameVersion)
{
throw new Exception("Downloaded Index version does not match game version.");
}

_lockProgress.Report("Removing old Backups...");
var backupDir = new DirectoryInfo(Settings.Default.Backup_Directory);
foreach (FileInfo file in backupDir.GetFiles())
{
file.Delete();
}


_lockProgress.Report("Copying new indexes to backup directory...");
var newFiles = Directory.GetFiles(tempDi.FullName);
foreach (var nFile in newFiles)
{
try
{
if (nFile.Contains(".win32.index"))
{
File.Copy(nFile, $"{Settings.Default.Backup_Directory}/{Path.GetFileName(nFile)}", true);
}
}
catch (Exception ex)
{
throw new Exception("Failed to copy index files.\n\n" + ex.Message);
}
}


_lockProgress.Report("Job Done.");
});
FlexibleMessageBox.Show("Successfully downloaded fresh index backups.\nYou may now use [Start Over] to apply them, if desired.", "Backup Download Success", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
}
catch(Exception Ex)
{
FlexibleMessageBox.Show("Unable to download Index Backups.\n\n" + Ex.Message, "Web Download Error", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);

}
finally
{
await UnlockUi();
}
}
}
}
4 changes: 2 additions & 2 deletions FFXIV_TexTools/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.2.0.4")]
[assembly: AssemblyFileVersion("2.2.0.4")]
[assembly: AssemblyVersion("2.2.0.5")]
[assembly: AssemblyFileVersion("2.2.0.5")]
2 changes: 1 addition & 1 deletion FFXIV_TexTools/Resources/UIMessages.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion FFXIV_TexTools/Resources/UIMessages.resx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Please set your Index Backups directory in Options &gt; Customize and try again.
<value>ColorSet BMP import is not supported.</value>
</data>
<data name="CreateBackupsMessage" xml:space="preserve">
<value>This will create a backup of the commonly modified index files (0a, 01, 04, 06)
<value>This will create a backup of all index files.


Do you want to Backup Now?
Expand Down
18 changes: 18 additions & 0 deletions FFXIV_TexTools/Resources/UIStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions FFXIV_TexTools/Resources/UIStrings.ko.resx
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,9 @@
<data name="Included_Mods_in_Option" xml:space="preserve">
<value>옵션을 포함한 모드</value>
</data>
<data name="Index_Backups_Url" xml:space="preserve">
<value>NONE</value>
</data>
<data name="Index_Locked" xml:space="preserve">
<value>게임이 실행중에는 들여올수 없습니다.</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions FFXIV_TexTools/Resources/UIStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -991,4 +991,10 @@ If you would like to enable this, first import a texture for the selected item.<
<data name="Skin" xml:space="preserve">
<value>Skin</value>
</data>
<data name="Download_Backups" xml:space="preserve">
<value>Download Index Backups</value>
</data>
<data name="Index_Backups_Url" xml:space="preserve">
<value>https://textools.sfo2.digitaloceanspaces.com/Index_Backups.zip</value>
</data>
</root>
3 changes: 3 additions & 0 deletions FFXIV_TexTools/Resources/UIStrings.zh.resx
Original file line number Diff line number Diff line change
Expand Up @@ -747,4 +747,7 @@
<data name="Convert_To" xml:space="preserve">
<value>转换到</value>
</data>
<data name="Index_Backups_Url" xml:space="preserve">
<value>NONE</value>
</data>
</root>
Loading

0 comments on commit d525fed

Please sign in to comment.