Skip to content

Commit

Permalink
Fast forward renaming and adaptive descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
MikuChan03 authored Sep 30, 2023
1 parent a9760b5 commit 2590e7f
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 20 deletions.
8 changes: 4 additions & 4 deletions src/game_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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";

Expand Down
4 changes: 2 additions & 2 deletions src/game_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ struct Game_ConfigAudio {
};

struct Game_ConfigInput {
RangeConfigParam<int> speed_modifier{ "Fast Forward: Speed", "Set fast forward speed", "Input", "SpeedModifier", 3, 2, 100 };
RangeConfigParam<int> speed_modifier_plus{ "Fast Forward Plus: Speed", "Set fast forward plus speed", "Input", "SpeedModifierPlus", 10, 2, 100 };
RangeConfigParam<int> speed_modifier_a{ "Fast Forward A: Speed", "Set fast forward A speed", "Input", "SpeedModifierA", 3, 2, 100 };
RangeConfigParam<int> 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 };
Expand Down
8 changes: 4 additions & 4 deletions src/input_buttons.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
12 changes: 6 additions & 6 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -198,8 +198,8 @@ void Player::Init(std::vector<std::string> 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() {
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 22 additions & 2 deletions src/window_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -391,6 +391,15 @@ void Window_Settings::RefreshButtonCategory() {
[this]() { Push(eInputListButtonsDeveloper, 2); });
}

const char * GetFastForwardDescription(int index){
Game_ConfigInput& cfg = Input::GetInputSource()->GetConfig();
RangeConfigParam<int> 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();
Expand Down Expand Up @@ -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](){
Expand Down

0 comments on commit 2590e7f

Please sign in to comment.