mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-29 12:52:18 -05:00
improving free cam settings configurability (#1987)
* Initial camera distance slider * works with freecam * improving the settings configurability, adding distance slider and transition speed for the free camera adding seperate sensitivity and invert settings for aiming/first person camera * spelling * tooltip msg on camera invvert * typos * removing the original free camera checkbox in experimental menu * adding name change to new presets file Co-authored-by: RaelCappra <rael.cappra@gmail.com>
This commit is contained in:
parent
cb4a0aa21b
commit
cabcfb009c
@ -229,20 +229,44 @@ namespace GameControlEditor {
|
||||
return;
|
||||
}
|
||||
|
||||
ImVec2 cursor = ImGui::GetCursorPos();
|
||||
ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5));
|
||||
UIWidgets::PaddedEnhancementCheckbox("Invert Camera X Axis", "gInvertXAxis");
|
||||
DrawHelpIcon("Inverts the Camera X Axis in:\n-Free camera\n-C-Up view\n-Weapon Aiming");
|
||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5);
|
||||
UIWidgets::PaddedEnhancementCheckbox("Invert Camera Y Axis", "gInvertYAxis");
|
||||
DrawHelpIcon("Inverts the Camera Y Axis in:\n-Free camera\n-C-Up view\n-Weapon Aiming");
|
||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5);
|
||||
UIWidgets::Spacer(0);
|
||||
SohImGui::BeginGroupPanel("Aiming/First-Person Camera", ImGui::GetContentRegionAvail());
|
||||
UIWidgets::PaddedEnhancementCheckbox("Right Stick Aiming", "gRightStickAiming");
|
||||
DrawHelpIcon("Allows for aiming with the right stick when:\n-Aiming in the C-Up view\n-Aiming with weapons");
|
||||
DrawHelpIcon("Allows for aiming with the right stick in:\n-First-Person/C-Up view\n-Weapon Aiming");
|
||||
UIWidgets::PaddedEnhancementCheckbox("Invert Aiming X Axis", "gInvertAimingXAxis");
|
||||
DrawHelpIcon("Inverts the Camera X Axis in:\n-First-Person/C-Up view\n-Weapon Aiming");
|
||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5);
|
||||
UIWidgets::PaddedEnhancementCheckbox("Disable Auto-Centering in First Person View", "gDisableAutoCenterView");
|
||||
UIWidgets::PaddedEnhancementCheckbox("Invert Aiming Y Axis", "gInvertAimingYAxis");
|
||||
DrawHelpIcon("Inverts the Camera Y Axis in:\n-First-Person/C-Up view\n-Weapon Aiming");
|
||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5);
|
||||
UIWidgets::PaddedEnhancementCheckbox("Disable Auto-Centering in First-Person View", "gDisableAutoCenterViewFirstPerson");
|
||||
DrawHelpIcon("Prevents the C-Up view from auto-centering, allowing for Gyro Aiming");
|
||||
UIWidgets::EnhancementSliderFloat("Camera Sensitivity: %d %%", "##Sensitivity", "gCameraSensitivity", 0.01f, 5.0f, "", 1.0f, true, true);
|
||||
UIWidgets::PaddedEnhancementCheckbox("Enable Custom Aiming/First-Person sensitivity", "gEnableFirstPersonSensitivity", true, false);
|
||||
if (CVar_GetS32("gEnableFirstPersonSensitivity", 0)) {
|
||||
UIWidgets::EnhancementSliderFloat("Aiming/First-Person Sensitivity: %d %%", "##FirstPersonSensitivity",
|
||||
"gFirstPersonCameraSensitivity", 0.01f, 5.0f, "", 1.0f, true, true);
|
||||
} else {
|
||||
CVar_SetFloat("gFirstPersonCameraSensitivity", 1.0f);
|
||||
}
|
||||
SohImGui::EndGroupPanel();
|
||||
|
||||
UIWidgets::Spacer(0);
|
||||
SohImGui::BeginGroupPanel("Third-Person Camera", ImGui::GetContentRegionAvail());
|
||||
|
||||
UIWidgets::PaddedEnhancementCheckbox("Free Camera", "gFreeCamera");
|
||||
DrawHelpIcon("Enables free camera control\nNote: You must remap C buttons off of the right stick in the "
|
||||
"controller config menu, and map the camera stick to the right stick.");
|
||||
UIWidgets::PaddedEnhancementCheckbox("Invert Camera X Axis", "gInvertXAxis");
|
||||
DrawHelpIcon("Inverts the Camera X Axis in:\n-Free camera");
|
||||
UIWidgets::PaddedEnhancementCheckbox("Invert Camera Y Axis", "gInvertYAxis");
|
||||
DrawHelpIcon("Inverts the Camera Y Axis in:\n-Free camera");
|
||||
UIWidgets::EnhancementSliderFloat("Third-Person Sensitivity: %d %%", "##ThirdPersonSensitivity",
|
||||
"gThirdPersonCameraSensitivity", 0.01f, 5.0f, "", 1.0f, true, true);
|
||||
UIWidgets::EnhancementSliderInt("Camera Distance: %d", "##CamDist",
|
||||
"gFreeCameraDistMax", 100, 900, "", 185, true);
|
||||
UIWidgets::EnhancementSliderInt("Camera Transition Speed: %d", "##CamTranSpeed",
|
||||
"gFreeCameraTransitionSpeed", 0, 900, "", 25, true);
|
||||
SohImGui::EndGroupPanel();
|
||||
}
|
||||
|
||||
void DrawDpadControlPanel() {
|
||||
|
@ -59,7 +59,7 @@ const std::vector<const char*> enhancementsCvars = {
|
||||
"gInvertXAxis",
|
||||
"gInvertYAxis",
|
||||
"gRightStickAiming",
|
||||
"gDisableAutoCenterView",
|
||||
"gDisableAutoCenterViewFirstPerson",
|
||||
"gTextSpeed",
|
||||
"gMweepSpeed",
|
||||
"gForgeTime",
|
||||
|
@ -944,8 +944,6 @@ namespace GameMenuBar {
|
||||
}
|
||||
UIWidgets::PaddedEnhancementCheckbox("Skip Text", "gSkipText", true, false);
|
||||
UIWidgets::Tooltip("Holding down B skips text");
|
||||
UIWidgets::PaddedEnhancementCheckbox("Free Camera", "gFreeCamera", true, false);
|
||||
UIWidgets::Tooltip("Enables camera control\nNote: You must remap C buttons off of the right stick in the controller config menu, and map the camera stick to the right stick.");
|
||||
|
||||
#ifdef __SWITCH__
|
||||
UIWidgets::Spacer(0);
|
||||
|
@ -1485,8 +1485,8 @@ s32 Camera_Free(Camera* camera) {
|
||||
|
||||
camera->animState = 0;
|
||||
|
||||
f32 newCamX = -D_8015BD7C->state.input[0].cur.right_stick_x * 10.0f * (CVar_GetFloat("gCameraSensitivity", 1.0f));
|
||||
f32 newCamY = D_8015BD7C->state.input[0].cur.right_stick_y * 10.0f * (CVar_GetFloat("gCameraSensitivity", 1.0f));
|
||||
f32 newCamX = -D_8015BD7C->state.input[0].cur.right_stick_x * 10.0f * (CVar_GetFloat("gThirdPersonCameraSensitivity", 1.0f));
|
||||
f32 newCamY = D_8015BD7C->state.input[0].cur.right_stick_y * 10.0f * (CVar_GetFloat("gThirdPersonCameraSensitivity", 1.0f));
|
||||
|
||||
camera->play->camX += newCamX * (CVar_GetS32("gInvertXAxis", 0) ? -1 : 1);
|
||||
camera->play->camY += newCamY * (CVar_GetS32("gInvertYAxis", 1) ? 1 : -1);
|
||||
@ -1498,7 +1498,11 @@ s32 Camera_Free(Camera* camera) {
|
||||
camera->play->camY = -0x228C;
|
||||
}
|
||||
|
||||
camera->dist = Camera_LERPCeilF(para1->distTarget, camera->dist, 1.0f / camera->rUpdateRateInv, 0.0f);
|
||||
f32 distTarget = CVar_GetS32("gFreeCameraDistMax", para1->distTarget);
|
||||
f32 speedScaler = CVar_GetS32("gFreeCameraTransitionSpeed", 25);
|
||||
f32 distDiff = ABS(distTarget - camera->dist);
|
||||
if (distDiff > 0)
|
||||
camera->dist = Camera_LERPCeilF(distTarget, camera->dist, speedScaler / (distDiff + speedScaler), 0.0f);
|
||||
OLib_Vec3fDiffToVecSphGeo(&spA8, at, eyeNext);
|
||||
|
||||
spA8.r = camera->dist;
|
||||
|
@ -11256,24 +11256,24 @@ void Player_Destroy(Actor* thisx, PlayState* play) {
|
||||
gSaveContext.linkAge = play->linkAgeOnLoad;
|
||||
}
|
||||
|
||||
//first person manipulate player actor
|
||||
s16 func_8084ABD8(PlayState* play, Player* this, s32 arg2, s16 arg3) {
|
||||
s32 temp1;
|
||||
s16 temp2;
|
||||
s16 temp3;
|
||||
|
||||
if (!func_8002DD78(this) && !func_808334B4(this) && (arg2 == 0)) {
|
||||
if (!CVar_GetS32("gDisableAutoCenterView", 0)) {
|
||||
temp2 = sControlInput->rel.stick_y * 240.0f * (CVar_GetS32("gInvertYAxis", 1) ? 1 : -1); // Sensitivity not applied here because higher than default sensitivies will allow the camera to escape the autocentering, and glitch out massively
|
||||
if (!func_8002DD78(this) && !func_808334B4(this) && (arg2 == 0) && !CVar_GetS32("gDisableAutoCenterViewFirstPerson", 0)) {
|
||||
temp2 = sControlInput->rel.stick_y * 240.0f * (CVar_GetS32("gInvertAimingYAxis", 1) ? 1 : -1); // Sensitivity not applied here because higher than default sensitivies will allow the camera to escape the autocentering, and glitch out massively
|
||||
Math_SmoothStepToS(&this->actor.focus.rot.x, temp2, 14, 4000, 30);
|
||||
|
||||
temp2 = sControlInput->rel.stick_x * -16.0f * (CVar_GetS32("gInvertXAxis", 0) ? -1 : 1) * (CVar_GetFloat("gCameraSensitivity", 1.0f));
|
||||
temp2 = sControlInput->rel.stick_x * -16.0f * (CVar_GetS32("gInvertAimingXAxis", 0) ? -1 : 1) * (CVar_GetFloat("gFirstPersonCameraSensitivity", 1.0f));
|
||||
temp2 = CLAMP(temp2, -3000, 3000);
|
||||
this->actor.focus.rot.y += temp2;
|
||||
} else {
|
||||
temp1 = (this->stateFlags1 & PLAYER_STATE1_23) ? 3500 : 14000;
|
||||
temp3 = ((sControlInput->rel.stick_y >= 0) ? 1 : -1) *
|
||||
(s32)((1.0f - Math_CosS(sControlInput->rel.stick_y * 200)) * 1500.0f *
|
||||
(CVar_GetS32("gInvertYAxis", 1) ? 1 : -1)) * (CVar_GetFloat("gCameraSensitivity", 1.0f));
|
||||
(CVar_GetS32("gInvertAimingYAxis", 1) ? 1 : -1)) * (CVar_GetFloat("gFirstPersonCameraSensitivity", 1.0f));
|
||||
this->actor.focus.rot.x += temp3;
|
||||
|
||||
if (fabsf(sControlInput->cur.gyro_x) > 0.01f) {
|
||||
@ -11282,7 +11282,7 @@ s16 func_8084ABD8(PlayState* play, Player* this, s32 arg2, s16 arg3) {
|
||||
|
||||
if (fabsf(sControlInput->cur.right_stick_y) > 15.0f && CVar_GetS32("gRightStickAiming", 0) != 0) {
|
||||
this->actor.focus.rot.x -=
|
||||
(sControlInput->cur.right_stick_y) * 10.0f * (CVar_GetS32("gInvertYAxis", 1) ? -1 : 1) * (CVar_GetFloat("gCameraSensitivity", 1.0f));
|
||||
(sControlInput->cur.right_stick_y) * 10.0f * (CVar_GetS32("gInvertAimingYAxis", 1) ? -1 : 1) * (CVar_GetFloat("gFirstPersonCameraSensitivity", 1.0f));
|
||||
}
|
||||
|
||||
this->actor.focus.rot.x = CLAMP(this->actor.focus.rot.x, -temp1, temp1);
|
||||
@ -11291,7 +11291,7 @@ s16 func_8084ABD8(PlayState* play, Player* this, s32 arg2, s16 arg3) {
|
||||
temp2 = this->actor.focus.rot.y - this->actor.shape.rot.y;
|
||||
temp3 = ((sControlInput->rel.stick_x >= 0) ? 1 : -1) *
|
||||
(s32)((1.0f - Math_CosS(sControlInput->rel.stick_x * 200)) * -1500.0f *
|
||||
(CVar_GetS32("gInvertXAxis", 0) ? -1 : 1)) * (CVar_GetFloat("gCameraSensitivity", 1.0f));
|
||||
(CVar_GetS32("gInvertAimingXAxis", 0) ? -1 : 1)) * (CVar_GetFloat("gFirstPersonCameraSensitivity", 1.0f));
|
||||
temp2 += temp3;
|
||||
|
||||
this->actor.focus.rot.y = CLAMP(temp2, -temp1, temp1) + this->actor.shape.rot.y;
|
||||
@ -11302,43 +11302,7 @@ s16 func_8084ABD8(PlayState* play, Player* this, s32 arg2, s16 arg3) {
|
||||
|
||||
if (fabsf(sControlInput->cur.right_stick_x) > 15.0f && CVar_GetS32("gRightStickAiming", 0) != 0) {
|
||||
this->actor.focus.rot.y +=
|
||||
(sControlInput->cur.right_stick_x) * 10.0f * (CVar_GetS32("gInvertXAxis", 0) ? 1 : -1) * (CVar_GetFloat("gCameraSensitivity", 1.0f));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
temp1 = (this->stateFlags1 & PLAYER_STATE1_23) ? 3500 : 14000;
|
||||
temp3 =
|
||||
((sControlInput->rel.stick_y >= 0) ? 1 : -1) * (s32)((1.0f - Math_CosS(sControlInput->rel.stick_y * 200)) *
|
||||
1500.0f * (CVar_GetS32("gInvertYAxis", 1) ? 1 : -1)) * (CVar_GetFloat("gCameraSensitivity", 1.0f));
|
||||
this->actor.focus.rot.x += temp3;
|
||||
|
||||
if (fabsf(sControlInput->cur.gyro_x) > 0.01f) {
|
||||
this->actor.focus.rot.x -= (sControlInput->cur.gyro_x) * 750.0f;
|
||||
}
|
||||
|
||||
if (fabsf(sControlInput->cur.right_stick_y) > 15.0f && CVar_GetS32("gRightStickAiming", 0) != 0) {
|
||||
this->actor.focus.rot.x -=
|
||||
(sControlInput->cur.right_stick_y) * 10.0f * (CVar_GetS32("gInvertYAxis", 1) ? -1 : 1) * (CVar_GetFloat("gCameraSensitivity", 1.0f));
|
||||
}
|
||||
|
||||
this->actor.focus.rot.x = CLAMP(this->actor.focus.rot.x, -temp1, temp1);
|
||||
|
||||
temp1 = 19114;
|
||||
temp2 = this->actor.focus.rot.y - this->actor.shape.rot.y;
|
||||
temp3 =
|
||||
((sControlInput->rel.stick_x >= 0) ? 1 : -1) * (s32)((1.0f - Math_CosS(sControlInput->rel.stick_x * 200)) *
|
||||
-1500.0f * (CVar_GetS32("gInvertXAxis", 0) ? -1 : 1)) * (CVar_GetFloat("gCameraSensitivity", 1.0f));
|
||||
temp2 += temp3;
|
||||
|
||||
this->actor.focus.rot.y = CLAMP(temp2, -temp1, temp1) + this->actor.shape.rot.y;
|
||||
|
||||
if (fabsf(sControlInput->cur.gyro_y) > 0.01f) {
|
||||
this->actor.focus.rot.y += (sControlInput->cur.gyro_y) * 750.0f;
|
||||
}
|
||||
|
||||
if (fabsf(sControlInput->cur.right_stick_x) > 15.0f && CVar_GetS32("gRightStickAiming", 0) != 0) {
|
||||
this->actor.focus.rot.y +=
|
||||
(sControlInput->cur.right_stick_x) * 10.0f * (CVar_GetS32("gInvertXAxis", 0) ? 1 : -1) * (CVar_GetFloat("gCameraSensitivity", 1.0f));
|
||||
(sControlInput->cur.right_stick_x) * 10.0f * (CVar_GetS32("gInvertAimingXAxis", 0) ? 1 : -1) * (CVar_GetFloat("gFirstPersonCameraSensitivity", 1.0f));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user