diff --git a/FModel/Constants.cs b/FModel/Constants.cs
index a33827d5..66e3bd14 100644
--- a/FModel/Constants.cs
+++ b/FModel/Constants.cs
@@ -16,7 +16,6 @@ namespace FModel
public const string BLUE = "#528BCC";
public const string DONATE_LINK = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=EP9SSWG8MW4UC&source=url";
- public const string CHANGELOG_LINK = "https://github.com/iAmAsval/FModel/releases/latest";
public const string ISSUE_LINK = "https://github.com/iAmAsval/FModel/issues/new";
public const string DISCORD_LINK = "https://discord.gg/fdkNYYQ";
diff --git a/FModel/Extensions/AvalonExtensions.cs b/FModel/Extensions/AvalonExtensions.cs
index 486c1f35..55c6449c 100644
--- a/FModel/Extensions/AvalonExtensions.cs
+++ b/FModel/Extensions/AvalonExtensions.cs
@@ -12,6 +12,7 @@ namespace FModel.Extensions
private static readonly IHighlightingDefinition _iniHighlighter = LoadHighlighter("Ini.xshd");
private static readonly IHighlightingDefinition _xmlHighlighter = LoadHighlighter("Xml.xshd");
private static readonly IHighlightingDefinition _cppHighlighter = LoadHighlighter("Cpp.xshd");
+ private static readonly IHighlightingDefinition _changelogHighlighter = LoadHighlighter("Changelog.xshd");
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static IHighlightingDefinition LoadHighlighter(string resourceName)
@@ -35,6 +36,8 @@ namespace FModel.Extensions
case "h":
case "cpp":
return _cppHighlighter;
+ case "changelog":
+ return _changelogHighlighter;
case "bat":
case "txt":
case "po":
diff --git a/FModel/FModel.csproj b/FModel/FModel.csproj
index 01cc0e98..fbdc1c1a 100644
--- a/FModel/FModel.csproj
+++ b/FModel/FModel.csproj
@@ -70,6 +70,7 @@
+
@@ -96,6 +97,7 @@
+
diff --git a/FModel/MainWindow.xaml b/FModel/MainWindow.xaml
index 9a0ef621..600d3f2b 100644
--- a/FModel/MainWindow.xaml
+++ b/FModel/MainWindow.xaml
@@ -194,7 +194,7 @@
diff --git a/FModel/Resources/Changelog.xshd b/FModel/Resources/Changelog.xshd
new file mode 100644
index 00000000..c09cf031
--- /dev/null
+++ b/FModel/Resources/Changelog.xshd
@@ -0,0 +1,39 @@
+
+
+
+
+ ^\+
+ .*(?:\t|\s{2,})+
+
+
+ ^\-
+ .*(?:\t|\s{2,})+
+
+
+ ^\~
+ .*(?:\t|\s{2,})+
+
+
+
+
+
+ .*(?:\t|\#{1}|\s{2,})+
+ \r\n
+
+
+ ^[0-9]\..*
+
+
+ ADDED
+ FIXED
+ REMOVED
+ IMPROVED
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/FModel/Settings/UserSettings.cs b/FModel/Settings/UserSettings.cs
index 759796e8..6b3796e9 100644
--- a/FModel/Settings/UserSettings.cs
+++ b/FModel/Settings/UserSettings.cs
@@ -35,6 +35,13 @@ namespace FModel.Settings
{
if (File.Exists(FilePath)) File.Delete(FilePath);
}
+
+ private bool _showChangelog = true;
+ public bool ShowChangelog
+ {
+ get => _showChangelog;
+ set => SetProperty(ref _showChangelog, value);
+ }
private string _outputDirectory;
public string OutputDirectory
diff --git a/FModel/ViewModels/ApiEndpoints/FModelApi.cs b/FModel/ViewModels/ApiEndpoints/FModelApi.cs
index 73041505..8a5c6b3c 100644
--- a/FModel/ViewModels/ApiEndpoints/FModelApi.cs
+++ b/FModel/ViewModels/ApiEndpoints/FModelApi.cs
@@ -5,6 +5,8 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using AutoUpdaterDotNET;
+using FModel.Extensions;
+using FModel.Services;
using FModel.Settings;
using FModel.ViewModels.ApiEndpoints.Models;
using Newtonsoft.Json;
@@ -23,6 +25,7 @@ namespace FModel.ViewModels.ApiEndpoints
private Info _infos;
private Backup[] _backups;
private readonly IDictionary _communityDesigns = new Dictionary();
+ private ApplicationViewModel _applicationView => ApplicationService.ApplicationView;
public FModelApi(IRestClient client) : base(client)
{
@@ -106,12 +109,17 @@ namespace FModel.ViewModels.ApiEndpoints
}
}
- private void CheckForUpdateEvent(UpdateInfoEventArgs args)
+ private async void CheckForUpdateEvent(UpdateInfoEventArgs args)
{
if (args is {CurrentVersion: { }})
{
var currentVersion = new Version(args.CurrentVersion);
- if (currentVersion == args.InstalledVersion) return;
+ if (currentVersion == args.InstalledVersion)
+ {
+ if (UserSettings.Default.ShowChangelog)
+ await ShowChangelog(args);
+ return;
+ }
var downgrade = currentVersion < args.InstalledVersion;
var messageBox = new MessageBoxModel
@@ -125,16 +133,18 @@ namespace FModel.ViewModels.ApiEndpoints
MessageBox.Show(messageBox);
if (messageBox.Result != MessageBoxResult.Yes) return;
-
+
try
{
if (AutoUpdater.DownloadUpdate(args))
{
+ UserSettings.Default.ShowChangelog = true;
Application.Current.Shutdown();
}
}
catch (Exception exception)
{
+ UserSettings.Default.ShowChangelog = false;
MessageBox.Show(exception.Message, exception.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Error);
}
}
@@ -145,5 +155,15 @@ namespace FModel.ViewModels.ApiEndpoints
"Update Check Failed", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
+
+ private async Task ShowChangelog(UpdateInfoEventArgs args)
+ {
+ var request = new RestRequest(args.ChangelogURL, Method.GET);
+ var response = await _client.ExecuteAsync(request).ConfigureAwait(false);
+ _applicationView.CUE4Parse.TabControl.AddTab($"Release Notes: {args.CurrentVersion}");
+ _applicationView.CUE4Parse.TabControl.SelectedTab.Highlighter = AvalonExtensions.HighlighterSelector("changelog");
+ _applicationView.CUE4Parse.TabControl.SelectedTab.SetDocumentText(response.Content, false);
+ UserSettings.Default.ShowChangelog = false;
+ }
}
}
\ No newline at end of file
diff --git a/FModel/ViewModels/CUE4ParseViewModel.cs b/FModel/ViewModels/CUE4ParseViewModel.cs
index eead9d3c..4172df76 100644
--- a/FModel/ViewModels/CUE4ParseViewModel.cs
+++ b/FModel/ViewModels/CUE4ParseViewModel.cs
@@ -418,7 +418,6 @@ namespace FModel.ViewModels
TabControl.SelectedTab.SetDocumentText(reader.ReadToEnd(), bulkSave);
}
-
break;
}
case "locmeta":
@@ -429,7 +428,6 @@ namespace FModel.ViewModels
var metadata = new FTextLocalizationMetaDataResource(archive);
TabControl.SelectedTab.SetDocumentText(JsonConvert.SerializeObject(metadata, Formatting.Indented), bulkSave);
}
-
break;
}
case "locres":
@@ -440,7 +438,6 @@ namespace FModel.ViewModels
var locres = new FTextLocalizationResource(archive);
TabControl.SelectedTab.SetDocumentText(JsonConvert.SerializeObject(locres, Formatting.Indented), bulkSave);
}
-
break;
}
case "bin":
@@ -451,7 +448,6 @@ namespace FModel.ViewModels
var registry = new FAssetRegistryState(archive);
TabControl.SelectedTab.SetDocumentText(JsonConvert.SerializeObject(registry, Formatting.Indented), bulkSave);
}
-
break;
}
case "bnk":
@@ -467,7 +463,6 @@ namespace FModel.ViewModels
SaveAndPlaySound(fullPath.SubstringBeforeWithLast("/") + name, "WEM", data);
}
}
-
break;
}
case "wem":
@@ -486,7 +481,6 @@ namespace FModel.ViewModels
var header = new FOodleDictionaryArchive(archive).Header;
TabControl.SelectedTab.SetDocumentText(JsonConvert.SerializeObject(header, Formatting.Indented), bulkSave);
}
-
break;
}
case "png":
@@ -496,9 +490,8 @@ namespace FModel.ViewModels
if (Provider.TrySaveAsset(fullPath, out var data))
{
using var stream = new MemoryStream(data) {Position = 0};
- SetImage(SKImage.FromBitmap(SKBitmap.Decode(stream)));
+ TabControl.SelectedTab.SetImage(SKImage.FromBitmap(SKBitmap.Decode(stream)));
}
-
break;
}
case "ufont":
@@ -509,13 +502,11 @@ namespace FModel.ViewModels
case "ushadercode":
{
TabControl.SelectedTab.Image = null;
-
if (Provider.TryCreateReader(fullPath, out var archive))
{
var ar = new FShaderCodeArchive(archive);
TabControl.SelectedTab.SetDocumentText(JsonConvert.SerializeObject(ar, Formatting.Indented), bulkSave);
}
-
break;
}
default:
@@ -562,7 +553,7 @@ namespace FModel.ViewModels
trigger.Text.EndsWith("TF_Nearest", StringComparison.OrdinalIgnoreCase);
TabControl.SelectedTab.ImageRender = bNearest ? BitmapScalingMode.NearestNeighbor : BitmapScalingMode.Linear;
- SetImage(texture.Decode(bNearest));
+ TabControl.SelectedTab.SetImage(texture.Decode(bNearest));
return true;
}
case UAkMediaAssetData:
@@ -576,25 +567,31 @@ namespace FModel.ViewModels
SaveAndPlaySound(Path.Combine(TabControl.SelectedTab.Directory, TabControl.SelectedTab.Header.SubstringBeforeLast('.')).Replace('\\', '/'), audioFormat, data);
return false;
}
- case UMaterialInterface when UserSettings.Default.IsAutoSaveMaterials:
- case UStaticMesh when UserSettings.Default.IsAutoSaveMeshes:
- case USkeletalMesh when UserSettings.Default.IsAutoSaveMeshes:
+ case UMaterialInterface:
+ case UStaticMesh:
+ case USkeletalMesh:
{
- var toSave = new Exporter(export, UserSettings.Default.TextureExportFormat, UserSettings.Default.LodExportFormat);
- var toSaveDirectory = new DirectoryInfo(Path.Combine(UserSettings.Default.OutputDirectory, "Saves"));
- if (toSave.TryWriteToDir(toSaveDirectory, out var savedFileName))
+ if (UserSettings.Default.IsAutoSaveMeshes || UserSettings.Default.IsAutoSaveMaterials)
{
- Log.Information("Successfully saved {FileName}", savedFileName);
- FLogger.AppendInformation();
- FLogger.AppendText($"Successfully saved {savedFileName}", Constants.WHITE, true);
+ var toSave = new Exporter(export, UserSettings.Default.TextureExportFormat, UserSettings.Default.LodExportFormat);
+ var toSaveDirectory = new DirectoryInfo(Path.Combine(UserSettings.Default.OutputDirectory, "Saves"));
+ if (toSave.TryWriteToDir(toSaveDirectory, out var savedFileName))
+ {
+ Log.Information("Successfully saved {FileName}", savedFileName);
+ FLogger.AppendInformation();
+ FLogger.AppendText($"Successfully saved {savedFileName}", Constants.WHITE, true);
+ }
+ else
+ {
+ Log.Error("{FileName} could not be saved", savedFileName);
+ FLogger.AppendError();
+ FLogger.AppendText($"Could not save '{savedFileName}'", Constants.WHITE, true);
+ }
}
else
{
- Log.Error("{FileName} could not be saved", savedFileName);
- FLogger.AppendError();
- FLogger.AppendText($"Could not save '{savedFileName}'", Constants.WHITE, true);
+ // preview
}
-
return false;
}
default:
@@ -603,27 +600,12 @@ namespace FModel.ViewModels
if (!package.TryConstructCreator(out var creator)) return false;
creator.ParseForInfo();
- SetImage(creator.Draw());
+ TabControl.SelectedTab.SetImage(creator.Draw());
return true;
}
}
}
- private void SetImage(SKImage img)
- {
- using var stream = img.Encode().AsStream();
- var image = new BitmapImage();
- image.BeginInit();
- image.CacheOption = BitmapCacheOption.OnLoad;
- image.StreamSource = stream;
- image.EndInit();
- image.Freeze();
-
- TabControl.SelectedTab.Image = image;
- if (UserSettings.Default.IsAutoSaveTextures)
- TabControl.SelectedTab.SaveImage(true);
- }
-
private void SaveAndPlaySound(string fullPath, string ext, byte[] data)
{
var userDir = Path.Combine(UserSettings.Default.OutputDirectory, "Sounds");
diff --git a/FModel/ViewModels/Commands/MenuCommand.cs b/FModel/ViewModels/Commands/MenuCommand.cs
index 237f386c..caf38ae9 100644
--- a/FModel/ViewModels/Commands/MenuCommand.cs
+++ b/FModel/ViewModels/Commands/MenuCommand.cs
@@ -1,6 +1,7 @@
using System.Diagnostics;
using AdonisUI.Controls;
using FModel.Framework;
+using FModel.Services;
using FModel.Settings;
using FModel.Views;
using FModel.Views.Resources.Controls;
@@ -45,7 +46,8 @@ namespace FModel.ViewModels.Commands
Process.Start(new ProcessStartInfo {FileName = Constants.DONATE_LINK, UseShellExecute = true});
break;
case "Help_Changelog":
- Process.Start(new ProcessStartInfo {FileName = Constants.CHANGELOG_LINK, UseShellExecute = true});
+ UserSettings.Default.ShowChangelog = true;
+ ApplicationService.ApiEndpointView.FModelApi.CheckForUpdates(UserSettings.Default.UpdateMode);
break;
case "Help_BugsReport":
Process.Start(new ProcessStartInfo {FileName = Constants.ISSUE_LINK, UseShellExecute = true});
diff --git a/FModel/ViewModels/TabControlViewModel.cs b/FModel/ViewModels/TabControlViewModel.cs
index 458bec22..8c42d24c 100644
--- a/FModel/ViewModels/TabControlViewModel.cs
+++ b/FModel/ViewModels/TabControlViewModel.cs
@@ -14,6 +14,7 @@ using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Highlighting;
using Microsoft.Win32;
using Serilog;
+using SkiaSharp;
namespace FModel.ViewModels
{
@@ -197,6 +198,21 @@ namespace FModel.ViewModels
Application.Current.Dispatcher.Invoke(() => File.WriteAllText(directory, Document.Text));
SaveCheck(directory, fileName);
}
+
+ public void SetImage(SKImage img)
+ {
+ using var stream = img.Encode().AsStream();
+ var image = new BitmapImage();
+ image.BeginInit();
+ image.CacheOption = BitmapCacheOption.OnLoad;
+ image.StreamSource = stream;
+ image.EndInit();
+ image.Freeze();
+
+ Image = image;
+ if (UserSettings.Default.IsAutoSaveTextures)
+ SaveImage(true);
+ }
public void SaveImage(bool autoSave)
{
diff --git a/FModel/Views/Resources/Resources.xaml b/FModel/Views/Resources/Resources.xaml
index 783022e1..008e152b 100644
--- a/FModel/Views/Resources/Resources.xaml
+++ b/FModel/Views/Resources/Resources.xaml
@@ -35,7 +35,7 @@
M22,24L16.75,19L17.38,21H4.5A2.5,2.5 0 0,1 2,18.5V3.5A2.5,2.5 0 0,1 4.5,1H19.5A2.5,2.5 0 0,1 22,3.5V24M12,6.8C9.32,6.8 7.44,7.95 7.44,7.95C8.47,7.03 10.27,6.5 10.27,6.5L10.1,6.33C8.41,6.36 6.88,7.53 6.88,7.53C5.16,11.12 5.27,14.22 5.27,14.22C6.67,16.03 8.75,15.9 8.75,15.9L9.46,15C8.21,14.73 7.42,13.62 7.42,13.62C7.42,13.62 9.3,14.9 12,14.9C14.7,14.9 16.58,13.62 16.58,13.62C16.58,13.62 15.79,14.73 14.54,15L15.25,15.9C15.25,15.9 17.33,16.03 18.73,14.22C18.73,14.22 18.84,11.12 17.12,7.53C17.12,7.53 15.59,6.36 13.9,6.33L13.73,6.5C13.73,6.5 15.53,7.03 16.56,7.95C16.56,7.95 14.68,6.8 12,6.8M9.93,10.59C10.58,10.59 11.11,11.16 11.1,11.86C11.1,12.55 10.58,13.13 9.93,13.13C9.29,13.13 8.77,12.55 8.77,11.86C8.77,11.16 9.28,10.59 9.93,10.59M14.1,10.59C14.75,10.59 15.27,11.16 15.27,11.86C15.27,12.55 14.75,13.13 14.1,13.13C13.46,13.13 12.94,12.55 12.94,11.86C12.94,11.16 13.45,10.59 14.1,10.59Z
M14,12H10V10H14M14,16H10V14H14M20,8H17.19C16.74,7.22 16.12,6.55 15.37,6.04L17,4.41L15.59,3L13.42,5.17C12.96,5.06 12.5,5 12,5C11.5,5 11.04,5.06 10.59,5.17L8.41,3L7,4.41L8.62,6.04C7.88,6.55 7.26,7.22 6.81,8H4V10H6.09C6.04,10.33 6,10.66 6,11V12H4V14H6V15C6,15.34 6.04,15.67 6.09,16H4V18H6.81C7.85,19.79 9.78,21 12,21C14.22,21 16.15,19.79 17.19,18H20V16H17.91C17.96,15.67 18,15.34 18,15V14H20V12H18V11C18,10.66 17.96,10.33 17.91,10H20V8Z
M22 10.92L19.26 9.33C21.9 7.08 19.25 2.88 16.08 4.31L15.21 4.68L15.1 3.72C15 2.64 14.44 1.87 13.7 1.42C12.06 .467 9.56 1.12 9.16 3.5L6.41 1.92C5.45 1.36 4.23 1.69 3.68 2.65L2.68 4.38C2.4 4.86 2.57 5.47 3.05 5.75L10.84 10.25L12.34 7.65L14.07 8.65L12.57 11.25L20.36 15.75C20.84 16 21.46 15.86 21.73 15.38L22.73 13.65C23.28 12.69 22.96 11.47 22 10.92M12.37 5C11.5 5.25 10.8 4.32 11.24 3.55C11.5 3.07 12.13 2.91 12.61 3.18C13.38 3.63 13.23 4.79 12.37 5M17.56 8C16.7 8.25 16 7.32 16.44 6.55C16.71 6.07 17.33 5.91 17.8 6.18C18.57 6.63 18.42 7.79 17.56 8M20.87 16.88C21.28 16.88 21.67 16.74 22 16.5V20C22 21.11 21.11 22 20 22H4C2.9 22 2 21.11 2 20V11H10.15L11 11.5V20H13V12.65L19.87 16.61C20.17 16.79 20.5 16.88 20.87 16.88Z
- M12,2A10,10 0 0,0 2,12C2,16.42 4.87,20.17 8.84,21.5C9.34,21.58 9.5,21.27 9.5,21C9.5,20.77 9.5,20.14 9.5,19.31C6.73,19.91 6.14,17.97 6.14,17.97C5.68,16.81 5.03,16.5 5.03,16.5C4.12,15.88 5.1,15.9 5.1,15.9C6.1,15.97 6.63,16.93 6.63,16.93C7.5,18.45 8.97,18 9.54,17.76C9.63,17.11 9.89,16.67 10.17,16.42C7.95,16.17 5.62,15.31 5.62,11.5C5.62,10.39 6,9.5 6.65,8.79C6.55,8.54 6.2,7.5 6.75,6.15C6.75,6.15 7.59,5.88 9.5,7.17C10.29,6.95 11.15,6.84 12,6.84C12.85,6.84 13.71,6.95 14.5,7.17C16.41,5.88 17.25,6.15 17.25,6.15C17.8,7.5 17.45,8.54 17.35,8.79C18,9.5 18.38,10.39 18.38,11.5C18.38,15.32 16.04,16.16 13.81,16.41C14.17,16.72 14.5,17.33 14.5,18.26C14.5,19.6 14.5,20.68 14.5,21C14.5,21.27 14.66,21.59 15.17,21.5C19.14,20.16 22,16.42 22,12A10,10 0 0,0 12,2Z
+ M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM8 19h12c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1zm0-6h12c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1zM7 6c0 .55.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1z
M11.5,2C6.81,2,3,5.81,3,10.5S6.81,19,11.5,19H12v3c4.86-2.34,8-7,8-11.5C20,5.81,16.19,2,11.5,2z M11.48,16 c-0.59,0-1.05-0.47-1.05-1.05c0-0.59,0.47-1.04,1.05-1.04c0.59,0,1.04,0.45,1.04,1.04C12.52,15.53,12.08,16,11.48,16z M13.99,9.83 c-0.63,0.93-1.23,1.21-1.56,1.81c-0.08,0.14-0.13,0.26-0.16,0.49c-0.05,0.39-0.36,0.68-0.75,0.68h-0.03 c-0.44,0-0.79-0.38-0.75-0.82c0.03-0.28,0.09-0.57,0.25-0.84c0.41-0.73,1.18-1.16,1.63-1.8c0.48-0.68,0.21-1.94-1.14-1.94 c-0.61,0-1.01,0.32-1.26,0.7c-0.19,0.29-0.57,0.39-0.89,0.25l0,0c-0.42-0.18-0.6-0.7-0.34-1.07C9.5,6.55,10.35,6,11.47,6 c1.23,0,2.08,0.56,2.51,1.26C14.34,7.87,14.56,8.99,13.99,9.83z
M6,19c0,1.1,0.9,2,2,2h8c1.1,0,2-0.9,2-2V7H6V19z M9.17,12.59c-0.39-0.39-0.39-1.02,0-1.41c0.39-0.39,1.02-0.39,1.41,0 L12,12.59l1.41-1.41c0.39-0.39,1.02-0.39,1.41,0s0.39,1.02,0,1.41L13.41,14l1.41,1.41c0.39,0.39,0.39,1.02,0,1.41 s-1.02,0.39-1.41,0L12,15.41l-1.41,1.41c-0.39,0.39-1.02,0.39-1.41,0c-0.39-0.39-0.39-1.02,0-1.41L10.59,14L9.17,12.59z M18,4h-2.5 l-0.71-0.71C14.61,3.11,14.35,3,14.09,3H9.91c-0.26,0-0.52,0.11-0.7,0.29L8.5,4H6C5.45,4,5,4.45,5,5s0.45,1,1,1h12 c0.55,0,1-0.45,1-1S18.55,4,18,4z
M18,4v16H6V4H18 M18,2H6C4.9,2,4,2.9,4,4v16c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2V4C20,2.9,19.1,2,18,2L18,2z M7,19h10v-6H7 V19z M10,10h4v1h3V5H7v6h3V10z