1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-25 01:20:37 +00:00

improved key handling: numpad works as directions with numlock off and numbers with numlock on; shift+5 works now; better key assignments in crystal rug

This commit is contained in:
Zeno Rogue 2018-12-06 12:31:51 +01:00
parent 9b21b9c5a0
commit b256ac70af
9 changed files with 115 additions and 93 deletions

View File

@ -209,15 +209,16 @@ namespace spiral {
goto breakloop; goto breakloop;
case SDL_KEYDOWN: { case SDL_KEYDOWN: {
int key = event.key.keysym.sym; int sym = event.key.keysym.sym;
// int uni = event.key.keysym.unicode; int uni = event.key.keysym.unicode;
if(key == SDLK_RIGHT) velx++; numlock_on = event.key.keysym.mod & KMOD_NUM;
if(key == SDLK_LEFT) velx--; if(DKEY == SDLK_RIGHT) velx++;
if(key == SDLK_UP) vely++; if(DKEY == SDLK_LEFT) velx--;
if(key == SDLK_DOWN) vely--; if(DKEY == SDLK_UP) vely++;
if(key == SDLK_ESCAPE) goto breakloop; if(DKEY == SDLK_DOWN) vely--;
if(key == 'h') displayhelp = !displayhelp; if(sym == SDLK_ESCAPE) goto breakloop;
if(key == 's') dosave = true; if(uni == 'h') displayhelp = !displayhelp;
if(uni == 's') dosave = true;
} }
} }
} }
@ -886,7 +887,7 @@ namespace conformal {
} }
else if(uni == 'a') else if(uni == 'a')
pushScreen(history_menu); pushScreen(history_menu);
else if(sym == 'r') { else if(uni == 'r') {
if(rotation < 0) rotation = 0; if(rotation < 0) rotation = 0;
dialog::editNumber(rotation, 0, 360, 90, 0, XLAT("rotation"), dialog::editNumber(rotation, 0, 360, 90, 0, XLAT("rotation"),
"This controls the automatic rotation of the world. " "This controls the automatic rotation of the world. "
@ -967,23 +968,23 @@ namespace conformal {
autoband = !autoband; autoband = !autoband;
else if(uni == 'm') else if(uni == 'm')
pushScreen(model_menu); pushScreen(model_menu);
else if(sym == 'a') else if(uni == 'a')
dialog::editNumber(lvspeed, -5, 5, .1, 1, XLAT("animation speed"), ""); dialog::editNumber(lvspeed, -5, 5, .1, 1, XLAT("animation speed"), "");
else if(sym == 'd') { else if(uni == 'd') {
dialog::editNumber(bandhalf, 5, 1000, 5, 200, XLAT("band width"), ""); dialog::editNumber(bandhalf, 5, 1000, 5, 200, XLAT("band width"), "");
dialog::bound_low(5); dialog::bound_low(5);
} }
else if(sym == 's') { else if(uni == 's') {
dialog::editNumber(bandsegment, 500, 32000, 500, 16000, XLAT("band segment"), ""); dialog::editNumber(bandsegment, 500, 32000, 500, 16000, XLAT("band segment"), "");
dialog::bound_low(500); dialog::bound_low(500);
} }
else if(sym == 'p') else if(uni == 'p')
dialog::editNumber(extra_line_steps, 0, 5, 1, 1, XLAT("extend the ends"), dialog::editNumber(extra_line_steps, 0, 5, 1, 1, XLAT("extend the ends"),
"0 = start at the game start, endat the end position; " "0 = start at the game start, endat the end position; "
"larger numbers give extra space at the ends." "larger numbers give extra space at the ends."
); );
else if(sym == 'g') { dospiral = !dospiral; } else if(uni == 'g') { dospiral = !dospiral; }
else if(sym == 'i') { else if(uni == 'i') {
if(canmove && !cheater) { if(canmove && !cheater) {
addMessage("Enable cheat mode or GAME OVER to use this"); addMessage("Enable cheat mode or GAME OVER to use this");
return; return;
@ -994,7 +995,7 @@ namespace conformal {
#if CAP_SDL #if CAP_SDL
else if(uni == 'f' && band_renderable_now()) createImage(dospiral); else if(uni == 'f' && band_renderable_now()) createImage(dospiral);
#endif #endif
else if(sym == 'j') { else if(uni == 'j') {
autobandhistory = !autobandhistory; autobandhistory = !autobandhistory;
} }
else if(doexiton(sym, uni)) popScreen(); else if(doexiton(sym, uni)) popScreen();

View File

@ -10,7 +10,7 @@ int mousex, mousey;
hyperpoint mouseh, mouseoh; hyperpoint mouseh, mouseoh;
bool leftclick, rightclick, targetclick, hiliteclick, anyshiftclick, wheelclick, bool leftclick, rightclick, targetclick, hiliteclick, anyshiftclick, wheelclick,
forcetarget, lshiftclick, lctrlclick; forcetarget, lshiftclick, lctrlclick, numlock_on;
bool gtouched; bool gtouched;
bool holdmouse; bool holdmouse;
@ -642,6 +642,7 @@ void handle_event(SDL_Event& ev) {
uni = ev.key.keysym.unicode; uni = ev.key.keysym.unicode;
if(ev.key.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT)) shiftmul = -1; if(ev.key.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT)) shiftmul = -1;
if(ev.key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) shiftmul /= 10; if(ev.key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) shiftmul /= 10;
numlock_on = ev.key.keysym.mod & KMOD_NUM;
if(sym == SDLK_RETURN && (ev.key.keysym.mod & (KMOD_LALT | KMOD_RALT))) { if(sym == SDLK_RETURN && (ev.key.keysym.mod & (KMOD_LALT | KMOD_RALT))) {
sym = 0; uni = 0; sym = 0; uni = 0;
switchFullscreen(); switchFullscreen();
@ -827,21 +828,36 @@ void displayabutton(int px, int py, string s, int col) {
} }
#endif #endif
bool numberkey(int sym, int uni, char number) { bool interpret_as_direction(int sym, int uni) {
return uni == number && !(sym >= SDLK_KP0 && sym <= SDLK_KP9); return (sym >= SDLK_KP0 && sym <= SDLK_KP9 && !numlock_on);
}
int get_direction_key(int sym, int uni) {
if(interpret_as_direction(sym, uni)) {
if(sym == SDLK_KP1) return SDLK_END;
if(sym == SDLK_KP2) return SDLK_DOWN;
if(sym == SDLK_KP3) return SDLK_PAGEDOWN;
if(sym == SDLK_KP4) return SDLK_LEFT;
if(sym == SDLK_KP6) return SDLK_RIGHT;
if(sym == SDLK_KP7) return SDLK_HOME;
if(sym == SDLK_KP8) return SDLK_UP;
if(sym == SDLK_KP8) return SDLK_PAGEUP;
return 0;
}
return sym;
} }
void gmodekeys(int sym, int uni) { void gmodekeys(int sym, int uni) {
#if CAP_RUG #if CAP_RUG
if(rug::rugged) rug::handlekeys(sym, uni); if(rug::rugged) rug::handlekeys(sym, uni);
#endif #endif
if(numberkey(sym, uni, '1') && !rug::rugged) { vid.alpha = 999; vid.scale = 998; vid.xposition = vid.yposition = 0; } if(NUMBERKEY == '1' && !rug::rugged) { vid.alpha = 999; vid.scale = 998; vid.xposition = vid.yposition = 0; }
if(numberkey(sym, uni, '2') && !rug::rugged) { vid.alpha = 1; vid.scale = 0.4; vid.xposition = vid.yposition = 0; } if(NUMBERKEY == '2' && !rug::rugged) { vid.alpha = 1; vid.scale = 0.4; vid.xposition = vid.yposition = 0; }
if(numberkey(sym, uni, '3') && !rug::rugged) { vid.alpha = 1; vid.scale = 1; vid.xposition = vid.yposition = 0; } if(NUMBERKEY == '3' && !rug::rugged) { vid.alpha = 1; vid.scale = 1; vid.xposition = vid.yposition = 0; }
if(numberkey(sym, uni, '4') && !rug::rugged) { vid.alpha = 0; vid.scale = 1; vid.xposition = vid.yposition = 0; } if(NUMBERKEY == '4' && !rug::rugged) { vid.alpha = 0; vid.scale = 1; vid.xposition = vid.yposition = 0; }
if(numberkey(sym, uni, '5')) { vid.wallmode += 60 + (shiftmul > 0 ? 1 : -1); vid.wallmode %= 6; } if(NUMBERKEY == '5') { vid.wallmode += 60 + (shiftmul > 0 ? 1 : -1); vid.wallmode %= 6; }
if(numberkey(sym, uni, '6')) vid.grid = !vid.grid; if(NUMBERKEY == '6') vid.grid = !vid.grid;
if(numberkey(sym, uni, '7')) { vid.darkhepta = !vid.darkhepta; } if(NUMBERKEY == '7') { vid.darkhepta = !vid.darkhepta; }
if(uni == '%') { if(uni == '%') {
if(vid.wallmode == 0) vid.wallmode = 6; if(vid.wallmode == 0) vid.wallmode = 6;
vid.wallmode--; vid.wallmode--;

View File

@ -400,26 +400,26 @@ namespace dialog {
} }
void handleNavigation(int &sym, int &uni) { void handleNavigation(int &sym, int &uni) {
if(uni == '\n' || uni == '\r' || sym == SDLK_KP5) if(uni == '\n' || uni == '\r' || DIRECTIONKEY == SDLK_KP5)
for(int i=0; i<isize(items); i++) for(int i=0; i<isize(items); i++)
if(isitem(items[i])) if(isitem(items[i]))
if(items[i].body == highlight_text) { if(items[i].body == highlight_text) {
uni = sym = items[i].key; uni = sym = items[i].key;
return; return;
} }
if(sym == SDLK_PAGEDOWN || sym == SDLK_KP3) { if(DKEY == SDLK_PAGEDOWN) {
for(int i=0; i<isize(items); i++) for(int i=0; i<isize(items); i++)
if(isitem(items[i])) if(isitem(items[i]))
highlight_text = items[i].body; highlight_text = items[i].body;
} }
if(sym == SDLK_PAGEUP || sym == SDLK_KP9) { if(DKEY == SDLK_PAGEUP) {
for(int i=0; i<isize(items); i++) for(int i=0; i<isize(items); i++)
if(isitem(items[i])) { if(isitem(items[i])) {
highlight_text = items[i].body; highlight_text = items[i].body;
break; break;
} }
} }
if(sym == SDLK_UP || sym == SDLK_KP8) { if(DKEY == SDLK_UP) {
string last = ""; string last = "";
for(int i=0; i<isize(items); i++) for(int i=0; i<isize(items); i++)
if(isitem(items[i])) if(isitem(items[i]))
@ -434,7 +434,7 @@ namespace dialog {
} }
highlight_text = last; highlight_text = last;
} }
if(sym == SDLK_DOWN || sym == SDLK_KP2) { if(DKEY == SDLK_DOWN) {
int state = 0; int state = 0;
for(int i=0; i<isize(items); i++) for(int i=0; i<isize(items); i++)
if(isitem(items[i])) { if(isitem(items[i])) {
@ -494,17 +494,17 @@ namespace dialog {
else if(palette && uni >= 'a' && uni < 'a'+(int) palette[0]) { else if(palette && uni >= 'a' && uni < 'a'+(int) palette[0]) {
color = palette[1 + uni - 'a'] >> shift; color = palette[1 + uni - 'a'] >> shift;
} }
else if(sym == SDLK_DOWN || sym == SDLK_KP2) { else if(DKEY == SDLK_DOWN) {
colorp = (colorp-1) & 3; colorp = (colorp-1) & 3;
} }
else if(sym == SDLK_UP || sym == SDLK_KP8) { else if(DKEY == SDLK_UP) {
colorp = (colorp+1) & 3; colorp = (colorp+1) & 3;
} }
else if(sym == SDLK_LEFT || sym == SDLK_KP4) { else if(DKEY == SDLK_LEFT) {
unsigned char* pts = (unsigned char*) &color; unsigned char* pts = (unsigned char*) &color;
pts[colorp] -= abs(shiftmul) < .6 ? 1 : 17; pts[colorp] -= abs(shiftmul) < .6 ? 1 : 17;
} }
else if(sym == SDLK_RIGHT || sym == SDLK_KP6) { else if(DKEY == SDLK_RIGHT) {
unsigned char* pts = (unsigned char*) &color; unsigned char* pts = (unsigned char*) &color;
pts[colorp] += abs(shiftmul) < .6 ? 1 : 17; pts[colorp] += abs(shiftmul) < .6 ? 1 : 17;
} }
@ -689,14 +689,14 @@ namespace dialog {
apply_edit(); apply_edit();
} }
#if !ISMOBILE #if !ISMOBILE
else if(sym == SDLK_RIGHT || sym == SDLK_KP6) { else if(DKEY == SDLK_RIGHT) {
if(ne.intval && abs(shiftmul) < .6) if(ne.intval && abs(shiftmul) < .6)
(*ne.editwhat)++; (*ne.editwhat)++;
else else
*ne.editwhat = ne.sc.inverse(ne.sc.direct(*ne.editwhat) + shiftmul * ne.step); *ne.editwhat = ne.sc.inverse(ne.sc.direct(*ne.editwhat) + shiftmul * ne.step);
apply_slider(); apply_slider();
} }
else if(sym == SDLK_LEFT || sym == SDLK_KP4) { else if(DKEY == SDLK_LEFT) {
if(ne.intval && abs(shiftmul) < .6) if(ne.intval && abs(shiftmul) < .6)
(*ne.editwhat)--; (*ne.editwhat)--;
else else
@ -998,8 +998,8 @@ namespace dialog {
bool handle_edit_string(int sym, int uni, function<string(int, int)> checker) { bool handle_edit_string(int sym, int uni, function<string(int, int)> checker) {
auto& es = *edited_string; auto& es = *edited_string;
string u2; string u2;
if(sym == SDLK_LEFT) editpos--; if(DKEY == SDLK_LEFT) editpos--;
else if(sym == SDLK_RIGHT) editpos++; else if(DKEY == SDLK_RIGHT) editpos++;
else if(uni == 8) { else if(uni == 8) {
if(editpos == 0) return true; if(editpos == 0) return true;
es.replace(editpos-1, 1, ""); es.replace(editpos-1, 1, "");

View File

@ -976,7 +976,7 @@ extern hyperpoint mouseh;
extern hyperpoint ccenter; extern hyperpoint ccenter;
extern ld crad; extern ld crad;
extern bool mousepressed, anyshiftclick; extern bool mousepressed, anyshiftclick, numlock_on;
extern string help; extern string help;
typedef function<void()> reaction_t; typedef function<void()> reaction_t;
@ -2488,7 +2488,12 @@ extern function <bool(SDL_Event &ev)> joyhandler;
void gmodekeys(int sym, int uni); void gmodekeys(int sym, int uni);
// check for a plain number key // check for a plain number key
bool numberkey(int sym, int uni, char number); #define NUMBERKEY (interpret_as_direction(sym, uni) ? 0 : uni)
#define DKEY (get_direction_key(sym, uni))
#define DIRECTIONKEY (interpret_as_direction(sym, uni) ? uni : 0)
bool interpret_as_direction(int sym, int uni);
int get_direction_key(int sym, int uni);
void switchGL(); void switchGL();
void switchFullscreen(); void switchFullscreen();

View File

@ -95,30 +95,30 @@ void showDemo() {
keyhandler = [] (int sym, int uni) { keyhandler = [] (int sym, int uni) {
dialog::handleNavigation(sym, uni); dialog::handleNavigation(sym, uni);
if(sym == SDLK_F1 || sym == 'h') gotoHelp(help); if(sym == SDLK_F1 || uni == 'h') gotoHelp(help);
else if(sym == 'a') { else if(uni == 'a') {
toggleanim(!demoanim); toggleanim(!demoanim);
popScreen(); popScreen();
} }
else if(sym == 'f') { else if(uni == 'f') {
firstland = laIce; firstland = laIce;
restart_game(tactic::on ? rg::tactic : rg::nothing); restart_game(tactic::on ? rg::tactic : rg::nothing);
} }
#if CAP_TOUR #if CAP_TOUR
else if(sym == 'T') { else if(uni == 'T') {
firstland = laIce; firstland = laIce;
if(!tour::on) tour::start(); if(!tour::on) tour::start();
} }
#endif #endif
else if(sym == 't') { else if(uni == 't') {
firstland = laTemple; firstland = laTemple;
restart_game(tactic::on ? rg::tactic : rg::nothing); restart_game(tactic::on ? rg::tactic : rg::nothing);
} }
else if(sym == 'l') { else if(uni == 'l') {
firstland = laStorms; firstland = laStorms;
restart_game(tactic::on ? rg::tactic : rg::nothing); restart_game(tactic::on ? rg::tactic : rg::nothing);
} }
else if(sym == 'b') { else if(uni == 'b') {
firstland = laBurial; firstland = laBurial;
restart_game(tactic::on ? rg::tactic : rg::nothing); restart_game(tactic::on ? rg::tactic : rg::nothing);
items[itOrbSword] = 60; items[itOrbSword] = 60;

View File

@ -248,21 +248,21 @@ void showMainMenu() {
keyhandler = [] (int sym, int uni) { keyhandler = [] (int sym, int uni) {
dialog::handleNavigation(sym, uni); dialog::handleNavigation(sym, uni);
if(sym == SDLK_F1 || sym == 'h') gotoHelp("@"); if(sym == SDLK_F1 || uni == 'h') gotoHelp("@");
else if(sym == 'c' && cheater) pushScreen(showCheatMenu); else if(uni == 'c' && cheater) pushScreen(showCheatMenu);
else if(sym == 'b') pushScreen(showBasicConfig); else if(uni == 'b') pushScreen(showBasicConfig);
else if(sym == 'g') pushScreen(showGraphConfig); else if(uni == 'g') pushScreen(showGraphConfig);
else if(sym == 'd') pushScreen(showDisplayMode); else if(uni == 'd') pushScreen(showDisplayMode);
else if(sym == 'm') pushScreen(showChangeMode); else if(uni == 'm') pushScreen(showChangeMode);
else if(uni == 'R') else if(uni == 'R')
popScreenAll(), pushScreen(showStartMenu); popScreenAll(), pushScreen(showStartMenu);
#if CAP_SAVE #if CAP_SAVE
else if(sym == 't') scores::load(); else if(uni == 't') scores::load();
#endif #endif
else if(uni == 'r' || sym == SDLK_F5) { else if(uni == 'r' || sym == SDLK_F5) {
restart_game(); restart_game();
} }
else if(sym == 'q' || sym == SDLK_F10) { else if(uni == 'q' || sym == SDLK_F10) {
#if ISMOBILE #if ISMOBILE
extern void openURL(); extern void openURL();
openURL(); openURL();
@ -270,12 +270,12 @@ void showMainMenu() {
quitmainloop = true; quitmainloop = true;
#endif #endif
} }
else if(sym == 'o') { else if(uni == 'o') {
clearMessages(); clearMessages();
get_o_key().second(); get_o_key().second();
} }
#if CAP_INV #if CAP_INV
else if(sym == 'i') { else if(uni == 'i') {
clearMessages(); clearMessages();
pushScreen(inv::show); pushScreen(inv::show);
} }
@ -284,7 +284,7 @@ void showMainMenu() {
showMissionScreen(); showMissionScreen();
#if ISMOBILE==1 #if ISMOBILE==1
#ifdef HAVE_ACHIEVEMENTS #ifdef HAVE_ACHIEVEMENTS
else if(sym == '3') { else if(NUMBERKEY == '3') {
achievement_final(false); achievement_final(false);
pushScreen(leader::showMenu); pushScreen(leader::showMenu);
} }
@ -791,7 +791,7 @@ void showStartMenu() {
pushScreen(daily::showMenu); pushScreen(daily::showMenu);
} }
#endif #endif
else if(sym == 'm') { else if(uni == 'm') {
popScreen(); popScreen();
pushScreen(showMainMenu); pushScreen(showMainMenu);
} }
@ -799,7 +799,7 @@ void showStartMenu() {
quitmainloop = true; quitmainloop = true;
else if(sym == SDLK_F1) else if(sym == SDLK_F1)
gotoHelp("@"); gotoHelp("@");
else if(sym == SDLK_ESCAPE || sym == ' ') { else if(sym == SDLK_ESCAPE || uni == ' ') {
popScreen(); popScreen();
timerstart = time(NULL); timerstart = time(NULL);
stampbase = ticks; stampbase = ticks;
@ -905,10 +905,10 @@ void showMessageLog() {
keyhandler = [lines] (int sym, int uni) { keyhandler = [lines] (int sym, int uni) {
if(uni == PSEUDOKEY_WHEELDOWN) messagelogpos++; if(uni == PSEUDOKEY_WHEELDOWN) messagelogpos++;
else if(uni == PSEUDOKEY_WHEELUP) messagelogpos--; else if(uni == PSEUDOKEY_WHEELUP) messagelogpos--;
else if(uni == SDLK_DOWN || uni == SDLK_KP2) messagelogpos++; else if(DKEY == SDLK_DOWN) messagelogpos++;
else if(uni == SDLK_UP || uni == SDLK_KP8) messagelogpos--; else if(DKEY == SDLK_UP) messagelogpos--;
else if(uni == SDLK_PAGEUP || uni == SDLK_KP9) messagelogpos -= lines; else if(DKEY == SDLK_PAGEUP) messagelogpos -= lines;
else if(uni == SDLK_PAGEDOWN || uni == SDLK_KP3) messagelogpos -= lines; else if(DKEY == SDLK_PAGEDOWN) messagelogpos -= lines;
else if(uni == 'c') gamelog.clear(); else if(uni == 'c') gamelog.clear();
else if(uni == 't') { timeformat++; timeformat %= 5; } else if(uni == 't') { timeformat++; timeformat %= 5; }
else if(doexiton(sym, uni)) popScreen(); else if(doexiton(sym, uni)) popScreen();

View File

@ -1485,7 +1485,7 @@ void move_forward(ld distance) {
#define CAP_HOLDKEYS CAP_SDL // && !ISWEB) #define CAP_HOLDKEYS CAP_SDL // && !ISWEB)
bool handlekeys(int sym, int uni) { bool handlekeys(int sym, int uni) {
if(numberkey(sym, uni, '1')) { if(NUMBERKEY == '1') {
ld bdist = 1e12; ld bdist = 1e12;
if(finger_center) if(finger_center)
finger_center = NULL; finger_center = NULL;
@ -1499,14 +1499,14 @@ bool handlekeys(int sym, int uni) {
if(renderonce) renderlate+=10; if(renderonce) renderlate+=10;
return true; return true;
} }
else if(numberkey(sym, uni, '2')) { else if(NUMBERKEY == '2') {
if(in_crystal()) if(in_crystal())
crystal::switch_z_coordinate(); crystal::switch_z_coordinate();
else else
apply_rotation(rotmatrix(M_PI, 0, 2)); apply_rotation(rotmatrix(M_PI, 0, 2));
return true; return true;
} }
else if(numberkey(sym, uni, '3')) { else if(NUMBERKEY == '3') {
if(in_crystal()) if(in_crystal())
crystal::flip_z(); crystal::flip_z();
else else

View File

@ -230,11 +230,11 @@ void show() {
displayButton(xr*50, i0, IFM(dialog::keyname(SDLK_ESCAPE) + " - ") + XLAT("go back"), '0', 8); displayButton(xr*50, i0, IFM(dialog::keyname(SDLK_ESCAPE) + " - ") + XLAT("go back"), '0', 8);
keyhandler = [] (int sym, int uni) { keyhandler = [] (int sym, int uni) {
if(sym == SDLK_LEFT || sym == SDLK_KP4 || sym == 'h' || sym == 'a') { if(DKEY == SDLK_LEFT || uni == 'h' || uni == 'a') {
scorerev = false; scorerev = false;
if(curcol > 0) curcol--; if(curcol > 0) curcol--;
} }
else if(sym == SDLK_RIGHT || sym == SDLK_KP6 || sym == 'l' || sym == 'd') { else if(DKEY == SDLK_RIGHT || uni == 'l' || uni == 'd') {
scorerev = false; scorerev = false;
if(curcol < POSSCORE) curcol++; if(curcol < POSSCORE) curcol++;
} }
@ -242,16 +242,16 @@ void show() {
scorerev = false; scorerev = false;
curcol = sym - 1000; curcol = sym - 1000;
} }
else if(sym == 't') { dialog::infix = ""; pushScreen(showPickScores); } else if(uni == 't') { dialog::infix = ""; pushScreen(showPickScores); }
else if(sym == SDLK_UP || sym == 'k' || sym == 'w') else if(DKEY == SDLK_UP || uni == 'k' || uni == 'w')
scorefrom -= 5; scorefrom -= 5;
else if(sym == SDLK_DOWN || sym == 'j' || sym == 'x') else if(DKEY == SDLK_DOWN || uni == 'j' || uni == 'x')
scorefrom += 5; scorefrom += 5;
else if(sym == PSEUDOKEY_WHEELUP) else if(sym == PSEUDOKEY_WHEELUP)
scorefrom--; scorefrom--;
else if(sym == PSEUDOKEY_WHEELDOWN) else if(sym == PSEUDOKEY_WHEELDOWN)
scorefrom++; scorefrom++;
else if(sym == 's') { else if(uni == 's') {
if(scorerev) reverse(scores.begin(), scores.end()); if(scorerev) reverse(scores.begin(), scores.end());
else { else {
scorerev = true; scorerev = true;

View File

@ -114,27 +114,27 @@ bool handleKeyTour(int sym, int uni) {
if(inhelp) slidehelp(); if(inhelp) slidehelp();
return true; return true;
} }
if(sym == '1' || sym == '2') { // || sym == '3') if(NUMBERKEY == '1' || NUMBERKEY == '2') {
int legal = slides[currentslide].flags & 7; int legal = slides[currentslide].flags & 7;
if(legal == LEGAL_NONE || legal == LEGAL_HYPERBOLIC) { if(legal == LEGAL_NONE || legal == LEGAL_HYPERBOLIC) {
addMessage(XLAT("You cannot change geometry in this slide.")); addMessage(XLAT("You cannot change geometry in this slide."));
return true; return true;
} }
if(legal == LEGAL_UNLIMITED && sym == '1') { if(legal == LEGAL_UNLIMITED && NUMBERKEY == '1') {
addMessage(XLAT("This does not work in bounded geometries.")); addMessage(XLAT("This does not work in bounded geometries."));
return true; return true;
} }
if(legal == LEGAL_NONEUC && sym == '2') { if(legal == LEGAL_NONEUC && NUMBERKEY == '2') {
addMessage(XLAT("This does not work in Euclidean geometry.")); addMessage(XLAT("This does not work in Euclidean geometry."));
return true; return true;
} }
if(legal == LEGAL_HYPERBOLIC && sym != '3') { if(legal == LEGAL_HYPERBOLIC && NUMBERKEY != '3') {
addMessage(XLAT("This works only in hyperbolic geometry.")); addMessage(XLAT("This works only in hyperbolic geometry."));
return true; return true;
} }
if(sym == '2') { if(NUMBERKEY == '2') {
dynamicval<eGeometry> g(geometry, gEuclid); dynamicval<eGeometry> g(geometry, gEuclid);
if(cwt.at->land != laCanvas && !land_validity(cwt.at->land).quality_level) { if(cwt.at->land != laCanvas && !land_validity(cwt.at->land).quality_level) {
addMessage(XLAT("This land has no Euclidean version.")); addMessage(XLAT("This land has no Euclidean version."));
@ -142,7 +142,7 @@ bool handleKeyTour(int sym, int uni) {
} }
} }
if(sym == '1') { if(NUMBERKEY == '1') {
dynamicval<eGeometry> g(geometry, gSphere); dynamicval<eGeometry> g(geometry, gSphere);
if(cwt.at->land != laCanvas && !land_validity(cwt.at->land).quality_level) { if(cwt.at->land != laCanvas && !land_validity(cwt.at->land).quality_level) {
addMessage(XLAT("This land has no spherical version.")); addMessage(XLAT("This land has no spherical version."));
@ -159,7 +159,7 @@ bool handleKeyTour(int sym, int uni) {
firstland = specialland = cwt.at->land; firstland = specialland = cwt.at->land;
push_game(); push_game();
switch(sym) { switch(NUMBERKEY) {
case '3': case '3':
set_variation(eVariation::pure); set_variation(eVariation::pure);
break; break;
@ -176,12 +176,12 @@ bool handleKeyTour(int sym, int uni) {
presentation(pmGeometryStart); presentation(pmGeometryStart);
string x; string x;
if(slides[currentslide].flags & USE_SLIDE_NAME) { if(slides[currentslide].flags & USE_SLIDE_NAME) {
if(sym == '1') x = XLAT("Spherical version of %the1. ", s0 + "'" + slides[currentslide].name + "'"); if(NUMBERKEY == '1') x = XLAT("Spherical version of %the1. ", s0 + "'" + slides[currentslide].name + "'");
if(sym == '2') x = XLAT("Euclidean version of %the1. ", s0 + "'" + slides[currentslide].name + "'"); if(NUMBERKEY == '2') x = XLAT("Euclidean version of %the1. ", s0 + "'" + slides[currentslide].name + "'");
} }
else { else {
if(sym == '1') x = XLAT("Spherical version of %the1. ", cwt.at->land); if(NUMBERKEY == '1') x = XLAT("Spherical version of %the1. ", cwt.at->land);
if(sym == '2') x = XLAT("Euclidean version of %the1. ", cwt.at->land); if(NUMBERKEY == '2') x = XLAT("Euclidean version of %the1. ", cwt.at->land);
} }
if(mousing) if(mousing)
addMessage(x + XLAT("Click again to go back to your game.")); addMessage(x + XLAT("Click again to go back to your game."));
@ -189,12 +189,12 @@ bool handleKeyTour(int sym, int uni) {
addMessage(x + XLAT("Press %1 again to go back to your game.", dialog::keyname(sym))); addMessage(x + XLAT("Press %1 again to go back to your game.", dialog::keyname(sym)));
return true; return true;
} }
if(sym == '3' && sphere) { if(NUMBERKEY == '3' && sphere) {
if(vid.alpha < 2) vid.scale = 400, vid.alpha = 400; else vid.scale = .5, vid.alpha = 1; if(vid.alpha < 2) vid.scale = 400, vid.alpha = 400; else vid.scale = .5, vid.alpha = 1;
addMessage(XLAT("Changed the projection.")); addMessage(XLAT("Changed the projection."));
return true; return true;
} }
if(sym == '4') { if(NUMBERKEY == '4') {
popScreenAll(); popScreenAll();
if(items[itOrbTeleport]) goto give_aether; if(items[itOrbTeleport]) goto give_aether;
items[itOrbTeleport] = 1; items[itOrbTeleport] = 1;
@ -217,11 +217,11 @@ bool handleKeyTour(int sym, int uni) {
)); ));
return true; return true;
} }
if(sym == '5') { if(NUMBERKEY == '5') {
presentation(pmKey); presentation(pmKey);
return true; return true;
} }
if(sym == '6') { if(NUMBERKEY == '6') {
sickmode = !sickmode; sickmode = !sickmode;
static ld spd; static ld spd;
if(sickmode == true) { if(sickmode == true) {
@ -234,17 +234,17 @@ bool handleKeyTour(int sym, int uni) {
} }
return true; return true;
} }
if(sym == '7') { if(NUMBERKEY == '7') {
texts = !texts; texts = !texts;
if(texts) slidehelp(); if(texts) slidehelp();
else addMessage("Help texts disabled."); else addMessage("Help texts disabled.");
return true; return true;
} }
if(sym == '8') { if(NUMBERKEY == '8') {
conformal::includeHistory = !conformal::includeHistory; conformal::includeHistory = !conformal::includeHistory;
return true; return true;
} }
if(sym == '9') { if(NUMBERKEY == '9') {
pushScreen(ss::showMenu); pushScreen(ss::showMenu);
return true; return true;
} }