forked from MeloNX/MeloNX
add overload for loading game info from path
This commit is contained in:
parent
9c510fec3e
commit
28eb812018
@ -20,6 +20,7 @@ using System.IO;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using LibHac.Tools.Fs;
|
||||
|
||||
namespace LibRyujinx
|
||||
{
|
||||
@ -89,9 +90,9 @@ namespace LibRyujinx
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "Java_org_ryujinx_android_RyujinxNative_deviceInitialize")]
|
||||
public static JBoolean JniInitializeDeviceNative(JEnvRef jEnv, JObjectLocalRef jObj, JBoolean isHostMapped)
|
||||
public static JBoolean JniInitializeDeviceNative(JEnvRef jEnv, JObjectLocalRef jObj, JBoolean isHostMapped, JBoolean useNce)
|
||||
{
|
||||
return InitializeDevice(isHostMapped);
|
||||
return InitializeDevice(isHostMapped, useNce);
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "Java_org_ryujinx_android_RyujinxNative_deviceGetGameStats")]
|
||||
@ -284,13 +285,26 @@ namespace LibRyujinx
|
||||
RunLoop();
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "Java_org_ryujinx_android_RyujinxNative_deviceGetGameInfoFromPath")]
|
||||
public static JObjectLocalRef JniGetGameInfo(JEnvRef jEnv, JObjectLocalRef jObj, JStringLocalRef path)
|
||||
{
|
||||
var info = GetGameInfo(GetString(jEnv, path)) ?? new GameInfo();
|
||||
SHA256 sha;
|
||||
return GetInfo(jEnv, info, out sha);
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "Java_org_ryujinx_android_RyujinxNative_deviceGetGameInfo")]
|
||||
public static JObjectLocalRef JniGetGameInfo(JEnvRef jEnv, JObjectLocalRef jObj, JInt fileDescriptor, JBoolean isXci)
|
||||
{
|
||||
using var stream = OpenFile(fileDescriptor);
|
||||
|
||||
var info = GetGameInfo(stream, isXci) ?? new GameInfo();
|
||||
SHA256 sha;
|
||||
return GetInfo(jEnv, info, out sha);
|
||||
}
|
||||
|
||||
private static JObjectLocalRef GetInfo(JEnvRef jEnv, GameInfo info, out SHA256 sha)
|
||||
{
|
||||
var javaClassName = GetCCharSequence("org/ryujinx/android/viewmodels/GameInfo");
|
||||
|
||||
JEnvValue value = jEnv.Environment;
|
||||
@ -316,9 +330,7 @@ namespace LibRyujinx
|
||||
var newGlobal = newGlobalRef(jEnv, javaClass._value);
|
||||
var constructor = getMethod(jEnv, javaClass, GetCCharSequence("<init>"), GetCCharSequence("()V"));
|
||||
var newObj = newObject(jEnv, javaClass, constructor, 0);
|
||||
|
||||
using var sha = SHA256.Create();
|
||||
|
||||
sha = SHA256.Create();
|
||||
var iconCacheByte = sha.ComputeHash(info.Icon ?? new byte[0]);
|
||||
var iconCache = BitConverter.ToString(iconCacheByte).Replace("-", "");
|
||||
|
||||
|
@ -15,17 +15,17 @@ namespace LibRyujinx
|
||||
[UnmanagedCallersOnly(EntryPoint = "device_initialize")]
|
||||
public static bool InitializeDeviceNative()
|
||||
{
|
||||
return InitializeDevice(true);
|
||||
return InitializeDevice(true, false);
|
||||
}
|
||||
|
||||
public static bool InitializeDevice(bool isHostMapped)
|
||||
public static bool InitializeDevice(bool isHostMapped, bool useNce)
|
||||
{
|
||||
if (SwitchDevice == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return SwitchDevice.InitializeContext(isHostMapped);
|
||||
return SwitchDevice.InitializeContext(isHostMapped, useNce);
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "device_load")]
|
||||
|
@ -83,7 +83,7 @@ namespace LibRyujinx
|
||||
Logger.SetEnable(LogLevel.AccessLog, false);
|
||||
|
||||
Logger.AddTarget(new AsyncLogTargetWrapper(
|
||||
new FileLogTarget(ReleaseInformation.GetBaseApplicationDirectory(), "file"),
|
||||
new FileLogTarget(basePath, "file"),
|
||||
1000,
|
||||
AsyncLogTargetOverflowAction.Block
|
||||
));
|
||||
@ -115,6 +115,14 @@ namespace LibRyujinx
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public static GameInfo GetGameInfo(string file)
|
||||
{
|
||||
using var stream = File.Open(file, FileMode.Open);
|
||||
|
||||
return GetGameInfo(stream, file.ToLower().EndsWith("xci"));
|
||||
}
|
||||
|
||||
public static GameInfo GetGameInfo(Stream gameStream, bool isXci)
|
||||
{
|
||||
var gameInfo = new GameInfo();
|
||||
@ -530,7 +538,7 @@ namespace LibRyujinx
|
||||
UserChannelPersistence = new UserChannelPersistence();
|
||||
}
|
||||
|
||||
public bool InitializeContext(bool isHostMapped)
|
||||
public bool InitializeContext(bool isHostMapped, bool useNce)
|
||||
{
|
||||
if(LibRyujinx.Renderer == null)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user