From 2590e7f0a5e7033b82a8f0f0daed70b2b4860981 Mon Sep 17 00:00:00 2001 From: MikuChan03 <39016940+MikuChan03@users.noreply.github.com> Date: Sun, 1 Oct 2023 01:59:35 +0200 Subject: [PATCH] Fast forward renaming and adaptive descriptions --- src/game_config.cpp | 8 ++++---- src/game_config.h | 4 ++-- src/input_buttons.h | 8 ++++---- src/player.cpp | 12 ++++++------ src/player.h | 4 ++-- src/window_settings.cpp | 24 ++++++++++++++++++++++-- 6 files changed, 40 insertions(+), 20 deletions(-) diff --git a/src/game_config.cpp b/src/game_config.cpp index 93202353cb..d93df1ff82 100644 --- a/src/game_config.cpp +++ b/src/game_config.cpp @@ -418,8 +418,8 @@ void Game_Config::LoadFromStream(Filesystem_Stream::InputStream& is) { input.gamepad_swap_analog.FromIni(ini); input.gamepad_swap_dpad_with_buttons.FromIni(ini); input.gamepad_swap_ab_and_xy.FromIni(ini); - input.speed_modifier.FromIni(ini); - input.speed_modifier_plus.FromIni(ini); + input.speed_modifier_a.FromIni(ini); + input.speed_modifier_b.FromIni(ini); /** PLAYER SECTION */ player.settings_autosave.FromIni(ini); @@ -487,8 +487,8 @@ void Game_Config::WriteToStream(Filesystem_Stream::OutputStream& os) const { input.gamepad_swap_analog.ToIni(os); input.gamepad_swap_dpad_with_buttons.ToIni(os); input.gamepad_swap_ab_and_xy.ToIni(os); - input.speed_modifier.ToIni(os); - input.speed_modifier_plus.ToIni(os); + input.speed_modifier_a.ToIni(os); + input.speed_modifier_b.ToIni(os); os << "\n"; diff --git a/src/game_config.h b/src/game_config.h index 82751cee47..4c84fe8810 100644 --- a/src/game_config.h +++ b/src/game_config.h @@ -97,8 +97,8 @@ struct Game_ConfigAudio { }; struct Game_ConfigInput { - RangeConfigParam speed_modifier{ "Fast Forward: Speed", "Set fast forward speed", "Input", "SpeedModifier", 3, 2, 100 }; - RangeConfigParam speed_modifier_plus{ "Fast Forward Plus: Speed", "Set fast forward plus speed", "Input", "SpeedModifierPlus", 10, 2, 100 }; + RangeConfigParam speed_modifier_a{ "Fast Forward A: Speed", "Set fast forward A speed", "Input", "SpeedModifierA", 3, 2, 100 }; + RangeConfigParam speed_modifier_b{ "Fast Forward B: Speed", "Set fast forward B speed", "Input", "SpeedModifierB", 10, 2, 100 }; BoolConfigParam gamepad_swap_analog{ "Gamepad: Swap Analog Sticks", "Swap left and right stick", "Input", "GamepadSwapAnalog", false }; BoolConfigParam gamepad_swap_dpad_with_buttons{ "Gamepad: Swap D-Pad with buttons", "Swap D-Pad with ABXY-Buttons", "Input", "GamepadSwapDpad", false }; BoolConfigParam gamepad_swap_ab_and_xy{ "Gamepad: Swap AB and XY", "Swap A and B with X and Y", "Input", "GamepadSwapAbxy", false }; diff --git a/src/input_buttons.h b/src/input_buttons.h index bcc6ff4b3f..eb2731f1e0 100644 --- a/src/input_buttons.h +++ b/src/input_buttons.h @@ -127,8 +127,8 @@ namespace Input { "MOUSE_MIDDLE", "SCROLL_UP", "SCROLL_DOWN", - "FAST_FORWARD", - "FAST_FORWARD_PLUS", + "FAST_FORWARD_A", + "FAST_FORWARD_B", "TOGGLE_FULLSCREEN", "TOGGLE_ZOOM", "BUTTON_COUNT"); @@ -172,8 +172,8 @@ namespace Input { "Middle mouse key", "Scroll up key", "Scroll down key", - "Fast forward the game", - "Fast forward the game even more", + "PLACEHOLDER", + "PLACEHOLDER", "Toggle Fullscreen mode", "Toggle Window Zoom level", "Total Button Count"); diff --git a/src/player.cpp b/src/player.cpp index 6aa0ed70c1..e86930e007 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -131,8 +131,8 @@ namespace Player { std::string replay_input_path; std::string record_input_path; std::string command_line; - int speed_modifier; - int speed_modifier_plus; + int speed_modifier_a; + int speed_modifier_b; int rng_seed = -1; Game_ConfigPlayer player_config; Game_ConfigGame game_config; @@ -198,8 +198,8 @@ void Player::Init(std::vector args) { Input::AddRecordingData(Input::RecordingData::CommandLine, command_line); player_config = std::move(cfg.player); - speed_modifier = cfg.input.speed_modifier.Get(); - speed_modifier_plus = cfg.input.speed_modifier_plus.Get(); + speed_modifier_a = cfg.input.speed_modifier_a.Get(); + speed_modifier_b = cfg.input.speed_modifier_b.Get(); } void Player::Run() { @@ -303,10 +303,10 @@ void Player::UpdateInput() { } float speed = 1.0; if (Input::IsSystemPressed(Input::FAST_FORWARD)) { - speed = speed_modifier; + speed = speed_modifier_a; } if (Input::IsSystemPressed(Input::FAST_FORWARD_PLUS)) { - speed = speed_modifier_plus; + speed = speed_modifier_b; } Game_Clock::SetGameSpeedFactor(speed); diff --git a/src/player.h b/src/player.h index 86d0ccff2d..dc7dd13b0e 100644 --- a/src/player.h +++ b/src/player.h @@ -399,8 +399,8 @@ namespace Player { * Only used for configuring the speedup, don't read this var directly use * GetSpeedModifier() instead. */ - extern int speed_modifier; - extern int speed_modifier_plus; + extern int speed_modifier_a; + extern int speed_modifier_b; /** * The engine game logic configuration diff --git a/src/window_settings.cpp b/src/window_settings.cpp index a1c2479f83..dcd0e6de36 100644 --- a/src/window_settings.cpp +++ b/src/window_settings.cpp @@ -378,8 +378,8 @@ void Window_Settings::RefreshInput() { AddOption(cfg.gamepad_swap_ab_and_xy, [&cfg](){ cfg.gamepad_swap_ab_and_xy.Toggle(); Input::ResetTriggerKeys(); }); AddOption(cfg.gamepad_swap_analog, [&cfg](){ cfg.gamepad_swap_analog.Toggle(); Input::ResetTriggerKeys(); }); AddOption(cfg.gamepad_swap_dpad_with_buttons, [&cfg](){ cfg.gamepad_swap_dpad_with_buttons.Toggle(); Input::ResetTriggerKeys(); }); - AddOption(cfg.speed_modifier, [this, &cfg](){ auto tmp = GetCurrentOption().current_value; Player::speed_modifier = tmp; cfg.speed_modifier.Set(tmp); }); - AddOption(cfg.speed_modifier_plus, [this, &cfg](){ auto tmp = GetCurrentOption().current_value; Player::speed_modifier_plus = tmp; cfg.speed_modifier_plus.Set(tmp); }); + AddOption(cfg.speed_modifier_a, [this, &cfg](){ auto tmp = GetCurrentOption().current_value; Player::speed_modifier_a = tmp; cfg.speed_modifier_a.Set(tmp); }); + AddOption(cfg.speed_modifier_b, [this, &cfg](){ auto tmp = GetCurrentOption().current_value; Player::speed_modifier_b = tmp; cfg.speed_modifier_b.Set(tmp); }); } void Window_Settings::RefreshButtonCategory() { @@ -391,6 +391,15 @@ void Window_Settings::RefreshButtonCategory() { [this]() { Push(eInputListButtonsDeveloper, 2); }); } +const char * GetFastForwardDescription(int index){ + Game_ConfigInput& cfg = Input::GetInputSource()->GetConfig(); + RangeConfigParam config_arr[] = {cfg.speed_modifier_a, cfg.speed_modifier_b}; + static char fast_forward_strs[2][64]; + + snprintf(fast_forward_strs[index], sizeof(fast_forward_strs[index]), "Run the game at x%i speed", config_arr[index].Get()); + return fast_forward_strs[index]; +} + void Window_Settings::RefreshButtonList() { auto& mappings = Input::GetInputSource()->GetButtonMappings(); auto custom_names = Input::GetInputKeyNames(); @@ -468,6 +477,17 @@ void Window_Settings::RefreshButtonList() { value_size += cur_value_size; } + switch(button){ + case Input::FAST_FORWARD: + help = GetFastForwardDescription(0); + break; + case Input::FAST_FORWARD_PLUS: + help = GetFastForwardDescription(1); + break; + default: + break; + } + auto param = MenuItem(name, help, value); AddOption(param, [this, button](){