mirror of
https://github.com/GreemDev/Ryujinx
synced 2024-11-24 10:46:54 +01:00
misc: Code cleanups
This commit is contained in:
parent
2facad4be3
commit
b20613661c
9 changed files with 52 additions and 84 deletions
|
@ -3,7 +3,7 @@ using System.Numerics;
|
|||
|
||||
namespace Ryujinx.Graphics.Texture.Astc
|
||||
{
|
||||
internal struct IntegerEncoded
|
||||
internal struct IntegerEncoded(IntegerEncoded.EIntegerEncoding encoding, int numBits)
|
||||
{
|
||||
internal const int StructSize = 8;
|
||||
private static readonly IntegerEncoded[] _encodings;
|
||||
|
@ -15,11 +15,11 @@ namespace Ryujinx.Graphics.Texture.Astc
|
|||
Trit,
|
||||
}
|
||||
|
||||
readonly EIntegerEncoding _encoding;
|
||||
public byte NumberBits { get; private set; }
|
||||
public byte TritValue { get; private set; }
|
||||
public byte QuintValue { get; private set; }
|
||||
public int BitValue { get; private set; }
|
||||
readonly EIntegerEncoding _encoding = encoding;
|
||||
public byte NumberBits { get; } = (byte)numBits;
|
||||
public byte TritValue { get; private set; } = 0;
|
||||
public byte QuintValue { get; private set; } = 0;
|
||||
public int BitValue { get; private set; } = 0;
|
||||
|
||||
static IntegerEncoded()
|
||||
{
|
||||
|
@ -31,15 +31,6 @@ namespace Ryujinx.Graphics.Texture.Astc
|
|||
}
|
||||
}
|
||||
|
||||
public IntegerEncoded(EIntegerEncoding encoding, int numBits)
|
||||
{
|
||||
_encoding = encoding;
|
||||
NumberBits = (byte)numBits;
|
||||
BitValue = 0;
|
||||
TritValue = 0;
|
||||
QuintValue = 0;
|
||||
}
|
||||
|
||||
public readonly bool MatchesEncoding(IntegerEncoded other)
|
||||
{
|
||||
return _encoding == other._encoding && NumberBits == other.NumberBits;
|
||||
|
|
|
@ -15,14 +15,8 @@ namespace Ryujinx.HLE.HOS.Applets
|
|||
|
||||
ResultCode GetResult();
|
||||
|
||||
bool DrawTo(RenderingSurfaceInfo surfaceInfo, IVirtualMemoryManager destination, ulong position)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool DrawTo(RenderingSurfaceInfo surfaceInfo, IVirtualMemoryManager destination, ulong position) => false;
|
||||
|
||||
static T ReadStruct<T>(ReadOnlySpan<byte> data) where T : unmanaged
|
||||
{
|
||||
return MemoryMarshal.Cast<byte, T>(data)[0];
|
||||
}
|
||||
static T ReadStruct<T>(ReadOnlySpan<byte> data) where T : unmanaged => MemoryMarshal.Cast<byte, T>(data)[0];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib
|
|||
{
|
||||
// NOTE: This call reset two internal fields to 0 and one internal field to "true".
|
||||
// It seems to be used only with software keyboard inline.
|
||||
// Since we doesn't support applets for now, it's fine to stub it.
|
||||
// Since we don't support applets for now, it's fine to stub it.
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceAm);
|
||||
|
||||
|
|
|
@ -2,18 +2,13 @@ using System;
|
|||
|
||||
namespace Ryujinx.Input.HLE
|
||||
{
|
||||
public class InputManager : IDisposable
|
||||
public class InputManager(IGamepadDriver keyboardDriver, IGamepadDriver gamepadDriver)
|
||||
: IDisposable
|
||||
{
|
||||
public IGamepadDriver KeyboardDriver { get; private set; }
|
||||
public IGamepadDriver GamepadDriver { get; private set; }
|
||||
public IGamepadDriver KeyboardDriver { get; } = keyboardDriver;
|
||||
public IGamepadDriver GamepadDriver { get; } = gamepadDriver;
|
||||
public IGamepadDriver MouseDriver { get; private set; }
|
||||
|
||||
public InputManager(IGamepadDriver keyboardDriver, IGamepadDriver gamepadDriver)
|
||||
{
|
||||
KeyboardDriver = keyboardDriver;
|
||||
GamepadDriver = gamepadDriver;
|
||||
}
|
||||
|
||||
public void SetMouseDriver(IGamepadDriver mouseDriver)
|
||||
{
|
||||
MouseDriver?.Dispose();
|
||||
|
|
|
@ -4,6 +4,8 @@ using Avalonia.Markup.Xaml;
|
|||
using Avalonia.Platform;
|
||||
using Avalonia.Styling;
|
||||
using Avalonia.Threading;
|
||||
using FluentAvalonia.UI.Windowing;
|
||||
using Gommon;
|
||||
using Ryujinx.Ava.Common;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.UI.Helpers;
|
||||
|
@ -24,6 +26,15 @@ namespace Ryujinx.Ava
|
|||
? $"Ryujinx {Program.Version}"
|
||||
: $"Ryujinx {Program.Version} - {LocaleManager.Instance[windowTitleKey.Value]}";
|
||||
|
||||
public static MainWindow MainWindow => Current!
|
||||
.ApplicationLifetime.Cast<IClassicDesktopStyleApplicationLifetime>()
|
||||
.MainWindow.Cast<MainWindow>();
|
||||
|
||||
public static void SetTaskbarProgress(TaskBarProgressBarState state) => MainWindow.PlatformFeatures.SetTaskBarProgressBarState(state);
|
||||
public static void SetTaskbarProgressValue(ulong current, ulong total) => MainWindow.PlatformFeatures.SetTaskBarProgressBarValue(current, total);
|
||||
public static void SetTaskbarProgressValue(long current, long total) => SetTaskbarProgressValue(Convert.ToUInt64(current), Convert.ToUInt64(total));
|
||||
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
Name = FormatTitle();
|
||||
|
@ -62,8 +73,7 @@ namespace Ryujinx.Ava
|
|||
|
||||
private void ShowRestartDialog()
|
||||
{
|
||||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
Dispatcher.UIThread.InvokeAsync(async () =>
|
||||
_ = Dispatcher.UIThread.InvokeAsync(async () =>
|
||||
{
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
|
@ -82,7 +92,6 @@ namespace Ryujinx.Ava
|
|||
}
|
||||
}
|
||||
});
|
||||
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
}
|
||||
|
||||
private void ThemeChanged_Event(object sender, ReactiveEventArgs<string> e)
|
||||
|
@ -134,16 +143,9 @@ namespace Ryujinx.Ava
|
|||
_ => ThemeVariant.Default,
|
||||
};
|
||||
|
||||
public static ThemeVariant DetectSystemTheme()
|
||||
{
|
||||
if (Application.Current is App app)
|
||||
{
|
||||
var colorValues = app.PlatformSettings.GetColorValues();
|
||||
|
||||
return ConvertThemeVariant(colorValues.ThemeVariant);
|
||||
}
|
||||
|
||||
return ThemeVariant.Default;
|
||||
}
|
||||
public static ThemeVariant DetectSystemTheme() =>
|
||||
Current is App { PlatformSettings: not null } app
|
||||
? ConvertThemeVariant(app.PlatformSettings.GetColorValues().ThemeVariant)
|
||||
: ThemeVariant.Default;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -466,7 +466,7 @@ namespace Ryujinx.Modules
|
|||
using Stream updateFileStream = File.Open(updateFile, FileMode.Create);
|
||||
|
||||
long totalBytes = response.Content.Headers.ContentLength.Value;
|
||||
long byteWritten = 0;
|
||||
long bytesWritten = 0;
|
||||
|
||||
byte[] buffer = new byte[32 * 1024];
|
||||
|
||||
|
@ -479,9 +479,10 @@ namespace Ryujinx.Modules
|
|||
break;
|
||||
}
|
||||
|
||||
byteWritten += readSize;
|
||||
bytesWritten += readSize;
|
||||
|
||||
taskDialog.SetProgressBarState(GetPercentage(byteWritten, totalBytes), TaskDialogProgressState.Normal);
|
||||
taskDialog.SetProgressBarState(GetPercentage(bytesWritten, totalBytes), TaskDialogProgressState.Normal);
|
||||
App.SetTaskbarProgressValue(bytesWritten, totalBytes);
|
||||
|
||||
updateFileStream.Write(buffer, 0, readSize);
|
||||
}
|
||||
|
|
|
@ -198,9 +198,6 @@ namespace Ryujinx.Ava.UI.Applet
|
|||
return showDetails;
|
||||
}
|
||||
|
||||
public IDynamicTextInputHandler CreateDynamicTextInputHandler()
|
||||
{
|
||||
return new AvaloniaDynamicTextInputHandler(_parent);
|
||||
}
|
||||
public IDynamicTextInputHandler CreateDynamicTextInputHandler() => new AvaloniaDynamicTextInputHandler(_parent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,14 +102,8 @@ namespace Ryujinx.Ava.UI.Applet
|
|||
|
||||
public bool TextProcessingEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return Volatile.Read(ref _canProcessInput);
|
||||
}
|
||||
set
|
||||
{
|
||||
Volatile.Write(ref _canProcessInput, value);
|
||||
}
|
||||
get => Volatile.Read(ref _canProcessInput);
|
||||
set => Volatile.Write(ref _canProcessInput, value);
|
||||
}
|
||||
|
||||
public event DynamicTextChangedHandler TextChangedEvent;
|
||||
|
@ -135,17 +129,14 @@ namespace Ryujinx.Ava.UI.Applet
|
|||
});
|
||||
}
|
||||
|
||||
public void SetText(string text, int cursorBegin)
|
||||
{
|
||||
public void SetText(string text, int cursorBegin) =>
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
_hiddenTextBox.Text = text;
|
||||
_hiddenTextBox.CaretIndex = cursorBegin;
|
||||
});
|
||||
}
|
||||
|
||||
public void SetText(string text, int cursorBegin, int cursorEnd)
|
||||
{
|
||||
public void SetText(string text, int cursorBegin, int cursorEnd) =>
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
_hiddenTextBox.Text = text;
|
||||
|
@ -153,5 +144,4 @@ namespace Ryujinx.Ava.UI.Applet
|
|||
_hiddenTextBox.SelectionEnd = cursorEnd;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||
return await ShowContentDialog(title, content, primaryButton, secondaryButton, closeButton, primaryButtonResult, deferResetEvent, deferCloseAction);
|
||||
}
|
||||
|
||||
public static Task<UserResult> ShowDeferredContentDialog(
|
||||
public static async Task<UserResult> ShowDeferredContentDialog(
|
||||
Window window,
|
||||
string title,
|
||||
string primaryText,
|
||||
|
@ -98,7 +98,7 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||
{
|
||||
bool startedDeferring = false;
|
||||
|
||||
return ShowTextDialog(
|
||||
return await ShowTextDialog(
|
||||
title,
|
||||
primaryText,
|
||||
secondaryText,
|
||||
|
@ -209,14 +209,14 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||
closeButton,
|
||||
(int)Symbol.Important);
|
||||
|
||||
internal static Task<UserResult> CreateConfirmationDialog(
|
||||
internal static async Task<UserResult> CreateConfirmationDialog(
|
||||
string primaryText,
|
||||
string secondaryText,
|
||||
string acceptButtonText,
|
||||
string cancelButtonText,
|
||||
string title,
|
||||
UserResult primaryButtonResult = UserResult.Yes)
|
||||
=> ShowTextDialog(
|
||||
=> await ShowTextDialog(
|
||||
string.IsNullOrWhiteSpace(title) ? LocaleManager.Instance[LocaleKeys.DialogConfirmationTitle] : title,
|
||||
primaryText,
|
||||
secondaryText,
|
||||
|
@ -226,16 +226,16 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||
(int)Symbol.Help,
|
||||
primaryButtonResult);
|
||||
|
||||
internal static Task<UserResult> CreateLocalizedConfirmationDialog(string primaryText, string secondaryText)
|
||||
=> CreateConfirmationDialog(
|
||||
internal static async Task<UserResult> CreateLocalizedConfirmationDialog(string primaryText, string secondaryText)
|
||||
=> await CreateConfirmationDialog(
|
||||
primaryText,
|
||||
secondaryText,
|
||||
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
||||
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
||||
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
|
||||
|
||||
internal static Task CreateUpdaterInfoDialog(string primary, string secondaryText)
|
||||
=> ShowTextDialog(
|
||||
internal static async Task CreateUpdaterInfoDialog(string primary, string secondaryText)
|
||||
=> await ShowTextDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterTitle],
|
||||
primary,
|
||||
secondaryText,
|
||||
|
@ -244,8 +244,8 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||
LocaleManager.Instance[LocaleKeys.InputDialogOk],
|
||||
(int)Symbol.Important);
|
||||
|
||||
internal static Task CreateWarningDialog(string primary, string secondaryText)
|
||||
=> ShowTextDialog(
|
||||
internal static async Task CreateWarningDialog(string primary, string secondaryText)
|
||||
=> await ShowTextDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogWarningTitle],
|
||||
primary,
|
||||
secondaryText,
|
||||
|
@ -254,11 +254,11 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||
LocaleManager.Instance[LocaleKeys.InputDialogOk],
|
||||
(int)Symbol.Important);
|
||||
|
||||
internal static Task CreateErrorDialog(string errorMessage, string secondaryErrorMessage = "")
|
||||
internal static async Task CreateErrorDialog(string errorMessage, string secondaryErrorMessage = "")
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application, errorMessage);
|
||||
|
||||
return ShowTextDialog(
|
||||
await ShowTextDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogErrorTitle],
|
||||
LocaleManager.Instance[LocaleKeys.DialogErrorMessage],
|
||||
errorMessage,
|
||||
|
@ -399,11 +399,9 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||
return result;
|
||||
}
|
||||
|
||||
public static Task ShowWindowAsync(Window dialogWindow, Window mainWindow = null)
|
||||
public static async Task ShowWindowAsync(Window dialogWindow, Window mainWindow = null)
|
||||
{
|
||||
mainWindow ??= GetMainWindow();
|
||||
|
||||
return dialogWindow.ShowDialog(_contentDialogOverlayWindow ?? mainWindow);
|
||||
await dialogWindow.ShowDialog(_contentDialogOverlayWindow ?? mainWindow ?? GetMainWindow());
|
||||
}
|
||||
|
||||
private static Window GetMainWindow()
|
||||
|
|
Loading…
Reference in a new issue