Skip to content

Commit

Permalink
avoid copying input_events unnecessarily
Browse files Browse the repository at this point in the history
clang-tidy was concerned about it so I guess we can use references.
  • Loading branch information
Daniel Brooks committed Jul 2, 2024
1 parent 1a554c1 commit 3b5cd55
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/npctalk_rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ void follower_rules_ui_impl::rules_transfer_popup( bool &exporting_rules, bool &

template<typename T>
void follower_rules_ui_impl::checkbox( int rule_number, const T &this_rule,
input_event assigned_hotkey, input_event pressed_key )
input_event &assigned_hotkey, const input_event &pressed_key )
{
ImGui::PushID( rule_number );
print_hotkey( assigned_hotkey );
Expand All @@ -303,7 +303,7 @@ void follower_rules_ui_impl::checkbox( int rule_number, const T &this_rule,
ImGui::SameLine();
auto label = _( "Default" );
auto x = ImGui::GetWindowWidth() - ImGui::GetStyle().ScrollbarSize -
ImGui::GetStyle().WindowPadding.x - ImGui::CalcTextSize( label, NULL, true ).x;
ImGui::GetStyle().WindowPadding.x - ImGui::CalcTextSize( label, nullptr, true ).x;
ImGui::SetCursorPosX( x );
if( ImGui::Button( label ) ) {
guy->rules.clear_flag( this_rule.rule );
Expand All @@ -314,15 +314,15 @@ void follower_rules_ui_impl::checkbox( int rule_number, const T &this_rule,

template<typename T>
void follower_rules_ui_impl::radio_group( const std::string header_id, const char *title, T *rule,
std::map<T, std::string> &values, input_event assigned_hotkey, input_event pressed_key )
std::map<T, std::string> &values, input_event &assigned_hotkey, const input_event &pressed_key )
{
ImGui::Separator();
ImGui::NewLine();
multi_rule_header( header_id, * &*rule, values,
pressed_key == assigned_hotkey );
print_hotkey( assigned_hotkey );
ImGui::SameLine();
auto x = ImGui::GetCursorPosX();
float x = ImGui::GetCursorPosX();
draw_colored_text( title, c_white );
for( const std::pair<const T, std::string> &value : values ) {
std::string rule_text = get_parsed( value.second );
Expand Down
8 changes: 4 additions & 4 deletions src/npctalk_rules.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ class follower_rules_ui_impl : public cataimgui::window

// makes a checkbox for the rule
template<typename T>
void checkbox( int rule_number, const T &this_rule, input_event assigned_hotkey,
input_event pressed_key );
void checkbox( int rule_number, const T &this_rule, input_event &assigned_hotkey,
const input_event &pressed_key );

// makes one radio button per option in the map
template<typename T>
void radio_group( const std::string header_id, const char *title, T *rule,
std::map<T, std::string> &values, input_event assigned_hotkey, input_event pressed_key );
void radio_group( std::string header_id, const char *title, T *rule,
std::map<T, std::string> &values, input_event &assigned_hotkey, const input_event &pressed_key );

// Prepares for a rule option with multiple valid selections. Advances and wraps through
// those options as the hotkey is pressed.
Expand Down

0 comments on commit 3b5cd55

Please sign in to comment.