Skip to content

Commit

Permalink
fix: main menu being unordered (cataclysmbnteam#2823)
Browse files Browse the repository at this point in the history
* fix: menu entries being unordered

* refactor: use anonymous namespace

(followed clang-tidy)
  • Loading branch information
scarf005 authored May 18, 2023
1 parent 5ff9d73 commit 8273e2f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,21 +657,23 @@ bool can_interact_at( action_id action, const tripoint &p )
}
}

static auto make_register_actions( std::vector<uilist_entry> &entries, const input_context &ctxt )
namespace
{
return [&]( std::set<action_id> &&names ) -> void {
auto make_register_actions( std::vector<uilist_entry> &entries, const input_context &ctxt )
{
return [&]( std::vector<action_id> &&names ) -> void {
const auto fn = [&]( action_id name ) -> uilist_entry {
return { name, true, hotkey_for_action( name ), ctxt.get_action_name( action_ident( name ) ) };
};
std::transform( names.begin(), names.end(), std::back_inserter( entries ), fn );
};
}

static auto make_register_categories( std::vector<uilist_entry> &entries,
std::map<int, std::string> &categories_by_int,
int &last_category )
auto make_register_categories( std::vector<uilist_entry> &entries,
std::map<int, std::string> &categories_by_int,
int &last_category )
{
return [&]( std::set<std::string> &&names ) -> void {
return [&]( std::vector<std::string> &&names ) -> void {
const auto fn = [&]( const std::string & name ) -> uilist_entry {
categories_by_int[last_category] = name;
return { last_category++, true, -1, name + "" };
Expand All @@ -680,6 +682,8 @@ static auto make_register_categories( std::vector<uilist_entry> &entries,
};
}

} // namespace

action_id handle_action_menu()
{
const input_context ctxt = get_default_mode_input_context();
Expand Down

0 comments on commit 8273e2f

Please sign in to comment.