mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-11-24 02:00:11 +01:00
misc: Code cleanups
This commit is contained in:
parent
2facad4be3
commit
b20613661c
@ -3,7 +3,7 @@ using System.Numerics;
|
|||||||
|
|
||||||
namespace Ryujinx.Graphics.Texture.Astc
|
namespace Ryujinx.Graphics.Texture.Astc
|
||||||
{
|
{
|
||||||
internal struct IntegerEncoded
|
internal struct IntegerEncoded(IntegerEncoded.EIntegerEncoding encoding, int numBits)
|
||||||
{
|
{
|
||||||
internal const int StructSize = 8;
|
internal const int StructSize = 8;
|
||||||
private static readonly IntegerEncoded[] _encodings;
|
private static readonly IntegerEncoded[] _encodings;
|
||||||
@ -15,11 +15,11 @@ namespace Ryujinx.Graphics.Texture.Astc
|
|||||||
Trit,
|
Trit,
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly EIntegerEncoding _encoding;
|
readonly EIntegerEncoding _encoding = encoding;
|
||||||
public byte NumberBits { get; private set; }
|
public byte NumberBits { get; } = (byte)numBits;
|
||||||
public byte TritValue { get; private set; }
|
public byte TritValue { get; private set; } = 0;
|
||||||
public byte QuintValue { get; private set; }
|
public byte QuintValue { get; private set; } = 0;
|
||||||
public int BitValue { get; private set; }
|
public int BitValue { get; private set; } = 0;
|
||||||
|
|
||||||
static IntegerEncoded()
|
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)
|
public readonly bool MatchesEncoding(IntegerEncoded other)
|
||||||
{
|
{
|
||||||
return _encoding == other._encoding && NumberBits == other.NumberBits;
|
return _encoding == other._encoding && NumberBits == other.NumberBits;
|
||||||
|
@ -15,14 +15,8 @@ namespace Ryujinx.HLE.HOS.Applets
|
|||||||
|
|
||||||
ResultCode GetResult();
|
ResultCode GetResult();
|
||||||
|
|
||||||
bool DrawTo(RenderingSurfaceInfo surfaceInfo, IVirtualMemoryManager destination, ulong position)
|
bool DrawTo(RenderingSurfaceInfo surfaceInfo, IVirtualMemoryManager destination, ulong position) => false;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static T ReadStruct<T>(ReadOnlySpan<byte> data) where T : unmanaged
|
static T ReadStruct<T>(ReadOnlySpan<byte> data) where T : unmanaged => MemoryMarshal.Cast<byte, T>(data)[0];
|
||||||
{
|
|
||||||
return 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".
|
// 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.
|
// 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);
|
Logger.Stub?.PrintStub(LogClass.ServiceAm);
|
||||||
|
|
||||||
|
@ -2,18 +2,13 @@ using System;
|
|||||||
|
|
||||||
namespace Ryujinx.Input.HLE
|
namespace Ryujinx.Input.HLE
|
||||||
{
|
{
|
||||||
public class InputManager : IDisposable
|
public class InputManager(IGamepadDriver keyboardDriver, IGamepadDriver gamepadDriver)
|
||||||
|
: IDisposable
|
||||||
{
|
{
|
||||||
public IGamepadDriver KeyboardDriver { get; private set; }
|
public IGamepadDriver KeyboardDriver { get; } = keyboardDriver;
|
||||||
public IGamepadDriver GamepadDriver { get; private set; }
|
public IGamepadDriver GamepadDriver { get; } = gamepadDriver;
|
||||||
public IGamepadDriver MouseDriver { get; private set; }
|
public IGamepadDriver MouseDriver { get; private set; }
|
||||||
|
|
||||||
public InputManager(IGamepadDriver keyboardDriver, IGamepadDriver gamepadDriver)
|
|
||||||
{
|
|
||||||
KeyboardDriver = keyboardDriver;
|
|
||||||
GamepadDriver = gamepadDriver;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetMouseDriver(IGamepadDriver mouseDriver)
|
public void SetMouseDriver(IGamepadDriver mouseDriver)
|
||||||
{
|
{
|
||||||
MouseDriver?.Dispose();
|
MouseDriver?.Dispose();
|
||||||
|
@ -4,6 +4,8 @@ using Avalonia.Markup.Xaml;
|
|||||||
using Avalonia.Platform;
|
using Avalonia.Platform;
|
||||||
using Avalonia.Styling;
|
using Avalonia.Styling;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
|
using FluentAvalonia.UI.Windowing;
|
||||||
|
using Gommon;
|
||||||
using Ryujinx.Ava.Common;
|
using Ryujinx.Ava.Common;
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
using Ryujinx.Ava.UI.Helpers;
|
using Ryujinx.Ava.UI.Helpers;
|
||||||
@ -24,6 +26,15 @@ namespace Ryujinx.Ava
|
|||||||
? $"Ryujinx {Program.Version}"
|
? $"Ryujinx {Program.Version}"
|
||||||
: $"Ryujinx {Program.Version} - {LocaleManager.Instance[windowTitleKey.Value]}";
|
: $"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()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
Name = FormatTitle();
|
Name = FormatTitle();
|
||||||
@ -62,8 +73,7 @@ namespace Ryujinx.Ava
|
|||||||
|
|
||||||
private void ShowRestartDialog()
|
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)
|
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)
|
private void ThemeChanged_Event(object sender, ReactiveEventArgs<string> e)
|
||||||
@ -134,16 +143,9 @@ namespace Ryujinx.Ava
|
|||||||
_ => ThemeVariant.Default,
|
_ => ThemeVariant.Default,
|
||||||
};
|
};
|
||||||
|
|
||||||
public static ThemeVariant DetectSystemTheme()
|
public static ThemeVariant DetectSystemTheme() =>
|
||||||
{
|
Current is App { PlatformSettings: not null } app
|
||||||
if (Application.Current is App app)
|
? ConvertThemeVariant(app.PlatformSettings.GetColorValues().ThemeVariant)
|
||||||
{
|
: ThemeVariant.Default;
|
||||||
var colorValues = app.PlatformSettings.GetColorValues();
|
|
||||||
|
|
||||||
return ConvertThemeVariant(colorValues.ThemeVariant);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ThemeVariant.Default;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -466,7 +466,7 @@ namespace Ryujinx.Modules
|
|||||||
using Stream updateFileStream = File.Open(updateFile, FileMode.Create);
|
using Stream updateFileStream = File.Open(updateFile, FileMode.Create);
|
||||||
|
|
||||||
long totalBytes = response.Content.Headers.ContentLength.Value;
|
long totalBytes = response.Content.Headers.ContentLength.Value;
|
||||||
long byteWritten = 0;
|
long bytesWritten = 0;
|
||||||
|
|
||||||
byte[] buffer = new byte[32 * 1024];
|
byte[] buffer = new byte[32 * 1024];
|
||||||
|
|
||||||
@ -479,9 +479,10 @@ namespace Ryujinx.Modules
|
|||||||
break;
|
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);
|
updateFileStream.Write(buffer, 0, readSize);
|
||||||
}
|
}
|
||||||
|
@ -198,9 +198,6 @@ namespace Ryujinx.Ava.UI.Applet
|
|||||||
return showDetails;
|
return showDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDynamicTextInputHandler CreateDynamicTextInputHandler()
|
public IDynamicTextInputHandler CreateDynamicTextInputHandler() => new AvaloniaDynamicTextInputHandler(_parent);
|
||||||
{
|
|
||||||
return new AvaloniaDynamicTextInputHandler(_parent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,14 +102,8 @@ namespace Ryujinx.Ava.UI.Applet
|
|||||||
|
|
||||||
public bool TextProcessingEnabled
|
public bool TextProcessingEnabled
|
||||||
{
|
{
|
||||||
get
|
get => Volatile.Read(ref _canProcessInput);
|
||||||
{
|
set => Volatile.Write(ref _canProcessInput, value);
|
||||||
return Volatile.Read(ref _canProcessInput);
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
Volatile.Write(ref _canProcessInput, value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public event DynamicTextChangedHandler TextChangedEvent;
|
public event DynamicTextChangedHandler TextChangedEvent;
|
||||||
@ -135,23 +129,19 @@ namespace Ryujinx.Ava.UI.Applet
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetText(string text, int cursorBegin)
|
public void SetText(string text, int cursorBegin) =>
|
||||||
{
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
Dispatcher.UIThread.Post(() =>
|
||||||
{
|
{
|
||||||
_hiddenTextBox.Text = text;
|
_hiddenTextBox.Text = text;
|
||||||
_hiddenTextBox.CaretIndex = cursorBegin;
|
_hiddenTextBox.CaretIndex = cursorBegin;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
public void SetText(string text, int cursorBegin, int cursorEnd)
|
public void SetText(string text, int cursorBegin, int cursorEnd) =>
|
||||||
{
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
Dispatcher.UIThread.Post(() =>
|
||||||
{
|
{
|
||||||
_hiddenTextBox.Text = text;
|
_hiddenTextBox.Text = text;
|
||||||
_hiddenTextBox.SelectionStart = cursorBegin;
|
_hiddenTextBox.SelectionStart = cursorBegin;
|
||||||
_hiddenTextBox.SelectionEnd = cursorEnd;
|
_hiddenTextBox.SelectionEnd = cursorEnd;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||||||
return await ShowContentDialog(title, content, primaryButton, secondaryButton, closeButton, primaryButtonResult, deferResetEvent, deferCloseAction);
|
return await ShowContentDialog(title, content, primaryButton, secondaryButton, closeButton, primaryButtonResult, deferResetEvent, deferCloseAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Task<UserResult> ShowDeferredContentDialog(
|
public static async Task<UserResult> ShowDeferredContentDialog(
|
||||||
Window window,
|
Window window,
|
||||||
string title,
|
string title,
|
||||||
string primaryText,
|
string primaryText,
|
||||||
@ -98,7 +98,7 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||||||
{
|
{
|
||||||
bool startedDeferring = false;
|
bool startedDeferring = false;
|
||||||
|
|
||||||
return ShowTextDialog(
|
return await ShowTextDialog(
|
||||||
title,
|
title,
|
||||||
primaryText,
|
primaryText,
|
||||||
secondaryText,
|
secondaryText,
|
||||||
@ -209,14 +209,14 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||||||
closeButton,
|
closeButton,
|
||||||
(int)Symbol.Important);
|
(int)Symbol.Important);
|
||||||
|
|
||||||
internal static Task<UserResult> CreateConfirmationDialog(
|
internal static async Task<UserResult> CreateConfirmationDialog(
|
||||||
string primaryText,
|
string primaryText,
|
||||||
string secondaryText,
|
string secondaryText,
|
||||||
string acceptButtonText,
|
string acceptButtonText,
|
||||||
string cancelButtonText,
|
string cancelButtonText,
|
||||||
string title,
|
string title,
|
||||||
UserResult primaryButtonResult = UserResult.Yes)
|
UserResult primaryButtonResult = UserResult.Yes)
|
||||||
=> ShowTextDialog(
|
=> await ShowTextDialog(
|
||||||
string.IsNullOrWhiteSpace(title) ? LocaleManager.Instance[LocaleKeys.DialogConfirmationTitle] : title,
|
string.IsNullOrWhiteSpace(title) ? LocaleManager.Instance[LocaleKeys.DialogConfirmationTitle] : title,
|
||||||
primaryText,
|
primaryText,
|
||||||
secondaryText,
|
secondaryText,
|
||||||
@ -226,16 +226,16 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||||||
(int)Symbol.Help,
|
(int)Symbol.Help,
|
||||||
primaryButtonResult);
|
primaryButtonResult);
|
||||||
|
|
||||||
internal static Task<UserResult> CreateLocalizedConfirmationDialog(string primaryText, string secondaryText)
|
internal static async Task<UserResult> CreateLocalizedConfirmationDialog(string primaryText, string secondaryText)
|
||||||
=> CreateConfirmationDialog(
|
=> await CreateConfirmationDialog(
|
||||||
primaryText,
|
primaryText,
|
||||||
secondaryText,
|
secondaryText,
|
||||||
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
||||||
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
||||||
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
|
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
|
||||||
|
|
||||||
internal static Task CreateUpdaterInfoDialog(string primary, string secondaryText)
|
internal static async Task CreateUpdaterInfoDialog(string primary, string secondaryText)
|
||||||
=> ShowTextDialog(
|
=> await ShowTextDialog(
|
||||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterTitle],
|
LocaleManager.Instance[LocaleKeys.DialogUpdaterTitle],
|
||||||
primary,
|
primary,
|
||||||
secondaryText,
|
secondaryText,
|
||||||
@ -244,8 +244,8 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||||||
LocaleManager.Instance[LocaleKeys.InputDialogOk],
|
LocaleManager.Instance[LocaleKeys.InputDialogOk],
|
||||||
(int)Symbol.Important);
|
(int)Symbol.Important);
|
||||||
|
|
||||||
internal static Task CreateWarningDialog(string primary, string secondaryText)
|
internal static async Task CreateWarningDialog(string primary, string secondaryText)
|
||||||
=> ShowTextDialog(
|
=> await ShowTextDialog(
|
||||||
LocaleManager.Instance[LocaleKeys.DialogWarningTitle],
|
LocaleManager.Instance[LocaleKeys.DialogWarningTitle],
|
||||||
primary,
|
primary,
|
||||||
secondaryText,
|
secondaryText,
|
||||||
@ -254,11 +254,11 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||||||
LocaleManager.Instance[LocaleKeys.InputDialogOk],
|
LocaleManager.Instance[LocaleKeys.InputDialogOk],
|
||||||
(int)Symbol.Important);
|
(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);
|
Logger.Error?.Print(LogClass.Application, errorMessage);
|
||||||
|
|
||||||
return ShowTextDialog(
|
await ShowTextDialog(
|
||||||
LocaleManager.Instance[LocaleKeys.DialogErrorTitle],
|
LocaleManager.Instance[LocaleKeys.DialogErrorTitle],
|
||||||
LocaleManager.Instance[LocaleKeys.DialogErrorMessage],
|
LocaleManager.Instance[LocaleKeys.DialogErrorMessage],
|
||||||
errorMessage,
|
errorMessage,
|
||||||
@ -399,11 +399,9 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Task ShowWindowAsync(Window dialogWindow, Window mainWindow = null)
|
public static async Task ShowWindowAsync(Window dialogWindow, Window mainWindow = null)
|
||||||
{
|
{
|
||||||
mainWindow ??= GetMainWindow();
|
await dialogWindow.ShowDialog(_contentDialogOverlayWindow ?? mainWindow ?? GetMainWindow());
|
||||||
|
|
||||||
return dialogWindow.ShowDialog(_contentDialogOverlayWindow ?? mainWindow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Window GetMainWindow()
|
private static Window GetMainWindow()
|
||||||
|
Loading…
Reference in New Issue
Block a user