diff --git a/archimedean.cpp b/archimedean.cpp index b0eec678..c1e55232 100644 --- a/archimedean.cpp +++ b/archimedean.cpp @@ -963,12 +963,12 @@ void enable(archimedean_tiling& arct) { stop_game(); if(geometry != gArchimedean) targetgeometry = gArchimedean, stop_game_and_switch_mode(rg::geometry); nonbitrunc = true; need_reset_geometry = true; gp::on = false; irr::on = false; - patterns::whichPattern = 0; + patterns::whichPattern = patterns::PAT_NONE; #if CAP_TEXTURE if(texture::config.tstate == texture::tsActive && texture::cgroup == cpThree) patterns::whichPattern = patterns::PAT_COLORING; if(texture::config.tstate == texture::tsActive && texture::cgroup == cpFootball) - patterns::whichPattern = 0, patterns::subpattern_flags = patterns::SPF_FOOTBALL; + patterns::whichPattern = patterns::PAT_TYPES, patterns::subpattern_flags = patterns::SPF_FOOTBALL; if(texture::config.tstate == texture::tsActive && texture::cgroup == cpChess) patterns::whichPattern = patterns::PAT_CHESS; #endif diff --git a/graph.cpp b/graph.cpp index 8b6d3153..e2f52a0f 100644 --- a/graph.cpp +++ b/graph.cpp @@ -2446,7 +2446,7 @@ void set_zebrafloor(cell *c) { set_floor(shFloor); return; } - auto si = patterns::getpatterninfo(c, 'z', patterns::SPF_SYM0123); + auto si = patterns::getpatterninfo(c, patterns::PAT_ZEBRA, patterns::SPF_SYM0123); int j; if(nonbitrunc) j = 4; @@ -2531,7 +2531,7 @@ void draw_reptile(cell *c, const transmatrix &V, int col) { void set_emeraldfloor(cell *c) { if(!masterless && !nonbitrunc) { - auto si = patterns::getpatterninfo(c, 'f', patterns::SPF_SYM0123); + auto si = patterns::getpatterninfo(c, patterns::PAT_EMERALD, patterns::SPF_SYM0123); int j = -1; @@ -3142,7 +3142,7 @@ void set_maywarp_floor(cell *c) { set_floor(shTriheptaFloor); return; } - auto si = patterns::getpatterninfo(c, 0, 0); + auto si = patterns::getpatterninfo(c, patterns::PAT_TYPES, 0); if(si.id == 0 || si.id == 1) set_floor(shTriheptaFloor); else if(si.id >= 14) diff --git a/hyper.h b/hyper.h index c4249616..c1a305c1 100644 --- a/hyper.h +++ b/hyper.h @@ -1025,19 +1025,23 @@ namespace patterns { extern char whichShape; extern int canvasback; - extern char whichPattern; extern cpatterntype cgroup, old_cgroup; - static const char PAT_WARP = 0; - static const char PAT_ZEBRA = 'z'; - static const char PAT_EMERALD = 'f'; - static const char PAT_PALACE = 'p'; - static const char PAT_FIELD = 'F'; - static const char PAT_DOWN = 'H'; - static const char PAT_COLORING = 'C'; - static const char PAT_SIBLING = 'S'; - static const char PAT_CHESS = 'c'; - static const char PAT_SINGLETYPE = 't'; + enum ePattern { + PAT_NONE = 0, + PAT_TYPES = 'T', + PAT_ZEBRA = 'z', + PAT_EMERALD = 'f', + PAT_PALACE = 'p', + PAT_FIELD = 'F', + PAT_DOWN = 'H', + PAT_COLORING = 'C', + PAT_SIBLING = 'S', + PAT_CHESS = 'c', + PAT_SINGLETYPE = 't' + }; + + extern ePattern whichPattern; extern int subpattern_flags; @@ -1068,7 +1072,7 @@ namespace patterns { int symmetries; }; - patterninfo getpatterninfo(cell *c, char pat, int sub); + patterninfo getpatterninfo(cell *c, ePattern pat, int sub); inline patterninfo getpatterninfo0(cell *c) { return getpatterninfo(c, whichPattern, subpattern_flags); diff --git a/mapeditor.cpp b/mapeditor.cpp index ccf36c22..7e94fda0 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -1335,7 +1335,7 @@ namespace mapeditor { int tg, wp; int nt; hr::ignore(fscanf(f, "%d%d%d%d\n", &tg, &nt, &wp, &patterns::subpattern_flags)); - patterns::whichPattern = wp; + patterns::whichPattern = patterns::ePattern(wp); if(tg != geometry) { targetgeometry = eGeometry(tg); stop_game_and_switch_mode(rg::geometry); } if(bool(nt) != nonbitrunc) stop_game_and_switch_mode(rg::bitrunc); start_game(); @@ -1348,7 +1348,7 @@ namespace mapeditor { if(siz < 0 || siz > 1000) break; if(i >= 4) { - if(i < 8) patterns::whichPattern = "xxxxfpzH"[i]; + if(i < 8) patterns::whichPattern = patterns::ePattern("xxxxfpzH"[i]); patterns::subpattern_flags = 0; i = 3; } diff --git a/pattern2.cpp b/pattern2.cpp index 4014e8b7..5fb2f054 100644 --- a/pattern2.cpp +++ b/pattern2.cpp @@ -846,7 +846,7 @@ namespace patterns { if(gp::on && has_nice_dual() && !ishept(c) && ishex1(c)) si.dir = fix6(si.dir+3); } - char whichPattern = 0; + ePattern whichPattern = PAT_NONE; int subpattern_flags; @@ -874,7 +874,7 @@ namespace patterns { applyAlt(si, sub, PAT_COLORING); } - patterninfo getpatterninfo(cell *c, char pat, int sub) { + patterninfo getpatterninfo(cell *c, ePattern pat, int sub) { bool symRotation = sub & SPF_ROT; // bool sym0 = sub & (SPF_SYM01 | SPF_SYM02 | SPF_SYM03); @@ -1502,10 +1502,12 @@ namespace patterns { void showPattern() { cmode = sm::SIDE | sm::MAYDARK; { - dynamicval dc(displaycodes, true); + dynamicval dc(displaycodes, whichPattern); gamescreen(0); } dialog::init(); + + dialog::addBoolItem(XLAT("cell types"), (whichPattern == PAT_TYPES), PAT_TYPES); if(stdhyperbolic || a4) dialog::addBoolItem(XLAT("Zebra Pattern"), (whichPattern == PAT_ZEBRA), PAT_ZEBRA); @@ -1618,9 +1620,9 @@ namespace patterns { keyhandler = [] (int sym, int uni) { dialog::handleNavigation(sym, uni); - if(among(uni, PAT_EMERALD, PAT_PALACE, PAT_ZEBRA, PAT_DOWN, PAT_FIELD, PAT_COLORING, PAT_SIBLING, PAT_CHESS, PAT_SINGLETYPE)) { - if(whichPattern == uni) whichPattern = 0; - else whichPattern = uni; + if(among(uni, PAT_EMERALD, PAT_PALACE, PAT_ZEBRA, PAT_DOWN, PAT_FIELD, PAT_COLORING, PAT_SIBLING, PAT_CHESS, PAT_SINGLETYPE, PAT_TYPES)) { + if(whichPattern == uni) whichPattern = PAT_NONE; + else whichPattern = ePattern(uni); #if CAP_EDIT mapeditor::modelcell.clear(); #endif @@ -1691,7 +1693,7 @@ namespace patterns { struct changeable_pattern_geometry { eGeometry geo; bool nonbitru; - char whichPattern; + ePattern whichPattern; int subpattern_flags; }; @@ -1702,18 +1704,18 @@ namespace patterns { vector cpatterns = { {"football", { - {gNormal, false, 0, 0}, - {gSphere, false, 0, 0}, - {gEuclid, false, 0, SPF_EXTRASYM}, - {gOctagon, false, 0, 0}, + {gNormal, false, PAT_TYPES, 0}, + {gSphere, false, PAT_TYPES, 0}, + {gEuclid, false, PAT_TYPES, SPF_EXTRASYM}, + {gOctagon, false, PAT_TYPES, 0}, {gOctagon, true, PAT_COLORING, SPF_FOOTBALL | SPF_EXTRASYM}, - {g45, false, 0, 0}, - {g46, false, 0, SPF_EXTRASYM}, - {g47, false, 0, 0}, - {gSmallSphere, false, 0, 0}, + {g45, false, PAT_TYPES, 0}, + {g46, false, PAT_TYPES, SPF_EXTRASYM}, + {g47, false, PAT_TYPES, 0}, + {gSmallSphere, false, PAT_TYPES, 0}, {gSmallSphere, true, PAT_COLORING, SPF_FOOTBALL | SPF_EXTRASYM}, - {gTinySphere, false, 0, SPF_EXTRASYM}, - {gEuclidSquare, false, 0, SPF_EXTRASYM}, + {gTinySphere, false, PAT_TYPES, SPF_EXTRASYM}, + {gEuclidSquare, false, PAT_TYPES, SPF_EXTRASYM}, }}, {"three colors", { {gEuclid, false, PAT_COLORING, SPF_SYM0123 | SPF_EXTRASYM}, @@ -2236,13 +2238,13 @@ int read_pattern_args() { const char *c = argcs(); using namespace patterns; subpattern_flags = 0; - whichPattern = 0; + whichPattern = PAT_NONE; while(*c) { if(*c >= '0' && *c <= '9') subpattern_flags ^= 1 << (*c - '0'); else if(*c == '@') subpattern_flags ^= 1 << 10; else if(*c == '-') subpattern_flags ^= 1 << 11; else if(*c == '~') subpattern_flags ^= 1 << 12; - else whichPattern = *c; + else whichPattern = ePattern(*c); c++; } } diff --git a/textures.cpp b/textures.cpp index 7d762406..d6cfcf23 100644 --- a/textures.cpp +++ b/textures.cpp @@ -797,7 +797,7 @@ void init_textureconfig() { addsaverenum(target_nonbitru, "bitruncated", false); // ... geometry parameters - addsaver(patterns::whichPattern, "pattern", 0); + addsaverenum(patterns::whichPattern, "pattern", patterns::PAT_TYPES); addsaver(patterns::subpattern_flags, "pattern flags", 0); addsaver(si_save.id, "center type", 1); @@ -873,7 +873,7 @@ bool texture_config::load() { polygonal::solve(); if(1) { - dynamicval d1(patterns::whichPattern, patterns::whichPattern); + dynamicval d1(patterns::whichPattern, patterns::whichPattern); dynamicval d2(patterns::subpattern_flags, patterns::subpattern_flags); if(targetgeometry != geometry) { diff --git a/tour.cpp b/tour.cpp index 9eb62fc6..7da5978e 100644 --- a/tour.cpp +++ b/tour.cpp @@ -617,10 +617,10 @@ slide default_slides[] = { setCanvas(mode, 't'); if(mode == 1) patterns::displaycodes = true, - patterns::whichPattern = 'z'; + patterns::whichPattern = patterns::PAT_ZEBRA; if(mode == 3) patterns::displaycodes = false, - patterns::whichPattern = 0; + patterns::whichPattern = patterns::PAT_NONE; SHOWLAND ( l == laCanvas ); } },