Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"all" option for distraction manager #77342

Merged
merged 2 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
distraction manager option for toggling all
  • Loading branch information
Kamejeir committed Oct 25, 2024
commit bf13223f7fe140820aba6d09587c04b647cda577
23 changes: 22 additions & 1 deletion src/distraction_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ struct configurable_distraction {
bool *state;
std::string name;
std::string description;
bool is_toggle = false;
};

static const std::vector<configurable_distraction> &get_configurable_distractions()
Expand All @@ -41,6 +42,7 @@ static const std::vector<configurable_distraction> &get_configurable_distraction
{&uistate.distraction_mutation, translate_marker( "Mutation" ), translate_marker( "This distraction will interrupt your activity when you gain or lose a mutation." )},
{&uistate.distraction_oxygen, translate_marker( "Asphyxiation" ), translate_marker( "This distraction will interrupt your activity when you can't breathe." )},
{&uistate.distraction_withdrawal, translate_marker( "Withdrawal" ), translate_marker( "This distraction will interrupt your activity when you have withdrawals." )},
{&uistate.distraction_all, translate_marker( "Toggle all" ), translate_marker( "Toggle all distractions" ), uistate.is_toggle = true }
};
return configurable_distractions;
}
Expand Down Expand Up @@ -155,10 +157,29 @@ void distraction_manager_gui::show()
break;
}

bool toggle_state;
if( navigate_ui_list( action, currentLine, 5, number_of_distractions, true ) ) {
} else if( action == "CONFIRM" || action == "LEFT" || action == "RIGHT" ) {
*( get_configurable_distractions()[currentLine].state ) ^= true;
}
if( get_configurable_distractions()[currentLine].is_toggle ) {
toggle_state = uistate.distraction_all;
uistate.distraction_noise = toggle_state;
uistate.distraction_pain = toggle_state;
uistate.distraction_attack = toggle_state;
uistate.distraction_hostile_close = toggle_state;
uistate.distraction_hostile_spotted = toggle_state;
uistate.distraction_conversation = toggle_state;
uistate.distraction_asthma = toggle_state;
uistate.distraction_dangerous_field = toggle_state;
uistate.distraction_weather_change = toggle_state;
uistate.distraction_hunger = toggle_state;
uistate.distraction_thirst = toggle_state;
uistate.distraction_temperature = toggle_state;
uistate.distraction_mutation = toggle_state;
uistate.distraction_oxygen = toggle_state;
uistate.distraction_withdrawal = toggle_state;
}
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/uistate.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ class uistatedata
bool distraction_mutation = true;
bool distraction_oxygen = true;
bool distraction_withdrawal = true;
bool distraction_all = true;
bool numpad_navigation = false;
bool is_toggle = false;

// V Menu Stuff
int list_item_sort = 0;
Expand Down
Loading