From 8f4a0935b9eb771a4d941be071d82e73cd4f202d Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 23 May 2021 15:47:45 +0200 Subject: [PATCH] more XLAT refactoring, and preparation for gentrans.cpp --- config.cpp | 4 +--- expansion.cpp | 4 ++-- geom-exp.cpp | 4 ++-- geometry.cpp | 6 +++--- graph.cpp | 2 +- language.cpp | 4 ++++ menus.cpp | 28 ++++++++++++++-------------- multi.cpp | 7 ++++--- orbgen.cpp | 2 +- quit.cpp | 8 ++++---- textures.cpp | 2 +- 11 files changed, 37 insertions(+), 34 deletions(-) diff --git a/config.cpp b/config.cpp index 6bc8ca30..1e9dcbd3 100644 --- a/config.cpp +++ b/config.cpp @@ -1841,8 +1841,6 @@ EX void projectionDialog() { XLAT("HyperRogue uses the Minkowski hyperboloid model internally. " "Klein and Poincaré models can be obtained by perspective, " "and the Gans model is obtained by orthogonal projection. " -// "This parameter specifies the distance from the hyperboloid center " -// "to the eye. " "See also the conformal mode (in the special modes menu) " "for more models.")); dialog::extra_options = [] () { @@ -2222,7 +2220,7 @@ EX void show3D() { else if(GDIM == 2 && !spatial_graphics) dialog::addInfo(XLAT("set 3D monsters or walls in basic config first")); else if(geom3::invalid != "") - dialog::addInfo(XLAT("error: "+geom3::invalid), 0xC00000); + dialog::addInfo(XLAT("error: ")+geom3::invalid, 0xC00000); else dialog::addInfo(XLAT("parameters set correctly")); dialog::addBreak(50); diff --git a/expansion.cpp b/expansion.cpp index a65f8119..8d7a8600 100644 --- a/expansion.cpp +++ b/expansion.cpp @@ -409,12 +409,12 @@ string expansion_analyzer::approximate_descendants(int d, int max_length) { } enum eDistanceFrom { dfPlayer, dfStart, dfWorld }; -string dfnames[3] = { "player", "start", "land" }; +EX string dfnames[3] = { "player", "start", "land" }; eDistanceFrom distance_from = dfPlayer; enum eNumberCoding { ncNone, ncDistance, ncType, ncDebug }; -string ncnames[4] = { "NO", "distance", "type", "debug" }; +EX string ncnames[4] = { "NO", "distance", "type", "debug" }; eNumberCoding number_coding = ncDistance; bool mod_allowed() { diff --git a/geom-exp.cpp b/geom-exp.cpp index e90c9640..75ddb319 100644 --- a/geom-exp.cpp +++ b/geom-exp.cpp @@ -261,7 +261,7 @@ EX geometry_filter gf_quotient = {"interesting quotient spaces", [] { return forced_quotient() && !elliptic; }}; -vector available_filters = { &gf_hyperbolic, &gf_spherical, &gf_euclidean, &gf_other, &gf_regular_2d, &gf_regular_3d, &gf_quotient }; +EX vector available_filters = { &gf_hyperbolic, &gf_spherical, &gf_euclidean, &gf_other, &gf_regular_2d, &gf_regular_3d, &gf_quotient }; void ge_select_filter() { cmode = sm::SIDE | sm::MAYDARK; @@ -674,7 +674,7 @@ EX void menuitem_binary_width(char key) { } EX void menuitem_nilwidth(char key) { - dialog::addSelItem(XLAT("nil width"), fts(nilv::nilwidth), key); + dialog::addSelItem(XLAT("Nil width"), fts(nilv::nilwidth), key); dialog::add_action([] { dialog::editNumber(nilv::nilwidth, 0.01, 2, 0.1, 1, XLAT("Nil width"), ""); dialog::reaction = ray::reset_raycaster; diff --git a/geometry.cpp b/geometry.cpp index 8945acd6..567f1b50 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -820,16 +820,16 @@ EX namespace geom3 { pconf.alpha = tan_auto(vid.depth) / tan_auto(vid.camera); else if(vid.tc_depth < vid.tc_alpha && vid.tc_depth < vid.tc_camera) { ld v = pconf.alpha * tan_auto(vid.camera); - if(hyperbolic && (v<1e-6-12 || v>1-1e-12)) invalid = "cannot adjust depth", vid.depth = vid.camera; + if(hyperbolic && (v<1e-6-12 || v>1-1e-12)) invalid = XLAT("cannot adjust depth"), vid.depth = vid.camera; else vid.depth = atan_auto(v); } else { ld v = tan_auto(vid.depth) / pconf.alpha; - if(hyperbolic && (v<1e-12-1 || v>1-1e-12)) invalid = "cannot adjust camera", vid.camera = vid.depth; + if(hyperbolic && (v<1e-12-1 || v>1-1e-12)) invalid = XLAT("cannot adjust camera"), vid.camera = vid.depth; else vid.camera = atan_auto(v); } - if(fabs(pconf.alpha) < 1e-6) invalid = "does not work with perfect Klein"; + if(fabs(pconf.alpha) < 1e-6) invalid = XLAT("does not work with perfect Klein"); if(invalid != "") { INFDEEP = .7; diff --git a/graph.cpp b/graph.cpp index 7f77c99f..7f961df6 100644 --- a/graph.cpp +++ b/graph.cpp @@ -3215,7 +3215,7 @@ EX colortable distcolors = { 0xA0A000, 0xA000A0, 0x00A0A0, 0xFFD500 }; -const char* minetexts[8] = { +EX const char* minetexts[8] = { "No mines next to you.", "A mine is next to you!", "Two mines next to you!", diff --git a/language.cpp b/language.cpp index 0cf886eb..faaf164f 100644 --- a/language.cpp +++ b/language.cpp @@ -112,6 +112,10 @@ string choose4(int g, string a, string b, string c, string d) { set warnshown; +EX bool translation_exists(const string& x) { + return findInHashTable(x, all_sentences); + } + void basicrep(string& x) { #if CAP_TRANS diff --git a/menus.cpp b/menus.cpp index 12e73f9f..8f628f66 100644 --- a/menus.cpp +++ b/menus.cpp @@ -235,16 +235,15 @@ EX void showMainMenu() { #if ISMOBILE dialog::addItem(XLAT("visit the website"), 'q'); #else - q = quitsaves() ? "save" : "quit"; - q = q + " the game"; - dialog::addItem(XLAT(q), 'q'); + q = quitsaves() ? XLAT("save the game") : XLAT("quit the game"); + dialog::addItem(q, 'q'); #endif - if(canmove) - q = "review your quest"; + if(canmove) + q = XLAT("review your quest"); else - q = "game over screen"; - dialog::addItem(XLAT(q), SDLK_ESCAPE); + q = XLAT("game over screen"); + dialog::addItem(q, SDLK_ESCAPE); dialog::addItem(get_o_key().first, 'o'); if(inv::on) @@ -260,11 +259,11 @@ EX void showMainMenu() { dialog::addItem("SHARE", 's'-96); #endif - if(!canmove) q = "review the scene"; - else if(turncount > 0) q = "continue game"; - else q = "play the game!"; + if(!canmove) q = XLAT("review the scene"); + else if(turncount > 0) q = XLAT("continue game"); + else q = XLAT("play the game!"); - dialog::addItem(XLAT(q), ' '); + dialog::addItem(q, ' '); dialog::display(); keyhandler = [] (int sym, int uni) { @@ -330,6 +329,10 @@ EX void editScale() { dialog::scaleSinh(); } +EX const char *wdmodes[7] = {"ASCII", "black", "plain", "Escher", "plain/3D", "Escher/3D", "ASCII/3D"}; +EX const char *mdmodes[6] = {"ASCII", "items only", "items and monsters", "3D", "?", "?"}; +EX const char *hlmodes[3] = {"press Alt", "highlight", "super-highlight"}; + EX void showGraphQuickKeys() { cmode = sm::SIDE | sm::MAYDARK; gamescreen(0); @@ -338,13 +341,10 @@ EX void showGraphQuickKeys() { dialog::addItem("quick projection", '1'); - const char *wdmodes[7] = {"ASCII", "black", "plain", "Escher", "plain/3D", "Escher/3D", "ASCII/3D"}; dialog::addSelItem(XLAT("wall display mode"), XLAT(wdmodes[vid.wallmode]), '5'); - const char *mdmodes[6] = {"ASCII", "items only", "items and monsters", "3D", "?", "?"}; dialog::addSelItem(XLAT("monster display mode"), XLAT(mdmodes[vid.monmode]), '8'); - const char *hlmodes[3] = {"press Alt", "highlight", "super-highlight"}; dialog::addSelItem(XLAT("highlight stuff"), XLAT(hlmodes[vid.highlightmode]), 508); dialog::addBoolItem(XLAT("draw the grid"), (vid.grid), '6'); diff --git a/multi.cpp b/multi.cpp index d2d38bc4..1486e490 100644 --- a/multi.cpp +++ b/multi.cpp @@ -115,7 +115,7 @@ EX namespace multi { #define SHMUPAXES_CUR ((SHMUPAXES_BASE) + 4 * playercfg) #endif -const char* axemodes[SHMUPAXES] = { +EX const char* axemodes[SHMUPAXES] = { "do nothing", "rotate view", "panning X", @@ -150,7 +150,7 @@ const char* axemodes[SHMUPAXES] = { "player 7 spin" }; -const char* axemodes3[4] = { +EX const char* axemodes3[4] = { "do nothing", "camera forward", "camera rotate X", @@ -378,6 +378,8 @@ struct joy_configurer { }; #endif +EX const char *axmodes[7] = {"OFF", "auto", "light", "heavy", "arrows", "WASD keys", "VI keys"}; + struct shmup_configurer { void operator()() { @@ -418,7 +420,6 @@ struct shmup_configurer { dialog::addItem(XLAT("configure player 5"), '5'); else if(!shmup::on && !multi::alwaysuse) { if(GDIM == 2) { - const char *axmodes[7] = {"OFF", "auto", "light", "heavy", "arrows", "WASD keys", "VI keys"}; dialog::addSelItem(XLAT("help for keyboard users"), XLAT(axmodes[vid.axes]), 'h'); dialog::add_action([] {vid.axes += 70 + (shiftmul > 0 ? 1 : -1); vid.axes %= 7; } ); } diff --git a/orbgen.cpp b/orbgen.cpp index 53a370c9..f156a26d 100644 --- a/orbgen.cpp +++ b/orbgen.cpp @@ -189,7 +189,7 @@ const orbinfo& getNativityOrbInfo(eItem orb) { return oi; } -EX string olrDescriptions[] = { +EX string olrDescriptions[18] = { "forbidden to find in %the1", "too dangerous to use in %the1", "useless in %the1", diff --git a/quit.cpp b/quit.cpp index 0908c029..5067f0ec 100644 --- a/quit.cpp +++ b/quit.cpp @@ -121,13 +121,13 @@ EX hint hints[] = { 0, []() { return in_full_game(); }, []() { - dialog::addInfo(XLAT( + dialog::addInfo( #if ISMOBILE - "The 'world overview' shows all the lands in HyperRogue." + XLAT("The 'world overview' shows all the lands in HyperRogue.") #else - "Press 'o' to see all the lands in HyperRogue." + XLAT("Press 'o' to see all the lands in HyperRogue.") #endif - )); + ); dialog::addBreak(50); dialog::addItem(XLAT("world overview"), 'z'); }, diff --git a/textures.cpp b/textures.cpp index e2657e4c..e6942ba2 100644 --- a/textures.cpp +++ b/textures.cpp @@ -729,7 +729,7 @@ enum eMagicParameter { mpMAX }; -vector mpnames = { +EX vector mpnames = { "affect model scale", "affect model projection", "affect model central point",