1
0

增加 fps 设置

This commit is contained in:
chinosk 2024-05-25 00:00:46 +08:00
parent 63d2c26e69
commit fb65a34684
No known key found for this signature in database
GPG Key ID: 00610B08C1BF7BE9
8 changed files with 67 additions and 4 deletions

View File

@ -25,6 +25,10 @@
android:name="xposedsharedprefs"
android:value="true" />
<meta-data
android:name="xposedscope"
android:value="com.bandainamcoent.idolmaster_gakuen" />
<activity
android:name=".MainActivity"
android:exported="true"

View File

@ -130,6 +130,11 @@ namespace GakumasLocal::HookMain {
return Unity_set_rotation_Injected_Orig(_this, value);
}
DEFINE_HOOK(void, Unity_set_targetFrameRate, (int value)) {
const auto configFps = Config::targetFrameRate;
return Unity_set_targetFrameRate_Orig(configFps == 0 ? value: configFps);
}
std::unordered_map<void*, std::string> loadHistory{};
DEFINE_HOOK(void*, AssetBundle_LoadAssetAsync, (void* _this, Il2cppString* name, void* type)) {
@ -365,6 +370,8 @@ namespace GakumasLocal::HookMain {
"UnityEngine.Transform::set_position_Injected(UnityEngine.Vector3&)"));
ADD_HOOK(Unity_set_rotation_Injected, Il2cppUtils::il2cpp_resolve_icall(
"UnityEngine.Transform::set_rotation_Injected(UnityEngine.Quaternion&)"));
ADD_HOOK(Unity_set_targetFrameRate, Il2cppUtils::il2cpp_resolve_icall(
"UnityEngine.Application::set_targetFrameRate(System.Int32)"));
}
// 77 2640 5000

View File

@ -7,12 +7,14 @@ namespace GakumasLocal::Config {
bool enabled = true;
bool enableFreeCamera = false;
int targetFrameRate = 0;
void LoadConfig(const std::string& configStr) {
try {
const auto config = nlohmann::json::parse(configStr);
enabled = config["enabled"];
targetFrameRate = config["targetFrameRate"];
enableFreeCamera = config["enableFreeCamera"];
}

View File

@ -7,6 +7,7 @@ namespace GakumasLocal::Config {
extern bool enabled;
extern bool enableFreeCamera;
extern int targetFrameRate;
void LoadConfig(const std::string& configStr);
}

View File

@ -4,6 +4,7 @@ package io.github.chinosk.gakumas.localify
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.Toast
import androidx.databinding.DataBindingUtil
import com.google.gson.Gson
@ -17,6 +18,7 @@ interface ConfigListener {
fun onClickStartGame()
fun onEnabledChanged(value: Boolean)
fun onEnableFreeCameraChanged(value: Boolean)
fun onTargetFpsChanged(s: CharSequence, start: Int, before: Int, count: Int)
}
class MainActivity : AppCompatActivity(), ConfigListener {
@ -83,6 +85,23 @@ class MainActivity : AppCompatActivity(), ConfigListener {
saveConfig()
}
override fun onTargetFpsChanged(s: CharSequence, start: Int, before: Int, count: Int) {
try {
val valueStr = s.toString()
val value = if (valueStr == "") {
0
} else {
valueStr.toInt()
}
config.targetFrameRate = value
saveConfig()
}
catch (e: Exception) {
return
}
}
override fun onClickStartGame() {
val intent = Intent().apply {
setClassName("com.bandainamcoent.idolmaster_gakuen", "com.google.firebase.MessagingUnityPlayerActivity")

View File

@ -2,6 +2,7 @@ package io.github.chinosk.gakumas.localify.models
data class GakumasConfig(
var enabled: Boolean = true,
var enableFreeCamera: Boolean = false
var enableFreeCamera: Boolean = false,
var targetFrameRate: Int = 0
)

View File

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<layout xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable name="config" type="io.github.chinosk.gakumas.localify.models.GakumasConfig" />
<variable
@ -9,8 +11,6 @@
</data>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="6sp"
@ -56,6 +56,33 @@
android:text="@string/enable_plugin" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="48dp"
app:boxBackgroundColor="@android:color/transparent"
android:background="@android:color/transparent"
android:hint="@string/setFpsTitle" >
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/editTextTargetFps"
android:layout_width="match_parent"
android:layout_height="48dp"
android:ems="10"
android:inputType="numberSigned"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:paddingBottom="0dp"
android:text="@={`` + config.targetFrameRate}"
android:onTextChanged="@{(s, st, b, a) -> listener.onTargetFpsChanged(s, st, b, a)}"/>
</com.google.android.material.textfield.TextInputLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -68,6 +95,7 @@
android:onCheckedChanged="@{(view, value) -> listener.onEnableFreeCameraChanged(value)}"
android:text="@string/enable_free_camera" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

View File

@ -4,4 +4,5 @@
<string name="enable_plugin">启用插件 (不可热重载)</string>
<string name="enable_free_camera">启用自由视角(可热重载; 需使用实体键盘)</string>
<string name="start_game">以上述配置启动游戏/重载配置</string>
<string name="setFpsTitle">最大 FPS (0 为保持游戏原设置)</string>
</resources>