mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-21 05:43:42 -07:00
Add support for extra buttons to be used as walk speed modifiers (#449)
This commit is contained in:
parent
242757777c
commit
8df4d640ac
10 changed files with 131 additions and 81 deletions
|
@ -48,19 +48,12 @@ namespace GameControlEditor {
|
|||
}
|
||||
}
|
||||
|
||||
void DrawHelpIcon(const std::string& helptext, bool sameline = true, int Pos = 0) {
|
||||
void DrawHelpIcon(const std::string& helptext) {
|
||||
// place the ? button to the most of the right side of the cell it is using.
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 22);
|
||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 15);
|
||||
ImGui::SmallButton("?");
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::SetTooltip("%s", helptext.c_str());
|
||||
}
|
||||
|
||||
if (sameline) {
|
||||
//I do not use ImGui::SameLine(); because it make some element vanish.
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 22);
|
||||
}
|
||||
UIWidgets::Tooltip(helptext.c_str());
|
||||
}
|
||||
|
||||
typedef uint32_t N64ButtonMask;
|
||||
|
@ -222,27 +215,36 @@ namespace GameControlEditor {
|
|||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
// CurrentPort is indexed started at 1 here due to the Generic tab, instead of 0 like in InputEditor
|
||||
// Therefore CurrentPort - 1 must always be used inside this function instead of CurrentPort
|
||||
void DrawCustomButtons() {
|
||||
SohImGui::GetInputEditor()->DrawControllerSelect(CurrentPort - 1);
|
||||
|
||||
SohImGui::GetInputEditor()->DrawButton("Modifier 1", BTN_MODIFIER1, CurrentPort - 1, &BtnReading);
|
||||
SohImGui::GetInputEditor()->DrawButton("Modifier 2", BTN_MODIFIER2, CurrentPort - 1, &BtnReading);
|
||||
}
|
||||
|
||||
void DrawCameraControlPanel() {
|
||||
if (!ImGui::CollapsingHeader("Camera Controls")) {
|
||||
if (!ImGui::CollapsingHeader("Camera Controls")) {
|
||||
return;
|
||||
}
|
||||
|
||||
ImVec2 cursor = ImGui::GetCursorPos();
|
||||
ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5));
|
||||
UIWidgets::PaddedEnhancementCheckbox("Invert Camera X Axis", "gInvertXAxis");
|
||||
UIWidgets::Tooltip("Inverts the Camera X Axis in:\n-Free camera\n-C-Up view\n-Weapon Aiming");
|
||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5);
|
||||
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");
|
||||
UIWidgets::Tooltip("Inverts the Camera Y Axis in:\n-Free camera\n-C-Up view\n-Weapon Aiming");
|
||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5);
|
||||
DrawHelpIcon("Inverts the Camera Y Axis in:\n-Free camera\n-C-Up view\n-Weapon Aiming");
|
||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5);
|
||||
UIWidgets::PaddedEnhancementCheckbox("Right Stick Aiming", "gRightStickAiming");
|
||||
UIWidgets::Tooltip("Allows for aiming with the rights stick when:\n-Aiming in the C-Up view\n-Aiming with weapons");
|
||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5);
|
||||
DrawHelpIcon("Allows for aiming with the right stick when:\n-Aiming in the C-Up view\n-Aiming with weapons");
|
||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5);
|
||||
UIWidgets::PaddedEnhancementCheckbox("Disable Auto-Centering in First Person View", "gDisableAutoCenterView");
|
||||
UIWidgets::Tooltip("Prevents the C-Up view from auto-centering, allowing for Gyro Aiming");
|
||||
}
|
||||
|
||||
void DrawUI(bool& open) {
|
||||
DrawHelpIcon("Prevents the C-Up view from auto-centering, allowing for Gyro Aiming");
|
||||
}
|
||||
|
||||
void DrawUI(bool& open) {
|
||||
if (!open) {
|
||||
CVar_SetS32("gGameControlEditorEnabled", false);
|
||||
return;
|
||||
|
@ -250,8 +252,27 @@ namespace GameControlEditor {
|
|||
|
||||
ImGui::SetNextWindowSize(ImVec2(465, 430), ImGuiCond_FirstUseEver);
|
||||
if (ImGui::Begin("Game Controls Configuration", &open)) {
|
||||
DrawOcarinaControlPanel();
|
||||
DrawCameraControlPanel();
|
||||
ImGui::BeginTabBar("##CustomControllers");
|
||||
if (ImGui::BeginTabItem("Generic")) {
|
||||
CurrentPort = 0;
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
for (int i = 1; i <= 4; i++) {
|
||||
if (ImGui::BeginTabItem(StringHelper::Sprintf("Port %d", i).c_str())) {
|
||||
CurrentPort = i;
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndTabBar();
|
||||
|
||||
if (CurrentPort == 0) {
|
||||
DrawOcarinaControlPanel();
|
||||
DrawCameraControlPanel();
|
||||
} else {
|
||||
DrawCustomButtons();
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
namespace GameControlEditor {
|
||||
static int CurrentPort = 0;
|
||||
static int BtnReading = -1;
|
||||
void Init();
|
||||
}
|
||||
|
|
|
@ -725,6 +725,12 @@ namespace GameMenuBar {
|
|||
UIWidgets::Tooltip("Allows the cursor on the pause menu to be over any slot\nSimilar to Rando and Spaceworld 97");
|
||||
UIWidgets::PaddedEnhancementCheckbox("Answer Navi Prompt with L Button", "gNaviOnL", true, false);
|
||||
UIWidgets::Tooltip("Speak to Navi with L but enter first-person camera with C-Up");
|
||||
UIWidgets::PaddedEnhancementCheckbox("Enable walk speed modifiers", "gEnableWalkModify", true, false);
|
||||
UIWidgets::Tooltip("Hold the assigned button to change the maximum walking speed\nTo change the assigned button, click Customize Game Controls");
|
||||
if (CVar_GetS32("gEnableWalkModify", 0)) {
|
||||
UIWidgets::EnhancementSliderFloat("Modifier 1: %d %%", "##WalkMod1", "gWalkModifierOne", 0.0f, 5.0f, "", 1.0f, true);
|
||||
UIWidgets::EnhancementSliderFloat("Modifier 2: %d %%", "##WalkMod2", "gWalkModifierTwo", 0.0f, 5.0f, "", 1.0f, true);
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
|
|
|
@ -6031,8 +6031,12 @@ void func_8083DFE0(Player* this, f32* arg1, s16* arg2) {
|
|||
}
|
||||
}
|
||||
|
||||
if (CVar_GetS32("gMMBunnyHood", 0) != 0 && this->currentMask == PLAYER_MASK_BUNNY) {
|
||||
if (CVar_GetS32("gMMBunnyHood", 0) && this->currentMask == PLAYER_MASK_BUNNY) {
|
||||
maxSpeed *= 1.5f;
|
||||
} else if (CVar_GetS32("gEnableWalkModify", 0) && CHECK_BTN_ALL(sControlInput->cur.button, BTN_MODIFIER1)) {
|
||||
maxSpeed *= CVar_GetFloat("gWalkModifierOne", 1.0f);
|
||||
} else if (CVar_GetS32("gEnableWalkModify", 0) && CHECK_BTN_ALL(sControlInput->cur.button, BTN_MODIFIER2)) {
|
||||
maxSpeed *= CVar_GetFloat("gWalkModifierTwo", 1.0f);
|
||||
}
|
||||
|
||||
this->linearVelocity = CLAMP(this->linearVelocity, -maxSpeed, maxSpeed);
|
||||
|
@ -7650,8 +7654,12 @@ void func_80842180(Player* this, GlobalContext* globalCtx) {
|
|||
}
|
||||
}
|
||||
|
||||
if (CVar_GetS32("gMMBunnyHood", 0) != 0 && this->currentMask == PLAYER_MASK_BUNNY) {
|
||||
if (CVar_GetS32("gMMBunnyHood", 0) && this->currentMask == PLAYER_MASK_BUNNY) {
|
||||
sp2C *= 1.5f;
|
||||
} else if (CVar_GetS32("gEnableWalkModify", 0) && CHECK_BTN_ALL(sControlInput->cur.button, BTN_MODIFIER1)) {
|
||||
sp2C *= CVar_GetFloat("gWalkModifierOne", 1.0f);
|
||||
} else if (CVar_GetS32("gEnableWalkModify", 0) && CHECK_BTN_ALL(sControlInput->cur.button, BTN_MODIFIER2)) {
|
||||
sp2C *= CVar_GetFloat("gWalkModifierTwo", 1.0f);
|
||||
}
|
||||
|
||||
func_8083DF68(this, sp2C, sp2A);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue