mirror of
https://github.com/4sval/FModel.git
synced 2026-09-25 10:39:14 -05:00
implemented loading label
This commit is contained in:
@@ -22,7 +22,6 @@ namespace FModel.ViewModels;
|
||||
public class ApplicationViewModel : ViewModel
|
||||
{
|
||||
private EBuildKind _build;
|
||||
|
||||
public EBuildKind Build
|
||||
{
|
||||
get => _build;
|
||||
@@ -33,24 +32,11 @@ public class ApplicationViewModel : ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isReady;
|
||||
|
||||
public bool IsReady
|
||||
{
|
||||
get => _isReady;
|
||||
private set => SetProperty(ref _isReady, value);
|
||||
}
|
||||
|
||||
private EStatusKind _status;
|
||||
|
||||
public EStatusKind Status
|
||||
private FStatus _status;
|
||||
public FStatus Status
|
||||
{
|
||||
get => _status;
|
||||
set
|
||||
{
|
||||
SetProperty(ref _status, value);
|
||||
IsReady = Status != EStatusKind.Loading && Status != EStatusKind.Stopping;
|
||||
}
|
||||
set => SetProperty(ref _status, value);
|
||||
}
|
||||
|
||||
public RightClickMenuCommand RightClickMenuCommand => _rightClickMenuCommand ??= new RightClickMenuCommand(this);
|
||||
@@ -76,7 +62,7 @@ public class ApplicationViewModel : ViewModel
|
||||
|
||||
public ApplicationViewModel()
|
||||
{
|
||||
Status = EStatusKind.Loading;
|
||||
Status = new FStatus();
|
||||
#if DEBUG
|
||||
Build = EBuildKind.Debug;
|
||||
#elif RELEASE
|
||||
@@ -93,7 +79,7 @@ public class ApplicationViewModel : ViewModel
|
||||
AesManager = new AesManagerViewModel(CUE4Parse);
|
||||
MapViewer = new MapViewerViewModel(CUE4Parse);
|
||||
AudioPlayer = new AudioPlayerViewModel();
|
||||
Status = EStatusKind.Ready;
|
||||
Status.SetStatus(EStatusKind.Ready);
|
||||
}
|
||||
|
||||
public void AvoidEmptyGameDirectoryAndSetEGame(bool bAlreadyLaunched)
|
||||
|
||||
@@ -56,7 +56,6 @@ public class CUE4ParseViewModel : ViewModel
|
||||
RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
||||
|
||||
private FGame _game;
|
||||
|
||||
public FGame Game
|
||||
{
|
||||
get => _game;
|
||||
@@ -458,7 +457,7 @@ public class CUE4ParseViewModel : ViewModel
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
try
|
||||
{
|
||||
Extract(asset.FullPath, TabControl.HasNoTabs);
|
||||
Extract(cancellationToken, asset.FullPath, TabControl.HasNoTabs);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -489,7 +488,7 @@ public class CUE4ParseViewModel : ViewModel
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
try
|
||||
{
|
||||
Extract(asset.FullPath, TabControl.HasNoTabs, true);
|
||||
Extract(cancellationToken, asset.FullPath, TabControl.HasNoTabs, true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -506,11 +505,11 @@ public class CUE4ParseViewModel : ViewModel
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
Extract(asset.FullPath, TabControl.HasNoTabs);
|
||||
Extract(cancellationToken, asset.FullPath, TabControl.HasNoTabs);
|
||||
}
|
||||
}
|
||||
|
||||
public void Extract(string fullPath, bool addNewTab = false, bool bulkSave = false)
|
||||
public void Extract(CancellationToken cancellationToken, string fullPath, bool addNewTab = false, bool bulkSave = false)
|
||||
{
|
||||
Log.Information("User DOUBLE-CLICKED to extract '{FullPath}'", fullPath);
|
||||
|
||||
@@ -543,7 +542,7 @@ public class CUE4ParseViewModel : ViewModel
|
||||
|
||||
foreach (var e in exports)
|
||||
{
|
||||
if (CheckExport(e))
|
||||
if (CheckExport(cancellationToken, e))
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -704,7 +703,7 @@ public class CUE4ParseViewModel : ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public void ExtractAndScroll(string fullPath, string objectName)
|
||||
public void ExtractAndScroll(CancellationToken cancellationToken, string fullPath, string objectName)
|
||||
{
|
||||
Log.Information("User CTRL-CLICKED to extract '{FullPath}'", fullPath);
|
||||
TabControl.AddTab(fullPath.SubstringAfterLast('/'), fullPath.SubstringBeforeLast('/'));
|
||||
@@ -716,12 +715,12 @@ public class CUE4ParseViewModel : ViewModel
|
||||
|
||||
foreach (var e in exports)
|
||||
{
|
||||
if (CheckExport(e))
|
||||
if (CheckExport(cancellationToken, e))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckExport(UObject export) // return true once you wanna stop searching for exports
|
||||
private bool CheckExport(CancellationToken cancellationToken, UObject export) // return true once you wanna stop searching for exports
|
||||
{
|
||||
switch (export)
|
||||
{
|
||||
@@ -758,7 +757,7 @@ public class CUE4ParseViewModel : ViewModel
|
||||
export.Owner.Name.EndsWith($"/RenderSwitch_Materials/{export.Name}", StringComparison.OrdinalIgnoreCase) ||
|
||||
export.Owner.Name.EndsWith($"/MI_BPTile/{export.Name}", StringComparison.OrdinalIgnoreCase))):
|
||||
{
|
||||
SnooperViewer.Run(export);
|
||||
SnooperViewer.Run(cancellationToken, export);
|
||||
return true;
|
||||
}
|
||||
case UMaterialInstance m when ModelIsOverwritingMaterial:
|
||||
|
||||
@@ -105,8 +105,7 @@ public class LoadCommand : ViewModelCommand<LoadingModesViewModel>
|
||||
private void FilterDirectoryFilesToDisplay(CancellationToken cancellationToken, IEnumerable<FileItem> directoryFiles)
|
||||
{
|
||||
HashSet<string> filter;
|
||||
if (directoryFiles == null)
|
||||
filter = null;
|
||||
if (directoryFiles == null) filter = null;
|
||||
else
|
||||
{
|
||||
filter = new HashSet<string>();
|
||||
|
||||
@@ -29,7 +29,7 @@ public class RightClickMenuCommand : ViewModelCommand<ApplicationViewModel>
|
||||
foreach (var asset in assetItems)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
contextViewModel.CUE4Parse.Extract(asset.FullPath, true);
|
||||
contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, true);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -45,7 +45,7 @@ public class RightClickMenuCommand : ViewModelCommand<ApplicationViewModel>
|
||||
foreach (var asset in assetItems)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
contextViewModel.CUE4Parse.Extract(asset.FullPath);
|
||||
contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath);
|
||||
contextViewModel.CUE4Parse.TabControl.SelectedTab.SaveProperty(false);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class RightClickMenuCommand : ViewModelCommand<ApplicationViewModel>
|
||||
foreach (var asset in assetItems)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
contextViewModel.CUE4Parse.Extract(asset.FullPath);
|
||||
contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath);
|
||||
contextViewModel.CUE4Parse.TabControl.SelectedTab.SaveImage(false);
|
||||
}
|
||||
|
||||
@@ -62,4 +62,4 @@ public class RightClickMenuCommand : ViewModelCommand<ApplicationViewModel>
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ThreadWorkerViewModel : ViewModel
|
||||
|
||||
public async Task Begin(Action<CancellationToken> action)
|
||||
{
|
||||
if (!_applicationView.IsReady)
|
||||
if (!_applicationView.Status.IsReady)
|
||||
{
|
||||
SignalOperationInProgress();
|
||||
return;
|
||||
@@ -79,7 +79,7 @@ public class ThreadWorkerViewModel : ViewModel
|
||||
{
|
||||
if (_jobs.Count > 0)
|
||||
{
|
||||
_applicationView.Status = EStatusKind.Loading;
|
||||
_applicationView.Status.SetStatus(EStatusKind.Loading);
|
||||
await foreach (var job in _jobs)
|
||||
{
|
||||
try
|
||||
@@ -89,7 +89,7 @@ public class ThreadWorkerViewModel : ViewModel
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
_applicationView.Status = EStatusKind.Stopped;
|
||||
_applicationView.Status.SetStatus(EStatusKind.Stopped);
|
||||
CurrentCancellationTokenSource = null; // kill token
|
||||
OperationCancelled = true;
|
||||
OperationCancelled = false;
|
||||
@@ -97,7 +97,7 @@ public class ThreadWorkerViewModel : ViewModel
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_applicationView.Status = EStatusKind.Failed;
|
||||
_applicationView.Status.SetStatus(EStatusKind.Failed);
|
||||
CurrentCancellationTokenSource = null; // kill token
|
||||
|
||||
Log.Error("{Exception}", e);
|
||||
@@ -134,7 +134,7 @@ public class ThreadWorkerViewModel : ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
_applicationView.Status = EStatusKind.Completed;
|
||||
_applicationView.Status.SetStatus(EStatusKind.Completed);
|
||||
CurrentCancellationTokenSource = null; // kill token
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user