From 9a1093fc6c2ff95e40f142170b5a2a4e49335925 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 26 Feb 2018 13:15:33 +0100 Subject: [PATCH] cleanup: help. Also rug help displayed when rug is on --- help.cpp | 191 ++++++++++++++++++++++++++---------------------- hyper.h | 5 +- language-cz.cpp | 20 ++--- language-de.cpp | 19 ++--- language-pl.cpp | 20 ++--- language-ru.cpp | 22 +++--- rug.cpp | 30 +++++--- 7 files changed, 167 insertions(+), 140 deletions(-) diff --git a/help.cpp b/help.cpp index 4c843de7..fd398a1a 100644 --- a/help.cpp +++ b/help.cpp @@ -5,34 +5,71 @@ string help; function help_delegate; -string buildHelpText() { +struct help_extension { + char key; + string text; + reaction_t action; + }; +vector help_extensions; + +vector extra_keys = { + "1 = orthogonal/Gans model", + "2 = small Poincare model/stereographic projection", + "3 = big Poincare model/stereographic projection", + "4 = Klein model/gnomonic projection", + "5 = change wall display mode", + "6 = change grid", + "7 = change heptagon marking", + "8 = change background color", + "9 = hyperboloid model", + "qweasdzxc, hjklyubn, numpad = move/skip turn", + "arrows = panning", + "o = world overview", + "v = menu", + "F1 = help", + "F5 = restart game", + "F10 = quit game", + "Esc = quest status", + "Alt+Enter = full screen", + "Alt = highlight interesting stuff", + "t = use a ranged Orb (target center of the screen)", + "g = drop a Dead Orb", + "click left mouse button = move/skip", + "shift+click left mouse button = use ranged Orb", + "click right mouse button = context help", + "mousewheel up = panning", + "hold middle mouse button = panning", + "mousewheel down = move/skip", + "shift + mousewheel = change projection", + "ctrl + mousewheel = change zoom", + "ctrl + shift + mousewheel = change both projection and zoom", + "ctrl + hold middle button = move the screen", + "shift + middle button = reset position" + }; + +void buildHelpText() { DEBB(DF_GRAPH, (debugfile,"buildHelpText\n")); -#if CAP_ROGUEVIZ - if(rogueviz::on) return rogueviz::makehelp(); -#endif - - string h; - h += XLAT("Welcome to HyperRogue"); + help = XLAT("Welcome to HyperRogue"); #if ISANDROID - h += XLAT(" for Android"); + help += XLAT(" for Android"); #endif #if ISIOS - h += XLAT(" for iOS"); + help += XLAT(" for iOS"); #endif - h += XLAT("! (version %1)\n\n", VER); + help += XLAT("! (version %1)\n\n", VER); - h += XLAT( + help += XLAT( "You have been trapped in a strange, non-Euclidean world. Collect as much treasure as possible " "before being caught by monsters. The more treasure you collect, the more " "monsters come to hunt you, as long as you are in the same land type. The " "Orbs of Yendor are the ultimate treasure; get at least one of them to win the game!" ); - h += XLAT(" (press ESC for some hints about it)."); - h += "\n\n"; + help += XLAT(" (press ESC for some hints about it)."); + help += "\n\n"; if(!shmup::on && !hardcore) - h += XLAT( + help += XLAT( "You can fight most monsters by moving into their location. " "The monster could also kill you by moving into your location, but the game " "automatically cancels all moves which result in that.\n\n" @@ -40,22 +77,22 @@ string buildHelpText() { #if CAP_INV if(inv::on) - h += XLAT( + help += XLAT( inv::helptext ); else #endif - h += XLAT( + help += XLAT( "There are many lands in HyperRogue. Collect 10 treasure " "in the given land type to complete it; this enables you to " "find the magical Orbs of this land, and in some cases " "get access to new lands. At 25 treasures " "this type of Orbs starts appearing in other lands as well. Press 'o' to " "get the details of all the Lands.\n\n"); - h += "\n\n"; + help += "\n\n"; #if ISMOBILE - h += XLAT( + help += XLAT( "Usually, you move by touching somewhere on the map; you can also touch one " "of the four buttons on the map corners to change this (to scroll the map " "or get information about map objects). You can also touch the " @@ -63,57 +100,64 @@ string buildHelpText() { ); #else if(DEFAULTCONTROL) - h += XLAT( + help += XLAT( "Move with mouse, num pad, qweadzxc, or hjklyubn. Wait by pressing 's' or '.'. Spin the world with arrows, PageUp/Down, and Home/Space. " "To save the game you need an Orb of Safety. Press 'v' for the main menu (configuration, special modes, etc.), ESC for the quest status.\n\n" ); - h += XLAT( + help += XLAT( "You can right click any element to get more information about it.\n\n" ); #if ISMAC - h += XLAT("(You can also use right Shift)\n\n"); + help += XLAT("(You can also use right Shift)\n\n"); #endif #endif - h += XLAT("See more on the website: ") + help += XLAT("See more on the website: ") + "http//roguetemple.com/z/hyper/\n\n"; #if CAP_TOUR - h += XLAT("Try the Tutorial to help with understanding the " + help += XLAT("Try the Tutorial to help with understanding the " "geometry of HyperRogue (menu -> special modes).\n\n"); #endif - h += XLAT("Still confused? Read the FAQ on the HyperRogue website!\n\n"); + help += XLAT("Still confused? Read the FAQ on the HyperRogue website!\n\n"); - return h; + help_extensions.clear(); + + help_extensions.push_back(help_extension{'c', XLAT("credits"), [] () { buildCredits(); }}); +#if ISMOBILE == 0 + help_extensions.push_back(help_extension{'k', XLAT("advanced keyboard shortcuts"), [] () { + help = ""; + for(string s: extra_keys) help += s, help += "\n\n"; + }}); +#endif } -string buildCredits() { - string h; - h += XLAT("game design, programming, texts and graphics by Zeno Rogue \n\n"); +void buildCredits() { + help = ""; + help += XLAT("game design, programming, texts and graphics by Zeno Rogue \n\n"); if(lang() != 0) - h += XLAT("add credits for your translation here"); + help += XLAT("add credits for your translation here"); #ifndef NOLICENSE - h += XLAT( + help += XLAT( "released under GNU General Public License version 2 and thus " "comes with absolutely no warranty; see COPYING for details\n\n" ); #endif - h += XLAT( + help += XLAT( "special thanks to the following people for their bug reports, feature requests, porting, and other help:\n\n%1\n\n", "Konstantin Stupnik, ortoslon, chrysn, Adam Borowski, Damyan Ivanov, Ryan Farnsley, mcobit, Darren Grey, tricosahedron, Maciej Chojecki, Marek Čtrnáct, " "wonderfullizardofoz, Piotr Migdał, tehora, Michael Heerdegen, Sprite Guard, zelda0x181e, Vipul, snowyowl0, Patashu, phenomist, Alan Malloy, Tom Fryers, Sinquetica, _monad, CtrlAltDestroy, jruderman, " "Kojiguchi Kazuki, baconcow, Alan, SurelyYouJest, hotdogPi" ); #ifdef EXTRALICENSE - h += EXTRALICENSE; + help += EXTRALICENSE; #endif #if !ISMOBILE - h += XLAT( + help += XLAT( "\n\nSee sounds/credits.txt for credits for sound effects" ); #endif - if(musiclicense != "") h += musiclicense; - return h; + if(musiclicense != "") help += musiclicense; } string pushtext(stringpar p) { @@ -805,13 +849,6 @@ void describeMouseover() { if(mousey < vid.fsize * 3/2) getcstat = SDLK_F1; } -struct help_extension { - char key; - string text; - reaction_t action; - }; -vector help_extensions; - void showHelp() { gamescreen(2); cmode = sm::HELP | sm::DOTOUR; @@ -821,8 +858,6 @@ void showHelp() { return; } - if(help == "@") help = buildHelpText(); - string help2; if(help[0] == '@') { int iv = help.find("\t"); @@ -852,60 +887,40 @@ void showHelp() { act(); return; } - if(sym == SDLK_F1 && help != "@") - help = "@"; + if(sym == SDLK_F1) { + auto i = help; + buildHelpText(); + if(help == i) popScreen(); + } else if(doexiton(sym, uni)) popScreen(); }; } -vector extra_keys = { - "1 = orthogonal/Gans model", - "2 = small Poincare model/stereographic projection", - "3 = big Poincare model/stereographic projection", - "4 = Klein model/gnomonic projection", - "5 = change wall display mode", - "6 = change grid", - "7 = change heptagon marking", - "8 = change background color", - "9 = hyperboloid model", - "qweasdzxc, hjklyubn, numpad = move/skip turn", - "arrows = panning", - "o = world overview", - "v = menu", - "F1 = help", - "F5 = restart game", - "F10 = quit game", - "Esc = quest status", - "Alt+Enter = full screen", - "Alt = highlight interesting stuff", - "t = use a ranged Orb (target center of the screen)", - "g = drop a Dead Orb", - "click left mouse button = move/skip", - "shift+click left mouse button = use ranged Orb", - "click right mouse button = context help", - "mousewheel up = panning", - "hold middle mouse button = panning", - "mousewheel down = move/skip", - "shift + mousewheel = change projection", - "ctrl + mousewheel = change zoom", - "ctrl + shift + mousewheel = change both projection and zoom", - "ctrl + hold middle button = move the screen", - "shift + middle button = reset position" - }; - void gotoHelp(const string& h) { help = h; help_extensions.clear(); pushScreen(showHelp); - if(help == "@" || help == buildHelpText()) { - help_extensions.push_back(help_extension{'c', XLAT("credits"), [] () { help = buildCredits(); }}); -#if ISMOBILE == 0 - help_extensions.push_back(help_extension{'k', XLAT("advanced keyboard shortcuts"), [] () { - help = ""; - for(string s: extra_keys) help += s, help += "\n\n"; - }}); + if(help == "@") { + +#if CAP_ROGUEVIZ + if(rogueviz::on) { + help = rogueviz::makehelp(); + help_extensions.push_back(help_extension{'u', XLAT("RogueViz menu"), [] () { popScreen(); pushScreen(rogueviz::showMenu); }}); + return; + } #endif + +#if CAP_RUG + if(rug::rugged) { + help = rug::makehelp(); + help_extensions.push_back(help_extension{'m', XLAT("Hypersian Rug menu"), [] () { popScreen(); rug::select(); }}); + help_extensions.push_back(help_extension{'h', XLAT("HyperRogue help"), [] () { buildHelpText(); }}); + return; + } +#endif + + buildHelpText(); } if(help == "HELPGEN") helpgenerator(); } diff --git a/hyper.h b/hyper.h index 62b414c4..88b9d751 100644 --- a/hyper.h +++ b/hyper.h @@ -769,6 +769,7 @@ namespace rug { void drawRugScene(); void push_all_points(int coord, ld val); void apply_rotation(const transmatrix& t); + string makehelp(); #endif } @@ -1781,8 +1782,8 @@ extern int lightat, safetyat; int watercolor(int phase); bool doHighlight(); -string buildHelpText(); -string buildCredits(); +void buildHelpText(); +void buildCredits(); void setAppropriateOverview(); bool quitsaves(); extern bool sidescreen; diff --git a/language-cz.cpp b/language-cz.cpp index 194d59bb..da763e56 100644 --- a/language-cz.cpp +++ b/language-cz.cpp @@ -3363,21 +3363,21 @@ S("\n\n(For the heptagonal mode, the radius has been reduced to 2 for closing pl S("hypersian rug mode", "mód hyperského koberce") -S( - "In this mode, HyperRogue is played on a 3D model of a part of the hyperbolic plane, " - "similar to one you get from the 'paper model creator' or by hyperbolic crocheting.\n\n" - "This requires some OpenGL extensions and may crash or not work correctly -- enabling " +S("In this mode, HyperRogue is played on a 3D model of a part of the hyperbolic plane, " + "similar to one you get from the 'paper model creator' or by hyperbolic crocheting.\n\n", + "V tomto módu můžete hrát HyperRogue na 3D modelu části hyperbolické roviny " + "podobném tomu, co vytváří generátor papírových modelů nebo hyperbolické háčkování.\n\n") + +S("This requires some OpenGL extensions and may crash or not work correctly -- enabling " "the 'render texture without OpenGL' options may be helpful in this case. Also the 'render once' option " "will make the rendering faster, but the surface will be rendered only once, so " - "you won't be able to play a game on it.\n\n" - "Use arrow keys to rotate, Page Up/Down to zoom.", - - "V tomto módu můžete hrát HyperRogue na 3D modelu části hyperbolické roviny " - "podobném tomu, co vytváří generátor papírových modelů nebo hyperbolické háčkování.\n\n" + "you won't be able to play a game on it.\n\n", "Je k tomu zapotřebí OpenGL a je možné, že v tomto módu hra spadne nebo nepoběží " "správně -- v takovém případě může pomoci zapnout možnost 'renderuj textury bez OpenGL'. " "Kromě toho je možné renderování urychlit volbou 'renderuj jednou', ale v takovém případě " - "bude povrch vygenerován pouze jednou, takže na něm není možné hrát.\n\n" + "bude povrch vygenerován pouze jednou, takže na něm není možné hrát.\n\n") + +S("Use arrow keys to rotate, Page Up/Down to zoom.", "Model se otáčí šipkami a lze ho zoomovat klávesami Page Up/Down.") S("what's this?", "co to je?") diff --git a/language-de.cpp b/language-de.cpp index 206f709d..09396f27 100644 --- a/language-de.cpp +++ b/language-de.cpp @@ -3151,20 +3151,21 @@ S("\n\n(For the heptagonal mode, the radius has been reduced to 2 for closing pl S("hypersian rug mode", "Hypersischer-Teppich-Modus") S("In this mode, HyperRogue is played on a 3D model of a part of the hyperbolic plane, " - "similar to one you get from the 'paper model creator' or by hyperbolic crocheting.\n\n" - "This requires some OpenGL extensions and may crash or not work correctly -- enabling " - "the 'render texture without OpenGL' options may be helpful in this case. Also the 'render once' option " - "will make the rendering faster, but the surface will be rendered only once, so " - "you won't be able to play a game on it.\n\n" - "Use arrow keys to rotate, Page Up/Down to zoom.", - + "similar to one you get from the 'paper model creator' or by hyperbolic crocheting.\n\n", "In diesem Modus wird HyperRogue auf einem 3D-Modell eines Teils einer hyperbolischen Ebene " "gespielt, ähnlich zu dem was man beim 'Papiermodell-Schöpfer' oder beim hyperbolischen Häkeln " - "erhält.\n\n" + "erhält.\n\n") + +S("This requires some OpenGL extensions and may crash or not work correctly -- enabling " + "the 'render texture without OpenGL' options may be helpful in this case. Also the 'render once' option " + "will make the rendering faster, but the surface will be rendered only once, so " + "you won't be able to play a game on it.\n\n", "Dieser Modus erfordert einige OpenGL-Erweiterungen und kann abstürzen oder fehlerhaft funktionieren " "-- das Einschalten der Option 'Rendere Textur ohne OpenGL' kann hilfreich sein. " "Auch die Option 'Rendere die Textur nur einmal' beschleunigt das Rendern, aber die Oberfläche " - "wird nur einmal gerendert und du kannst darauf nicht spielen.\n\n" + "wird nur einmal gerendert und du kannst darauf nicht spielen.\n\n") + +S("Use arrow keys to rotate, Page Up/Down to zoom.", "Verwende die Pfeiltasten zum Rotieren, Bild auf/ab zum Zoomen.") S("what's this?", "Was ist das?") diff --git a/language-pl.cpp b/language-pl.cpp index 20400fb7..b612b51a 100644 --- a/language-pl.cpp +++ b/language-pl.cpp @@ -3297,21 +3297,23 @@ S("hypersian rug mode", "tryb hiperskiego dywanu") S( "In this mode, HyperRogue is played on a 3D model of a part of the hyperbolic plane, " - "similar to one you get from the 'paper model creator' or by hyperbolic crocheting.\n\n" - "This requires some OpenGL extensions and may crash or not work correctly -- enabling " - "the 'render texture without OpenGL' options may be helpful in this case. Also the 'render once' option " - "will make the rendering faster, but the surface will be rendered only once, so " - "you won't be able to play a game on it.\n\n" - "Use arrow keys to rotate, Page Up/Down to zoom.", - + "similar to one you get from the 'paper model creator' or by hyperbolic crocheting.\n\n", "W tym trybie można grać w HyperRogue na trójwymiarowym modelu części płaszczyzny " "hiperbolicznej, podobnym do tego, który można otrzymać w kreatorze modeli " - "papierowych albo poprzez hiperboliczne szydełkowanie.\n\n" + "papierowych albo poprzez hiperboliczne szydełkowanie.\n\n") + +S("This requires some OpenGL extensions and may crash or not work correctly -- enabling " + "the 'render texture without OpenGL' options may be helpful in this case. Also the 'render once' option " + "will make the rendering faster, but the surface will be rendered only once, so " + "you won't be able to play a game on it.\n\n", + "Działanie wymaga pewnych rozszerzeń OpenGL i może działać nieprawidłowo lub " "powodować zatrzymanie gry -- w takim przypadku może być przydatne włączenie opcji " "'renderuj bez OpenGL'. Opcja 'renderuj raz' spowoduje, że animacja będzie szybsza, " "ale tekstura powierzchni zostanie narysowana tylko raz, zatem nie będzie możliwe " - "granie na niej na żywo.\n\nMożesz obracać model strzałkami, a przybliżać i oddalać go " + "granie na niej na żywo.\n\n") + +S("Use arrow keys to rotate, Page Up/Down to zoom.", "Możesz obracać model strzałkami, a przybliżać i oddalać go " "klawiszami Page Up/Down.") S("what's this?", "co to jest?") diff --git a/language-ru.cpp b/language-ru.cpp index 2b5bf7a6..6a77ede3 100644 --- a/language-ru.cpp +++ b/language-ru.cpp @@ -3386,21 +3386,23 @@ S("\n\n(For the heptagonal mode, the radius has been reduced to 2 for closing pl S("hypersian rug mode", "режим гиперсидского ковра") -S( - "In this mode, HyperRogue is played on a 3D model of a part of the hyperbolic plane, " - "similar to one you get from the 'paper model creator' or by hyperbolic crocheting.\n\n" - "This requires some OpenGL extensions and may crash or not work correctly -- enabling " +S("In this mode, HyperRogue is played on a 3D model of a part of the hyperbolic plane, " + "similar to one you get from the 'paper model creator' or by hyperbolic crocheting.\n\n", + + "В этом режиме Вы играете в HyperRogue на трёхмерной модели гиперболической " + "плоскости, похожей на те, что можно получить в 'создателе бумажных моделей'.\n\n" + ) + +S("This requires some OpenGL extensions and may crash or not work correctly -- enabling " "the 'render texture without OpenGL' options may be helpful in this case. Also the 'render once' option " "will make the rendering faster, but the surface will be rendered only once, so " - "you won't be able to play a game on it.\n\n" - "Use arrow keys to rotate, Page Up/Down to zoom.", - - "В этом режиме Вы играете в HyperRogue на трёхмерной модели гиперболической " - "плоскости, похожей на те, что можно получить в 'создателе бумажных моделей'\n\n" + "you won't be able to play a game on it.\n\n", "Это требует некоторых расширений OpenGL, может работать некорректно или вызывать " "падение игры -- включение опции 'не использовать OpenGL' может помочь. " "Опция 'отрисовать один раз' ускоряет отрисовку, " - "но играть в таком режиме невозможно.\n\n" + "но играть в таком режиме невозможно.\n\n") + +S("Use arrow keys to rotate, Page Up/Down to zoom.", "Используйте стрелки для вращения, Page Up/Down для изменения масштаба.") S("what's this?", "что это?") diff --git a/rug.cpp b/rug.cpp index 558f7a53..6b2928a2 100644 --- a/rug.cpp +++ b/rug.cpp @@ -1513,6 +1513,23 @@ hyperpoint gethyper(ld x, ld y) { return h; } +string makehelp() { + return + XLAT( + "In this mode, HyperRogue is played on a 3D model of a part of the hyperbolic plane, " + "similar to one you get from the 'paper model creator' or by hyperbolic crocheting.\n\n") + /* + "This requires some OpenGL extensions and may crash or not work correctly -- enabling " + "the 'render texture without OpenGL' options may be helpful in this case. Also the 'render once' option " + "will make the rendering faster, but the surface will be rendered only once, so " + "you won't be able to play a game on it.\n\n" */ + #if !ISMOBILE + + XLAT("Use arrow keys to rotate, Page Up/Down to zoom.") + + "\n\n" + + XLAT("In the perspective projection, you can use arrows to rotate the camera, Page Up/Down to go forward/backward, Shift+arrows to strafe, and Ctrl+arrows to rotate the model."); + #endif + } + void show() { cmode = sm::SIDE; gamescreen(0); @@ -1558,18 +1575,7 @@ void show() { keyhandler = [] (int sym, int uni) { dialog::handleNavigation(sym, uni); - if(uni == 'h') gotoHelp( - XLAT( - "In this mode, HyperRogue is played on a 3D model of a part of the hyperbolic plane, " - "similar to one you get from the 'paper model creator' or by hyperbolic crocheting.\n\n" - "This requires some OpenGL extensions and may crash or not work correctly -- enabling " - "the 'render texture without OpenGL' options may be helpful in this case. Also the 'render once' option " - "will make the rendering faster, but the surface will be rendered only once, so " - "you won't be able to play a game on it.\n\n" - "Use arrow keys to rotate, Page Up/Down to zoom.") - + "\n\n" + - XLAT("In the perspective projection, you can use arrows to rotate the camera, Page Up/Down to go forward/backward, Shift+arrows to strafe, and Ctrl+arrows to rotate the model.") - ); + if(uni == 'h') gotoHelp(makehelp()); else if(uni == 'u') { if(rug::rugged) rug::close(); else rug::init();