actually implementing dotnet features

This commit is contained in:
Asval
2024-10-06 15:31:04 +02:00
parent 784704b645
commit 774525ed50
7 changed files with 34 additions and 20 deletions

View File

@@ -106,7 +106,7 @@ public partial class App
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss} [FModel] [{Level:u3}] {Message:lj}{NewLine}{Exception}").CreateLogger();
#endif
Log.Information("Version {Version}", Constants.APP_VERSION);
Log.Information("Version {Version} ({CommitId})", Constants.APP_VERSION, Constants.APP_COMMIT_ID);
Log.Information("{OS}", GetOperatingSystemProductName());
Log.Information("{RuntimeVer}", RuntimeInformation.FrameworkDescription);
Log.Information("Culture {SysLang}", CultureInfo.CurrentCulture);

View File

@@ -1,12 +1,20 @@
using System.Numerics;
using System;
using System.Diagnostics;
using System.IO;
using System.Numerics;
using System.Reflection;
using CUE4Parse.UE4.Objects.Core.Misc;
using FModel.Extensions;
namespace FModel;
public static class Constants
{
public static readonly string APP_VERSION = Assembly.GetExecutingAssembly().GetName().Version?.ToString();
public static readonly string APP_PATH = Path.GetFullPath(Environment.GetCommandLineArgs()[0]);
public static readonly string APP_VERSION = FileVersionInfo.GetVersionInfo(APP_PATH).FileVersion;
public static readonly string APP_COMMIT_ID = FileVersionInfo.GetVersionInfo(APP_PATH).ProductVersion.SubstringAfter('+');
public static readonly string APP_SHORT_COMMIT_ID = APP_COMMIT_ID[..7];
public const string ZERO_64_CHAR = "0000000000000000000000000000000000000000000000000000000000000000";
public static readonly FGuid ZERO_GUID = new(0U);

View File

@@ -200,13 +200,6 @@ namespace FModel.Settings
set => SetProperty(ref _nextUpdateCheck, value);
}
private string _commitHash = Constants.APP_VERSION;
public string CommitHash
{
get => _commitHash;
set => SetProperty(ref _commitHash, value);
}
private bool _keepDirectoryStructure = true;
public bool KeepDirectoryStructure
{
@@ -279,8 +272,6 @@ namespace FModel.Settings
[JsonIgnore]
public DirectorySettings CurrentDir { get; set; }
[JsonIgnore]
public string ShortCommitHash => CommitHash[..7];
/// <summary>
/// TO DELETEEEEEEEEEEEEE

View File

@@ -156,8 +156,8 @@ public class FModelApiEndpoint : AbstractApiProvider
var qa = (CustomMandatory) args.Mandatory;
var currentVersion = new System.Version(args.CurrentVersion);
if ((qa.Value && qa.CommitHash == UserSettings.Default.CommitHash) || // qa branch : same commit id
(!qa.Value && currentVersion == args.InstalledVersion && args.CurrentVersion == UserSettings.Default.CommitHash)) // stable - beta branch : same version + commit id = version
if ((qa.Value && qa.CommitHash == Constants.APP_COMMIT_ID) || // qa branch : same commit id
(!qa.Value && currentVersion == args.InstalledVersion)) // stable - beta branch : same version + commit id = version
{
if (UserSettings.Default.ShowChangelog)
ShowChangelog(args);

View File

@@ -63,13 +63,24 @@ public class GitHubCommit : ViewModel
}
}
public bool IsCurrent => Sha == UserSettings.Default.CommitHash;
public bool IsCurrent => Sha == Constants.APP_COMMIT_ID;
public string ShortSha => Sha[..7];
public bool IsDownloadable => Asset != null;
public void Download()
{
if (IsCurrent) return;
if (IsCurrent)
{
MessageBox.Show(new MessageBoxModel
{
Text = "You are already on the latest version.",
Caption = "Update FModel",
Icon = MessageBoxImage.Information,
Buttons = [MessageBoxButtons.Ok()],
IsSoundEnabled = false
});
return;
}
var messageBox = new MessageBoxModel
{
@@ -87,7 +98,6 @@ public class GitHubCommit : ViewModel
{
if (AutoUpdater.DownloadUpdate(new UpdateInfoEventArgs { DownloadURL = Asset.BrowserDownloadUrl }))
{
UserSettings.Default.CommitHash = Sha;
Application.Current.Shutdown();
}
}

View File

@@ -49,7 +49,7 @@ public class ApplicationViewModel : ViewModel
public CopyCommand CopyCommand => _copyCommand ??= new CopyCommand(this);
private CopyCommand _copyCommand;
public string InitialWindowTitle => $"FModel ({UserSettings.Default.ShortCommitHash})";
public string InitialWindowTitle => $"FModel ({Constants.APP_SHORT_COMMIT_ID})";
public string GameDisplayName => CUE4Parse.Provider.GameDisplayName ?? "Unknown";
public string TitleExtra => $"({UserSettings.Default.CurrentDir.UeVersion}){(Build != EBuildKind.Release ? $" ({Build})" : "")}";
@@ -143,7 +143,7 @@ public class ApplicationViewModel : ViewModel
StartInfo = new ProcessStartInfo
{
FileName = "dotnet",
Arguments = $"\"{Path.GetFullPath(Environment.GetCommandLineArgs()[0])}\"",
Arguments = $"\"{path}\"",
UseShellExecute = false,
RedirectStandardOutput = false,
RedirectStandardError = false,

View File

@@ -1,10 +1,12 @@
using System.ComponentModel;
using System;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Data;
using FModel.Extensions;
using FModel.Framework;
using FModel.Services;
using FModel.Settings;
using FModel.ViewModels.ApiEndpoints.Models;
using FModel.ViewModels.Commands;
using FModel.Views.Resources.Converters;
@@ -28,6 +30,9 @@ public class UpdateViewModel : ViewModel
{
GroupDescriptions = { new PropertyGroupDescription("Commit.Author.Date", new DateTimeToDateConverter()) }
};
if (UserSettings.Default.NextUpdateCheck < DateTime.Now)
RemindMeCommand.Execute(this, null);
}
public async Task Load()