From 7e76c554f84575883996f711c1a704d4983c8600 Mon Sep 17 00:00:00 2001 From: chinosk <74499927+chinosk6@users.noreply.github.com> Date: Sat, 15 Jun 2024 14:21:07 -0500 Subject: [PATCH] Softer Breast (#19) * add breast parameter editer * add pre-config, add scale set --- app/src/main/cpp/GakumasLocalify/Hook.cpp | 97 ++++- .../main/cpp/GakumasLocalify/Il2cppUtils.hpp | 2 +- .../cpp/GakumasLocalify/config/Config.cpp | 25 ++ .../cpp/GakumasLocalify/config/Config.hpp | 13 + .../gakumas/localify/ConfigUpdateListener.kt | 375 +++++++++++++++++ .../chinosk/gakumas/localify/MainActivity.kt | 250 +----------- .../gakumas/localify/models/GakumasConfig.kt | 14 +- app/src/main/res/layout/activity_main.xml | 379 ++++++++++++++++++ app/src/main/res/values-zh-rCN/strings.xml | 13 + app/src/main/res/values/strings.xml | 13 + 10 files changed, 947 insertions(+), 234 deletions(-) create mode 100644 app/src/main/java/io/github/chinosk/gakumas/localify/ConfigUpdateListener.kt diff --git a/app/src/main/cpp/GakumasLocalify/Hook.cpp b/app/src/main/cpp/GakumasLocalify/Hook.cpp index fb6dc25..7741a72 100644 --- a/app/src/main/cpp/GakumasLocalify/Hook.cpp +++ b/app/src/main/cpp/GakumasLocalify/Hook.cpp @@ -617,6 +617,11 @@ namespace GakumasLocal::HookMain { } DEFINE_HOOK(void, CampusActorController_LateUpdate, (void* _this, void* mtd)) { + static auto CampusActorController_klass = Il2cppUtils::GetClass("campus-submodule.Runtime.dll", + "Campus.Common", "CampusActorController"); + static auto rootBody_field = CampusActorController_klass->Get("_rootBody"); + static auto parentKlass = UnityResolve::Invoke("il2cpp_class_get_parent", CampusActorController_klass->address); + if (!Config::enableFreeCamera || (GKCamera::GetCameraMode() == GKCamera::CameraMode::FREE)) { if (needRestoreHides) { needRestoreHides = false; @@ -626,10 +631,6 @@ namespace GakumasLocal::HookMain { return CampusActorController_LateUpdate_Orig(_this, mtd); } - static auto CampusActorController_klass = Il2cppUtils::GetClass("campus-submodule.Runtime.dll", - "Campus.Common", "CampusActorController"); - static auto rootBody_field = CampusActorController_klass->Get("_rootBody"); - static auto parentKlass = UnityResolve::Invoke("il2cpp_class_get_parent", CampusActorController_klass->address); static auto GetHumanBodyBoneTransform_mtd = Il2cppUtils::il2cpp_class_get_method_from_name(parentKlass, "GetHumanBodyBoneTransform", 1); static auto GetHumanBodyBoneTransform = reinterpret_cast( GetHumanBodyBoneTransform_mtd->methodPointer @@ -684,6 +685,90 @@ namespace GakumasLocal::HookMain { CampusActorController_LateUpdate_Orig(_this, mtd); } + void UpdateSwingBreastBonesData(void* initializeData) { + if (!Config::enableBreastParam) return; + static auto CampusActorAnimationInitializeData_klass = Il2cppUtils::GetClass("campus-submodule.Runtime.dll", "ActorAnimation", + "CampusActorAnimationInitializeData"); + static auto ActorSwingBreastBone_klass = Il2cppUtils::GetClass("ActorAnimation.Runtime.dll", "ActorAnimation", + "ActorSwingBreastBone"); + static auto LimitInfo_klass = Il2cppUtils::GetClass("ActorAnimation.Runtime.dll", "ActorAnimation", + "LimitInfo"); + + static auto Data_swingBreastBones_field = CampusActorAnimationInitializeData_klass->Get("swingBreastBones"); + static auto damping_field = ActorSwingBreastBone_klass->Get("damping"); + static auto stiffness_field = ActorSwingBreastBone_klass->Get("stiffness"); + static auto spring_field = ActorSwingBreastBone_klass->Get("spring"); + static auto pendulum_field = ActorSwingBreastBone_klass->Get("pendulum"); + static auto pendulumRange_field = ActorSwingBreastBone_klass->Get("pendulumRange"); + static auto average_field = ActorSwingBreastBone_klass->Get("average"); + static auto rootWeight_field = ActorSwingBreastBone_klass->Get("rootWeight"); + static auto useArmCorrection_field = ActorSwingBreastBone_klass->Get("useArmCorrection"); + static auto isDirty_field = ActorSwingBreastBone_klass->Get("k__BackingField"); + static auto leftBreast_field = ActorSwingBreastBone_klass->Get("leftBreast"); + static auto rightBreast_field = ActorSwingBreastBone_klass->Get("rightBreast"); + static auto leftBreastEnd_field = ActorSwingBreastBone_klass->Get("leftBreastEnd"); + static auto rightBreastEnd_field = ActorSwingBreastBone_klass->Get("rightBreastEnd"); + static auto limitInfo_field = ActorSwingBreastBone_klass->Get("limitInfo"); + + static auto limitInfo_useLimit_field = LimitInfo_klass->Get("useLimit"); + + auto swingBreastBones = Il2cppUtils::ClassGetFieldValue + *>(initializeData, Data_swingBreastBones_field); + + auto boneArr = swingBreastBones->ToArray(); + for (int i = 0; i < boneArr->max_length; i++) { + auto bone = boneArr->At(i); + if (!bone) continue; + + auto damping = Il2cppUtils::ClassGetFieldValue(bone, damping_field); + auto stiffness = Il2cppUtils::ClassGetFieldValue(bone, stiffness_field); + auto spring = Il2cppUtils::ClassGetFieldValue(bone, spring_field); + auto pendulum = Il2cppUtils::ClassGetFieldValue(bone, pendulum_field); + auto pendulumRange = Il2cppUtils::ClassGetFieldValue(bone, pendulumRange_field); + auto average = Il2cppUtils::ClassGetFieldValue(bone, average_field); + auto rootWeight = Il2cppUtils::ClassGetFieldValue(bone, rootWeight_field); + auto useArmCorrection = Il2cppUtils::ClassGetFieldValue(bone, useArmCorrection_field); + auto isDirty = Il2cppUtils::ClassGetFieldValue(bone, isDirty_field); + + auto limitInfo = Il2cppUtils::ClassGetFieldValue(bone, limitInfo_field); + auto useLimit = Il2cppUtils::ClassGetFieldValue(limitInfo, limitInfo_useLimit_field); + + if (Config::bUseScale) { + auto leftBreast = Il2cppUtils::ClassGetFieldValue(bone, leftBreast_field); + auto rightBreast = Il2cppUtils::ClassGetFieldValue(bone, rightBreast_field); + auto leftBreastEnd = Il2cppUtils::ClassGetFieldValue(bone, leftBreastEnd_field); + auto rightBreastEnd = Il2cppUtils::ClassGetFieldValue(bone, rightBreastEnd_field); + + const auto setScale = UnityResolve::UnityType::Vector3(Config::bScale, Config::bScale, Config::bScale); + leftBreast->SetLocalScale(setScale); + rightBreast->SetLocalScale(setScale); + leftBreastEnd->SetLocalScale(setScale); + rightBreastEnd->SetLocalScale(setScale); + } + + Log::DebugFmt("orig bone: damping: %f, stiffness: %f, spring: %f, pendulum: %f, " + "pendulumRange: %f, average: %f, rootWeight: %f, useLimit: %d, useArmCorrection: %d, isDirty: %d", + damping, stiffness, spring, pendulum, pendulumRange, average, rootWeight, useLimit, useArmCorrection, isDirty); + + Il2cppUtils::ClassSetFieldValue(limitInfo, limitInfo_useLimit_field, Config::bUseLimit); + Il2cppUtils::ClassSetFieldValue(bone, damping_field, Config::bDamping); + Il2cppUtils::ClassSetFieldValue(bone, stiffness_field, Config::bStiffness); + Il2cppUtils::ClassSetFieldValue(bone, spring_field, Config::bSpring); + Il2cppUtils::ClassSetFieldValue(bone, pendulum_field, Config::bPendulum); + Il2cppUtils::ClassSetFieldValue(bone, pendulumRange_field, Config::bPendulumRange); + Il2cppUtils::ClassSetFieldValue(bone, average_field, Config::bAverage); + Il2cppUtils::ClassSetFieldValue(bone, rootWeight_field, Config::bRootWeight); + Il2cppUtils::ClassSetFieldValue(bone, useArmCorrection_field, Config::bUseArmCorrection); + // Il2cppUtils::ClassSetFieldValue(bone, isDirty_field, Config::bIsDirty); + } + // Log::DebugFmt("\n"); + } + + DEFINE_HOOK(void, CampusActorAnimation_Setup, (void* _this, void* rootTrans, void* initializeData)) { + UpdateSwingBreastBonesData(initializeData); + return CampusActorAnimation_Setup_Orig(_this, rootTrans, initializeData); + } + void StartInjectFunctions() { const auto hookInstaller = Plugin::GetInstance().GetHookInstaller(); UnityResolve::Init(xdl_open(hookInstaller->m_il2cppLibraryPath.c_str(), RTLD_NOW), UnityResolve::Mode::Il2Cpp); @@ -770,6 +855,10 @@ namespace GakumasLocal::HookMain { Log::DebugFmt("CampusActorController.%s at %p", i->name.c_str(), i->function); }*/ + ADD_HOOK(CampusActorAnimation_Setup, + Il2cppUtils::GetMethodPointer("campus-submodule.Runtime.dll", "Campus.Common", + "CampusActorAnimation", "Setup")); + ADD_HOOK(CampusQualityManager_set_TargetFrameRate, Il2cppUtils::GetMethodPointer("campus-submodule.Runtime.dll", "Campus.Common", "CampusQualityManager", "set_TargetFrameRate")); diff --git a/app/src/main/cpp/GakumasLocalify/Il2cppUtils.hpp b/app/src/main/cpp/GakumasLocalify/Il2cppUtils.hpp index 9d0e942..8a296f2 100644 --- a/app/src/main/cpp/GakumasLocalify/Il2cppUtils.hpp +++ b/app/src/main/cpp/GakumasLocalify/Il2cppUtils.hpp @@ -157,7 +157,7 @@ namespace Il2cppUtils { template auto ClassSetFieldValue(void* obj, UnityResolve::Field* field, RType value) -> void { - return *reinterpret_cast(reinterpret_cast(obj) + field->offset) = value; + *reinterpret_cast(reinterpret_cast(obj) + field->offset) = value; } diff --git a/app/src/main/cpp/GakumasLocalify/config/Config.cpp b/app/src/main/cpp/GakumasLocalify/config/Config.cpp index b3cf550..c98987d 100644 --- a/app/src/main/cpp/GakumasLocalify/config/Config.cpp +++ b/app/src/main/cpp/GakumasLocalify/config/Config.cpp @@ -27,6 +27,19 @@ namespace GakumasLocal::Config { int reflectionQualityLevel = 4; int lodQualityLevel = 4; + bool enableBreastParam = false; + int bUseLimit = 1; + float bDamping = 0.33f; + float bStiffness = 0.08f; + float bSpring = 1.0f; + float bPendulum = 0.055f; + float bPendulumRange = 0.15f; + float bAverage = 0.20f; + float bRootWeight = 0.5f; + bool bUseArmCorrection = true; + bool bUseScale = false; + float bScale = 1.0f; + void LoadConfig(const std::string& configStr) { try { const auto config = nlohmann::json::parse(configStr); @@ -52,6 +65,18 @@ namespace GakumasLocal::Config { GetConfigItem(maxBufferPixel); GetConfigItem(reflectionQualityLevel); GetConfigItem(lodQualityLevel); + GetConfigItem(enableBreastParam); + GetConfigItem(bUseLimit); + GetConfigItem(bDamping); + GetConfigItem(bStiffness); + GetConfigItem(bSpring); + GetConfigItem(bPendulum); + GetConfigItem(bPendulumRange); + GetConfigItem(bAverage); + GetConfigItem(bRootWeight); + GetConfigItem(bUseArmCorrection); + GetConfigItem(bUseScale); + GetConfigItem(bScale); } catch (std::exception& e) { diff --git a/app/src/main/cpp/GakumasLocalify/config/Config.hpp b/app/src/main/cpp/GakumasLocalify/config/Config.hpp index a37ea34..728be5b 100644 --- a/app/src/main/cpp/GakumasLocalify/config/Config.hpp +++ b/app/src/main/cpp/GakumasLocalify/config/Config.hpp @@ -26,5 +26,18 @@ namespace GakumasLocal::Config { extern int reflectionQualityLevel; extern int lodQualityLevel; + extern bool enableBreastParam; + extern int bUseLimit; + extern float bDamping; + extern float bStiffness; + extern float bSpring; + extern float bPendulum; + extern float bPendulumRange; + extern float bAverage; + extern float bRootWeight; + extern bool bUseArmCorrection; + extern bool bUseScale; + extern float bScale; + void LoadConfig(const std::string& configStr); } diff --git a/app/src/main/java/io/github/chinosk/gakumas/localify/ConfigUpdateListener.kt b/app/src/main/java/io/github/chinosk/gakumas/localify/ConfigUpdateListener.kt new file mode 100644 index 0000000..a6be571 --- /dev/null +++ b/app/src/main/java/io/github/chinosk/gakumas/localify/ConfigUpdateListener.kt @@ -0,0 +1,375 @@ +package io.github.chinosk.gakumas.localify + +import android.view.KeyEvent +import io.github.chinosk.gakumas.localify.databinding.ActivityMainBinding + + +interface ConfigListener { + fun onClickStartGame() + fun onEnabledChanged(value: Boolean) + fun onForceExportResourceChanged(value: Boolean) + fun onTextTestChanged(value: Boolean) + fun onEnableFreeCameraChanged(value: Boolean) + fun onTargetFpsChanged(s: CharSequence, start: Int, before: Int, count: Int) + fun onUnlockAllLiveChanged(value: Boolean) + fun onLiveCustomeDressChanged(value: Boolean) + fun onLiveCustomeHeadIdChanged(s: CharSequence, start: Int, before: Int, count: Int) + fun onLiveCustomeCostumeIdChanged(s: CharSequence, start: Int, before: Int, count: Int) + fun onUseCustomeGraphicSettingsChanged(value: Boolean) + fun onRenderScaleChanged(s: CharSequence, start: Int, before: Int, count: Int) + fun onQualitySettingsLevelChanged(s: CharSequence, start: Int, before: Int, count: Int) + fun onVolumeIndexChanged(s: CharSequence, start: Int, before: Int, count: Int) + fun onMaxBufferPixelChanged(s: CharSequence, start: Int, before: Int, count: Int) + 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) + + fun onEnableBreastParamChanged(value: Boolean) + fun onBDampingChanged(s: CharSequence, start: Int, before: Int, count: Int) + fun onBStiffnessChanged(s: CharSequence, start: Int, before: Int, count: Int) + fun onBSpringChanged(s: CharSequence, start: Int, before: Int, count: Int) + fun onBPendulumChanged(s: CharSequence, start: Int, before: Int, count: Int) + fun onBPendulumRangeChanged(s: CharSequence, start: Int, before: Int, count: Int) + fun onBAverageChanged(s: CharSequence, start: Int, before: Int, count: Int) + fun onBRootWeightChanged(s: CharSequence, start: Int, before: Int, count: Int) + fun onBUseLimitChanged(s: CharSequence, start: Int, before: Int, count: Int) + fun onBScaleChanged(s: CharSequence, start: Int, before: Int, count: Int) + fun onBUseArmCorrectionChanged(value: Boolean) + fun onBUseScaleChanged(value: Boolean) + fun onBClickPresetChanged(index: Int) +} + + +interface ConfigUpdateListener: ConfigListener { + var binding: ActivityMainBinding + + fun pushKeyEvent(event: KeyEvent): Boolean + fun getConfigContent(): String + fun checkConfigAndUpdateView() + fun saveConfig() + + + override fun onEnabledChanged(value: Boolean) { + binding.config!!.enabled = value + saveConfig() + pushKeyEvent(KeyEvent(1145, 29)) + } + + override fun onForceExportResourceChanged(value: Boolean) { + binding.config!!.forceExportResource = value + saveConfig() + pushKeyEvent(KeyEvent(1145, 30)) + } + + override fun onTextTestChanged(value: Boolean) { + binding.config!!.textTest = value + saveConfig() + } + + override fun onDumpTextChanged(value: Boolean) { + binding.config!!.dumpText = value + saveConfig() + } + + override fun onEnableFreeCameraChanged(value: Boolean) { + binding.config!!.enableFreeCamera = value + saveConfig() + } + + override fun onUnlockAllLiveChanged(value: Boolean) { + binding.config!!.unlockAllLive = value + 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() + } + binding.config!!.targetFrameRate = value + saveConfig() + } + catch (e: Exception) { + return + } + } + + override fun onLiveCustomeDressChanged(value: Boolean) { + binding.config!!.enableLiveCustomeDress = value + saveConfig() + } + + override fun onLiveCustomeCostumeIdChanged(s: CharSequence, start: Int, before: Int, count: Int) { + binding.config!!.liveCustomeCostumeId = s.toString() + saveConfig() + } + + override fun onUseCustomeGraphicSettingsChanged(value: Boolean) { + binding.config!!.useCustomeGraphicSettings = value + saveConfig() + } + + override fun onRenderScaleChanged(s: CharSequence, start: Int, before: Int, count: Int) { + binding.config!!.renderScale = try { + s.toString().toFloat() + } + catch (e: Exception) { + 0.0f + } + saveConfig() + } + + override fun onQualitySettingsLevelChanged(s: CharSequence, start: Int, before: Int, count: Int) { + binding.config!!.qualitySettingsLevel = try { + s.toString().toInt() + } + catch (e: Exception) { + 0 + } + saveConfig() + } + + override fun onVolumeIndexChanged(s: CharSequence, start: Int, before: Int, count: Int) { + binding.config!!.volumeIndex = try { + s.toString().toInt() + } + catch (e: Exception) { + 0 + } + saveConfig() + } + + override fun onMaxBufferPixelChanged(s: CharSequence, start: Int, before: Int, count: Int) { + binding.config!!.maxBufferPixel = try { + s.toString().toInt() + } + catch (e: Exception) { + 0 + } + saveConfig() + } + + override fun onLiveCustomeHeadIdChanged(s: CharSequence, start: Int, before: Int, count: Int) { + binding.config!!.liveCustomeHeadId = s.toString() + saveConfig() + } + + override fun onReflectionQualityLevelChanged(s: CharSequence, start: Int, before: Int, count: Int) { + binding.config!!.reflectionQualityLevel = try { + val value = s.toString().toInt() + if (value > 5) 5 else value + } + catch (e: Exception) { + 0 + } + saveConfig() + } + + override fun onLodQualityLevelChanged(s: CharSequence, start: Int, before: Int, count: Int) { + binding.config!!.lodQualityLevel = try { + val value = s.toString().toInt() + if (value > 5) 5 else value + } + catch (e: Exception) { + 0 + } + saveConfig() + } + + override fun onChangePresetQuality(level: Int) { + when (level) { + 0 -> { + binding.config!!.renderScale = 0.5f + binding.config!!.qualitySettingsLevel = 1 + binding.config!!.volumeIndex = 0 + binding.config!!.maxBufferPixel = 1024 + binding.config!!.lodQualityLevel = 1 + binding.config!!.reflectionQualityLevel = 1 + } + 1 -> { + binding.config!!.renderScale = 0.59f + binding.config!!.qualitySettingsLevel = 1 + binding.config!!.volumeIndex = 1 + binding.config!!.maxBufferPixel = 1440 + binding.config!!.lodQualityLevel = 2 + binding.config!!.reflectionQualityLevel = 2 + } + 2 -> { + binding.config!!.renderScale = 0.67f + binding.config!!.qualitySettingsLevel = 2 + binding.config!!.volumeIndex = 2 + binding.config!!.maxBufferPixel = 2538 + binding.config!!.lodQualityLevel = 3 + binding.config!!.reflectionQualityLevel = 3 + } + 3 -> { + binding.config!!.renderScale = 0.77f + binding.config!!.qualitySettingsLevel = 3 + binding.config!!.volumeIndex = 3 + binding.config!!.maxBufferPixel = 3384 + binding.config!!.lodQualityLevel = 4 + binding.config!!.reflectionQualityLevel = 4 + } + 4 -> { + binding.config!!.renderScale = 1.0f + binding.config!!.qualitySettingsLevel = 5 + binding.config!!.volumeIndex = 4 + binding.config!!.maxBufferPixel = 8190 + binding.config!!.lodQualityLevel = 5 + binding.config!!.reflectionQualityLevel = 5 + } + } + checkConfigAndUpdateView() + saveConfig() + } + + 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() + } + + override fun onEnableBreastParamChanged(value: Boolean) { + binding.config!!.enableBreastParam = value + saveConfig() + checkConfigAndUpdateView() + } + + override fun onBUseArmCorrectionChanged(value: Boolean) { + binding.config!!.bUseArmCorrection = value + saveConfig() + } + + override fun onBUseScaleChanged(value: Boolean) { + binding.config!!.bUseScale = value + saveConfig() + checkConfigAndUpdateView() + } + + override fun onBDampingChanged(s: CharSequence, start: Int, before: Int, count: Int) { + binding.config!!.bDamping = try { + s.toString().toFloat() + } + catch (e: Exception) { + 0f + } + saveConfig() + } + + override fun onBStiffnessChanged(s: CharSequence, start: Int, before: Int, count: Int){ + binding.config!!.bStiffness = try { + s.toString().toFloat() + } + catch (e: Exception) { + 0f + } + saveConfig() + } + + override fun onBSpringChanged(s: CharSequence, start: Int, before: Int, count: Int){ + binding.config!!.bSpring = try { + s.toString().toFloat() + } + catch (e: Exception) { + 0f + } + saveConfig() + } + + override fun onBPendulumChanged(s: CharSequence, start: Int, before: Int, count: Int){ + binding.config!!.bPendulum = try { + s.toString().toFloat() + } + catch (e: Exception) { + 0f + } + saveConfig() + } + + override fun onBPendulumRangeChanged(s: CharSequence, start: Int, before: Int, count: Int){ + binding.config!!.bPendulumRange = try { + s.toString().toFloat() + } + catch (e: Exception) { + 0f + } + saveConfig() + } + + override fun onBAverageChanged(s: CharSequence, start: Int, before: Int, count: Int){ + binding.config!!.bAverage = try { + s.toString().toFloat() + } + catch (e: Exception) { + 0f + } + saveConfig() + } + + override fun onBRootWeightChanged(s: CharSequence, start: Int, before: Int, count: Int){ + binding.config!!.bRootWeight = try { + s.toString().toFloat() + } + catch (e: Exception) { + 0f + } + saveConfig() + } + + override fun onBUseLimitChanged(s: CharSequence, start: Int, before: Int, count: Int){ + binding.config!!.bUseLimit = try { + s.toString().toInt() + } + catch (e: Exception) { + 0 + } + saveConfig() + } + + override fun onBScaleChanged(s: CharSequence, start: Int, before: Int, count: Int){ + binding.config!!.bScale = try { + s.toString().toFloat() + } + catch (e: Exception) { + 0f + } + saveConfig() + } + override fun onBClickPresetChanged(index: Int) { + val setData: FloatArray = when (index) { + // 0.33, 0.08, 0.7, 0.12, 0.25, 0.2, 0.8, 0, noUseArm 啥玩意 + 0 -> floatArrayOf(0.33f, 0.07f, 0.7f, 0.06f, 0.25f, 0.2f, 0.5f, 1f) + 1 -> floatArrayOf(0.365f, 0.06f, 0.62f, 0.07f, 0.25f, 0.2f, 0.5f, 1f) + 2 -> floatArrayOf(0.4f, 0.065f, 0.55f, 0.075f, 0.25f, 0.2f, 0.5f, 1f) + 3 -> floatArrayOf(0.4f, 0.065f, 0.55f, 0.075f, 0.25f, 0.2f, 0.5f, 0f) + 4 -> floatArrayOf(0.4f, 0.06f, 0.4f, 0.075f, 0.55f, 0.2f, 0.8f, 0f) + + 5 -> floatArrayOf(0.33f, 0.08f, 0.8f, 0.12f, 0.55f, 0.2f, 1.0f, 0f) + + else -> floatArrayOf(0.33f, 0.08f, 1.0f, 0.055f, 0.15f, 0.2f, 0.5f, 1f) + } + + binding.config!!.bDamping = setData[0] + binding.config!!.bStiffness = setData[1] + binding.config!!.bSpring = setData[2] + binding.config!!.bPendulum = setData[3] + binding.config!!.bPendulumRange = setData[4] + binding.config!!.bAverage = setData[5] + binding.config!!.bRootWeight = setData[6] + binding.config!!.bUseLimit = setData[7].toInt() + binding.config!!.bUseArmCorrection = true + + checkConfigAndUpdateView() + saveConfig() + } + +} \ No newline at end of file diff --git a/app/src/main/java/io/github/chinosk/gakumas/localify/MainActivity.kt b/app/src/main/java/io/github/chinosk/gakumas/localify/MainActivity.kt index b952404..094d222 100644 --- a/app/src/main/java/io/github/chinosk/gakumas/localify/MainActivity.kt +++ b/app/src/main/java/io/github/chinosk/gakumas/localify/MainActivity.kt @@ -23,31 +23,8 @@ import io.github.chinosk.gakumas.localify.models.GakumasConfig import java.io.File -interface ConfigListener { - fun onClickStartGame() - fun onEnabledChanged(value: Boolean) - fun onForceExportResourceChanged(value: Boolean) - fun onTextTestChanged(value: Boolean) - fun onEnableFreeCameraChanged(value: Boolean) - fun onTargetFpsChanged(s: CharSequence, start: Int, before: Int, count: Int) - fun onUnlockAllLiveChanged(value: Boolean) - fun onLiveCustomeDressChanged(value: Boolean) - fun onLiveCustomeHeadIdChanged(s: CharSequence, start: Int, before: Int, count: Int) - fun onLiveCustomeCostumeIdChanged(s: CharSequence, start: Int, before: Int, count: Int) - fun onUseCustomeGraphicSettingsChanged(value: Boolean) - fun onRenderScaleChanged(s: CharSequence, start: Int, before: Int, count: Int) - fun onQualitySettingsLevelChanged(s: CharSequence, start: Int, before: Int, count: Int) - fun onVolumeIndexChanged(s: CharSequence, start: Int, before: Int, count: Int) - fun onMaxBufferPixelChanged(s: CharSequence, start: Int, before: Int, count: Int) - 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) -} - -class MainActivity : AppCompatActivity(), ConfigListener { - private lateinit var binding: ActivityMainBinding +class MainActivity : AppCompatActivity(), ConfigUpdateListener { + override lateinit var binding: ActivityMainBinding private val TAG = "GakumasLocalify" override fun onCreate(savedInstanceState: Bundle?) { @@ -80,6 +57,15 @@ class MainActivity : AppCompatActivity(), ConfigListener { }) } + override fun onClickStartGame() { + val intent = Intent().apply { + setClassName("com.bandainamcoent.idolmaster_gakuen", "com.google.firebase.MessagingUnityPlayerActivity") + putExtra("gkmsData", getConfigContent()) + flags = Intent.FLAG_ACTIVITY_NEW_TASK + } + startActivity(intent) + } + private fun onScrollChanged() { val fab: FloatingActionButton = findViewById(R.id.fabStartGame) val startGameButton: MaterialButton = findViewById(R.id.StartGameButton) @@ -108,7 +94,7 @@ class MainActivity : AppCompatActivity(), ConfigListener { Toast.makeText(this, message, Toast.LENGTH_SHORT).show() } - private fun getConfigContent(): String { + override fun getConfigContent(): String { val configFile = File(filesDir, "gkms-config.json") return if (configFile.exists()) { configFile.readText() @@ -119,6 +105,11 @@ class MainActivity : AppCompatActivity(), ConfigListener { } } + override fun saveConfig() { + val configFile = File(filesDir, "gkms-config.json") + configFile.writeText(Gson().toJson(binding.config!!)) + } + @SuppressLint("SetTextI18n") private fun showVersion() { val titleLabel = findViewById(R.id.textViewTitle) @@ -150,212 +141,15 @@ class MainActivity : AppCompatActivity(), ConfigListener { saveConfig() } - private fun saveConfig() { - val configFile = File(filesDir, "gkms-config.json") - configFile.writeText(Gson().toJson(binding.config!!)) - } - - override fun onEnabledChanged(value: Boolean) { - binding.config!!.enabled = value - saveConfig() - dispatchKeyEvent(KeyEvent(1145, 29)) - } - - override fun onForceExportResourceChanged(value: Boolean) { - binding.config!!.forceExportResource = value - saveConfig() - dispatchKeyEvent(KeyEvent(1145, 30)) - } - - override fun onTextTestChanged(value: Boolean) { - binding.config!!.textTest = value - saveConfig() - } - - override fun onDumpTextChanged(value: Boolean) { - binding.config!!.dumpText = value - saveConfig() - } - - override fun onEnableFreeCameraChanged(value: Boolean) { - binding.config!!.enableFreeCamera = value - saveConfig() - } - - override fun onUnlockAllLiveChanged(value: Boolean) { - binding.config!!.unlockAllLive = value - 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() - } - binding.config!!.targetFrameRate = value - saveConfig() - } - catch (e: Exception) { - return - } - } - - override fun onLiveCustomeDressChanged(value: Boolean) { - binding.config!!.enableLiveCustomeDress = value - saveConfig() - } - - override fun onLiveCustomeCostumeIdChanged(s: CharSequence, start: Int, before: Int, count: Int) { - binding.config!!.liveCustomeCostumeId = s.toString() - saveConfig() - } - - override fun onUseCustomeGraphicSettingsChanged(value: Boolean) { - binding.config!!.useCustomeGraphicSettings = value - saveConfig() - } - - override fun onRenderScaleChanged(s: CharSequence, start: Int, before: Int, count: Int) { - binding.config!!.renderScale = try { - s.toString().toFloat() - } - catch (e: Exception) { - 0.0f - } - saveConfig() - } - - override fun onQualitySettingsLevelChanged(s: CharSequence, start: Int, before: Int, count: Int) { - binding.config!!.qualitySettingsLevel = try { - s.toString().toInt() - } - catch (e: Exception) { - 0 - } - saveConfig() - } - - override fun onVolumeIndexChanged(s: CharSequence, start: Int, before: Int, count: Int) { - binding.config!!.volumeIndex = try { - s.toString().toInt() - } - catch (e: Exception) { - 0 - } - saveConfig() - } - - override fun onMaxBufferPixelChanged(s: CharSequence, start: Int, before: Int, count: Int) { - binding.config!!.maxBufferPixel = try { - s.toString().toInt() - } - catch (e: Exception) { - 0 - } - saveConfig() - } - - override fun onLiveCustomeHeadIdChanged(s: CharSequence, start: Int, before: Int, count: Int) { - binding.config!!.liveCustomeHeadId = s.toString() - saveConfig() - } - - override fun onClickStartGame() { - val intent = Intent().apply { - setClassName("com.bandainamcoent.idolmaster_gakuen", "com.google.firebase.MessagingUnityPlayerActivity") - putExtra("gkmsData", getConfigContent()) - flags = Intent.FLAG_ACTIVITY_NEW_TASK - } - startActivity(intent) - } - - override fun onReflectionQualityLevelChanged(s: CharSequence, start: Int, before: Int, count: Int) { - binding.config!!.reflectionQualityLevel = try { - val value = s.toString().toInt() - if (value > 5) 5 else value - } - catch (e: Exception) { - 0 - } - saveConfig() - } - - override fun onLodQualityLevelChanged(s: CharSequence, start: Int, before: Int, count: Int) { - binding.config!!.lodQualityLevel = try { - val value = s.toString().toInt() - if (value > 5) 5 else value - } - catch (e: Exception) { - 0 - } - saveConfig() - } - - override fun onChangePresetQuality(level: Int) { - when (level) { - 0 -> { - binding.config!!.renderScale = 0.5f - binding.config!!.qualitySettingsLevel = 1 - binding.config!!.volumeIndex = 0 - binding.config!!.maxBufferPixel = 1024 - binding.config!!.lodQualityLevel = 1 - binding.config!!.reflectionQualityLevel = 1 - } - 1 -> { - binding.config!!.renderScale = 0.59f - binding.config!!.qualitySettingsLevel = 1 - binding.config!!.volumeIndex = 1 - binding.config!!.maxBufferPixel = 1440 - binding.config!!.lodQualityLevel = 2 - binding.config!!.reflectionQualityLevel = 2 - } - 2 -> { - binding.config!!.renderScale = 0.67f - binding.config!!.qualitySettingsLevel = 2 - binding.config!!.volumeIndex = 2 - binding.config!!.maxBufferPixel = 2538 - binding.config!!.lodQualityLevel = 3 - binding.config!!.reflectionQualityLevel = 3 - } - 3 -> { - binding.config!!.renderScale = 0.77f - binding.config!!.qualitySettingsLevel = 3 - binding.config!!.volumeIndex = 3 - binding.config!!.maxBufferPixel = 3384 - binding.config!!.lodQualityLevel = 4 - binding.config!!.reflectionQualityLevel = 4 - } - 4 -> { - binding.config!!.renderScale = 1.0f - binding.config!!.qualitySettingsLevel = 5 - binding.config!!.volumeIndex = 4 - binding.config!!.maxBufferPixel = 8190 - binding.config!!.lodQualityLevel = 5 - binding.config!!.reflectionQualityLevel = 5 - } - } - checkConfigAndUpdateView() - saveConfig() - } - - 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() - } - - private fun checkConfigAndUpdateView() { + override fun checkConfigAndUpdateView() { binding.config = binding.config binding.notifyChange() } + override fun pushKeyEvent(event: KeyEvent): Boolean { + return dispatchKeyEvent(event) + } + override fun dispatchKeyEvent(event: KeyEvent): Boolean { // Log.d(TAG, "${event.keyCode}, ${event.action}") if (MainKeyEventDispatcher.checkDbgKey(event.keyCode, event.action)) { diff --git a/app/src/main/java/io/github/chinosk/gakumas/localify/models/GakumasConfig.kt b/app/src/main/java/io/github/chinosk/gakumas/localify/models/GakumasConfig.kt index b0a48c5..2a621ed 100644 --- a/app/src/main/java/io/github/chinosk/gakumas/localify/models/GakumasConfig.kt +++ b/app/src/main/java/io/github/chinosk/gakumas/localify/models/GakumasConfig.kt @@ -1,6 +1,5 @@ package io.github.chinosk.gakumas.localify.models -import androidx.databinding.BaseObservable data class GakumasConfig ( var dbgMode: Boolean = false, @@ -23,4 +22,17 @@ data class GakumasConfig ( var maxBufferPixel: Int = 3384, var reflectionQualityLevel: Int = 4, // 0~5 var lodQualityLevel: Int = 4, // 0~5 + + var enableBreastParam: Boolean = false, + var bUseLimit: Int = 1, + var bDamping: Float = 0.33f, + var bStiffness: Float = 0.08f, + var bSpring: Float = 1.0f, + var bPendulum: Float = 0.055f, + var bPendulumRange: Float = 0.15f, + var bAverage: Float = 0.20f, + var bRootWeight: Float = 0.5f, + var bUseArmCorrection: Boolean = true, + var bUseScale: Boolean = false, + var bScale: Float = 1.0f ) diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index b0c508d..1ee491c 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -587,6 +587,385 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index bc9cb7d..6d1b1cf 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -23,4 +23,17 @@ 竖屏 横屏 方向锁定 + 启用胸部参数 + 阻尼 (Damping) + 刚度 (Stiffness) + 弹簧系数 (Spring) + 钟摆系数 (Pendulum) + 钟摆范围 (PendulumRange) + Average + RootWeight + 限制范围 (0/1) + 使用手臂矫正 + IsDirty + 应用缩放 + 胸部缩放倍率 \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d4dc9e6..2b96685 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -23,5 +23,18 @@ Portrait Landscape Orientation Lock + Enable Breast Param + Damping + Stiffness + Spring + Pendulum + Pendulum Range + Average + Root Weight + Use Limit (0/1) + Use Arm Correction + IsDirty + Use Breast Scale + Breast Scale \ No newline at end of file