Skip to content

Commit

Permalink
misc: Code cleanups.
Browse files Browse the repository at this point in the history
  • Loading branch information
GreemDev committed Oct 24, 2024
1 parent a2cd3c2 commit 7618ef1
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 112 deletions.
4 changes: 3 additions & 1 deletion src/Ryujinx.HLE/Loaders/Processes/ProcessResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ public bool Start(Switch device)
}

// TODO: LibHac npdm currently doesn't support version field.
string version = ProgramId > 0x0100000000007FFF ? DisplayVersion : device.System.ContentManager.GetCurrentFirmwareVersion()?.VersionString ?? "?";
string version = ProgramId > 0x0100000000007FFF
? DisplayVersion
: device.System.ContentManager.GetCurrentFirmwareVersion()?.VersionString ?? "?";

Logger.Info?.Print(LogClass.Loader, $"Application Loaded: {Name} v{version} [{ProgramIdText}] [{(Is64Bit ? "64-bit" : "32-bit")}]");

Expand Down
4 changes: 1 addition & 3 deletions src/Ryujinx.Headless.SDL2/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,10 @@ private static InputConfig HandlePlayerConfiguration(string inputProfileName, st
}
}

IGamepad gamepad;
IGamepad gamepad = _inputManager.KeyboardDriver.GetGamepad(inputId);

bool isKeyboard = true;

gamepad = _inputManager.KeyboardDriver.GetGamepad(inputId);

if (gamepad == null)
{
gamepad = _inputManager.GamepadDriver.GetGamepad(inputId);
Expand Down
4 changes: 2 additions & 2 deletions src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,12 @@ public class SystemSection
public ReactiveObject<bool> EnableDockedMode { get; private set; }

/// <summary>
/// Enables or disables profiled translation cache persistency
/// Enables or disables persistent profiled translation cache
/// </summary>
public ReactiveObject<bool> EnablePtc { get; private set; }

/// <summary>
/// Enables or disables low-power profiled translation cache persistency loading
/// Enables or disables low-power persistent profiled translation cache loading
/// </summary>
public ReactiveObject<bool> EnableLowPowerPtc { get; private set; }

Expand Down
21 changes: 17 additions & 4 deletions src/Ryujinx.UI.Common/DiscordIntegrationModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static void SwitchToPlayingState(ApplicationMetadata appMeta, ProcessResu
{
Assets = new Assets
{
LargeImageKey = _discordGameAssetKeys.Contains(procRes.ProgramIdText.ToLower()) ? procRes.ProgramIdText : "game",
LargeImageKey = _discordGameAssetKeys.Contains(procRes.ProgramIdText) ? procRes.ProgramIdText : "game",
LargeImageText = TruncateToByteLength($"{appMeta.Title} | {procRes.DisplayVersion}"),
SmallImageKey = "ryujinx",
SmallImageText = TruncateToByteLength(_description)
Expand Down Expand Up @@ -121,8 +121,8 @@ public static void Exit()
}

private static readonly string[] _discordGameAssetKeys =
[
"01002da013484000", // The Legend of Zelda: Skyward Sword HD
[
"01002da013484000", // The Legend of Zelda: Skyward Sword HD
"01007ef00011e000", // The Legend of Zelda: Breath of the Wild
"0100f2c0115b6000", // The Legend of Zelda: Tears of the Kingdom
"01008cf01baac000", // The Legend of Zelda: Echoes of Wisdom
Expand All @@ -131,9 +131,15 @@ public static void Exit()
"0100000000010000", // SUPER MARIO ODYSSEY
"010015100b514000", // Super Mario Bros. Wonder
"0100152000022000", // Mario Kart 8 Deluxe
"01006fe013472000", // Mario Party Superstars
"0100965017338000", // Super Mario Party Jamboree
"010049900f546000", // Super Mario 3D All-Stars
"010028600ebda000", // Super Mario 3D World + Bowser's Fury
"0100ecd018ebe000", // Paper Mario: The Thousand-Year Door
"010019401051c000", // Mario Strikers League
"0100ea80032ea000", // Super Mario Bros. U Deluxe
"0100bc0018138000", // Super Mario RPG
"0100bde00862a000", // Mario Tennis Aces

"010048701995e000", // Luigi's Mansion 2 HD
"0100dca0064a6000", // Luigi's Mansion 3
Expand All @@ -148,15 +154,22 @@ public static void Exit()
"0100d680194b2000", // Pikmin 2
"0100f4c009322000", // Pikmin 3 Deluxe
"0100b7c00933a000", // Pikmin 4

"01004ad014bf0000", // Sonic Frontiers

"01004d300c5ae000", // Kirby and the Forgotten Land
"01006b601380e000", // Kirby's Return to Dreamland Deluxe
"01007e3006dda000", // Kirby Star Allies

"0100c2500fc20000", // Splatoon 3
"0100ba0018500000", // Splatoon 3: Splatfest World Premiere
"01000a10041ea000", // The Elder Scrolls V: Skyrim
"01007820196a6000", // Red Dead Redemption
"01008c8012920000", // Dying Light Platinum Edition
"0100744001588000", // Cars 3: Driven to Win
"0100c1f0051b6000", // Donkey Kong Country: Tropical Freeze
"01002b00111a2000", // Hyrule Warriors: Age of Calamity
"01006f8002326000", // Animal Crossing: New Horizons
"01004d300c5ae000", // Kirby and the Forgotten Land
"0100853015e86000", // No Man's Sky
"01008d100d43e000", // Saints Row IV
"0100de600beee000", // Saints Row: The Third - The Full Package
Expand Down
2 changes: 1 addition & 1 deletion src/Ryujinx/Common/ApplicationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private static bool TryFindSaveData(string titleName, ulong titleId, BlitStruct<
Logger.Warning?.Print(LogClass.Application, "No control file was found for this game. Using a dummy one instead. This may cause inaccuracies in some games.");
}

Uid user = new((ulong)_accountManager.LastOpenedUser.UserId.High, (ulong)_accountManager.LastOpenedUser.UserId.Low);
Uid user = _accountManager.LastOpenedUser.UserId.ToLibHacUid();

result = _horizonClient.Fs.EnsureApplicationSaveData(out _, new ApplicationId(titleId), in control, in user);
if (result.IsFailure())
Expand Down
11 changes: 3 additions & 8 deletions src/Ryujinx/UI/Applet/ControllerAppletDialog.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,9 @@ internal partial class ControllerAppletDialog : UserControl

public ControllerAppletDialog(MainWindow mainWindow, ControllerAppletUIArgs args)
{
if (args.PlayerCountMin == args.PlayerCountMax)
{
PlayerCount = args.PlayerCountMin.ToString();
}
else
{
PlayerCount = $"{args.PlayerCountMin} - {args.PlayerCountMax}";
}
PlayerCount = args.PlayerCountMin == args.PlayerCountMax
? args.PlayerCountMin.ToString()
: $"{args.PlayerCountMin} - {args.PlayerCountMax}";

SupportsProController = (args.SupportedStyles & ControllerType.ProController) != 0;
SupportsLeftJoycon = (args.SupportedStyles & ControllerType.JoyconLeft) != 0;
Expand Down
20 changes: 10 additions & 10 deletions src/Ryujinx/UI/Helpers/BitmapArrayValueConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ internal class BitmapArrayValueConverter : IValueConverter

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
switch (value)
{
return null;
}

if (value is byte[] buffer && targetType == typeof(IImage))
{
MemoryStream mem = new(buffer);
case null:
return null;
case byte[] buffer when targetType == typeof(IImage):
{
MemoryStream mem = new(buffer);

return new Bitmap(mem);
return new Bitmap(mem);
}
default:
throw new NotSupportedException();
}

throw new NotSupportedException();
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
Expand Down
6 changes: 1 addition & 5 deletions src/Ryujinx/UI/Helpers/ButtonKeyAssigner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ public async void GetInputAndAssign(IButtonAssigner assigner, IKeyboard keyboard

if (_isWaitingForInput)
{
Dispatcher.UIThread.Post(() =>
{
Cancel();
});

Dispatcher.UIThread.Post(() => Cancel());
return;
}

Expand Down
21 changes: 5 additions & 16 deletions src/Ryujinx/UI/Helpers/GlyphValueConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,11 @@ public GlyphValueConverter(string key)
_key = key;
}

public string this[string key]
{
get
{
if (_glyphs.TryGetValue(Enum.Parse<Glyph>(key), out var val))
{
return val;
}

return string.Empty;
}
}
public string this[string key] =>
_glyphs.TryGetValue(Enum.Parse<Glyph>(key), out var val)
? val
: string.Empty;

public override object ProvideValue(IServiceProvider serviceProvider)
{
return this[_key];
}
public override object ProvideValue(IServiceProvider serviceProvider) => this[_key];
}
}
44 changes: 0 additions & 44 deletions src/Ryujinx/UI/Helpers/LocalizedNeverConverter.cs

This file was deleted.

16 changes: 0 additions & 16 deletions src/Ryujinx/UI/Models/StatusInitEventArgs.cs

This file was deleted.

1 change: 0 additions & 1 deletion src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public class InputViewModel : BaseModel, IDisposable

private PlayerIndex _playerId;
private int _controller;
private readonly int _controllerNumber;
private string _controllerImage;
private int _device;
private object _configViewModel;
Expand Down
2 changes: 1 addition & 1 deletion src/Ryujinx/UI/Windows/IconColorPicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private static int GetColorScore(Dictionary<int, int> dominantColorBin, int maxH
var value = GetColorValue(color);

// If the color is rarely used on the image,
// then chances are that theres a better candidate, even if the saturation value
// then chances are that there's a better candidate, even if the saturation value
// is high. By multiplying the saturation value with a weight, we can lower
// it if the color is almost never used (hit count is low).
var satWeighted = quantSat;
Expand Down

0 comments on commit 7618ef1

Please sign in to comment.