Skip to content

Commit

Permalink
qa testing test
Browse files Browse the repository at this point in the history
  • Loading branch information
4sval committed Nov 4, 2023
1 parent 5e50516 commit ef94d35
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 14 deletions.
4 changes: 3 additions & 1 deletion FModel/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ public enum EUpdateMode
[Description("Stable")]
Stable,
[Description("Beta")]
Beta
Beta,
[Description("QA Testing")]
Qa
}

public enum ECompressedAudio
Expand Down
2 changes: 1 addition & 1 deletion FModel/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private async void OnLoaded(object sender, RoutedEventArgs e)
{
var newOrUpdated = UserSettings.Default.ShowChangelog;
#if !DEBUG
ApplicationService.ApiEndpointView.FModelApi.CheckForUpdates(UserSettings.Default.UpdateMode);
ApplicationService.ApiEndpointView.FModelApi.CheckForUpdates(UserSettings.Default.UpdateMode, true);
#endif

switch (UserSettings.Default.AesReload)
Expand Down
9 changes: 9 additions & 0 deletions FModel/Settings/UserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ public EUpdateMode UpdateMode
set => SetProperty(ref _updateMode, value);
}

private string _commitId = Constants.APP_VERSION;
public string CommitId
{
get => _commitId;
set => SetProperty(ref _commitId, value);
}

private bool _keepDirectoryStructure = true;
public bool KeepDirectoryStructure
{
Expand Down Expand Up @@ -231,6 +238,8 @@ public IDictionary<string, DirectorySettings> PerDirectory

[JsonIgnore]
public DirectorySettings CurrentDir { get; set; }
[JsonIgnore]
public string ShortCommitId => CommitId[..7];

/// <summary>
/// TO DELETEEEEEEEEEEEEE
Expand Down
31 changes: 24 additions & 7 deletions FModel/ViewModels/ApiEndpoints/FModelApiEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,13 @@ public CommunityDesign GetDesign(string designName)
return communityDesign;
}

public void CheckForUpdates(EUpdateMode updateMode)
public void CheckForUpdates(EUpdateMode updateMode, bool launch = false)
{
AutoUpdater.ParseUpdateInfoEvent += ParseUpdateInfoEvent;
AutoUpdater.CheckForUpdateEvent += CheckForUpdateEvent;
if (launch)
{
AutoUpdater.ParseUpdateInfoEvent += ParseUpdateInfoEvent;
AutoUpdater.CheckForUpdateEvent += CheckForUpdateEvent;
}
AutoUpdater.Start($"https://api.fmodel.app/v1/infos/{updateMode}");
}

Expand All @@ -130,9 +133,14 @@ private void ParseUpdateInfoEvent(ParseUpdateInfoEventArgs args)
{
args.UpdateInfo = new UpdateInfoEventArgs
{
CurrentVersion = _infos.Version,
CurrentVersion = _infos.Version.SubstringBefore('-'),
ChangelogURL = _infos.ChangelogUrl,
DownloadURL = _infos.DownloadUrl
DownloadURL = _infos.DownloadUrl,
Mandatory = new CustomMandatory
{
Value = UserSettings.Default.UpdateMode == EUpdateMode.Qa,
CommitId = _infos.Version.SubstringAfter('+')
}
};
}
}
Expand All @@ -141,8 +149,10 @@ private void CheckForUpdateEvent(UpdateInfoEventArgs args)
{
if (args is { CurrentVersion: { } })
{
var qa = (CustomMandatory) args.Mandatory;
var currentVersion = new System.Version(args.CurrentVersion);
if (currentVersion == args.InstalledVersion)
if ((qa.Value && qa.CommitId == UserSettings.Default.CommitId) || // qa branch : same commit id
(!qa.Value && currentVersion == args.InstalledVersion && args.CurrentVersion == UserSettings.Default.CommitId)) // stable - beta branch : same version + commit id = version
{
if (UserSettings.Default.ShowChangelog)
ShowChangelog(args);
Expand All @@ -152,7 +162,7 @@ private void CheckForUpdateEvent(UpdateInfoEventArgs args)
var downgrade = currentVersion < args.InstalledVersion;
var messageBox = new MessageBoxModel
{
Text = $"The latest version of FModel {UserSettings.Default.UpdateMode} is {args.CurrentVersion}. You are using version {args.InstalledVersion}. Do you want to {(downgrade ? "downgrade" : "update")} the application now?",
Text = $"The latest version of FModel {UserSettings.Default.UpdateMode.GetDescription()} is {(qa.Value ? qa.ShortCommitId : args.CurrentVersion)}. You are using version {(qa.Value ? UserSettings.Default.ShortCommitId : args.InstalledVersion)}. Do you want to {(downgrade ? "downgrade" : "update")} the application now?",
Caption = $"{(downgrade ? "Downgrade" : "Update")} Available",
Icon = MessageBoxImage.Question,
Buttons = MessageBoxButtons.YesNo(),
Expand All @@ -167,6 +177,7 @@ private void CheckForUpdateEvent(UpdateInfoEventArgs args)
if (AutoUpdater.DownloadUpdate(args))
{
UserSettings.Default.ShowChangelog = true;
UserSettings.Default.CommitId = qa.CommitId;
Application.Current.Shutdown();
}
}
Expand Down Expand Up @@ -196,3 +207,9 @@ private void ShowChangelog(UpdateInfoEventArgs args)
UserSettings.Default.ShowChangelog = false;
}
}

public class CustomMandatory : Mandatory
{
public string CommitId { get; set; }
public string ShortCommitId => CommitId[..7];
}
2 changes: 1 addition & 1 deletion FModel/ViewModels/ApplicationViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public FStatus Status
public CopyCommand CopyCommand => _copyCommand ??= new CopyCommand(this);
private CopyCommand _copyCommand;

public string InitialWindowTitle => $"FModel {UserSettings.Default.UpdateMode}";
public string InitialWindowTitle => $"FModel {UserSettings.Default.UpdateMode.GetDescription()}";
public string GameDisplayName => CUE4Parse.Provider.GameDisplayName ?? "Unknown";
public string TitleExtra => $"({UserSettings.Default.CurrentDir.UeVersion}){(Build != EBuildKind.Release ? $" ({Build})" : "")}";

Expand Down
4 changes: 2 additions & 2 deletions FModel/ViewModels/GameSelectorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ private IEnumerable<EGame> EnumerateUeGames()
.OrderBy(value => (int)value == ((int)value & ~0xF));
private IEnumerable<DirectorySettings> EnumerateDetectedGames()
{
yield return GetUnrealEngineGame("Fortnite", "\\FortniteGame\\Content\\Paks", EGame.GAME_UE5_3);
yield return DirectorySettings.Default("Fortnite [LIVE]", Constants._FN_LIVE_TRIGGER, ue: EGame.GAME_UE5_3);
yield return GetUnrealEngineGame("Fortnite", "\\FortniteGame\\Content\\Paks", EGame.GAME_UE5_4);
yield return DirectorySettings.Default("Fortnite [LIVE]", Constants._FN_LIVE_TRIGGER, ue: EGame.GAME_UE5_4);
yield return GetUnrealEngineGame("Pewee", "\\RogueCompany\\Content\\Paks", EGame.GAME_RogueCompany);
yield return GetUnrealEngineGame("Rosemallow", "\\Indiana\\Content\\Paks", EGame.GAME_UE4_21);
yield return GetUnrealEngineGame("Catnip", "\\OakGame\\Content\\Paks", EGame.GAME_Borderlands3);
Expand Down
2 changes: 1 addition & 1 deletion FModel/Views/ImageMerger.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private async void OnImageAdd(object sender, RoutedEventArgs e)
var fileBrowser = new OpenFileDialog
{
Title = "Add image(s)",
InitialDirectory = $"{UserSettings.Default.OutputDirectory}\\Exports",
InitialDirectory = Path.Combine(UserSettings.Default.OutputDirectory, "Exports"),
Multiselect = true,
Filter = "Image Files (*.png,*.bmp,*.jpg,*.jpeg,*.jfif,*.jpe,*.tiff,*.tif)|*.png;*.bmp;*.jpg;*.jpeg;*.jfif;*.jpe;*.tiff;*.tif|All Files (*.*)|*.*"
};
Expand Down

0 comments on commit ef94d35

Please sign in to comment.