Skip to content

Commit

Permalink
Allow traversing main menu horizontally with TAB and SHIFT + TAB (#40…
Browse files Browse the repository at this point in the history
…585)
  • Loading branch information
TheStoneWolf authored May 29, 2020
1 parent e45f651 commit 6847331
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions src/main_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,11 +524,15 @@ bool main_menu::opening_screen()
load_char_templates();

ctxt.register_cardinal();
ctxt.register_action( "NEXT_TAB" );
ctxt.register_action( "PREV_TAB" );

ctxt.register_action( "QUIT" );
ctxt.register_action( "CONFIRM" );
ctxt.register_action( "DELETE_TEMPLATE" );
ctxt.register_action( "PAGE_UP" );
ctxt.register_action( "PAGE_DOWN" );

// for the menu shortcuts
ctxt.register_action( "ANY_INPUT" );
bool start = false;
Expand Down Expand Up @@ -625,15 +629,15 @@ bool main_menu::opening_screen()
sel1 = 8;
action = "CONFIRM";
}
} else if( action == "LEFT" ) {
} else if( action == "LEFT" || action == "PREV_TAB" ) {
sel_line = 0;
if( sel1 > 0 ) {
sel1--;
} else {
sel1 = 8;
}
on_move();
} else if( action == "RIGHT" ) {
} else if( action == "RIGHT" || action == "NEXT_TAB" ) {
sel_line = 0;
if( sel1 < 8 ) {
sel1++;
Expand Down Expand Up @@ -685,14 +689,14 @@ bool main_menu::opening_screen()
}

std::string action = ctxt.handle_input();
if( action == "LEFT" ) {
if( action == "LEFT" || action == "PREV_TAB" ) {
if( sel2 > 0 ) {
sel2--;
} else {
sel2 = NUM_SPECIAL_GAMES - 2;
}
on_move();
} else if( action == "RIGHT" ) {
} else if( action == "RIGHT" || action == "NEXT_TAB" ) {
if( sel2 < NUM_SPECIAL_GAMES - 2 ) {
sel2++;
} else {
Expand Down Expand Up @@ -742,14 +746,14 @@ bool main_menu::opening_screen()
}
}

if( action == "LEFT" ) {
if( action == "LEFT" || action == "PREV_TAB" ) {
if( sel2 > 0 ) {
--sel2;
} else {
sel2 = settings_subs_to_display - 1;
}
on_move();
} else if( action == "RIGHT" ) {
} else if( action == "RIGHT" || action == "NEXT_TAB" ) {
if( sel2 < settings_subs_to_display - 1 ) {
++sel2;
} else {
Expand Down Expand Up @@ -869,13 +873,13 @@ bool main_menu::new_character_tab()
}
}
}
if( action == "LEFT" ) {
if( action == "LEFT" || action == "PREV_TAB" ) {
sel2--;
if( sel2 < 0 ) {
sel2 = vSubItems.size() - 1;
}
on_move();
} else if( action == "RIGHT" ) {
} else if( action == "RIGHT" || action == "NEXT_TAB" ) {
sel2++;
if( sel2 >= static_cast<int>( vSubItems.size() ) ) {
sel2 = 0;
Expand Down Expand Up @@ -959,7 +963,7 @@ bool main_menu::new_character_tab()
} else {
sel3 = 0;
}
} else if( action == "LEFT" || action == "QUIT" ) {
} else if( action == "LEFT" || action == "PREV_TAB" || action == "QUIT" ) {
sel1 = 1;
layer = 2;
} else if( !templates.empty() && action == "DELETE_TEMPLATE" ) {
Expand All @@ -975,7 +979,7 @@ bool main_menu::new_character_tab()
}
}
}
} else if( action == "RIGHT" || action == "CONFIRM" ) {
} else if( action == "RIGHT" || action == "NEXT_TAB" || action == "CONFIRM" ) {
on_out_of_scope cleanup( []() {
g->u = avatar();
world_generator->set_active_world( nullptr );
Expand Down Expand Up @@ -1128,9 +1132,9 @@ bool main_menu::load_character_tab( bool transfer )
} else {
sel2 = 0;
}
} else if( action == "LEFT" || action == "QUIT" ) {
} else if( action == "LEFT" || action == "PREV_TAB" || action == "QUIT" ) {
layer = 1;
} else if( action == "RIGHT" || action == "CONFIRM" ) {
} else if( action == "RIGHT" || action == "NEXT_TAB" || action == "CONFIRM" ) {
if( sel2 >= 0 && sel2 < static_cast<int>( all_worldnames.size() ) ) {
layer = 3;
}
Expand Down Expand Up @@ -1165,11 +1169,11 @@ bool main_menu::load_character_tab( bool transfer )
} else {
sel3 = 0;
}
} else if( action == "LEFT" || action == "QUIT" ) {
} else if( action == "LEFT" || action == "PREV_TAB" || action == "QUIT" ) {
layer = transfer ? 1 : 2;
sel3 = 0;
}
if( action == "RIGHT" || action == "CONFIRM" ) {
if( action == "RIGHT" || action == "NEXT_TAB" || action == "CONFIRM" ) {
if( sel3 >= 0 && sel3 < static_cast<int>( savegames.size() ) ) {
on_out_of_scope cleanup( []() {
g->u = avatar();
Expand Down Expand Up @@ -1324,11 +1328,11 @@ void main_menu::world_tab()
sel3 = 0;
}
on_move();
} else if( action == "LEFT" || action == "QUIT" ) {
} else if( action == "LEFT" || action == "PREV_TAB" || action == "QUIT" ) {
layer = 2;
}

if( action == "RIGHT" || action == "CONFIRM" ) {
if( action == "RIGHT" || action == "NEXT_TAB" || action == "CONFIRM" ) {
if( sel3 == 2 ) { // Active World Mods
WORLDPTR world = world_generator->get_world( all_worldnames[sel2 - 1] );
world_generator->show_active_world_mods( world->active_mod_order );
Expand Down Expand Up @@ -1392,10 +1396,10 @@ void main_menu::world_tab()
} else {
sel2 = 0;
}
} else if( action == "LEFT" || action == "QUIT" ) {
} else if( action == "LEFT" || action == "PREV_TAB" || action == "QUIT" ) {
layer = 1;
}
if( action == "RIGHT" || action == "CONFIRM" ) {
if( action == "RIGHT" || action == "NEXT_TAB" || action == "CONFIRM" ) {
if( sel2 == 0 ) {
world_generator->make_new_world();

Expand Down

0 comments on commit 6847331

Please sign in to comment.