1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-01-15 11:45:48 +00:00

factored out some functions from the normal view

This commit is contained in:
Zeno Rogue 2024-12-01 12:44:19 +01:00
parent 6cff0839fd
commit 1b61d7dc22
2 changed files with 33 additions and 24 deletions

View File

@ -553,6 +553,23 @@ EX array<int, 8> keys_vi = {{'l', 'n', 'j', 'b', 'h', 'y', 'k', 'u'}};
EX array<int, 8> keys_wasd = {{'d', 'c', 'x', 'z', 'a', 'q', 'w', 'e'}}; EX array<int, 8> keys_wasd = {{'d', 'c', 'x', 'z', 'a', 'q', 'w', 'e'}};
EX array<int, 8> keys_numpad = {{SDLK_KP6, SDLK_KP3, SDLK_KP2, SDLK_KP1, SDLK_KP4, SDLK_KP7, SDLK_KP8, SDLK_KP9}}; EX array<int, 8> keys_numpad = {{SDLK_KP6, SDLK_KP3, SDLK_KP2, SDLK_KP1, SDLK_KP4, SDLK_KP7, SDLK_KP8, SDLK_KP9}};
EX void handle_movement(int sym, int uni) {
if(!(uni >= 'A' && uni <= 'Z') && DEFAULTCONTROL && !game_keys_scroll) {
for(int i=0; i<8; i++)
if(among(sym, keys_vi[i], keys_wasd[i], (uni >= '0' && uni <= '9' && !ISMAC) ? -1 : keys_numpad[i]))
movepckeydir(i);
}
#if ISPANDORA
if(DEFAULTCONTROL) {
if(sym == SDLK_RIGHT) movepckeydir(0);
if(sym == SDLK_LEFT) movepckeydir(4);
if(sym == SDLK_DOWN) movepckeydir(2 + (pandora_leftclick?1:0) - (pandora_rightclick?1:0));
if(sym == SDLK_UP) movepckeydir(6 - (pandora_leftclick?1:0) + (pandora_rightclick?1:0));
}
#endif
}
EX void handleKeyNormal(int sym, int uni) { EX void handleKeyNormal(int sym, int uni) {
if(cheater && sym < 256 && sym > 0 && !dialog::key_actions.count(uni)) { if(cheater && sym < 256 && sym > 0 && !dialog::key_actions.count(uni)) {
@ -570,20 +587,7 @@ EX void handleKeyNormal(int sym, int uni) {
if(handleTune(sym, uni)) return; if(handleTune(sym, uni)) return;
#endif #endif
if(!(uni >= 'A' && uni <= 'Z') && DEFAULTCONTROL && !game_keys_scroll) { handle_movement(sym, uni);
for(int i=0; i<8; i++)
if(among(sym, keys_vi[i], keys_wasd[i], (uni >= '0' && uni <= '9' && !ISMAC) ? -1 : keys_numpad[i]))
movepckeydir(i);
}
#if ISPANDORA
if(DEFAULTCONTROL) {
if(sym == SDLK_RIGHT) movepckeydir(0);
if(sym == SDLK_LEFT) movepckeydir(4);
if(sym == SDLK_DOWN) movepckeydir(2 + (pandora_leftclick?1:0) - (pandora_rightclick?1:0));
if(sym == SDLK_UP) movepckeydir(6 - (pandora_leftclick?1:0) + (pandora_rightclick?1:0));
}
#endif
#if CAP_COMPLEX2 #if CAP_COMPLEX2
if(DEFAULTNOR(sym)) { if(DEFAULTNOR(sym)) {

View File

@ -5854,6 +5854,19 @@ EX void emptyscreen() {
EX int nohelp; EX int nohelp;
EX bool no_find_player; EX bool no_find_player;
EX void show_menu_button() {
if(menu_format != "")
displayButton(vid.xres-8, vid.yres-vid.fsize, eval_programmable_string(menu_format), 'v', 16);
else if(nomenukey || ISMOBILE)
;
#if CAP_TOUR
else if(tour::on)
displayButton(vid.xres-8, vid.yres-vid.fsize, XLAT("(ESC) tour menu"), SDLK_ESCAPE, 16);
#endif
else
displayButton(vid.xres-8, vid.yres-vid.fsize, XLAT("(v) menu"), 'v', 16);
}
EX void normalscreen() { EX void normalscreen() {
help = "@"; help = "@";
@ -5867,16 +5880,8 @@ EX void normalscreen() {
cmode = sm::NORMAL | sm::DOTOUR | sm::CENTER; cmode = sm::NORMAL | sm::DOTOUR | sm::CENTER;
if(viewdists && show_distance_lists) cmode |= sm::SIDE | sm::MAYDARK; if(viewdists && show_distance_lists) cmode |= sm::SIDE | sm::MAYDARK;
gamescreen(); drawStats(); gamescreen(); drawStats();
if(menu_format != "")
displayButton(vid.xres-8, vid.yres-vid.fsize, eval_programmable_string(menu_format), 'v', 16); show_menu_button();
else if(nomenukey || ISMOBILE)
;
#if CAP_TOUR
else if(tour::on)
displayButton(vid.xres-8, vid.yres-vid.fsize, XLAT("(ESC) tour menu"), SDLK_ESCAPE, 16);
#endif
else
displayButton(vid.xres-8, vid.yres-vid.fsize, XLAT("(v) menu"), 'v', 16);
keyhandler = handleKeyNormal; keyhandler = handleKeyNormal;
if(!playerfound && !anims::any_on() && !sphere && !no_find_player && mapeditor::drawplayer) if(!playerfound && !anims::any_on() && !sphere && !no_find_player && mapeditor::drawplayer)