1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-01-11 09:50:34 +00:00

PAT_TYPES now separate from PAT_NONE; PAT_* constants now use enum

This commit is contained in:
Zeno Rogue 2018-08-28 04:05:32 +02:00
parent d049cb63af
commit c17efce3b5
7 changed files with 48 additions and 42 deletions

View File

@ -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

View File

@ -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)

28
hyper.h
View File

@ -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);

View File

@ -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;
}

View File

@ -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<bool> dc(displaycodes, true);
dynamicval<bool> 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<changeable_pattern> 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++;
}
}

View File

@ -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<char> d1(patterns::whichPattern, patterns::whichPattern);
dynamicval<patterns::ePattern> d1(patterns::whichPattern, patterns::whichPattern);
dynamicval<int> d2(patterns::subpattern_flags, patterns::subpattern_flags);
if(targetgeometry != geometry) {

View File

@ -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 );
}
},