Skip to content

Commit

Permalink
Main menu: highlight menu items when mousing over
Browse files Browse the repository at this point in the history
  • Loading branch information
dseguin committed May 17, 2022
1 parent 67df929 commit 3c80a70
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/main_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ bool main_menu::opening_screen()

// for mouse selection
ctxt.register_action( "SELECT" );
ctxt.register_action( "MOUSE_MOVE" );

// for the menu shortcuts
ctxt.register_action( "ANY_INPUT" );
Expand Down Expand Up @@ -699,6 +700,34 @@ bool main_menu::opening_screen()
}
}
}
if( action == "SELECT" || action == "MOUSE_MOVE" ) {
cata::optional<point> coord = ctxt.get_coordinates_text( catacurses::stdscr );
for( const auto &it : main_menu_button_map ) {
if( coord.has_value() && it.first.contains( coord.value() ) ) {
if( sel1 != it.second ) {
sel1 = it.second;
sel2 = sel1 == getopt( main_menu_opts::LOADCHAR ) ? last_world_pos : 0;
}
if( action == "SELECT" &&
( sel1 == getopt( main_menu_opts::HELP ) || sel1 == getopt( main_menu_opts::QUIT ) ) ) {
action = "CONFIRM";
}
ui_manager::redraw();
break;
}
}
for( const auto &it : main_menu_sub_button_map ) {
if( coord.has_value() && it.first.contains( coord.value() ) ) {
sel1 = it.second.first;
sel2 = it.second.second;
if( action == "SELECT" ) {
action = "CONFIRM";
}
ui_manager::redraw();
break;
}
}
}

// also check special keys
if( action == "QUIT" ) {
Expand Down

0 comments on commit 3c80a70

Please sign in to comment.