2022-05-15 04:30:15 -07:00
|
|
|
using Avalonia.Controls;
|
2023-01-08 09:46:25 -08:00
|
|
|
using Avalonia.Controls.ApplicationLifetimes;
|
2022-05-15 04:30:15 -07:00
|
|
|
using Avalonia.Input;
|
|
|
|
using Avalonia.Media;
|
|
|
|
using Avalonia.Threading;
|
|
|
|
using DynamicData;
|
|
|
|
using DynamicData.Binding;
|
|
|
|
using LibHac.Fs;
|
|
|
|
using LibHac.FsSystem;
|
|
|
|
using Ryujinx.Ava.Common;
|
|
|
|
using Ryujinx.Ava.Common.Locale;
|
2022-07-05 11:06:31 -07:00
|
|
|
using Ryujinx.Ava.Input;
|
2022-12-29 06:24:05 -08:00
|
|
|
using Ryujinx.Ava.UI.Controls;
|
|
|
|
using Ryujinx.Ava.UI.Helpers;
|
2023-01-08 09:46:25 -08:00
|
|
|
using Ryujinx.Ava.UI.Models;
|
2022-12-29 06:24:05 -08:00
|
|
|
using Ryujinx.Ava.UI.Windows;
|
2022-05-15 04:30:15 -07:00
|
|
|
using Ryujinx.Common;
|
|
|
|
using Ryujinx.Common.Configuration;
|
|
|
|
using Ryujinx.Common.Logging;
|
2023-01-04 15:01:44 -08:00
|
|
|
using Ryujinx.Cpu;
|
2022-05-15 04:30:15 -07:00
|
|
|
using Ryujinx.HLE;
|
|
|
|
using Ryujinx.HLE.FileSystem;
|
2022-11-25 03:41:34 -08:00
|
|
|
using Ryujinx.HLE.HOS;
|
2023-01-08 09:46:25 -08:00
|
|
|
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
|
|
|
using Ryujinx.HLE.Ui;
|
2022-05-15 04:30:15 -07:00
|
|
|
using Ryujinx.Ui.App.Common;
|
|
|
|
using Ryujinx.Ui.Common;
|
|
|
|
using Ryujinx.Ui.Common.Configuration;
|
|
|
|
using Ryujinx.Ui.Common.Helper;
|
2023-01-08 09:46:25 -08:00
|
|
|
using SixLabors.ImageSharp.PixelFormats;
|
2022-05-15 04:30:15 -07:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.IO;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Path = System.IO.Path;
|
|
|
|
using ShaderCacheLoadingState = Ryujinx.Graphics.Gpu.Shader.ShaderCacheState;
|
2023-01-08 09:46:25 -08:00
|
|
|
using UserId = LibHac.Fs.UserId;
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2022-12-29 06:24:05 -08:00
|
|
|
namespace Ryujinx.Ava.UI.ViewModels
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
public class MainWindowViewModel : BaseModel
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2022-08-16 09:32:37 -07:00
|
|
|
private const int HotKeyPressDelayMs = 500;
|
|
|
|
|
2022-05-15 04:30:15 -07:00
|
|
|
private ObservableCollection<ApplicationData> _applications;
|
|
|
|
private string _aspectStatusText;
|
|
|
|
|
|
|
|
private string _loadHeading;
|
|
|
|
private string _cacheLoadStatus;
|
|
|
|
private string _searchText;
|
2022-11-25 03:41:34 -08:00
|
|
|
private Timer _searchTimer;
|
2022-05-15 04:30:15 -07:00
|
|
|
private string _dockedStatusText;
|
|
|
|
private string _fifoStatusText;
|
|
|
|
private string _gameStatusText;
|
2022-09-19 12:04:22 -07:00
|
|
|
private string _volumeStatusText;
|
2022-05-15 04:30:15 -07:00
|
|
|
private string _gpuStatusText;
|
|
|
|
private bool _isAmiiboRequested;
|
|
|
|
private bool _isGameRunning;
|
2023-01-08 09:46:25 -08:00
|
|
|
private bool _isFullScreen;
|
2022-05-15 04:30:15 -07:00
|
|
|
private int _progressMaximum;
|
|
|
|
private int _progressValue;
|
2022-08-16 09:32:37 -07:00
|
|
|
private long _lastFullscreenToggle = Environment.TickCount64;
|
2022-05-15 04:30:15 -07:00
|
|
|
private bool _showLoadProgress;
|
|
|
|
private bool _showMenuAndStatusBar = true;
|
|
|
|
private bool _showStatusSeparator;
|
|
|
|
private Brush _progressBarForegroundColor;
|
|
|
|
private Brush _progressBarBackgroundColor;
|
|
|
|
private Brush _vsyncColor;
|
|
|
|
private byte[] _selectedIcon;
|
|
|
|
private bool _isAppletMenuActive;
|
|
|
|
private int _statusBarProgressMaximum;
|
|
|
|
private int _statusBarProgressValue;
|
|
|
|
private bool _isPaused;
|
|
|
|
private bool _showContent = true;
|
|
|
|
private bool _isLoadingIndeterminate = true;
|
2022-07-08 11:47:11 -07:00
|
|
|
private bool _showAll;
|
|
|
|
private string _lastScannedAmiiboId;
|
2023-01-08 09:46:25 -08:00
|
|
|
private bool _statusBarVisible;
|
2022-05-15 04:30:15 -07:00
|
|
|
private ReadOnlyObservableCollection<ApplicationData> _appsObservableList;
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
private string _showUiKey = "F4";
|
|
|
|
private string _pauseKey = "F5";
|
|
|
|
private string _screenshotKey = "F8";
|
|
|
|
private float _volume;
|
|
|
|
private string _backendText;
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public ApplicationData ListSelectedApplication;
|
|
|
|
public ApplicationData GridSelectedApplication;
|
|
|
|
private bool _canUpdate;
|
|
|
|
private Cursor _cursor;
|
|
|
|
private string _title;
|
|
|
|
private string _currentEmulatedGamePath;
|
|
|
|
private AutoResetEvent _rendererWaitEvent;
|
|
|
|
private WindowState _windowState;
|
|
|
|
private bool _isActive;
|
|
|
|
|
|
|
|
public event Action ReloadGameList;
|
|
|
|
|
|
|
|
private string TitleName { get; set; }
|
|
|
|
internal AppHost AppHost { get; set; }
|
2022-05-15 04:30:15 -07:00
|
|
|
|
|
|
|
public MainWindowViewModel()
|
|
|
|
{
|
|
|
|
Applications = new ObservableCollection<ApplicationData>();
|
|
|
|
|
|
|
|
Applications.ToObservableChangeSet()
|
|
|
|
.Filter(Filter)
|
|
|
|
.Sort(GetComparer())
|
|
|
|
.Bind(out _appsObservableList).AsObservableList();
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
_rendererWaitEvent = new AutoResetEvent(false);
|
|
|
|
|
2022-05-15 04:30:15 -07:00
|
|
|
if (Program.PreviewerDetached)
|
|
|
|
{
|
2022-07-05 11:06:31 -07:00
|
|
|
LoadConfigurableHotKeys();
|
2022-05-15 04:30:15 -07:00
|
|
|
|
|
|
|
Volume = ConfigurationState.Instance.System.AudioVolume;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public void Initialize(
|
|
|
|
ContentManager contentManager,
|
|
|
|
ApplicationLibrary applicationLibrary,
|
|
|
|
VirtualFileSystem virtualFileSystem,
|
|
|
|
AccountManager accountManager,
|
|
|
|
Ryujinx.Input.HLE.InputManager inputManager,
|
|
|
|
UserChannelPersistence userChannelPersistence,
|
|
|
|
LibHacHorizonManager libHacHorizonManager,
|
|
|
|
IHostUiHandler uiHandler,
|
|
|
|
Action<bool> showLoading,
|
|
|
|
Action<bool> switchToGameControl,
|
|
|
|
Action<Control> setMainContent,
|
|
|
|
TopLevel topLevel)
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
ContentManager = contentManager;
|
|
|
|
ApplicationLibrary = applicationLibrary;
|
|
|
|
VirtualFileSystem = virtualFileSystem;
|
|
|
|
AccountManager = accountManager;
|
|
|
|
InputManager = inputManager;
|
|
|
|
UserChannelPersistence = userChannelPersistence;
|
|
|
|
LibHacHorizonManager = libHacHorizonManager;
|
|
|
|
UiHandler = uiHandler;
|
|
|
|
|
|
|
|
ShowLoading = showLoading;
|
|
|
|
SwitchToGameControl = switchToGameControl;
|
|
|
|
SetMainContent = setMainContent;
|
|
|
|
TopLevel = topLevel;
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
#region Properties
|
|
|
|
|
2022-05-15 04:30:15 -07:00
|
|
|
public string SearchText
|
|
|
|
{
|
|
|
|
get => _searchText;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_searchText = value;
|
|
|
|
|
2022-11-25 03:41:34 -08:00
|
|
|
_searchTimer?.Dispose();
|
|
|
|
|
|
|
|
_searchTimer = new Timer(TimerCallback, null, 1000, 0);
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-25 03:41:34 -08:00
|
|
|
private void TimerCallback(object obj)
|
|
|
|
{
|
|
|
|
RefreshView();
|
|
|
|
|
|
|
|
_searchTimer.Dispose();
|
|
|
|
_searchTimer = null;
|
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public bool CanUpdate
|
|
|
|
{
|
|
|
|
get => _canUpdate;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_canUpdate = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Cursor Cursor
|
|
|
|
{
|
|
|
|
get => _cursor;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_cursor = value;
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-15 04:30:15 -07:00
|
|
|
public ReadOnlyObservableCollection<ApplicationData> AppsObservableList
|
|
|
|
{
|
|
|
|
get => _appsObservableList;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_appsObservableList = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool IsPaused
|
|
|
|
{
|
|
|
|
get => _isPaused;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_isPaused = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public long LastFullscreenToggle
|
|
|
|
{
|
|
|
|
get => _lastFullscreenToggle;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_lastFullscreenToggle = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool StatusBarVisible
|
|
|
|
{
|
|
|
|
get => _statusBarVisible && EnableNonGameRunningControls;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_statusBarVisible = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-15 04:30:15 -07:00
|
|
|
public bool EnableNonGameRunningControls => !IsGameRunning;
|
|
|
|
|
|
|
|
public bool ShowFirmwareStatus => !ShowLoadProgress;
|
|
|
|
|
|
|
|
public bool IsGameRunning
|
|
|
|
{
|
|
|
|
get => _isGameRunning;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_isGameRunning = value;
|
|
|
|
|
|
|
|
if (!value)
|
|
|
|
{
|
|
|
|
ShowMenuAndStatusBar = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
OnPropertyChanged(nameof(EnableNonGameRunningControls));
|
2023-01-08 09:46:25 -08:00
|
|
|
OnPropertyChanged(nameof(StatusBarVisible));
|
2022-05-15 04:30:15 -07:00
|
|
|
OnPropertyChanged(nameof(ShowFirmwareStatus));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool IsAmiiboRequested
|
|
|
|
{
|
|
|
|
get => _isAmiiboRequested && _isGameRunning;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_isAmiiboRequested = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool ShowLoadProgress
|
|
|
|
{
|
|
|
|
get => _showLoadProgress;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_showLoadProgress = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
OnPropertyChanged(nameof(ShowFirmwareStatus));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public string GameStatusText
|
|
|
|
{
|
|
|
|
get => _gameStatusText;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_gameStatusText = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public bool IsFullScreen
|
|
|
|
{
|
|
|
|
get => _isFullScreen;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_isFullScreen = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool ShowAll
|
|
|
|
{
|
|
|
|
get => _showAll;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_showAll = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public string LastScannedAmiiboId
|
|
|
|
{
|
|
|
|
get => _lastScannedAmiiboId;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_lastScannedAmiiboId = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
|
|
|
|
public ApplicationData SelectedApplication
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2022-11-25 03:41:34 -08:00
|
|
|
return Glyph switch
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
Glyph.List => ListSelectedApplication,
|
|
|
|
Glyph.Grid => GridSelectedApplication,
|
|
|
|
_ => null,
|
2022-11-25 03:41:34 -08:00
|
|
|
};
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public string LoadHeading
|
|
|
|
{
|
|
|
|
get => _loadHeading;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_loadHeading = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public string CacheLoadStatus
|
|
|
|
{
|
|
|
|
get => _cacheLoadStatus;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_cacheLoadStatus = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Brush ProgressBarBackgroundColor
|
|
|
|
{
|
|
|
|
get => _progressBarBackgroundColor;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_progressBarBackgroundColor = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Brush ProgressBarForegroundColor
|
|
|
|
{
|
|
|
|
get => _progressBarForegroundColor;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_progressBarForegroundColor = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Brush VsyncColor
|
|
|
|
{
|
|
|
|
get => _vsyncColor;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_vsyncColor = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public byte[] SelectedIcon
|
|
|
|
{
|
|
|
|
get => _selectedIcon;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_selectedIcon = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int ProgressMaximum
|
|
|
|
{
|
|
|
|
get => _progressMaximum;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_progressMaximum = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int ProgressValue
|
|
|
|
{
|
|
|
|
get => _progressValue;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_progressValue = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int StatusBarProgressMaximum
|
|
|
|
{
|
|
|
|
get => _statusBarProgressMaximum;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_statusBarProgressMaximum = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int StatusBarProgressValue
|
|
|
|
{
|
|
|
|
get => _statusBarProgressValue;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_statusBarProgressValue = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public string FifoStatusText
|
|
|
|
{
|
|
|
|
get => _fifoStatusText;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_fifoStatusText = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Vulkan backend (#2518)
* WIP Vulkan implementation
* No need to initialize attributes on the SPIR-V backend anymore
* Allow multithreading shaderc and vkCreateShaderModule
You'll only really see the benefit here with threaded-gal or parallel shader cache compile.
Fix shaderc multithreaded changes
Thread safety for shaderc Options constructor
Dunno how they managed to make a constructor not thread safe, but you do you. May avoid some freezes.
* Support multiple levels/layers for blit.
Fixes MK8D when scaled, maybe a few other games. AMD software "safe" blit not supported right now.
* TextureStorage should hold a ref of the foreign storage, otherwise it might be freed while in use
* New depth-stencil blit method for AMD
* Workaround for AMD driver bug
* Fix some tessellation related issues (still doesn't work?)
* Submit command buffer before Texture GetData. (UE4 fix)
* DrawTexture support
* Fix BGRA on OpenGL backend
* Fix rebase build break
* Support format aliasing on SetImage
* Fix uniform buffers being lost when bindings are out of order
* Fix storage buffers being lost when bindings are out of order
(also avoid allocations when changing bindings)
* Use current command buffer for unscaled copy (perf)
Avoids flushing commands and renting a command buffer when fulfilling copy dependencies and when games do unscaled copies.
* Update to .net6
* Update Silk.NET to version 2.10.1
Somehow, massive performance boost. Seems like their vtable for looking up vulkan methods was really slow before.
* Fix PrimitivesGenerated query, disable Transform Feedback queries for now
Lets Splatoon 2 work on nvidia. (mostly)
* Update counter queue to be similar to the OGL one
Fixes softlocks when games had to flush counters.
* Don't throw when ending conditional rendering for now
This should be re-enabled when conditional rendering is enabled on nvidia etc.
* Update findMSB/findLSB to match master's instruction enum
* Fix triangle overlay on SMO, Captain Toad, maybe others?
* Don't make Intel Mesa pay for Intel Windows bugs
* Fix samplers with MinFilter Linear or Nearest (fixes New Super Mario Bros U Deluxe black borders)
* Update Spv.Generator
* Add alpha test emulation on shader (but no shader specialisation yet...)
* Fix R4G4B4A4Unorm texture format permutation
* Validation layers should be enabled for any log level other than None
* Add barriers around vkCmdCopyImage
Write->Read barrier for src image (we want to wait for a write to read it)
Write->Read barrier for dst image (we want to wait for the copy to complete before use)
* Be a bit more careful with texture access flags, since it can be used for anything
* Device local mapping for all buffers
May avoid issues with drivers with NVIDIA on linux/older gpus on windows when using large buffers (?)
Also some performance things and fixes issues with opengl games loading textures weird.
* Cleanup, disable device local buffers for now.
* Add single queue support
Multiqueue seems to be a bit more responsive on NVIDIA. Should fix texture flush on intel. AMD has been forced to single queue for an experiment.
* Fix some validation errors around extended dynamic state
* Remove Intel bug workaround, it was fixed on the latest driver
* Use circular queue for checking consumption on command buffers
Speeds up games that spam command buffers a little. Avoids checking multiple command buffers if multiple are active at once.
* Use SupportBufferUpdater, add single layer flush
* Fix counter queue leak when game decides to use host conditional rendering
* Force device local storage for textures (fixes linux performance)
* Port #3019
* Insert barriers around vkCmdBlitImage (may fix some amd flicker)
* Fix transform feedback on Intel, gl_Position feedback and clears to inexistent depth buffers
* Don't pause transform feedback for multi draw
* Fix draw outside of render pass and missing capability
* Workaround for wrong last attribute on AMD (affects FFVII, STRIKERS1945, probably more)
* Better workaround for AMD vertex buffer size alignment issue
* More instructions + fixes on SPIR-V backend
* Allow custom aspect ratio on Vulkan
* Correct GTK UI status bar positions
* SPIR-V: Functions must always end with a return
* SPIR-V: Fix ImageQuerySizeLod
* SPIR-V: Set DepthReplacing execution mode when FragDepth is modified
* SPIR-V: Implement LoopContinue IR instruction
* SPIR-V: Geometry shader support
* SPIR-V: Use correct binding number on storage buffers array
* Reduce allocations for Spir-v serialization
Passes BinaryWriter instead of the stream to Write and WriteOperand
- Removes creation of BinaryWriter for each instruction
- Removes allocations for literal string
* Some optimizations to Spv.Generator
- Dictionary for lookups of type declarations, constants, extinst
- LiteralInteger internal data format -> ushort
- Deterministic HashCode implementation to avoid spirv result not being the same between runs
- Inline operand list instead of List<T>, falls back to array if many operands. (large performance boost)
TODO: improve instruction allocation, structured program creator, ssa?
* Pool Spv.Generator resources, cache delegates, spv opts
- Pools for Instructions and LiteralIntegers. Can be passed in when creating the generator module.
- NewInstruction is called instead of new Instruction()
- Ryujinx SpirvGenerator passes in some pools that are static. The idea is for these to be shared between threads eventually.
- Estimate code size when creating the output MemoryStream
- LiteralInteger pools using ThreadStatic pools that are initialized before and after creation... not sure of a better way since the way these are created is via implicit cast.
Also, cache delegates for Spv.Generator for functions that are passed around to GenerateBinary etc, since passing the function raw creates a delegate on each call.
TODO: update python spv cs generator to make the coregrammar with NewInstruction and the `params` overloads.
* LocalDefMap for Ssa Rewriter
Rather than allocating a large array of all registers for each block in the shader, allocate one array of all registers and clear it between blocks. Reduces allocations in the shader translator.
* SPIR-V: Transform feedback support
* SPIR-V: Fragment shader interlock support (and image coherency)
* SPIR-V: Add early fragment tests support
* SPIR-V: Implement SwizzleAdd, add missing Triangles ExecutionMode for geometry shaders, remove SamplerType field from TextureMeta
* Don't pass depth clip state right now (fix decals)
Explicitly disabling it is incorrect. OpenGL currently automatically disables based on depth clamp, which is the behaviour if this state is omitted.
* Multisampling support
* Multisampling: Use resolve if src samples count > dst samples count
* Multisampling: We can only resolve for unscaled copies
* SPIR-V: Only add FSI exec mode if used.
* SPIR-V: Use ConstantComposite for Texture Offset Vector
Fixes a bunch of freezes with SPIR-V on AMD hardware, and validation errors. Note: Obviously assumes input offsets are constant, which they currently are.
* SPIR-V: Don't OpReturn if we already OpExit'ed
Fixes spir-v parse failure and stack smashing in RADV (obviously you still need bolist)
* SPIR-V: Only use input attribute type for input attributes
Output vertex attributes should always be of type float.
* Multithreaded Pipeline Compilation
* Address some feedback
* Make this 32
* Update topology with GpuAccessorState
* Cleanup for merge (note: disables spir-v)
* Make more robust to shader compilation failure
- Don't freeze when GLSL compilation fails
- Background SPIR-V pipeline compile failure results in skipped draws, similar to GLSL compilation failure.
* Fix Multisampling
* Only update fragment scale count if a vertex texture needs a scale.
Fixes a performance regression introduced by texture scaling in the vertex stage where support buffer updates would be very frequent, even at 1x, if any textures were used on the vertex stage.
This check doesn't exactly look cheap (a flag in the shader stage would probably be preferred), but it is much cheaper than uploading scales in both vulkan and opengl, so it will do for now.
* Use a bitmap to do granular tracking for buffer uploads.
This path is only taken if the much faster check of "is the buffer rented at all" is triggered, so it doesn't actually end up costing too much, and the time saved by not ending render passes (and on gpu for not waiting on barriers) is probably helpful.
Avoids ending render passes to update buffer data (not all the time)
- 140-180 to 35-45 in SMO metro kingdom (these updates are in the UI)
- Very variable 60-150(!) to 16-25 in mario kart 8 (these updates are in the UI)
As well as allowing more data to be preloaded persistently, this will also allow more data to be loaded in the preload buffer, which should be faster as it doesn't need to insert barriers between draws. (and on tbdr, does not need to flush and reload tile memory)
Improves performance in GPU limited scenarios. Should notably improve performance on TBDR gpus. Still a lot more to do here.
* Copy query results after RP ends, rather than ending to copy
We need to end the render pass to get the data (submit command buffer) anyways...
Reduces render passes created in games that use queries.
* Rework Query stuff a bit to avoid render pass end
Tries to reset returned queries in background when possible, rather than ending the render pass.
Still ends render pass when resetting a counter after draws, but maybe that can be solved too. (by just pulling an empty object off the pool?)
* Remove unnecessary lines
Was for testing
* Fix validation error for query reset
Need to think of a better way to do this.
* SPIR-V: Fix SwizzleAdd and some validation errors
* SPIR-V: Implement attribute indexing and StoreAttribute
* SPIR-V: Fix TextureSize for MS and Buffer sampler types
* Fix relaunch issues
* SPIR-V: Implement LogicalExclusiveOr
* SPIR-V: Constant buffer indexing support
* Ignore unsupported attributes rather than throwing (matches current GLSL behaviour)
* SPIR-V: Implement tessellation support
* SPIR-V: Geometry shader passthrough support
* SPIR-V: Implement StoreShader8/16 and StoreStorage8/16
* SPIR-V: Resolution scale support and fix TextureSample multisample with LOD bug
* SPIR-V: Fix field index for scale count
* SPIR-V: Fix another case of wrong field index
* SPIRV/GLSL: More scaling related fixes
* SPIR-V: Fix ImageLoad CompositeExtract component type
* SPIR-V: Workaround for Intel FrontFacing bug
* Enable SPIR-V backend by default
* Allow null samplers (samplers are not required when only using texelFetch to access the texture)
* Fix some validation errors related to texel block view usage flag and invalid image barrier base level
* Use explicit subgroup size if we can (might fix some block flickering on AMD)
* Take componentMask and scissor into account when clearing framebuffer attachments
* Add missing barriers around CmdFillBuffer (fixes Monster Hunter Rise flickering on NVIDIA)
* Use ClampToEdge for Clamp sampler address mode on Vulkan (fixes Hollow Knight)
Clamp is unsupported on Vulkan, but ClampToEdge behaves almost the same. ClampToBorder on the other hand (which was being used before) is pretty different
* Shader specialization for new Vulkan required state (fixes remaining alpha test issues, vertex stretching on AMD on Crash Bandicoot, etc)
* Check if the subgroup size is supported before passing a explicit size
* Only enable ShaderFloat64 if the GPU supports it
* We don't need to recompile shaders if alpha test state changed but alpha test is disabled
* Enable shader cache on Vulkan and implement MultiplyHighS32/U32 on SPIR-V (missed those before)
* Fix pipeline state saving before it is updated.
This should fix a few warnings and potential stutters due to bad pipeline states being saved in the cache. You may need to clear your guest cache.
* Allow null samplers on OpenGL backend
* _unit0Sampler should be set only for binding 0
* Remove unused PipelineConverter format variable (was causing IOR)
* Raise textures limit to 64 on Vulkan
* No need to pack the shader binaries if shader cache is disabled
* Fix backbuffer not being cleared and scissor not being re-enabled on OpenGL
* Do not clear unbound framebuffer color attachments
* Geometry shader passthrough emulation
* Consolidate UpdateDepthMode and GetDepthMode implementation
* Fix A1B5G5R5 texture format and support R4G4 on Vulkan
* Add barrier before use of some modified images
* Report 32 bit query result on AMD windows (smo issue)
* Add texture recompression support (disabled for now)
It recompresses ASTC textures into BC7, which might reduce VRAM usage significantly on games that uses ASTC textures
* Do not report R4G4 format as supported on Vulkan
It was causing mario head to become white on Super Mario 64 (???)
* Improvements to -1 to 1 depth mode.
- Transformation is only applied on the last stage in the vertex pipeline.
- Should fix some issues with geometry and tessellation (hopefully)
- Reading back FragCoord Z on fragment will transform back to -1 to 1.
* Geometry Shader index count from ThreadsPerInputPrimitive
Generally fixes SPIR-V emitting too many triangles, may change games in OpenGL
* Remove gl_FragDepth scaling
This is always 0-1; the other two issues were causing the problems. Fixes regression with Xenoblade.
* Add Gl StencilOp enum values to Vulkan
* Update guest cache to v1.1 (due to specialization state changes)
This will explode your shader cache from earlier vulkan build, but it must be done. :pensive:
* Vulkan/SPIR-V support for viewport inverse
* Fix typo
* Don't create query pools for unsupported query types
* Return of the Vector Indexing Bug
One day, everyone will get this right.
* Check for transform feedback query support
Sometimes transform feedback is supported without the query type.
* Fix gl_FragCoord.z transformation
FragCoord.z is always in 0-1, even when the real depth range is -1 to 1. Turns out the only bug was geo and tess stage outputs.
Fixes Pokemon Sword/Shield, possibly others.
* Fix Avalonia Rebase
Vulkan is currently not available on Avalonia, but the build does work and you can use opengl.
* Fix headless build
* Add support for BC6 and BC7 decompression, decompress all BC formats if they are not supported by the host
* Fix BCn 4/5 conversion, GetTextureTarget
BCn 4/5 could generate invalid data when a line's size in bytes was not divisible by 4, which both backends expect.
GetTextureTarget was not creating a view with the replacement format.
* Fix dependency
* Fix inverse viewport transform vector type on SPIR-V
* Do not require null descriptors support
* If MultiViewport is not supported, do not try to set more than one viewport/scissor
* Bounds check on bitmap add.
* Flush queries on attachment change rather than program change
Occlusion queries are usually used in a depth only pass so the attachments changing is a better indication of the query block ending.
Write mask changes are also considered since some games do depth only pass by setting 0 write mask on all the colour targets.
* Add support for avalonia (#6)
* add avalonia support
* only lock around skia flush
* addressed review
* cleanup
* add fallback size if avalonia attempts to render but the window size is 0. read desktop scale after enabling dpi check
* fix getting window handle on linux. skip render is size is 0
* Combine non-buffer with buffer image descriptor sets
* Support multisample texture copy with automatic resolve on Vulkan
* Remove old CompileShader methods from the Vulkan backend
* Add minimal pipeline layouts that only contains used bindings
They are used by helper shaders, the intention is avoiding needing to recompile the shaders (from GLSL to SPIR-V) if the bindings changes on the translated guest shaders
* Pre-compile helper shader as SPIR-V, and some fixes
* Remove pre-compiled shaderc binary for Windows as its no longer needed by default
* Workaround RADV crash
Enabling the descriptor indexing extension, even if it is not used, forces the radv driver to use "bolist".
* Use RobustBufferAccess on NVIDIA gpus
Avoids the SMO waterfall triangle on older NVIDIA gpus.
* Implement GPU selector and expose texture recompression on the UI and config
* Fix and enable background compute shader compilation
Also disables warnings from shader cache pipeline misses.
* Fix error due to missing subpass dependency when Attachment Write -> Shader Read barriers are added
* If S8D24 is not supported, use D32FS8
* Ensure all fences are destroyed on dispose
* Pre-allocate arrays up front on DescriptorSetUpdater, allows the removal of some checks
* Add missing clear layer parameter after rebase
* Use selected gpu from config for avalonia (#7)
* use configured device
* address review
* Fix D32S8 copy workaround (AMD)
Fixes water in Pokemon Legends Arceus on AMD GPUs. Possibly fixes other things.
* Use push descriptors for uniform buffer updates (disabled for now)
* Push descriptor support check, buffer redundancy checks
Should make push descriptors faster, needs more testing though.
* Increase light command buffer pool to 2 command buffers, throw rather than returning invalid cbs
* Adjust bindings array sizes
* Force submit command buffers if memory in use by its resources is high
* Add workaround for AMD GCN cubemap view sins
`ImageCreateCubeCompatibleBit` seems to generally break 2D array textures with mipmaps... even if they are eventually aliased as a cubemap with mipmaps. Forcing a copy here works around the issue.
This could be used in future if enabling this bit reduces performance on certain GPUs. (mobile class is generally a worry)
Currently also enabled on Linux as I don't know if they managed to dodge this bug (someone please tell me). Not enabled on Vega at the moment, but easy to add if the issue is there.
* Add mobile, non-RX variants to the GCN regex.
Also make sure that the 3 digit ones only include numbers starting with 7 or 8.
* Increase image limit per stage from 8 to 16
Xenoblade Chronicles 2 was hiting the limit of 8
* Minor code cleanup
* Fix NRE caused by SupportBufferUpdater calling pipeline ClearBuffer
* Add gpu selector to Avalonia (#8)
* Add gpu selector to avalonia settings
* show backend label on window
* some fixes
* address review
* Minor changes to the Avalonia UI
* Update graphics window UI and locales. (#9)
* Update xaml and update locales
* locale updates
Did my best here but likely needs to be checked by native speakers, especially the use of ampersands in greek, russian and turkish?
* Fix locales with more (?) correct translations.
* add separator to render widget
* fix spanish and portuguese
* Add new IdList, replaces buffer list that could not remove elements and had unbounded growth
* Don't crash the settings window if Vulkan is not supported
* Fix Actions menu not being clickable on GTK UI after relaunch
* Rename VulkanGraphicsDevice to VulkanRenderer and Renderer to OpenGLRenderer
* Fix IdList and make it not thread safe
* Revert useless OpenGL format table changes
* Fix headless project build
* List throws ArgumentOutOfRangeException
* SPIR-V: Fix tessellation
* Increase shader cache version due to tessellation fix
* Reduce number of Sync objects created (improves perf in some specific titles)
* Fix vulkan validation errors for NPOT compressed upload and GCN workaround.
* Add timestamp to the shader cache and force rebuild if host cache is outdated
* Prefer Mail box present mode for popups (#11)
* Prefer Mail box present mode
* fix debug
* switch present mode when vsync is toggled
* only disable vsync on the main window
* SPIR-V: Fix geometry shader input load with transform feedback
* BC7 Encoder: Prefer more precision on alpha rather than RGB when alpha is 0
* Fix Avalonia build
* Address initial PR feedback
* Only set transform feedback outputs on last vertex stage
* Address riperiperi PR feedback
* Remove outdated comment
* Remove unused constructor
* Only throw for negative results
* Throw for QueueSubmit and other errors
No point in delaying the inevitable
* Transform feedback decorations inside gl_PerVertex struct breaks the NVIDIA compiler
* Fix some resolution scale issues
* No need for two UpdateScale calls
* Fix comments on SPIR-V generator project
* Try to fix shader local memory size
On DOOM, a shader is using local memory, but both Low and High size are 0, CRS size is 1536, it seems to store on that region?
* Remove RectangleF that is now unused
* Fix ImageGather with multiple offsets
Needs ImageGatherExtended capability, and must use `ConstantComposite` instead of `CompositeConstruct`
* Address PR feedback from jD in all projects except Avalonia
* Address most of jD PR feedback on Avalonia
* Remove unsafe
* Fix VulkanSkiaGpu
* move present mode request out of Create Swapchain method
* split more parts of create swapchain
* addressed reviews
* addressed review
* Address second batch of jD PR feedback
* Fix buffer <-> image copy row length and height alignment
AlignUp helper does not support NPOT alignment, and ASTC textures can have NPOT block sizes
* Better fix for NPOT alignment issue
* Use switch expressions on Vulkan EnumConversion
Thanks jD
* Fix Avalonia build
* Add Vulkan selection prompt on startup
* Grammar fixes on Vulkan prompt message
* Add missing Vulkan migration flag
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
Co-authored-by: Emmanuel Hansen <emmausssss@gmail.com>
Co-authored-by: MutantAura <44103205+MutantAura@users.noreply.github.com>
2022-07-31 14:26:06 -07:00
|
|
|
public string GpuNameText
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
|
|
|
get => _gpuStatusText;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_gpuStatusText = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Vulkan backend (#2518)
* WIP Vulkan implementation
* No need to initialize attributes on the SPIR-V backend anymore
* Allow multithreading shaderc and vkCreateShaderModule
You'll only really see the benefit here with threaded-gal or parallel shader cache compile.
Fix shaderc multithreaded changes
Thread safety for shaderc Options constructor
Dunno how they managed to make a constructor not thread safe, but you do you. May avoid some freezes.
* Support multiple levels/layers for blit.
Fixes MK8D when scaled, maybe a few other games. AMD software "safe" blit not supported right now.
* TextureStorage should hold a ref of the foreign storage, otherwise it might be freed while in use
* New depth-stencil blit method for AMD
* Workaround for AMD driver bug
* Fix some tessellation related issues (still doesn't work?)
* Submit command buffer before Texture GetData. (UE4 fix)
* DrawTexture support
* Fix BGRA on OpenGL backend
* Fix rebase build break
* Support format aliasing on SetImage
* Fix uniform buffers being lost when bindings are out of order
* Fix storage buffers being lost when bindings are out of order
(also avoid allocations when changing bindings)
* Use current command buffer for unscaled copy (perf)
Avoids flushing commands and renting a command buffer when fulfilling copy dependencies and when games do unscaled copies.
* Update to .net6
* Update Silk.NET to version 2.10.1
Somehow, massive performance boost. Seems like their vtable for looking up vulkan methods was really slow before.
* Fix PrimitivesGenerated query, disable Transform Feedback queries for now
Lets Splatoon 2 work on nvidia. (mostly)
* Update counter queue to be similar to the OGL one
Fixes softlocks when games had to flush counters.
* Don't throw when ending conditional rendering for now
This should be re-enabled when conditional rendering is enabled on nvidia etc.
* Update findMSB/findLSB to match master's instruction enum
* Fix triangle overlay on SMO, Captain Toad, maybe others?
* Don't make Intel Mesa pay for Intel Windows bugs
* Fix samplers with MinFilter Linear or Nearest (fixes New Super Mario Bros U Deluxe black borders)
* Update Spv.Generator
* Add alpha test emulation on shader (but no shader specialisation yet...)
* Fix R4G4B4A4Unorm texture format permutation
* Validation layers should be enabled for any log level other than None
* Add barriers around vkCmdCopyImage
Write->Read barrier for src image (we want to wait for a write to read it)
Write->Read barrier for dst image (we want to wait for the copy to complete before use)
* Be a bit more careful with texture access flags, since it can be used for anything
* Device local mapping for all buffers
May avoid issues with drivers with NVIDIA on linux/older gpus on windows when using large buffers (?)
Also some performance things and fixes issues with opengl games loading textures weird.
* Cleanup, disable device local buffers for now.
* Add single queue support
Multiqueue seems to be a bit more responsive on NVIDIA. Should fix texture flush on intel. AMD has been forced to single queue for an experiment.
* Fix some validation errors around extended dynamic state
* Remove Intel bug workaround, it was fixed on the latest driver
* Use circular queue for checking consumption on command buffers
Speeds up games that spam command buffers a little. Avoids checking multiple command buffers if multiple are active at once.
* Use SupportBufferUpdater, add single layer flush
* Fix counter queue leak when game decides to use host conditional rendering
* Force device local storage for textures (fixes linux performance)
* Port #3019
* Insert barriers around vkCmdBlitImage (may fix some amd flicker)
* Fix transform feedback on Intel, gl_Position feedback and clears to inexistent depth buffers
* Don't pause transform feedback for multi draw
* Fix draw outside of render pass and missing capability
* Workaround for wrong last attribute on AMD (affects FFVII, STRIKERS1945, probably more)
* Better workaround for AMD vertex buffer size alignment issue
* More instructions + fixes on SPIR-V backend
* Allow custom aspect ratio on Vulkan
* Correct GTK UI status bar positions
* SPIR-V: Functions must always end with a return
* SPIR-V: Fix ImageQuerySizeLod
* SPIR-V: Set DepthReplacing execution mode when FragDepth is modified
* SPIR-V: Implement LoopContinue IR instruction
* SPIR-V: Geometry shader support
* SPIR-V: Use correct binding number on storage buffers array
* Reduce allocations for Spir-v serialization
Passes BinaryWriter instead of the stream to Write and WriteOperand
- Removes creation of BinaryWriter for each instruction
- Removes allocations for literal string
* Some optimizations to Spv.Generator
- Dictionary for lookups of type declarations, constants, extinst
- LiteralInteger internal data format -> ushort
- Deterministic HashCode implementation to avoid spirv result not being the same between runs
- Inline operand list instead of List<T>, falls back to array if many operands. (large performance boost)
TODO: improve instruction allocation, structured program creator, ssa?
* Pool Spv.Generator resources, cache delegates, spv opts
- Pools for Instructions and LiteralIntegers. Can be passed in when creating the generator module.
- NewInstruction is called instead of new Instruction()
- Ryujinx SpirvGenerator passes in some pools that are static. The idea is for these to be shared between threads eventually.
- Estimate code size when creating the output MemoryStream
- LiteralInteger pools using ThreadStatic pools that are initialized before and after creation... not sure of a better way since the way these are created is via implicit cast.
Also, cache delegates for Spv.Generator for functions that are passed around to GenerateBinary etc, since passing the function raw creates a delegate on each call.
TODO: update python spv cs generator to make the coregrammar with NewInstruction and the `params` overloads.
* LocalDefMap for Ssa Rewriter
Rather than allocating a large array of all registers for each block in the shader, allocate one array of all registers and clear it between blocks. Reduces allocations in the shader translator.
* SPIR-V: Transform feedback support
* SPIR-V: Fragment shader interlock support (and image coherency)
* SPIR-V: Add early fragment tests support
* SPIR-V: Implement SwizzleAdd, add missing Triangles ExecutionMode for geometry shaders, remove SamplerType field from TextureMeta
* Don't pass depth clip state right now (fix decals)
Explicitly disabling it is incorrect. OpenGL currently automatically disables based on depth clamp, which is the behaviour if this state is omitted.
* Multisampling support
* Multisampling: Use resolve if src samples count > dst samples count
* Multisampling: We can only resolve for unscaled copies
* SPIR-V: Only add FSI exec mode if used.
* SPIR-V: Use ConstantComposite for Texture Offset Vector
Fixes a bunch of freezes with SPIR-V on AMD hardware, and validation errors. Note: Obviously assumes input offsets are constant, which they currently are.
* SPIR-V: Don't OpReturn if we already OpExit'ed
Fixes spir-v parse failure and stack smashing in RADV (obviously you still need bolist)
* SPIR-V: Only use input attribute type for input attributes
Output vertex attributes should always be of type float.
* Multithreaded Pipeline Compilation
* Address some feedback
* Make this 32
* Update topology with GpuAccessorState
* Cleanup for merge (note: disables spir-v)
* Make more robust to shader compilation failure
- Don't freeze when GLSL compilation fails
- Background SPIR-V pipeline compile failure results in skipped draws, similar to GLSL compilation failure.
* Fix Multisampling
* Only update fragment scale count if a vertex texture needs a scale.
Fixes a performance regression introduced by texture scaling in the vertex stage where support buffer updates would be very frequent, even at 1x, if any textures were used on the vertex stage.
This check doesn't exactly look cheap (a flag in the shader stage would probably be preferred), but it is much cheaper than uploading scales in both vulkan and opengl, so it will do for now.
* Use a bitmap to do granular tracking for buffer uploads.
This path is only taken if the much faster check of "is the buffer rented at all" is triggered, so it doesn't actually end up costing too much, and the time saved by not ending render passes (and on gpu for not waiting on barriers) is probably helpful.
Avoids ending render passes to update buffer data (not all the time)
- 140-180 to 35-45 in SMO metro kingdom (these updates are in the UI)
- Very variable 60-150(!) to 16-25 in mario kart 8 (these updates are in the UI)
As well as allowing more data to be preloaded persistently, this will also allow more data to be loaded in the preload buffer, which should be faster as it doesn't need to insert barriers between draws. (and on tbdr, does not need to flush and reload tile memory)
Improves performance in GPU limited scenarios. Should notably improve performance on TBDR gpus. Still a lot more to do here.
* Copy query results after RP ends, rather than ending to copy
We need to end the render pass to get the data (submit command buffer) anyways...
Reduces render passes created in games that use queries.
* Rework Query stuff a bit to avoid render pass end
Tries to reset returned queries in background when possible, rather than ending the render pass.
Still ends render pass when resetting a counter after draws, but maybe that can be solved too. (by just pulling an empty object off the pool?)
* Remove unnecessary lines
Was for testing
* Fix validation error for query reset
Need to think of a better way to do this.
* SPIR-V: Fix SwizzleAdd and some validation errors
* SPIR-V: Implement attribute indexing and StoreAttribute
* SPIR-V: Fix TextureSize for MS and Buffer sampler types
* Fix relaunch issues
* SPIR-V: Implement LogicalExclusiveOr
* SPIR-V: Constant buffer indexing support
* Ignore unsupported attributes rather than throwing (matches current GLSL behaviour)
* SPIR-V: Implement tessellation support
* SPIR-V: Geometry shader passthrough support
* SPIR-V: Implement StoreShader8/16 and StoreStorage8/16
* SPIR-V: Resolution scale support and fix TextureSample multisample with LOD bug
* SPIR-V: Fix field index for scale count
* SPIR-V: Fix another case of wrong field index
* SPIRV/GLSL: More scaling related fixes
* SPIR-V: Fix ImageLoad CompositeExtract component type
* SPIR-V: Workaround for Intel FrontFacing bug
* Enable SPIR-V backend by default
* Allow null samplers (samplers are not required when only using texelFetch to access the texture)
* Fix some validation errors related to texel block view usage flag and invalid image barrier base level
* Use explicit subgroup size if we can (might fix some block flickering on AMD)
* Take componentMask and scissor into account when clearing framebuffer attachments
* Add missing barriers around CmdFillBuffer (fixes Monster Hunter Rise flickering on NVIDIA)
* Use ClampToEdge for Clamp sampler address mode on Vulkan (fixes Hollow Knight)
Clamp is unsupported on Vulkan, but ClampToEdge behaves almost the same. ClampToBorder on the other hand (which was being used before) is pretty different
* Shader specialization for new Vulkan required state (fixes remaining alpha test issues, vertex stretching on AMD on Crash Bandicoot, etc)
* Check if the subgroup size is supported before passing a explicit size
* Only enable ShaderFloat64 if the GPU supports it
* We don't need to recompile shaders if alpha test state changed but alpha test is disabled
* Enable shader cache on Vulkan and implement MultiplyHighS32/U32 on SPIR-V (missed those before)
* Fix pipeline state saving before it is updated.
This should fix a few warnings and potential stutters due to bad pipeline states being saved in the cache. You may need to clear your guest cache.
* Allow null samplers on OpenGL backend
* _unit0Sampler should be set only for binding 0
* Remove unused PipelineConverter format variable (was causing IOR)
* Raise textures limit to 64 on Vulkan
* No need to pack the shader binaries if shader cache is disabled
* Fix backbuffer not being cleared and scissor not being re-enabled on OpenGL
* Do not clear unbound framebuffer color attachments
* Geometry shader passthrough emulation
* Consolidate UpdateDepthMode and GetDepthMode implementation
* Fix A1B5G5R5 texture format and support R4G4 on Vulkan
* Add barrier before use of some modified images
* Report 32 bit query result on AMD windows (smo issue)
* Add texture recompression support (disabled for now)
It recompresses ASTC textures into BC7, which might reduce VRAM usage significantly on games that uses ASTC textures
* Do not report R4G4 format as supported on Vulkan
It was causing mario head to become white on Super Mario 64 (???)
* Improvements to -1 to 1 depth mode.
- Transformation is only applied on the last stage in the vertex pipeline.
- Should fix some issues with geometry and tessellation (hopefully)
- Reading back FragCoord Z on fragment will transform back to -1 to 1.
* Geometry Shader index count from ThreadsPerInputPrimitive
Generally fixes SPIR-V emitting too many triangles, may change games in OpenGL
* Remove gl_FragDepth scaling
This is always 0-1; the other two issues were causing the problems. Fixes regression with Xenoblade.
* Add Gl StencilOp enum values to Vulkan
* Update guest cache to v1.1 (due to specialization state changes)
This will explode your shader cache from earlier vulkan build, but it must be done. :pensive:
* Vulkan/SPIR-V support for viewport inverse
* Fix typo
* Don't create query pools for unsupported query types
* Return of the Vector Indexing Bug
One day, everyone will get this right.
* Check for transform feedback query support
Sometimes transform feedback is supported without the query type.
* Fix gl_FragCoord.z transformation
FragCoord.z is always in 0-1, even when the real depth range is -1 to 1. Turns out the only bug was geo and tess stage outputs.
Fixes Pokemon Sword/Shield, possibly others.
* Fix Avalonia Rebase
Vulkan is currently not available on Avalonia, but the build does work and you can use opengl.
* Fix headless build
* Add support for BC6 and BC7 decompression, decompress all BC formats if they are not supported by the host
* Fix BCn 4/5 conversion, GetTextureTarget
BCn 4/5 could generate invalid data when a line's size in bytes was not divisible by 4, which both backends expect.
GetTextureTarget was not creating a view with the replacement format.
* Fix dependency
* Fix inverse viewport transform vector type on SPIR-V
* Do not require null descriptors support
* If MultiViewport is not supported, do not try to set more than one viewport/scissor
* Bounds check on bitmap add.
* Flush queries on attachment change rather than program change
Occlusion queries are usually used in a depth only pass so the attachments changing is a better indication of the query block ending.
Write mask changes are also considered since some games do depth only pass by setting 0 write mask on all the colour targets.
* Add support for avalonia (#6)
* add avalonia support
* only lock around skia flush
* addressed review
* cleanup
* add fallback size if avalonia attempts to render but the window size is 0. read desktop scale after enabling dpi check
* fix getting window handle on linux. skip render is size is 0
* Combine non-buffer with buffer image descriptor sets
* Support multisample texture copy with automatic resolve on Vulkan
* Remove old CompileShader methods from the Vulkan backend
* Add minimal pipeline layouts that only contains used bindings
They are used by helper shaders, the intention is avoiding needing to recompile the shaders (from GLSL to SPIR-V) if the bindings changes on the translated guest shaders
* Pre-compile helper shader as SPIR-V, and some fixes
* Remove pre-compiled shaderc binary for Windows as its no longer needed by default
* Workaround RADV crash
Enabling the descriptor indexing extension, even if it is not used, forces the radv driver to use "bolist".
* Use RobustBufferAccess on NVIDIA gpus
Avoids the SMO waterfall triangle on older NVIDIA gpus.
* Implement GPU selector and expose texture recompression on the UI and config
* Fix and enable background compute shader compilation
Also disables warnings from shader cache pipeline misses.
* Fix error due to missing subpass dependency when Attachment Write -> Shader Read barriers are added
* If S8D24 is not supported, use D32FS8
* Ensure all fences are destroyed on dispose
* Pre-allocate arrays up front on DescriptorSetUpdater, allows the removal of some checks
* Add missing clear layer parameter after rebase
* Use selected gpu from config for avalonia (#7)
* use configured device
* address review
* Fix D32S8 copy workaround (AMD)
Fixes water in Pokemon Legends Arceus on AMD GPUs. Possibly fixes other things.
* Use push descriptors for uniform buffer updates (disabled for now)
* Push descriptor support check, buffer redundancy checks
Should make push descriptors faster, needs more testing though.
* Increase light command buffer pool to 2 command buffers, throw rather than returning invalid cbs
* Adjust bindings array sizes
* Force submit command buffers if memory in use by its resources is high
* Add workaround for AMD GCN cubemap view sins
`ImageCreateCubeCompatibleBit` seems to generally break 2D array textures with mipmaps... even if they are eventually aliased as a cubemap with mipmaps. Forcing a copy here works around the issue.
This could be used in future if enabling this bit reduces performance on certain GPUs. (mobile class is generally a worry)
Currently also enabled on Linux as I don't know if they managed to dodge this bug (someone please tell me). Not enabled on Vega at the moment, but easy to add if the issue is there.
* Add mobile, non-RX variants to the GCN regex.
Also make sure that the 3 digit ones only include numbers starting with 7 or 8.
* Increase image limit per stage from 8 to 16
Xenoblade Chronicles 2 was hiting the limit of 8
* Minor code cleanup
* Fix NRE caused by SupportBufferUpdater calling pipeline ClearBuffer
* Add gpu selector to Avalonia (#8)
* Add gpu selector to avalonia settings
* show backend label on window
* some fixes
* address review
* Minor changes to the Avalonia UI
* Update graphics window UI and locales. (#9)
* Update xaml and update locales
* locale updates
Did my best here but likely needs to be checked by native speakers, especially the use of ampersands in greek, russian and turkish?
* Fix locales with more (?) correct translations.
* add separator to render widget
* fix spanish and portuguese
* Add new IdList, replaces buffer list that could not remove elements and had unbounded growth
* Don't crash the settings window if Vulkan is not supported
* Fix Actions menu not being clickable on GTK UI after relaunch
* Rename VulkanGraphicsDevice to VulkanRenderer and Renderer to OpenGLRenderer
* Fix IdList and make it not thread safe
* Revert useless OpenGL format table changes
* Fix headless project build
* List throws ArgumentOutOfRangeException
* SPIR-V: Fix tessellation
* Increase shader cache version due to tessellation fix
* Reduce number of Sync objects created (improves perf in some specific titles)
* Fix vulkan validation errors for NPOT compressed upload and GCN workaround.
* Add timestamp to the shader cache and force rebuild if host cache is outdated
* Prefer Mail box present mode for popups (#11)
* Prefer Mail box present mode
* fix debug
* switch present mode when vsync is toggled
* only disable vsync on the main window
* SPIR-V: Fix geometry shader input load with transform feedback
* BC7 Encoder: Prefer more precision on alpha rather than RGB when alpha is 0
* Fix Avalonia build
* Address initial PR feedback
* Only set transform feedback outputs on last vertex stage
* Address riperiperi PR feedback
* Remove outdated comment
* Remove unused constructor
* Only throw for negative results
* Throw for QueueSubmit and other errors
No point in delaying the inevitable
* Transform feedback decorations inside gl_PerVertex struct breaks the NVIDIA compiler
* Fix some resolution scale issues
* No need for two UpdateScale calls
* Fix comments on SPIR-V generator project
* Try to fix shader local memory size
On DOOM, a shader is using local memory, but both Low and High size are 0, CRS size is 1536, it seems to store on that region?
* Remove RectangleF that is now unused
* Fix ImageGather with multiple offsets
Needs ImageGatherExtended capability, and must use `ConstantComposite` instead of `CompositeConstruct`
* Address PR feedback from jD in all projects except Avalonia
* Address most of jD PR feedback on Avalonia
* Remove unsafe
* Fix VulkanSkiaGpu
* move present mode request out of Create Swapchain method
* split more parts of create swapchain
* addressed reviews
* addressed review
* Address second batch of jD PR feedback
* Fix buffer <-> image copy row length and height alignment
AlignUp helper does not support NPOT alignment, and ASTC textures can have NPOT block sizes
* Better fix for NPOT alignment issue
* Use switch expressions on Vulkan EnumConversion
Thanks jD
* Fix Avalonia build
* Add Vulkan selection prompt on startup
* Grammar fixes on Vulkan prompt message
* Add missing Vulkan migration flag
Co-authored-by: riperiperi <rhy3756547@hotmail.com>
Co-authored-by: Emmanuel Hansen <emmausssss@gmail.com>
Co-authored-by: MutantAura <44103205+MutantAura@users.noreply.github.com>
2022-07-31 14:26:06 -07:00
|
|
|
public string BackendText
|
|
|
|
{
|
|
|
|
get => _backendText;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_backendText = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-15 04:30:15 -07:00
|
|
|
public string DockedStatusText
|
|
|
|
{
|
|
|
|
get => _dockedStatusText;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_dockedStatusText = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public string AspectRatioStatusText
|
|
|
|
{
|
|
|
|
get => _aspectStatusText;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_aspectStatusText = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public string VolumeStatusText
|
|
|
|
{
|
2022-09-19 12:04:22 -07:00
|
|
|
get => _volumeStatusText;
|
|
|
|
set
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2022-09-19 12:04:22 -07:00
|
|
|
_volumeStatusText = value;
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2022-09-19 12:04:22 -07:00
|
|
|
OnPropertyChanged();
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool VolumeMuted => _volume == 0;
|
|
|
|
|
|
|
|
public float Volume
|
|
|
|
{
|
|
|
|
get => _volume;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_volume = value;
|
|
|
|
|
|
|
|
if (_isGameRunning)
|
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
AppHost.Device.SetVolume(_volume);
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
2022-11-25 03:41:34 -08:00
|
|
|
|
2022-05-15 04:30:15 -07:00
|
|
|
OnPropertyChanged(nameof(VolumeStatusText));
|
|
|
|
OnPropertyChanged(nameof(VolumeMuted));
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool ShowStatusSeparator
|
|
|
|
{
|
|
|
|
get => _showStatusSeparator;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_showStatusSeparator = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
2023-01-04 15:01:44 -08:00
|
|
|
|
2022-05-15 04:30:15 -07:00
|
|
|
public bool ShowMenuAndStatusBar
|
|
|
|
{
|
|
|
|
get => _showMenuAndStatusBar;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_showMenuAndStatusBar = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool IsLoadingIndeterminate
|
|
|
|
{
|
|
|
|
get => _isLoadingIndeterminate;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_isLoadingIndeterminate = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public bool IsActive
|
|
|
|
{
|
|
|
|
get => _isActive;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_isActive = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-05-15 04:30:15 -07:00
|
|
|
public bool ShowContent
|
|
|
|
{
|
|
|
|
get => _showContent;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_showContent = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool IsAppletMenuActive
|
|
|
|
{
|
|
|
|
get => _isAppletMenuActive && EnableNonGameRunningControls;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_isAppletMenuActive = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public WindowState WindowState
|
|
|
|
{
|
|
|
|
get => _windowState;
|
|
|
|
internal set
|
|
|
|
{
|
|
|
|
_windowState = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-15 04:30:15 -07:00
|
|
|
public bool IsGrid => Glyph == Glyph.Grid;
|
|
|
|
public bool IsList => Glyph == Glyph.List;
|
|
|
|
|
|
|
|
internal void Sort(bool isAscending)
|
|
|
|
{
|
|
|
|
IsAscending = isAscending;
|
2022-11-25 03:41:34 -08:00
|
|
|
|
2022-05-15 04:30:15 -07:00
|
|
|
RefreshView();
|
|
|
|
}
|
|
|
|
|
|
|
|
internal void Sort(ApplicationSort sort)
|
|
|
|
{
|
|
|
|
SortMode = sort;
|
2022-11-25 03:41:34 -08:00
|
|
|
|
2022-05-15 04:30:15 -07:00
|
|
|
RefreshView();
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool StartGamesInFullscreen
|
|
|
|
{
|
|
|
|
get => ConfigurationState.Instance.Ui.StartFullscreen;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
ConfigurationState.Instance.Ui.StartFullscreen.Value = value;
|
|
|
|
|
|
|
|
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool ShowConsole
|
|
|
|
{
|
|
|
|
get => ConfigurationState.Instance.Ui.ShowConsole;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
ConfigurationState.Instance.Ui.ShowConsole.Value = value;
|
|
|
|
|
|
|
|
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public string Title
|
|
|
|
{
|
|
|
|
get => _title;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_title = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-12 05:58:31 -07:00
|
|
|
public bool ShowConsoleVisible
|
|
|
|
{
|
|
|
|
get => ConsoleHelper.SetConsoleWindowStateSupported;
|
|
|
|
}
|
|
|
|
|
2022-05-15 04:30:15 -07:00
|
|
|
public ObservableCollection<ApplicationData> Applications
|
|
|
|
{
|
|
|
|
get => _applications;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_applications = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Glyph Glyph
|
|
|
|
{
|
|
|
|
get => (Glyph)ConfigurationState.Instance.Ui.GameListViewMode.Value;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
ConfigurationState.Instance.Ui.GameListViewMode.Value = (int)value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
OnPropertyChanged(nameof(IsGrid));
|
|
|
|
OnPropertyChanged(nameof(IsList));
|
|
|
|
|
|
|
|
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool ShowNames
|
|
|
|
{
|
|
|
|
get => ConfigurationState.Instance.Ui.ShowNames && ConfigurationState.Instance.Ui.GridSize > 1; set
|
|
|
|
{
|
|
|
|
ConfigurationState.Instance.Ui.ShowNames.Value = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
OnPropertyChanged(nameof(GridSizeScale));
|
2023-01-08 09:46:25 -08:00
|
|
|
OnPropertyChanged(nameof(GridItemSelectorSize));
|
2022-05-15 04:30:15 -07:00
|
|
|
|
|
|
|
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
internal ApplicationSort SortMode
|
|
|
|
{
|
|
|
|
get => (ApplicationSort)ConfigurationState.Instance.Ui.ApplicationSort.Value;
|
|
|
|
private set
|
|
|
|
{
|
|
|
|
ConfigurationState.Instance.Ui.ApplicationSort.Value = (int)value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
OnPropertyChanged(nameof(SortName));
|
|
|
|
|
|
|
|
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public int ListItemSelectorSize
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
switch (ConfigurationState.Instance.Ui.GridSize)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
return 78;
|
|
|
|
case 2:
|
|
|
|
return 100;
|
|
|
|
case 3:
|
|
|
|
return 120;
|
|
|
|
case 4:
|
|
|
|
return 140;
|
|
|
|
default:
|
|
|
|
return 16;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int GridItemSelectorSize
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
switch (ConfigurationState.Instance.Ui.GridSize)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
return 120;
|
|
|
|
case 2:
|
|
|
|
return ShowNames ? 210 : 150;
|
|
|
|
case 3:
|
|
|
|
return ShowNames ? 240 : 180;
|
|
|
|
case 4:
|
|
|
|
return ShowNames ? 280 : 220;
|
|
|
|
default:
|
|
|
|
return 16;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int GridSizeScale
|
|
|
|
{
|
|
|
|
get => ConfigurationState.Instance.Ui.GridSize;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
ConfigurationState.Instance.Ui.GridSize.Value = value;
|
|
|
|
|
|
|
|
if (value < 2)
|
|
|
|
{
|
|
|
|
ShowNames = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
OnPropertyChanged(nameof(IsGridSmall));
|
|
|
|
OnPropertyChanged(nameof(IsGridMedium));
|
|
|
|
OnPropertyChanged(nameof(IsGridLarge));
|
|
|
|
OnPropertyChanged(nameof(IsGridHuge));
|
|
|
|
OnPropertyChanged(nameof(ListItemSelectorSize));
|
|
|
|
OnPropertyChanged(nameof(GridItemSelectorSize));
|
|
|
|
OnPropertyChanged(nameof(ShowNames));
|
|
|
|
|
|
|
|
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
|
|
|
|
}
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
|
|
|
|
public string SortName
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2022-11-25 03:41:34 -08:00
|
|
|
return SortMode switch
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
ApplicationSort.Title => LocaleManager.Instance[LocaleKeys.GameListHeaderApplication],
|
|
|
|
ApplicationSort.Developer => LocaleManager.Instance[LocaleKeys.GameListHeaderDeveloper],
|
|
|
|
ApplicationSort.LastPlayed => LocaleManager.Instance[LocaleKeys.GameListHeaderLastPlayed],
|
2023-01-03 10:45:08 -08:00
|
|
|
ApplicationSort.TotalTimePlayed => LocaleManager.Instance[LocaleKeys.GameListHeaderTimePlayed],
|
2023-01-08 09:46:25 -08:00
|
|
|
ApplicationSort.FileType => LocaleManager.Instance[LocaleKeys.GameListHeaderFileExtension],
|
|
|
|
ApplicationSort.FileSize => LocaleManager.Instance[LocaleKeys.GameListHeaderFileSize],
|
|
|
|
ApplicationSort.Path => LocaleManager.Instance[LocaleKeys.GameListHeaderPath],
|
|
|
|
ApplicationSort.Favorite => LocaleManager.Instance[LocaleKeys.CommonFavorite],
|
|
|
|
_ => string.Empty,
|
2022-11-25 03:41:34 -08:00
|
|
|
};
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool IsAscending
|
|
|
|
{
|
|
|
|
get => ConfigurationState.Instance.Ui.IsAscendingOrder;
|
|
|
|
private set
|
|
|
|
{
|
|
|
|
ConfigurationState.Instance.Ui.IsAscendingOrder.Value = value;
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
OnPropertyChanged(nameof(SortMode));
|
|
|
|
OnPropertyChanged(nameof(SortName));
|
|
|
|
|
|
|
|
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public KeyGesture ShowUiKey
|
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
get => KeyGesture.Parse(_showUiKey);
|
|
|
|
set
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
_showUiKey = value.ToString();
|
2022-11-25 03:41:34 -08:00
|
|
|
|
2022-05-15 04:30:15 -07:00
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public KeyGesture ScreenshotKey
|
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
get => KeyGesture.Parse(_screenshotKey);
|
|
|
|
set
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
_screenshotKey = value.ToString();
|
2022-11-25 03:41:34 -08:00
|
|
|
|
2022-05-15 04:30:15 -07:00
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public KeyGesture PauseKey
|
|
|
|
{
|
|
|
|
get => KeyGesture.Parse(_pauseKey); set
|
|
|
|
{
|
|
|
|
_pauseKey = value.ToString();
|
2022-11-25 03:41:34 -08:00
|
|
|
|
2022-05-15 04:30:15 -07:00
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public ContentManager ContentManager { get; private set; }
|
|
|
|
public ApplicationLibrary ApplicationLibrary { get; private set; }
|
|
|
|
public VirtualFileSystem VirtualFileSystem { get; private set; }
|
|
|
|
public AccountManager AccountManager { get; private set; }
|
|
|
|
public Ryujinx.Input.HLE.InputManager InputManager { get; private set; }
|
|
|
|
public UserChannelPersistence UserChannelPersistence { get; private set; }
|
|
|
|
public Action<bool> ShowLoading { get; private set; }
|
|
|
|
public Action<bool> SwitchToGameControl { get; private set; }
|
|
|
|
public Action<Control> SetMainContent { get; private set; }
|
|
|
|
public TopLevel TopLevel { get; private set; }
|
|
|
|
public RendererHost RendererControl { get; private set; }
|
|
|
|
public bool IsClosing { get; set; }
|
|
|
|
public LibHacHorizonManager LibHacHorizonManager { get; internal set; }
|
|
|
|
public IHostUiHandler UiHandler { get; internal set; }
|
|
|
|
public bool IsSortedByFavorite => SortMode == ApplicationSort.Favorite;
|
|
|
|
public bool IsSortedByTitle => SortMode == ApplicationSort.Title;
|
|
|
|
public bool IsSortedByDeveloper => SortMode == ApplicationSort.Developer;
|
|
|
|
public bool IsSortedByLastPlayed => SortMode == ApplicationSort.LastPlayed;
|
|
|
|
public bool IsSortedByTimePlayed => SortMode == ApplicationSort.TotalTimePlayed;
|
|
|
|
public bool IsSortedByType => SortMode == ApplicationSort.FileType;
|
|
|
|
public bool IsSortedBySize => SortMode == ApplicationSort.FileSize;
|
|
|
|
public bool IsSortedByPath => SortMode == ApplicationSort.Path;
|
|
|
|
public bool IsGridSmall => ConfigurationState.Instance.Ui.GridSize == 1;
|
2022-05-15 04:30:15 -07:00
|
|
|
public bool IsGridMedium => ConfigurationState.Instance.Ui.GridSize == 2;
|
2023-01-08 09:46:25 -08:00
|
|
|
public bool IsGridLarge => ConfigurationState.Instance.Ui.GridSize == 3;
|
|
|
|
public bool IsGridHuge => ConfigurationState.Instance.Ui.GridSize == 4;
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
#endregion
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
#region PrivateMethods
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
private IComparer<ApplicationData> GetComparer()
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
return SortMode switch
|
2022-07-08 11:47:11 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
ApplicationSort.LastPlayed => new Models.Generic.LastPlayedSortComparer(IsAscending),
|
|
|
|
ApplicationSort.FileSize => IsAscending ? SortExpressionComparer<ApplicationData>.Ascending(app => app.FileSizeBytes)
|
|
|
|
: SortExpressionComparer<ApplicationData>.Descending(app => app.FileSizeBytes),
|
|
|
|
ApplicationSort.TotalTimePlayed => IsAscending ? SortExpressionComparer<ApplicationData>.Ascending(app => app.TimePlayedNum)
|
|
|
|
: SortExpressionComparer<ApplicationData>.Descending(app => app.TimePlayedNum),
|
|
|
|
ApplicationSort.Title => IsAscending ? SortExpressionComparer<ApplicationData>.Ascending(app => app.TitleName)
|
|
|
|
: SortExpressionComparer<ApplicationData>.Descending(app => app.TitleName),
|
|
|
|
ApplicationSort.Favorite => !IsAscending ? SortExpressionComparer<ApplicationData>.Ascending(app => app.Favorite)
|
|
|
|
: SortExpressionComparer<ApplicationData>.Descending(app => app.Favorite),
|
|
|
|
ApplicationSort.Developer => IsAscending ? SortExpressionComparer<ApplicationData>.Ascending(app => app.Developer)
|
|
|
|
: SortExpressionComparer<ApplicationData>.Descending(app => app.Developer),
|
|
|
|
ApplicationSort.FileType => IsAscending ? SortExpressionComparer<ApplicationData>.Ascending(app => app.FileExtension)
|
|
|
|
: SortExpressionComparer<ApplicationData>.Descending(app => app.FileExtension),
|
|
|
|
ApplicationSort.Path => IsAscending ? SortExpressionComparer<ApplicationData>.Ascending(app => app.Path)
|
|
|
|
: SortExpressionComparer<ApplicationData>.Descending(app => app.Path),
|
|
|
|
_ => null,
|
|
|
|
};
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
private void RefreshView()
|
|
|
|
{
|
|
|
|
RefreshGrid();
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
private void RefreshGrid()
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
Applications.ToObservableChangeSet()
|
|
|
|
.Filter(Filter)
|
|
|
|
.Sort(GetComparer())
|
|
|
|
.Bind(out _appsObservableList).AsObservableList();
|
2023-01-04 15:01:44 -08:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
OnPropertyChanged(nameof(AppsObservableList));
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private bool Filter(object arg)
|
|
|
|
{
|
|
|
|
if (arg is ApplicationData app)
|
|
|
|
{
|
|
|
|
return string.IsNullOrWhiteSpace(_searchText) || app.TitleName.ToLower().Contains(_searchText.ToLower());
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
private async Task HandleFirmwareInstallation(string filename)
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
try
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
SystemVersion firmwareVersion = ContentManager.VerifyFirmwarePackage(filename);
|
2022-12-05 14:04:18 -08:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
if (firmwareVersion == null)
|
2022-12-05 14:04:18 -08:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
await ContentDialogHelper.CreateErrorDialog(string.Format(LocaleManager.Instance[LocaleKeys.DialogFirmwareInstallerFirmwareNotFoundErrorMessage], filename));
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
return;
|
|
|
|
}
|
2022-11-25 03:41:34 -08:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
string dialogTitle = string.Format(LocaleManager.Instance[LocaleKeys.DialogFirmwareInstallerFirmwareInstallTitle], firmwareVersion.VersionString);
|
2022-11-25 03:41:34 -08:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
SystemVersion currentVersion = ContentManager.GetCurrentFirmwareVersion();
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
string dialogMessage = string.Format(LocaleManager.Instance[LocaleKeys.DialogFirmwareInstallerFirmwareInstallMessage], firmwareVersion.VersionString);
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
if (currentVersion != null)
|
|
|
|
{
|
|
|
|
dialogMessage += string.Format(LocaleManager.Instance[LocaleKeys.DialogFirmwareInstallerFirmwareInstallSubMessage], currentVersion.VersionString);
|
|
|
|
}
|
|
|
|
|
|
|
|
dialogMessage += LocaleManager.Instance[LocaleKeys.DialogFirmwareInstallerFirmwareInstallConfirmMessage];
|
|
|
|
|
|
|
|
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(
|
|
|
|
dialogTitle,
|
|
|
|
dialogMessage,
|
|
|
|
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
|
|
|
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
|
|
|
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
|
|
|
|
|
|
|
|
UpdateWaitWindow waitingDialog = ContentDialogHelper.CreateWaitingDialog(dialogTitle, LocaleManager.Instance[LocaleKeys.DialogFirmwareInstallerFirmwareInstallWaitMessage]);
|
|
|
|
|
|
|
|
if (result == UserResult.Yes)
|
|
|
|
{
|
|
|
|
Logger.Info?.Print(LogClass.Application, $"Installing firmware {firmwareVersion.VersionString}");
|
|
|
|
|
|
|
|
Thread thread = new(() =>
|
|
|
|
{
|
|
|
|
Dispatcher.UIThread.InvokeAsync(delegate
|
|
|
|
{
|
|
|
|
waitingDialog.Show();
|
|
|
|
});
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
ContentManager.InstallFirmware(filename);
|
|
|
|
|
|
|
|
Dispatcher.UIThread.InvokeAsync(async delegate
|
|
|
|
{
|
|
|
|
waitingDialog.Close();
|
|
|
|
|
|
|
|
string message = string.Format(LocaleManager.Instance[LocaleKeys.DialogFirmwareInstallerFirmwareInstallSuccessMessage], firmwareVersion.VersionString);
|
|
|
|
|
|
|
|
await ContentDialogHelper.CreateInfoDialog(dialogTitle, message, LocaleManager.Instance[LocaleKeys.InputDialogOk], "", LocaleManager.Instance[LocaleKeys.RyujinxInfo]);
|
|
|
|
|
|
|
|
Logger.Info?.Print(LogClass.Application, message);
|
|
|
|
|
|
|
|
// Purge Applet Cache.
|
|
|
|
|
|
|
|
DirectoryInfo miiEditorCacheFolder = new DirectoryInfo(Path.Combine(AppDataManager.GamesDirPath, "0100000000001009", "cache"));
|
|
|
|
|
|
|
|
if (miiEditorCacheFolder.Exists)
|
|
|
|
{
|
|
|
|
miiEditorCacheFolder.Delete(true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
Dispatcher.UIThread.InvokeAsync(async () =>
|
|
|
|
{
|
|
|
|
waitingDialog.Close();
|
|
|
|
|
|
|
|
await ContentDialogHelper.CreateErrorDialog(ex.Message);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
|
|
|
RefreshFirmwareStatus();
|
|
|
|
}
|
|
|
|
}) { Name = "GUI.FirmwareInstallerThread" };
|
|
|
|
|
|
|
|
thread.Start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (LibHac.Common.Keys.MissingKeyException ex)
|
|
|
|
{
|
|
|
|
if (Avalonia.Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
|
|
|
{
|
|
|
|
Logger.Error?.Print(LogClass.Application, ex.ToString());
|
|
|
|
|
|
|
|
async void Action() => await UserErrorDialog.ShowUserErrorDialog(UserError.NoKeys, (desktop.MainWindow as MainWindow));
|
|
|
|
|
|
|
|
Dispatcher.UIThread.Post(Action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
await ContentDialogHelper.CreateErrorDialog(ex.Message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void ProgressHandler<T>(T state, int current, int total) where T : Enum
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
Dispatcher.UIThread.Post((() =>
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
ProgressMaximum = total;
|
|
|
|
ProgressValue = current;
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case LoadState ptcState:
|
|
|
|
CacheLoadStatus = $"{current} / {total}";
|
|
|
|
switch (ptcState)
|
|
|
|
{
|
|
|
|
case LoadState.Unloaded:
|
|
|
|
case LoadState.Loading:
|
|
|
|
LoadHeading = LocaleManager.Instance[LocaleKeys.CompilingPPTC];
|
|
|
|
IsLoadingIndeterminate = false;
|
|
|
|
break;
|
|
|
|
case LoadState.Loaded:
|
|
|
|
LoadHeading = string.Format(LocaleManager.Instance[LocaleKeys.LoadingHeading], TitleName);
|
|
|
|
IsLoadingIndeterminate = true;
|
|
|
|
CacheLoadStatus = "";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ShaderCacheLoadingState shaderCacheState:
|
|
|
|
CacheLoadStatus = $"{current} / {total}";
|
|
|
|
switch (shaderCacheState)
|
|
|
|
{
|
|
|
|
case ShaderCacheLoadingState.Start:
|
|
|
|
case ShaderCacheLoadingState.Loading:
|
|
|
|
LoadHeading = LocaleManager.Instance[LocaleKeys.CompilingShaders];
|
|
|
|
IsLoadingIndeterminate = false;
|
|
|
|
break;
|
|
|
|
case ShaderCacheLoadingState.Loaded:
|
|
|
|
LoadHeading = string.Format(LocaleManager.Instance[LocaleKeys.LoadingHeading], TitleName);
|
|
|
|
IsLoadingIndeterminate = true;
|
|
|
|
CacheLoadStatus = "";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
throw new ArgumentException($"Unknown Progress Handler type {typeof(T)}");
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OpenSaveDirectory(in SaveDataFilter filter, ApplicationData data, ulong titleId)
|
|
|
|
{
|
|
|
|
ApplicationHelper.OpenSaveDir(in filter, titleId, data.ControlHolder, data.TitleName);
|
|
|
|
}
|
|
|
|
|
|
|
|
private async void ExtractLogo()
|
|
|
|
{
|
|
|
|
var selection = SelectedApplication;
|
|
|
|
if (selection != null)
|
|
|
|
{
|
|
|
|
await ApplicationHelper.ExtractSection(NcaSectionType.Logo, selection.Path);
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
2023-01-08 09:46:25 -08:00
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
private async void ExtractRomFs()
|
|
|
|
{
|
|
|
|
var selection = SelectedApplication;
|
|
|
|
if (selection != null)
|
|
|
|
{
|
|
|
|
await ApplicationHelper.ExtractSection(NcaSectionType.Data, selection.Path);
|
|
|
|
}
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
private async void ExtractExeFs()
|
|
|
|
{
|
|
|
|
var selection = SelectedApplication;
|
|
|
|
if (selection != null)
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
await ApplicationHelper.ExtractSection(NcaSectionType.Code, selection.Path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void PrepareLoadScreen()
|
|
|
|
{
|
|
|
|
using MemoryStream stream = new(SelectedIcon);
|
|
|
|
using var gameIconBmp = SixLabors.ImageSharp.Image.Load<Bgra32>(stream);
|
|
|
|
|
|
|
|
var dominantColor = IconColorPicker.GetFilteredColor(gameIconBmp).ToPixel<Bgra32>();
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
const float colorMultiple = 0.5f;
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
Color progressFgColor = Color.FromRgb(dominantColor.R, dominantColor.G, dominantColor.B);
|
|
|
|
Color progressBgColor = Color.FromRgb(
|
|
|
|
(byte)(dominantColor.R * colorMultiple),
|
|
|
|
(byte)(dominantColor.G * colorMultiple),
|
|
|
|
(byte)(dominantColor.B * colorMultiple));
|
|
|
|
|
|
|
|
ProgressBarForegroundColor = new SolidColorBrush(progressFgColor);
|
|
|
|
ProgressBarBackgroundColor = new SolidColorBrush(progressBgColor);
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
private void InitializeGame()
|
|
|
|
{
|
|
|
|
RendererControl.RendererInitialized += GlRenderer_Created;
|
|
|
|
|
|
|
|
AppHost.StatusUpdatedEvent += Update_StatusBar;
|
|
|
|
AppHost.AppExit += AppHost_AppExit;
|
|
|
|
|
|
|
|
_rendererWaitEvent.WaitOne();
|
|
|
|
|
|
|
|
AppHost?.Start();
|
|
|
|
|
|
|
|
AppHost?.DisposeContext();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void HandleRelaunch()
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
if (UserChannelPersistence.PreviousIndex != -1 && UserChannelPersistence.ShouldRestart)
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
UserChannelPersistence.ShouldRestart = false;
|
|
|
|
|
|
|
|
Dispatcher.UIThread.Post(() =>
|
|
|
|
{
|
|
|
|
LoadApplication(_currentEmulatedGamePath);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Otherwise, clear state.
|
|
|
|
UserChannelPersistence = new UserChannelPersistence();
|
|
|
|
_currentEmulatedGamePath = null;
|
|
|
|
}
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
private void Update_StatusBar(object sender, StatusUpdatedEventArgs args)
|
|
|
|
{
|
|
|
|
if (ShowMenuAndStatusBar && !ShowLoadProgress)
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
Dispatcher.UIThread.InvokeAsync(() =>
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
Avalonia.Application.Current.Styles.TryGetResource(args.VSyncEnabled
|
|
|
|
? "VsyncEnabled"
|
|
|
|
: "VsyncDisabled", out object color);
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
if (color is not null)
|
|
|
|
{
|
|
|
|
VsyncColor = new SolidColorBrush((Color)color);
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
DockedStatusText = args.DockedMode;
|
|
|
|
AspectRatioStatusText = args.AspectRatio;
|
|
|
|
GameStatusText = args.GameStatus;
|
|
|
|
VolumeStatusText = args.VolumeStatus;
|
|
|
|
FifoStatusText = args.FifoStatus;
|
|
|
|
GpuNameText = args.GpuName;
|
|
|
|
BackendText = args.GpuBackend;
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
ShowStatusSeparator = true;
|
|
|
|
});
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
private void GlRenderer_Created(object sender, EventArgs e)
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
ShowLoading(false);
|
|
|
|
|
|
|
|
_rendererWaitEvent.Set();
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
#endregion
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
#region PublicMethods
|
|
|
|
|
|
|
|
public void SetUIProgressHandlers(Switch emulationContext)
|
|
|
|
{
|
|
|
|
if (emulationContext.Application.DiskCacheLoadState != null)
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
emulationContext.Application.DiskCacheLoadState.StateChanged -= ProgressHandler;
|
|
|
|
emulationContext.Application.DiskCacheLoadState.StateChanged += ProgressHandler;
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
2023-01-08 09:46:25 -08:00
|
|
|
|
|
|
|
emulationContext.Gpu.ShaderCacheStateChanged -= ProgressHandler;
|
|
|
|
emulationContext.Gpu.ShaderCacheStateChanged += ProgressHandler;
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
|
2022-07-05 11:06:31 -07:00
|
|
|
public void LoadConfigurableHotKeys()
|
|
|
|
{
|
2022-12-06 07:32:14 -08:00
|
|
|
if (AvaloniaKeyboardMappingHelper.TryGetAvaKey((Ryujinx.Input.Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ShowUi, out var showUiKey))
|
2022-07-05 11:06:31 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
ShowUiKey = new KeyGesture(showUiKey);
|
2022-07-05 11:06:31 -07:00
|
|
|
}
|
2022-11-25 03:41:34 -08:00
|
|
|
|
2022-12-06 07:32:14 -08:00
|
|
|
if (AvaloniaKeyboardMappingHelper.TryGetAvaKey((Ryujinx.Input.Key)ConfigurationState.Instance.Hid.Hotkeys.Value.Screenshot, out var screenshotKey))
|
2022-07-05 11:06:31 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
ScreenshotKey = new KeyGesture(screenshotKey);
|
2022-07-05 11:06:31 -07:00
|
|
|
}
|
2022-11-25 03:41:34 -08:00
|
|
|
|
2022-12-06 07:32:14 -08:00
|
|
|
if (AvaloniaKeyboardMappingHelper.TryGetAvaKey((Ryujinx.Input.Key)ConfigurationState.Instance.Hid.Hotkeys.Value.Pause, out var pauseKey))
|
2022-07-05 11:06:31 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
PauseKey = new KeyGesture(pauseKey);
|
2022-07-05 11:06:31 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-15 04:30:15 -07:00
|
|
|
public void TakeScreenshot()
|
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
AppHost.ScreenshotRequested = true;
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public void HideUi()
|
|
|
|
{
|
|
|
|
ShowMenuAndStatusBar = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetListMode()
|
|
|
|
{
|
|
|
|
Glyph = Glyph.List;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetGridMode()
|
|
|
|
{
|
|
|
|
Glyph = Glyph.Grid;
|
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public async void InstallFirmwareFromFile()
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
if (Avalonia.Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
|
|
|
{
|
|
|
|
OpenFileDialog dialog = new() { AllowMultiple = false };
|
|
|
|
dialog.Filters.Add(new FileDialogFilter { Name = LocaleManager.Instance[LocaleKeys.FileDialogAllTypes], Extensions = { "xci", "zip" } });
|
|
|
|
dialog.Filters.Add(new FileDialogFilter { Name = "XCI", Extensions = { "xci" } });
|
|
|
|
dialog.Filters.Add(new FileDialogFilter { Name = "ZIP", Extensions = { "zip" } });
|
|
|
|
|
|
|
|
string[] file = await dialog.ShowAsync(desktop.MainWindow);
|
|
|
|
|
|
|
|
if (file != null && file.Length > 0)
|
|
|
|
{
|
|
|
|
await HandleFirmwareInstallation(file[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public async void InstallFirmwareFromFolder()
|
|
|
|
{
|
|
|
|
if (Avalonia.Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
OpenFolderDialog dialog = new();
|
|
|
|
|
|
|
|
string folder = await dialog.ShowAsync(desktop.MainWindow);
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(folder))
|
|
|
|
{
|
|
|
|
await HandleFirmwareInstallation(folder);
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void OpenRyujinxFolder()
|
|
|
|
{
|
|
|
|
OpenHelper.OpenFolder(AppDataManager.BaseDirPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void OpenLogsFolder()
|
|
|
|
{
|
2023-01-07 00:06:13 -08:00
|
|
|
string logPath = Path.Combine(ReleaseInformation.GetBaseApplicationDirectory(), "Logs");
|
2022-05-15 04:30:15 -07:00
|
|
|
|
|
|
|
new DirectoryInfo(logPath).Create();
|
|
|
|
|
|
|
|
OpenHelper.OpenFolder(logPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ToggleDockMode()
|
|
|
|
{
|
|
|
|
if (IsGameRunning)
|
|
|
|
{
|
2022-11-25 03:41:34 -08:00
|
|
|
ConfigurationState.Instance.System.EnableDockedMode.Value = !ConfigurationState.Instance.System.EnableDockedMode.Value;
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public async void ExitCurrentState()
|
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
if (WindowState == WindowState.FullScreen)
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
|
|
|
ToggleFullscreen();
|
|
|
|
}
|
|
|
|
else if (IsGameRunning)
|
|
|
|
{
|
|
|
|
await Task.Delay(100);
|
2022-11-25 03:41:34 -08:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
AppHost?.ShowExitPrompt();
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public void ChangeLanguage(object obj)
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
LocaleManager.Instance.LoadDefaultLanguage();
|
|
|
|
LocaleManager.Instance.LoadLanguage((string)obj);
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
|
2022-07-08 11:47:11 -07:00
|
|
|
public async void ManageProfiles()
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
await NavigationDialogHost.Show(AccountManager, ContentManager, VirtualFileSystem, LibHacHorizonManager.RyujinxClient);
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public void OpenPtcDirectory()
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
ApplicationData selection = SelectedApplication;
|
|
|
|
if (selection != null)
|
|
|
|
{
|
|
|
|
string ptcDir = Path.Combine(AppDataManager.GamesDirPath, selection.TitleId, "cache", "cpu");
|
|
|
|
string mainPath = Path.Combine(ptcDir, "0");
|
|
|
|
string backupPath = Path.Combine(ptcDir, "1");
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
if (!Directory.Exists(ptcDir))
|
|
|
|
{
|
|
|
|
Directory.CreateDirectory(ptcDir);
|
|
|
|
Directory.CreateDirectory(mainPath);
|
|
|
|
Directory.CreateDirectory(backupPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
OpenHelper.OpenFolder(ptcDir);
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public async void PurgePtcCache()
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
ApplicationData selection = SelectedApplication;
|
|
|
|
if (selection != null)
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
DirectoryInfo mainDir = new(Path.Combine(AppDataManager.GamesDirPath, selection.TitleId, "cache", "cpu", "0"));
|
|
|
|
DirectoryInfo backupDir = new(Path.Combine(AppDataManager.GamesDirPath, selection.TitleId, "cache", "cpu", "1"));
|
2022-05-15 04:30:15 -07:00
|
|
|
|
|
|
|
// FIXME: Found a way to reproduce the bold effect on the title name (fork?).
|
2023-01-04 15:01:44 -08:00
|
|
|
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(LocaleManager.Instance[LocaleKeys.DialogWarning],
|
2023-01-03 10:45:08 -08:00
|
|
|
string.Format(LocaleManager.Instance[LocaleKeys.DialogPPTCDeletionMessage], selection.TitleName),
|
|
|
|
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
|
|
|
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
|
|
|
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
|
2022-05-15 04:30:15 -07:00
|
|
|
|
|
|
|
List<FileInfo> cacheFiles = new();
|
|
|
|
|
|
|
|
if (mainDir.Exists)
|
|
|
|
{
|
|
|
|
cacheFiles.AddRange(mainDir.EnumerateFiles("*.cache"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (backupDir.Exists)
|
|
|
|
{
|
|
|
|
cacheFiles.AddRange(backupDir.EnumerateFiles("*.cache"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cacheFiles.Count > 0 && result == UserResult.Yes)
|
|
|
|
{
|
|
|
|
foreach (FileInfo file in cacheFiles)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
file.Delete();
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
2023-01-03 10:45:08 -08:00
|
|
|
await ContentDialogHelper.CreateErrorDialog(string.Format(LocaleManager.Instance[LocaleKeys.DialogPPTCDeletionErrorMessage], file.Name, e));
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OpenShaderCacheDirectory()
|
|
|
|
{
|
2022-11-25 03:41:34 -08:00
|
|
|
ApplicationData selection = SelectedApplication;
|
2022-05-15 04:30:15 -07:00
|
|
|
if (selection != null)
|
|
|
|
{
|
|
|
|
string shaderCacheDir = Path.Combine(AppDataManager.GamesDirPath, selection.TitleId, "cache", "shader");
|
|
|
|
|
|
|
|
if (!Directory.Exists(shaderCacheDir))
|
|
|
|
{
|
|
|
|
Directory.CreateDirectory(shaderCacheDir);
|
|
|
|
}
|
|
|
|
|
|
|
|
OpenHelper.OpenFolder(shaderCacheDir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SimulateWakeUpMessage()
|
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
AppHost.Device.System.SimulateWakeUpMessage();
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public async void PurgeShaderCache()
|
|
|
|
{
|
2022-11-25 03:41:34 -08:00
|
|
|
ApplicationData selection = SelectedApplication;
|
2022-05-15 04:30:15 -07:00
|
|
|
if (selection != null)
|
|
|
|
{
|
|
|
|
DirectoryInfo shaderCacheDir = new(Path.Combine(AppDataManager.GamesDirPath, selection.TitleId, "cache", "shader"));
|
|
|
|
|
|
|
|
// FIXME: Found a way to reproduce the bold effect on the title name (fork?).
|
2023-01-03 10:45:08 -08:00
|
|
|
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(LocaleManager.Instance[LocaleKeys.DialogWarning],
|
|
|
|
string.Format(LocaleManager.Instance[LocaleKeys.DialogShaderDeletionMessage], selection.TitleName),
|
|
|
|
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
|
|
|
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
|
|
|
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2022-11-25 03:41:34 -08:00
|
|
|
List<DirectoryInfo> oldCacheDirectories = new();
|
2023-01-08 09:46:25 -08:00
|
|
|
List<FileInfo> newCacheFiles = new();
|
2022-05-15 04:30:15 -07:00
|
|
|
|
|
|
|
if (shaderCacheDir.Exists)
|
|
|
|
{
|
|
|
|
oldCacheDirectories.AddRange(shaderCacheDir.EnumerateDirectories("*"));
|
|
|
|
newCacheFiles.AddRange(shaderCacheDir.GetFiles("*.toc"));
|
|
|
|
newCacheFiles.AddRange(shaderCacheDir.GetFiles("*.data"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((oldCacheDirectories.Count > 0 || newCacheFiles.Count > 0) && result == UserResult.Yes)
|
|
|
|
{
|
|
|
|
foreach (DirectoryInfo directory in oldCacheDirectories)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
directory.Delete(true);
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
2023-01-03 10:45:08 -08:00
|
|
|
await ContentDialogHelper.CreateErrorDialog(string.Format(LocaleManager.Instance[LocaleKeys.DialogPPTCDeletionErrorMessage], directory.Name, e));
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (FileInfo file in newCacheFiles)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
file.Delete();
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
2023-01-03 10:45:08 -08:00
|
|
|
await ContentDialogHelper.CreateErrorDialog(string.Format(LocaleManager.Instance[LocaleKeys.ShaderCachePurgeError], file.Name, e));
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public void OpenDeviceSaveDirectory()
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2022-11-25 03:41:34 -08:00
|
|
|
ApplicationData selection = SelectedApplication;
|
2022-07-08 11:47:11 -07:00
|
|
|
if (selection != null)
|
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
Task.Run(() =>
|
|
|
|
{
|
|
|
|
if (!ulong.TryParse(selection.TitleId, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out ulong titleIdNumber))
|
|
|
|
{
|
|
|
|
async void Action()
|
|
|
|
{
|
|
|
|
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogRyujinxErrorMessage], LocaleManager.Instance[LocaleKeys.DialogInvalidTitleIdErrorMessage]);
|
|
|
|
}
|
|
|
|
|
|
|
|
Dispatcher.UIThread.Post(Action);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var saveDataFilter = SaveDataFilter.Make(titleIdNumber, SaveDataType.Device, userId: default, saveDataId: default, index: default);
|
|
|
|
OpenSaveDirectory(in saveDataFilter, selection, titleIdNumber);
|
|
|
|
});
|
2022-07-08 11:47:11 -07:00
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public void OpenBcatSaveDirectory()
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2022-11-25 03:41:34 -08:00
|
|
|
ApplicationData selection = SelectedApplication;
|
2022-07-08 11:47:11 -07:00
|
|
|
if (selection != null)
|
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
Task.Run(() =>
|
|
|
|
{
|
|
|
|
if (!ulong.TryParse(selection.TitleId, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out ulong titleIdNumber))
|
|
|
|
{
|
|
|
|
async void Action()
|
|
|
|
{
|
|
|
|
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogRyujinxErrorMessage], LocaleManager.Instance[LocaleKeys.DialogInvalidTitleIdErrorMessage]);
|
|
|
|
}
|
|
|
|
|
|
|
|
Dispatcher.UIThread.Post(Action);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var saveDataFilter = SaveDataFilter.Make(titleIdNumber, SaveDataType.Bcat, userId: default, saveDataId: default, index: default);
|
|
|
|
OpenSaveDirectory(in saveDataFilter, selection, titleIdNumber);
|
|
|
|
});
|
2022-07-08 11:47:11 -07:00
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public void ToggleFavorite()
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2022-11-25 03:41:34 -08:00
|
|
|
ApplicationData selection = SelectedApplication;
|
2022-07-08 11:47:11 -07:00
|
|
|
if (selection != null)
|
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
selection.Favorite = !selection.Favorite;
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
ApplicationLibrary.LoadAndSaveMetaData(selection.TitleId, appMetadata =>
|
|
|
|
{
|
|
|
|
appMetadata.Favorite = selection.Favorite;
|
|
|
|
});
|
2022-07-08 11:47:11 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
RefreshView();
|
2022-07-08 11:47:11 -07:00
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public void OpenUserSaveDirectory()
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2022-11-25 03:41:34 -08:00
|
|
|
ApplicationData selection = SelectedApplication;
|
2022-05-15 04:30:15 -07:00
|
|
|
if (selection != null)
|
|
|
|
{
|
|
|
|
Task.Run(() =>
|
|
|
|
{
|
2022-11-25 03:41:34 -08:00
|
|
|
if (!ulong.TryParse(selection.TitleId, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out ulong titleIdNumber))
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
async void Action()
|
2022-07-11 15:25:33 -07:00
|
|
|
{
|
2023-01-03 10:45:08 -08:00
|
|
|
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogRyujinxErrorMessage], LocaleManager.Instance[LocaleKeys.DialogInvalidTitleIdErrorMessage]);
|
2023-01-08 09:46:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
Dispatcher.UIThread.Post(Action);
|
2022-05-15 04:30:15 -07:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
UserId userId = new((ulong)AccountManager.LastOpenedUser.UserId.High, (ulong)AccountManager.LastOpenedUser.UserId.Low);
|
|
|
|
SaveDataFilter saveDataFilter = SaveDataFilter.Make(titleIdNumber, saveType: default, userId, saveDataId: default, index: default);
|
2022-05-15 04:30:15 -07:00
|
|
|
OpenSaveDirectory(in saveDataFilter, selection, titleIdNumber);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public void OpenModsDirectory()
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2022-11-25 03:41:34 -08:00
|
|
|
ApplicationData selection = SelectedApplication;
|
2022-05-15 04:30:15 -07:00
|
|
|
if (selection != null)
|
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
string modsBasePath = VirtualFileSystem.ModLoader.GetModsBasePath();
|
|
|
|
string titleModsPath = VirtualFileSystem.ModLoader.GetTitleDir(modsBasePath, selection.TitleId);
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
OpenHelper.OpenFolder(titleModsPath);
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public void OpenSdModsDirectory()
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
ApplicationData selection = SelectedApplication;
|
|
|
|
|
|
|
|
if (selection != null)
|
|
|
|
{
|
|
|
|
string sdModsBasePath = VirtualFileSystem.ModLoader.GetSdModsBasePath();
|
|
|
|
string titleModsPath = VirtualFileSystem.ModLoader.GetTitleDir(sdModsBasePath, selection.TitleId);
|
|
|
|
|
|
|
|
OpenHelper.OpenFolder(titleModsPath);
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public async void OpenTitleUpdateManager()
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
ApplicationData selection = SelectedApplication;
|
2022-05-15 04:30:15 -07:00
|
|
|
if (selection != null)
|
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
if (Avalonia.Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
|
|
|
{
|
|
|
|
await new TitleUpdateWindow(VirtualFileSystem, ulong.Parse(selection.TitleId, NumberStyles.HexNumber), selection.TitleName).ShowDialog(desktop.MainWindow);
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public async void OpenDownloadableContentManager()
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
ApplicationData selection = SelectedApplication;
|
2022-05-15 04:30:15 -07:00
|
|
|
if (selection != null)
|
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
if (Avalonia.Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
|
|
|
{
|
|
|
|
await new DownloadableContentManagerWindow(VirtualFileSystem, ulong.Parse(selection.TitleId, NumberStyles.HexNumber), selection.TitleName).ShowDialog(desktop.MainWindow);
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public async void OpenCheatManager()
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
ApplicationData selection = SelectedApplication;
|
2022-05-15 04:30:15 -07:00
|
|
|
if (selection != null)
|
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
if (Avalonia.Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
|
|
|
{
|
|
|
|
await new CheatWindow(VirtualFileSystem, selection.TitleId, selection.TitleName).ShowDialog(desktop.MainWindow);
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public async void LoadApplications()
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
|
{
|
|
|
|
Applications.Clear();
|
|
|
|
|
|
|
|
StatusBarVisible = true;
|
|
|
|
StatusBarProgressMaximum = 0;
|
|
|
|
StatusBarProgressValue = 0;
|
|
|
|
|
|
|
|
LocaleManager.Instance.UpdateDynamicValue(LocaleKeys.StatusBarGamesLoaded, 0, 0);
|
|
|
|
});
|
|
|
|
|
|
|
|
ReloadGameList?.Invoke();
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public async void OpenFile()
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
if (Avalonia.Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
OpenFileDialog dialog = new()
|
|
|
|
{
|
|
|
|
Title = LocaleManager.Instance[LocaleKeys.OpenFileDialogTitle]
|
|
|
|
};
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
dialog.Filters.Add(new FileDialogFilter
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
Name = LocaleManager.Instance[LocaleKeys.AllSupportedFormats],
|
|
|
|
Extensions =
|
|
|
|
{
|
|
|
|
"nsp",
|
|
|
|
"pfs0",
|
|
|
|
"xci",
|
|
|
|
"nca",
|
|
|
|
"nro",
|
|
|
|
"nso"
|
|
|
|
}
|
|
|
|
});
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
dialog.Filters.Add(new FileDialogFilter { Name = "NSP", Extensions = { "nsp" } });
|
|
|
|
dialog.Filters.Add(new FileDialogFilter { Name = "PFS0", Extensions = { "pfs0" } });
|
|
|
|
dialog.Filters.Add(new FileDialogFilter { Name = "XCI", Extensions = { "xci" } });
|
|
|
|
dialog.Filters.Add(new FileDialogFilter { Name = "NCA", Extensions = { "nca" } });
|
|
|
|
dialog.Filters.Add(new FileDialogFilter { Name = "NRO", Extensions = { "nro" } });
|
|
|
|
dialog.Filters.Add(new FileDialogFilter { Name = "NSO", Extensions = { "nso" } });
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
string[] files = await dialog.ShowAsync(desktop.MainWindow);
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
if (files != null && files.Length > 0)
|
|
|
|
{
|
|
|
|
LoadApplication(files[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public async void OpenFolder()
|
|
|
|
{
|
|
|
|
if (Avalonia.Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
|
|
|
{
|
|
|
|
OpenFolderDialog dialog = new()
|
|
|
|
{
|
|
|
|
Title = LocaleManager.Instance[LocaleKeys.OpenFolderDialogTitle]
|
|
|
|
};
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
string folder = await dialog.ShowAsync(desktop.MainWindow);
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(folder) && Directory.Exists(folder))
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
LoadApplication(folder);
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
2023-01-08 09:46:25 -08:00
|
|
|
}
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public async void LoadApplication(string path, bool startFullscreen = false, string titleName = "")
|
|
|
|
{
|
|
|
|
if (AppHost != null)
|
|
|
|
{
|
|
|
|
await ContentDialogHelper.CreateInfoDialog(
|
|
|
|
LocaleManager.Instance[LocaleKeys.DialogLoadAppGameAlreadyLoadedMessage],
|
|
|
|
LocaleManager.Instance[LocaleKeys.DialogLoadAppGameAlreadyLoadedSubMessage],
|
|
|
|
LocaleManager.Instance[LocaleKeys.InputDialogOk],
|
|
|
|
"",
|
|
|
|
LocaleManager.Instance[LocaleKeys.RyujinxInfo]);
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
return;
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
#if RELEASE
|
|
|
|
await PerformanceCheck();
|
|
|
|
#endif
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
Logger.RestartTime();
|
|
|
|
|
|
|
|
if (SelectedIcon == null)
|
|
|
|
{
|
|
|
|
SelectedIcon = ApplicationLibrary.GetApplicationIcon(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
PrepareLoadScreen();
|
|
|
|
|
|
|
|
RendererControl = new RendererHost(ConfigurationState.Instance.Logger.GraphicsDebugLevel);
|
|
|
|
if (ConfigurationState.Instance.Graphics.GraphicsBackend.Value == GraphicsBackend.OpenGl)
|
|
|
|
{
|
|
|
|
RendererControl.CreateOpenGL();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RendererControl.CreateVulkan();
|
|
|
|
}
|
|
|
|
|
|
|
|
AppHost = new AppHost(
|
|
|
|
RendererControl,
|
|
|
|
InputManager,
|
|
|
|
path,
|
|
|
|
VirtualFileSystem,
|
|
|
|
ContentManager,
|
|
|
|
AccountManager,
|
|
|
|
UserChannelPersistence,
|
|
|
|
this,
|
|
|
|
TopLevel);
|
|
|
|
|
|
|
|
async void Action()
|
|
|
|
{
|
|
|
|
if (!await AppHost.LoadGuestApplication())
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
AppHost.DisposeContext();
|
|
|
|
AppHost = null;
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
return;
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
CanUpdate = false;
|
|
|
|
LoadHeading = string.IsNullOrWhiteSpace(titleName) ? string.Format(LocaleManager.Instance[LocaleKeys.LoadingHeading], AppHost.Device.Application.TitleName) : titleName;
|
|
|
|
TitleName = string.IsNullOrWhiteSpace(titleName) ? AppHost.Device.Application.TitleName : titleName;
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
SwitchToRenderer(startFullscreen);
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
_currentEmulatedGamePath = path;
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
Thread gameThread = new(InitializeGame) { Name = "GUI.WindowThread" };
|
|
|
|
gameThread.Start();
|
|
|
|
}
|
2022-11-25 03:41:34 -08:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
Dispatcher.UIThread.Post(Action);
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public void SwitchToRenderer(bool startFullscreen)
|
|
|
|
{
|
|
|
|
Dispatcher.UIThread.Post(() =>
|
|
|
|
{
|
|
|
|
SwitchToGameControl(startFullscreen);
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
SetMainContent(RendererControl);
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
RendererControl.Focus();
|
|
|
|
});
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public void UpdateGameMetadata(string titleId)
|
|
|
|
{
|
|
|
|
ApplicationLibrary.LoadAndSaveMetaData(titleId, appMetadata =>
|
|
|
|
{
|
|
|
|
if (DateTime.TryParse(appMetadata.LastPlayed, out DateTime lastPlayedDateTime))
|
|
|
|
{
|
|
|
|
double sessionTimePlayed = DateTime.UtcNow.Subtract(lastPlayedDateTime).TotalSeconds;
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
appMetadata.TimePlayed += Math.Round(sessionTimePlayed, MidpointRounding.AwayFromZero);
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
2023-01-08 09:46:25 -08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public void RefreshFirmwareStatus()
|
|
|
|
{
|
|
|
|
SystemVersion version = null;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
version = ContentManager.GetCurrentFirmwareVersion();
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
2023-01-08 09:46:25 -08:00
|
|
|
catch (Exception) { }
|
|
|
|
|
|
|
|
bool hasApplet = false;
|
|
|
|
|
|
|
|
if (version != null)
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
LocaleManager.Instance.UpdateDynamicValue(LocaleKeys.StatusBarSystemVersion,
|
|
|
|
version.VersionString);
|
2022-11-25 03:41:34 -08:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
hasApplet = version.Major > 3;
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
2023-01-08 09:46:25 -08:00
|
|
|
else
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
LocaleManager.Instance.UpdateDynamicValue(LocaleKeys.StatusBarSystemVersion, "0.0");
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
2023-01-08 09:46:25 -08:00
|
|
|
|
|
|
|
IsAppletMenuActive = hasApplet;
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public void AppHost_AppExit(object sender, EventArgs e)
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
if (IsClosing)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
IsGameRunning = false;
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
Dispatcher.UIThread.InvokeAsync(() =>
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
ShowMenuAndStatusBar = true;
|
|
|
|
ShowContent = true;
|
|
|
|
ShowLoadProgress = false;
|
|
|
|
IsLoadingIndeterminate = false;
|
|
|
|
CanUpdate = true;
|
|
|
|
Cursor = Cursor.Default;
|
|
|
|
|
|
|
|
SetMainContent(null);
|
|
|
|
|
|
|
|
AppHost = null;
|
|
|
|
|
|
|
|
HandleRelaunch();
|
|
|
|
});
|
|
|
|
|
|
|
|
RendererControl.RendererInitialized -= GlRenderer_Created;
|
|
|
|
RendererControl = null;
|
|
|
|
|
|
|
|
SelectedIcon = null;
|
|
|
|
|
|
|
|
Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
|
{
|
|
|
|
Title = $"Ryujinx {Program.Version}";
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ToggleFullscreen()
|
|
|
|
{
|
|
|
|
if (Environment.TickCount64 - LastFullscreenToggle < HotKeyPressDelayMs)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
LastFullscreenToggle = Environment.TickCount64;
|
|
|
|
|
|
|
|
if (WindowState == WindowState.FullScreen)
|
|
|
|
{
|
|
|
|
WindowState = WindowState.Normal;
|
|
|
|
|
|
|
|
if (IsGameRunning)
|
|
|
|
{
|
|
|
|
ShowMenuAndStatusBar = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WindowState = WindowState.FullScreen;
|
|
|
|
|
|
|
|
if (IsGameRunning)
|
|
|
|
{
|
|
|
|
ShowMenuAndStatusBar = false;
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
2023-01-08 09:46:25 -08:00
|
|
|
|
|
|
|
IsFullScreen = WindowState == WindowState.FullScreen;
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public static void SaveConfig()
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
public static async Task PerformanceCheck()
|
|
|
|
{
|
|
|
|
if (ConfigurationState.Instance.Logger.EnableTrace.Value)
|
|
|
|
{
|
|
|
|
string mainMessage = LocaleManager.Instance[LocaleKeys.DialogPerformanceCheckLoggingEnabledMessage];
|
|
|
|
string secondaryMessage = LocaleManager.Instance[LocaleKeys.DialogPerformanceCheckLoggingEnabledConfirmMessage];
|
2022-05-15 04:30:15 -07:00
|
|
|
|
2023-01-08 09:46:25 -08:00
|
|
|
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(
|
|
|
|
mainMessage,
|
|
|
|
secondaryMessage,
|
|
|
|
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
|
|
|
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
|
|
|
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
|
|
|
|
|
|
|
|
if (result != UserResult.Yes)
|
|
|
|
{
|
|
|
|
ConfigurationState.Instance.Logger.EnableTrace.Value = false;
|
|
|
|
|
|
|
|
SaveConfig();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(ConfigurationState.Instance.Graphics.ShadersDumpPath.Value))
|
2022-05-15 04:30:15 -07:00
|
|
|
{
|
2023-01-08 09:46:25 -08:00
|
|
|
string mainMessage = LocaleManager.Instance[LocaleKeys.DialogPerformanceCheckShaderDumpEnabledMessage];
|
|
|
|
string secondaryMessage = LocaleManager.Instance[LocaleKeys.DialogPerformanceCheckShaderDumpEnabledConfirmMessage];
|
|
|
|
|
|
|
|
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(
|
|
|
|
mainMessage,
|
|
|
|
secondaryMessage,
|
|
|
|
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
|
|
|
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
|
|
|
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
|
|
|
|
|
|
|
|
if (result != UserResult.Yes)
|
|
|
|
{
|
|
|
|
ConfigurationState.Instance.Graphics.ShadersDumpPath.Value = "";
|
|
|
|
|
|
|
|
SaveConfig();
|
|
|
|
}
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
}
|
2023-01-08 09:46:25 -08:00
|
|
|
|
|
|
|
#endregion
|
2022-05-15 04:30:15 -07:00
|
|
|
}
|
|
|
|
}
|