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 all commits
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
21 changes: 21 additions & 0 deletions 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,9 +157,28 @@ 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 @@
bool distraction_mutation = true;
bool distraction_oxygen = true;
bool distraction_withdrawal = true;
bool distraction_all = true;

Check failure on line 162 in src/uistate.h

View workflow job for this annotation

GitHub Actions / build (src)

Function 'deserialize' appears to be a serialization function for class 'uistatedata' but does not mention field 'distraction_all'. [cata-serialize,-warnings-as-errors]

Check failure on line 162 in src/uistate.h

View workflow job for this annotation

GitHub Actions / build (src)

Function 'serialize' appears to be a serialization function for class 'uistatedata' but does not mention field 'distraction_all'. [cata-serialize,-warnings-as-errors]
bool numpad_navigation = false;
bool is_toggle = false;

Check failure on line 164 in src/uistate.h

View workflow job for this annotation

GitHub Actions / build (src)

Function 'deserialize' appears to be a serialization function for class 'uistatedata' but does not mention field 'is_toggle'. [cata-serialize,-warnings-as-errors]

Check failure on line 164 in src/uistate.h

View workflow job for this annotation

GitHub Actions / build (src)

Function 'serialize' appears to be a serialization function for class 'uistatedata' but does not mention field 'is_toggle'. [cata-serialize,-warnings-as-errors]

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