Skip to content

Commit

Permalink
Merge pull request #134 from chinosk6/main
Browse files Browse the repository at this point in the history
增加 LIVE 景深控制选项
  • Loading branch information
chinosk6 authored May 10, 2023
2 parents cac8c71 + 1f8384b commit ef24d88
Show file tree
Hide file tree
Showing 11 changed files with 233 additions and 50 deletions.
4 changes: 2 additions & 2 deletions resources/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"mouseSpeed": 100.0,
"force_changeVisibility_false": false,
"moveStep": 0.1,
"enableLiveDofController": false,
"close_all_blur": false,
"setLiveFovAsGlobal": false
},
Expand Down Expand Up @@ -93,6 +94,5 @@
"raceInfoTab": {
"enableRaceInfoTab": false,
"raceInfoTabAttachToGame": false
},
"dumpGameAssemblyPath": null
}
}
12 changes: 5 additions & 7 deletions resources/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@
"description": "关闭所有模糊镜头",
"type": "boolean"
},
"enableLiveDofController": {
"description": "启用景深控制(点击 LIVE 设置按钮开启)",
"type": "boolean",
"default": false
},
"setLiveFovAsGlobal": {
"description": "将 Live 的 FOV 应用到游戏全局",
"type": "boolean",
Expand Down Expand Up @@ -388,13 +393,6 @@
"items": {
"type": "string"
}
},
"dumpGameAssemblyPath": {
"description": "Dump GameAssembly.dll 到指定地址,设置为 null 关闭",
"type": [
"string",
"null"
]
}
},
"additionalProperties": false,
Expand Down
12 changes: 5 additions & 7 deletions resources/config_en.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@
"description": "Camera move step",
"type": "number"
},
"enableLiveDofController": {
"description": "Enable DOF control (click LIVE setting button)",
"type": "boolean",
"default": false
},
"close_all_blur": {
"description": "Disable all blur",
"type": "boolean"
Expand Down Expand Up @@ -388,13 +393,6 @@
"items": {
"type": "string"
}
},
"dumpGameAssemblyPath": {
"description": "Dump GameAssembly.dll to the indicated path, null to disable",
"type": [
"string",
"null"
]
}
},
"additionalProperties": false,
Expand Down
12 changes: 5 additions & 7 deletions resources/config_zh_tw.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@
"description": "相機移動步幅",
"type": "number"
},
"enableLiveDofController": {
"description": "啟用景深控制(點擊LIVE設定按鈕開啟)",
"type": "boolean",
"default": false
},
"close_all_blur": {
"description": "關閉所有模糊鏡頭",
"type": "boolean"
Expand Down Expand Up @@ -388,13 +393,6 @@
"items": {
"type": "string"
}
},
"dumpGameAssemblyPath": {
"description": "Dump GameAssembly.dll 到指定地址,設置為 null 關閉",
"type": [
"string",
"null"
]
}
},
"additionalProperties": false,
Expand Down
116 changes: 93 additions & 23 deletions src/hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1869,31 +1869,84 @@ namespace
return reinterpret_cast<decltype(live_on_destroy_hook)*>(live_on_destroy_orig)(_this);
}

/*
void* LiveTimelineKeyPostEffectDOFData_klass;
FieldInfo* LiveTimelineKeyPostEffectDOFData_forcalSize;
FieldInfo* LiveTimelineKeyPostEffectDOFData_blurSpread;

void* PostEffectUpdateInfo_DOF_klass;
FieldInfo* PostEffectUpdateInfo_DOF_forcalPosition;

bool isffinit = false;
void init_LiveTimelineKeyPostEffectDOFData() {
LiveTimelineKeyPostEffectDOFData_klass = il2cpp_symbols::get_class("umamusume.dll", "Gallop.Live.Cutt",
"LiveTimelineKeyPostEffectDOFData");
LiveTimelineKeyPostEffectDOFData_forcalSize = il2cpp_class_get_field_from_name(LiveTimelineKeyPostEffectDOFData_klass, "forcalSize");
LiveTimelineKeyPostEffectDOFData_blurSpread = il2cpp_class_get_field_from_name(LiveTimelineKeyPostEffectDOFData_klass, "blurSpread");
if (isffinit) return;
PostEffectUpdateInfo_DOF_klass = il2cpp_symbols::get_class("umamusume.dll", "Gallop.Live.Cutt", "PostEffectUpdateInfo_DOF");
PostEffectUpdateInfo_DOF_forcalPosition = il2cpp_class_get_field_from_name(PostEffectUpdateInfo_DOF_klass, "forcalPosition");
isffinit = true;
}
*/

bool guiStarting = false;
void startUmaGui();

void* Live_OnClickSettingButton_orig;
void Live_OnClickSettingButton_hook(void* _this) {
reinterpret_cast<decltype(Live_OnClickSettingButton_hook)*>(Live_OnClickSettingButton_orig)(_this);
if (g_enable_live_dof_controller) {
SetShowLiveWnd(true);
if (getUmaGuiDone()) {
startUmaGui();
}
}
}

enum class UpdateDOFType {
MainCamera,
MuitiCamera,
Unknown
};
UpdateDOFType updateDOFType = UpdateDOFType::Unknown;

template <typename T>
void changeValueByType(T* p1, T* p2, bool condition) {
if (condition) {
*p1 = *p2;
}
else {
*p2 = *p1;
}
}

void* SetupDOFUpdateInfo_orig;
void SetupDOFUpdateInfo_hook(void* _this, void* updateInfo, void* curData, void* nextData, int currentFrame, Vector3_t* cameraLookAt) {
void SetupDOFUpdateInfo_hook(void* _this, UmaGUiShowData::PostEffectUpdateInfo_DOF* updateInfo, void* curData, void* nextData, int currentFrame, Vector3_t* cameraLookAt) {

if (g_enable_live_dof_controller && guiStarting && GetShowLiveWnd() && (updateDOFType == UpdateDOFType::MainCamera)) {
init_LiveTimelineKeyPostEffectDOFData();

auto forcalPosition = reinterpret_cast<Vector3_t*>(
static_cast<std::byte*>(reinterpret_cast<void*>(updateInfo)) + PostEffectUpdateInfo_DOF_forcalPosition->offset
);

if (UmaGUiShowData::dofColtrollerFollowGame) {
reinterpret_cast<decltype(SetupDOFUpdateInfo_hook)*>(SetupDOFUpdateInfo_orig)(_this, updateInfo, curData, nextData, currentFrame, cameraLookAt);
}
changeValueByType(&UmaGUiShowData::postEffectUpdateInfo_DOF.IsEnableDOF, &updateInfo->IsEnableDOF, UmaGUiShowData::dofColtrollerFollowGame);
changeValueByType(&UmaGUiShowData::postEffectUpdateInfo_DOF.forcalSize, &updateInfo->forcalSize, UmaGUiShowData::dofColtrollerFollowGame);
changeValueByType(&UmaGUiShowData::postEffectUpdateInfo_DOF.blurSpread, &updateInfo->blurSpread, UmaGUiShowData::dofColtrollerFollowGame);
changeValueByType(&UmaGUiShowData::liveDOFForcalPosition.x, &forcalPosition->x, UmaGUiShowData::dofColtrollerFollowGame);
changeValueByType(&UmaGUiShowData::liveDOFForcalPosition.y, &forcalPosition->y, UmaGUiShowData::dofColtrollerFollowGame);
changeValueByType(&UmaGUiShowData::liveDOFForcalPosition.z, &forcalPosition->z, UmaGUiShowData::dofColtrollerFollowGame);
changeValueByType(&UmaGUiShowData::postEffectUpdateInfo_DOF.dofQuality, &updateInfo->dofQuality, UmaGUiShowData::dofColtrollerFollowGame);
changeValueByType(&UmaGUiShowData::postEffectUpdateInfo_DOF.dofBlurType, &updateInfo->dofBlurType, UmaGUiShowData::dofColtrollerFollowGame);
changeValueByType(&UmaGUiShowData::postEffectUpdateInfo_DOF.dofForegroundSize, &updateInfo->dofForegroundSize, UmaGUiShowData::dofColtrollerFollowGame);
changeValueByType(&UmaGUiShowData::postEffectUpdateInfo_DOF.dofFocalPoint, &updateInfo->dofFocalPoint, UmaGUiShowData::dofColtrollerFollowGame);
changeValueByType(&UmaGUiShowData::postEffectUpdateInfo_DOF.dofSoomthness, &updateInfo->dofSoomthness, UmaGUiShowData::dofColtrollerFollowGame);
changeValueByType(&UmaGUiShowData::postEffectUpdateInfo_DOF.isUseFocalPoint, &updateInfo->isUseFocalPoint, UmaGUiShowData::dofColtrollerFollowGame);
changeValueByType(&UmaGUiShowData::postEffectUpdateInfo_DOF.BallBlurCurveFactor, &updateInfo->BallBlurCurveFactor, UmaGUiShowData::dofColtrollerFollowGame);
changeValueByType(&UmaGUiShowData::postEffectUpdateInfo_DOF.BallBlurBrightnessThreshhold, &updateInfo->BallBlurBrightnessThreshhold, UmaGUiShowData::dofColtrollerFollowGame);
changeValueByType(&UmaGUiShowData::postEffectUpdateInfo_DOF.BallBlurBrightnessIntensity, &updateInfo->BallBlurBrightnessIntensity, UmaGUiShowData::dofColtrollerFollowGame);
changeValueByType(&UmaGUiShowData::postEffectUpdateInfo_DOF.BallBlurSpread, &updateInfo->BallBlurSpread, UmaGUiShowData::dofColtrollerFollowGame);
changeValueByType(&UmaGUiShowData::postEffectUpdateInfo_DOF.IsPointBallBlur, &updateInfo->IsPointBallBlur, UmaGUiShowData::dofColtrollerFollowGame);
return;
}

if (g_live_close_all_blur) return;
reinterpret_cast<decltype(SetupDOFUpdateInfo_hook)*>(SetupDOFUpdateInfo_orig)(_this, updateInfo, curData, nextData, currentFrame, cameraLookAt);

// if (!isffinit) init_LiveTimelineKeyPostEffectDOFData();
// printf("SetupDOFUpdateInfo forcalSize: %f, blurSpread: %f\n",
// il2cpp_symbols::read_field<float>(curData, LiveTimelineKeyPostEffectDOFData_forcalSize),
// il2cpp_symbols::read_field<float>(curData, LiveTimelineKeyPostEffectDOFData_blurSpread)
// );
}

void* get_camera_pos2_orig; // 暂时没用
Expand Down Expand Up @@ -2255,7 +2308,6 @@ namespace
return ret;
}

bool guiStarting = false;
void startUmaGui() {
if (guiStarting) return;
guiStarting = true;
Expand All @@ -2264,6 +2316,7 @@ namespace
guimain();
guiStarting = false;
printf("GUI END\n");
SetShowLiveWnd(false);
}).detach();
}

Expand Down Expand Up @@ -2409,10 +2462,15 @@ namespace
}

void* AlterUpdate_PostEffect_DOF_orig;
void AlterUpdate_PostEffect_DOF_hook(void* _this, Il2CppObject* sheet, int currentFrame, Vector3_t* cameraLookAt) {
if (g_live_free_camera) return;
void AlterUpdate_PostEffect_DOF_hook(void* _this, void* sheet, int currentFrame, Vector3_t* cameraLookAt) {
updateDOFType = UpdateDOFType::MainCamera;
return reinterpret_cast<decltype(AlterUpdate_PostEffect_DOF_hook)*>(AlterUpdate_PostEffect_DOF_orig)(_this, sheet, currentFrame, cameraLookAt);
// return true;
}

void* AlterUpdate_MultiCameraPostEffect_DOF_orig;
void AlterUpdate_MultiCameraPostEffect_DOF_hook(void* _this, Il2CppObject* sheet, int currentFrame) {
updateDOFType = UpdateDOFType::MuitiCamera;
return reinterpret_cast<decltype(AlterUpdate_MultiCameraPostEffect_DOF_hook)*>(AlterUpdate_MultiCameraPostEffect_DOF_orig)(_this, sheet, currentFrame);
}

void* AlterUpdate_CameraMotion_orig;
Expand Down Expand Up @@ -2706,9 +2764,8 @@ namespace
umaUsedSkillList.clear();
raceDisabledObj.clear();
// updateRaceGUIData(umaRaceData);
if (raceInfoTabAttachToGame)
SetShowRaceWnd(false);
else {
SetShowRaceWnd(false);
if (!raceInfoTabAttachToGame) {
if (closeWhenRaceEnd) {
SetShowRaceWnd(false);
SetGuiDone(true);
Expand Down Expand Up @@ -3789,6 +3846,11 @@ namespace
auto AlterUpdate_PostEffect_DOF_addr = il2cpp_symbols::get_method_pointer(
"umamusume.dll", "Gallop.Live.Cutt",
"LiveTimelineControl", "AlterUpdate_PostEffect_DOF", 3
);

auto AlterUpdate_MultiCameraPostEffect_DOF_addr = il2cpp_symbols::get_method_pointer(
"umamusume.dll", "Gallop.Live.Cutt",
"LiveTimelineControl", "AlterUpdate_MultiCameraPostEffect_DOF", 2
);

auto AlterUpdate_CameraLayer_addr = il2cpp_symbols::get_method_pointer(
Expand Down Expand Up @@ -3912,6 +3974,11 @@ namespace
"LiveTimelineControl", "SetupDOFUpdateInfo", 5
);

auto Live_OnClickSettingButton_addr = il2cpp_symbols::get_method_pointer(
"umamusume.dll", "Gallop",
"LiveTheaterViewController", "OnClickSettingButton", 0
);

auto RaceCameraManager_AlterLateUpdate_addr = il2cpp_symbols::get_method_pointer(
"umamusume.dll", "Gallop",
"RaceCameraManager", "AlterLateUpdate", 0
Expand Down Expand Up @@ -4113,6 +4180,7 @@ namespace
ADD_HOOK(AlterUpdate_MultiCameraLookAt, "AlterUpdate_MultiCameraLookAt at %p\n");
ADD_HOOK(live_on_destroy, "live_on_destroy at %p\n");
ADD_HOOK(SetupDOFUpdateInfo, "SetupDOFUpdateInfo at %p\n");
ADD_HOOK(Live_OnClickSettingButton, "Live_OnClickSettingButton at %p\n");
ADD_HOOK(get_camera_pos, "get_camera_pos at %p\n");
ADD_HOOK(get_camera_pos2, "get_camera_pos2 at %p\n");
ADD_HOOK(GetCharacterWorldPos, "GetCharacterWorldPos at %p\n");
Expand All @@ -4126,6 +4194,8 @@ namespace
ADD_HOOK(AlterUpdate_CameraMotion, "AlterUpdate_CameraMotion at %p\n");
ADD_HOOK(AlterUpdate_TiltShift, "AlterUpdate_TiltShift at %p\n");
ADD_HOOK(AlterUpdate_CameraLayer, "AlterUpdate_CameraLayer at %p\n");
ADD_HOOK(AlterUpdate_PostEffect_DOF, "AlterUpdate_PostEffect_DOF at %p\n");
ADD_HOOK(AlterUpdate_MultiCameraPostEffect_DOF, "AlterUpdate_MultiCameraPostEffect_DOF at %p\n");
ADD_HOOK(AlterLateUpdate_CameraMotion, "AlterLateUpdate_CameraMotion at %p\n");
ADD_HOOK(AlterUpdate_CameraFov, "AlterUpdate_CameraFov at %p\n");
ADD_HOOK(AlterUpdate_CameraRoll, "AlterUpdate_CameraRoll at %p\n");
Expand Down
5 changes: 5 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ std::string g_race_jikkyo_message_dict_path;
std::list<std::function<void(void)>> onPluginReload{};
bool enableRaceInfoTab = false;
bool raceInfoTabAttachToGame = false;
bool g_enable_live_dof_controller = false;

constexpr const char LocalizedDataPath[] = "localized_data";
constexpr const char OldLocalizedDataPath[] = "old_localized_data";
Expand Down Expand Up @@ -556,6 +557,10 @@ namespace
g_free_camera_mouse_speed = document["live"]["mouseSpeed"].GetFloat();
}

if (document["live"].HasMember("enableLiveDofController")) {
g_enable_live_dof_controller = document["live"]["enableLiveDofController"].GetBool();
}

auto moveStep = document["live"]["moveStep"].GetFloat();
g_live_move_step = moveStep;
UmaCamera::setMoveStep(moveStep);
Expand Down
1 change: 1 addition & 0 deletions src/stdinclude.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,4 @@ extern std::string g_autoupdateUrl;
extern std::function<void(Il2CppString* title, Il2CppString* content, int buttonCount, int button1Text, int button2Text, int button3Text, int btn_type)> showDialog;
extern bool g_force_landscape;
extern std::string dumpGameAssemblyPath;
extern bool g_enable_live_dof_controller;
7 changes: 6 additions & 1 deletion src/umagui/guiShowData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
#include "umagui/guiShowData.hpp"

bool ignoreNegativeSpeed = false;

Vector3_t UmaGUiShowData::liveDOFForcalPosition { .0f, 1.72f, 1.0f };
UmaGUiShowData::PostEffectUpdateInfo_DOF UmaGUiShowData::postEffectUpdateInfo_DOF {
false, 5.0f, 1.6f, DofQuality::OnlyBackground, DofBlur::Mixed,
1.72, 1.0, 0.5, false, 3.25, 0.5, 0.4, -0.67, 0
};
bool UmaGUiShowData::dofColtrollerFollowGame = false;

UmaGUiShowData::UmaRaceMotionData::UmaRaceMotionData(int gateNo, std::wstring charaName, std::wstring trainerName) {
this->gateNo = gateNo;
Expand Down
35 changes: 34 additions & 1 deletion src/umagui/guiShowData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,37 @@ namespace UmaGUiShowData {
void SetSkillName(std::string skillName);
};

}
enum class DofQuality {
OnlyBackground = 0x1,
BackgroundAndForeground = 0x5
};

enum class DofBlur {
Horizon = 0x0,
Mixed = 0x1,
Disc = 0x2,
BallBlur = 0x3,
};

struct PostEffectUpdateInfo_DOF {
bool IsEnableDOF;
float forcalSize;
float blurSpread;
// Vector3_t* forcalPosition;
DofQuality dofQuality;
DofBlur dofBlurType;
float dofForegroundSize;
float dofFocalPoint;
float dofSoomthness;
bool isUseFocalPoint;
float BallBlurCurveFactor;
float BallBlurBrightnessThreshhold;
float BallBlurBrightnessIntensity;
float BallBlurSpread;
bool IsPointBallBlur;
};

extern Vector3_t liveDOFForcalPosition;
extern PostEffectUpdateInfo_DOF postEffectUpdateInfo_DOF;
extern bool dofColtrollerFollowGame;
}
Loading

0 comments on commit ef24d88

Please sign in to comment.