add feature: orientation lock
This commit is contained in:
parent
2dddf856ea
commit
9f915abaed
@ -221,6 +221,15 @@ namespace GakumasLocal::HookMain {
|
||||
return Unity_set_position_Injected_Orig(_this, data);
|
||||
}
|
||||
|
||||
DEFINE_HOOK(void*, InternalSetOrientationAsync, (void* _this, int type, void* c, void* tc, void* mtd)) {
|
||||
switch (Config::gameOrientation) {
|
||||
case 1: type = 0x2; break; // FixedPortrait
|
||||
case 2: type = 0x3; break; // FixedLandscape
|
||||
default: break;
|
||||
}
|
||||
return InternalSetOrientationAsync_Orig(_this, type, c, tc, mtd);
|
||||
}
|
||||
|
||||
DEFINE_HOOK(void, EndCameraRendering, (void* ctx, void* camera, void* method)) {
|
||||
EndCameraRendering_Orig(ctx, camera, method);
|
||||
|
||||
@ -770,6 +779,10 @@ namespace GakumasLocal::HookMain {
|
||||
ADD_HOOK(Internal_Log, Il2cppUtils::il2cpp_resolve_icall(
|
||||
"UnityEngine.DebugLogHandler::Internal_Log(UnityEngine.LogType,UnityEngine.LogOption,System.String,UnityEngine.Object)"));
|
||||
|
||||
ADD_HOOK(InternalSetOrientationAsync,
|
||||
Il2cppUtils::GetMethodPointer("campus-submodule.Runtime.dll", "Campus.Common",
|
||||
"ScreenOrientationControllerBase", "InternalSetOrientationAsync"));
|
||||
|
||||
ADD_HOOK(Unity_set_position_Injected, Il2cppUtils::il2cpp_resolve_icall(
|
||||
"UnityEngine.Transform::set_position_Injected(UnityEngine.Vector3&)"));
|
||||
ADD_HOOK(Unity_set_rotation_Injected, Il2cppUtils::il2cpp_resolve_icall(
|
||||
|
@ -9,6 +9,7 @@ namespace GakumasLocal::Config {
|
||||
bool enabled = true;
|
||||
bool forceExportResource = true;
|
||||
bool textTest = false;
|
||||
int gameOrientation = 0;
|
||||
bool dumpText = false;
|
||||
bool enableFreeCamera = false;
|
||||
int targetFrameRate = 0;
|
||||
@ -35,6 +36,7 @@ namespace GakumasLocal::Config {
|
||||
GetConfigItem(dbgMode);
|
||||
GetConfigItem(enabled);
|
||||
GetConfigItem(forceExportResource);
|
||||
GetConfigItem(gameOrientation);
|
||||
GetConfigItem(textTest);
|
||||
GetConfigItem(dumpText);
|
||||
GetConfigItem(targetFrameRate);
|
||||
|
@ -6,6 +6,7 @@ namespace GakumasLocal::Config {
|
||||
extern bool dbgMode;
|
||||
extern bool enabled;
|
||||
extern bool forceExportResource;
|
||||
extern int gameOrientation;
|
||||
extern bool textTest;
|
||||
extern bool dumpText;
|
||||
extern bool enableFreeCamera;
|
||||
|
@ -3,17 +3,17 @@ package io.github.chinosk.gakumas.localify
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.ViewTreeObserver
|
||||
import android.widget.ScrollView
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.databinding.ObservableField
|
||||
import com.google.android.material.switchmaterial.SwitchMaterial
|
||||
import com.google.android.material.textfield.TextInputEditText
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonSyntaxException
|
||||
import io.github.chinosk.gakumas.localify.databinding.ActivityMainBinding
|
||||
@ -42,6 +42,7 @@ interface ConfigListener {
|
||||
fun onChangePresetQuality(level: Int)
|
||||
fun onReflectionQualityLevelChanged(s: CharSequence, start: Int, before: Int, count: Int)
|
||||
fun onLodQualityLevelChanged(s: CharSequence, start: Int, before: Int, count: Int)
|
||||
fun onGameOrientationChanged(checkedId: Int)
|
||||
fun onDumpTextChanged(value: Boolean)
|
||||
}
|
||||
|
||||
@ -65,6 +66,42 @@ class MainActivity : AppCompatActivity(), ConfigListener {
|
||||
}
|
||||
}
|
||||
showVersion()
|
||||
|
||||
val scrollView: ScrollView = findViewById(R.id.scrollView)
|
||||
scrollView.viewTreeObserver.addOnScrollChangedListener { onScrollChanged() }
|
||||
onScrollChanged()
|
||||
|
||||
val coordinatorLayout = findViewById<View>(R.id.coordinatorLayout)
|
||||
coordinatorLayout.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
|
||||
override fun onGlobalLayout() {
|
||||
onScrollChanged()
|
||||
coordinatorLayout.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun onScrollChanged() {
|
||||
val fab: FloatingActionButton = findViewById(R.id.fabStartGame)
|
||||
val startGameButton: MaterialButton = findViewById(R.id.StartGameButton)
|
||||
val scrollView: ScrollView = findViewById(R.id.scrollView)
|
||||
|
||||
val location = IntArray(2)
|
||||
startGameButton.getLocationOnScreen(location)
|
||||
val buttonTop = location[1]
|
||||
val buttonBottom = buttonTop + startGameButton.height
|
||||
|
||||
val scrollViewLocation = IntArray(2)
|
||||
scrollView.getLocationOnScreen(scrollViewLocation)
|
||||
val scrollViewTop = scrollViewLocation[1]
|
||||
val scrollViewBottom = scrollViewTop + scrollView.height
|
||||
|
||||
val isButtonVisible = buttonTop >= scrollViewTop && buttonBottom <= scrollViewBottom
|
||||
|
||||
if (isButtonVisible) {
|
||||
fab.hide()
|
||||
} else {
|
||||
fab.show()
|
||||
}
|
||||
}
|
||||
|
||||
private fun showToast(message: String) {
|
||||
@ -301,18 +338,22 @@ class MainActivity : AppCompatActivity(), ConfigListener {
|
||||
binding.config!!.reflectionQualityLevel = 5
|
||||
}
|
||||
}
|
||||
binding.config = binding.config
|
||||
binding.notifyChange()
|
||||
checkConfigAndUpdateView()
|
||||
saveConfig()
|
||||
}
|
||||
|
||||
private fun showTextInputLayoutHint(view: TextInputLayout) {
|
||||
showToast(view.hint.toString())
|
||||
override fun onGameOrientationChanged(checkedId: Int) {
|
||||
when (checkedId) {
|
||||
R.id.radioButtonGameDefault -> binding.config!!.gameOrientation = 0
|
||||
R.id.radioButtonGamePortrait -> binding.config!!.gameOrientation = 1
|
||||
R.id.radioButtonGameLandscape -> binding.config!!.gameOrientation = 2
|
||||
}
|
||||
saveConfig()
|
||||
}
|
||||
|
||||
fun checkConfigAndUpdateView() {
|
||||
val sw = findViewById<SwitchMaterial>(R.id.SwitchUnlockAllLive)
|
||||
sw.visibility = if (binding.config!!.dbgMode) android.view.View.VISIBLE else android.view.View.GONE
|
||||
private fun checkConfigAndUpdateView() {
|
||||
binding.config = binding.config
|
||||
binding.notifyChange()
|
||||
}
|
||||
|
||||
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
|
||||
@ -321,8 +362,7 @@ class MainActivity : AppCompatActivity(), ConfigListener {
|
||||
val origDbg = binding.config?.dbgMode
|
||||
if (origDbg != null) {
|
||||
binding.config!!.dbgMode = !origDbg
|
||||
binding.config = binding.config
|
||||
binding.notifyChange()
|
||||
checkConfigAndUpdateView()
|
||||
saveConfig()
|
||||
showToast("TestMode: ${!origDbg}")
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ data class GakumasConfig (
|
||||
var enabled: Boolean = true,
|
||||
var textTest: Boolean = false,
|
||||
var dumpText: Boolean = false,
|
||||
var gameOrientation: Int = 0,
|
||||
var forceExportResource: Boolean = false,
|
||||
var enableFreeCamera: Boolean = false,
|
||||
var targetFrameRate: Int = 0,
|
||||
|
5
app/src/main/res/drawable/start_game.xml
Normal file
5
app/src/main/res/drawable/start_game.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<vector android:autoMirrored="true" android:height="24dp"
|
||||
android:tint="#000000" android:viewportHeight="24"
|
||||
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M9.31,6.71c-0.39,0.39 -0.39,1.02 0,1.41L13.19,12l-3.88,3.88c-0.39,0.39 -0.39,1.02 0,1.41 0.39,0.39 1.02,0.39 1.41,0l4.59,-4.59c0.39,-0.39 0.39,-1.02 0,-1.41L10.72,6.7c-0.38,-0.38 -1.02,-0.38 -1.41,0.01z"/>
|
||||
</vector>
|
File diff suppressed because it is too large
Load Diff
@ -19,4 +19,8 @@
|
||||
<string name="hign">高</string>
|
||||
<string name="middle">中</string>
|
||||
<string name="low">低</string>
|
||||
<string name="orientation_orig">游戏原版</string>
|
||||
<string name="orientation_portrait">竖屏</string>
|
||||
<string name="orientation_landscape">横屏</string>
|
||||
<string name="orientation_lock">方向锁定</string>
|
||||
</resources>
|
@ -19,4 +19,9 @@
|
||||
<string name="hign">High</string>
|
||||
<string name="middle">Mid</string>
|
||||
<string name="low">Low</string>
|
||||
<string name="orientation_orig">Original</string>
|
||||
<string name="orientation_portrait">Portrait</string>
|
||||
<string name="orientation_landscape">Landscape</string>
|
||||
<string name="orientation_lock">Orientation Lock</string>
|
||||
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user