1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-01-12 02:10:34 +00:00

gp:: texture:: menu added

This commit is contained in:
Zeno Rogue 2018-04-10 05:12:40 +02:00
parent 699798a968
commit e318a8e04a
4 changed files with 57 additions and 33 deletions

View File

@ -263,7 +263,7 @@ void showEuclideanMenu() {
else if(S3 != 3) else if(S3 != 3)
dialog::addBoolItem(XLAT("bitruncated"), !nonbitrunc, 't'); dialog::addBoolItem(XLAT("bitruncated"), !nonbitrunc, 't');
else { else {
dialog::addBoolItem(XLAT("operation"), nonbitrunc, 't'); dialog::addBoolItem(XLAT("Goldberg"), nonbitrunc, 't');
dialog::lastItem().value = gp::operation_name(); dialog::lastItem().value = gp::operation_name();
} }

View File

@ -392,12 +392,14 @@ namespace gp {
else if(param == loc(3, 0)) else if(param == loc(3, 0))
return XLAT("2x bitruncated"); return XLAT("2x bitruncated");
else else
return "(" + its(param.first) + "," + its(param.second) + ")"; return "GP(" + its(param.first) + "," + its(param.second) + ")";
} }
int config_x, config_y; int config_x, config_y;
void whirl_set(int x, int y) { void whirl_set(int x, int y, bool texture_remap) {
auto old_tstate = texture::config.tstate;
auto old_tstate_max = texture::config.tstate_max;
if(y < 0) { y = -y; x -= y; } if(y < 0) { y = -y; x -= y; }
if(x < 0) { x = -x; y = -y; } if(x < 0) { x = -x; y = -y; }
if(x < y) swap(x, y); if(x < y) swap(x, y);
@ -419,37 +421,50 @@ namespace gp {
param = loc(x, y); param = loc(x, y);
restartGame(rg::gp); restartGame(rg::gp);
} }
if(texture_remap)
texture::config.remap(old_tstate, old_tstate_max);
screens = g; screens = g;
} }
string helptext() { string helptext() {
return return
"HyperRogue's map is obtained by applying an operator to the basic regular tesselation. " "Goldberg polyhedra are obtained by adding extra hexagons to a dodecahedron. "
"Operator (x,y) means that, to get to a nearest non-hex from any non-hex, you should move x " "GP(x,y) means that, to get to a nearest non-hex from any non-hex, you should move x "
"cells in any direction, turn right 60 degrees, and move y cells. " "cells in any direction, turn right 60 degrees, and move y cells. "
"By default HyperRogue uses bitruncation, which corresponds to (1,1)."; "HyperRogue generalizes this to any tesselation with 3 faces per vertex. "
"By default HyperRogue uses bitruncation, which corresponds to GP(1,1).";
} }
void show() { void show(bool texture_remap) {
cmode = sm::SIDE; cmode = sm::SIDE;
gamescreen(0); gamescreen(0);
dialog::init(XLAT("operators")); dialog::init(XLAT("Goldberg"));
bool show_nonthree = !(texture_remap && (S7&1));
if(show_nonthree) {
dialog::addBoolItem(XLAT("OFF"), param == loc(1,0), 'a'); dialog::addBoolItem(XLAT("OFF"), param == loc(1,0), 'a');
dialog::lastItem().value = "(1,0)"; dialog::lastItem().value = "GP(1,0)";
}
dialog::addBoolItem(XLAT("bitruncated"), param == loc(1,1), 'b'); dialog::addBoolItem(XLAT("bitruncated"), param == loc(1,1), 'b');
dialog::lastItem().value = "(1,1)"; dialog::lastItem().value = "GP(1,1)";
if(show_nonthree) {
dialog::addBoolItem(XLAT("chamfered"), param == loc(2,0), 'c'); dialog::addBoolItem(XLAT("chamfered"), param == loc(2,0), 'c');
dialog::lastItem().value = "(2,0)"; dialog::lastItem().value = "GP(2,0)";
}
dialog::addBoolItem(XLAT("2x bitruncated"), param == loc(3,0), 'd'); dialog::addBoolItem(XLAT("2x bitruncated"), param == loc(3,0), 'd');
dialog::lastItem().value = "(3,0)"; dialog::lastItem().value = "GP(3,0)";
dialog::addBreak(100); dialog::addBreak(100);
dialog::addSelItem("x", its(config_x), 0); dialog::addSelItem("x", its(config_x), 'x');
dialog::addSelItem("y", its(config_y), 0); dialog::addSelItem("y", its(config_y), 'y');
if((config_x-config_y)%3 && !show_nonthree)
dialog::addInfo("This pattern needs x-y divisible by 3");
else
dialog::addBoolItem(XLAT("tuned"), param == loc(config_x, config_y), 'f'); dialog::addBoolItem(XLAT("tuned"), param == loc(config_x, config_y), 'f');
dialog::addBreak(100); dialog::addBreak(100);
@ -457,18 +472,18 @@ namespace gp {
dialog::addItem(XLAT("back"), '0'); dialog::addItem(XLAT("back"), '0');
dialog::display(); dialog::display();
keyhandler = [] (int sym, int uni) { keyhandler = [show_nonthree, texture_remap] (int sym, int uni) {
dialog::handleNavigation(sym, uni); dialog::handleNavigation(sym, uni);
if(uni == 'a') if(uni == 'a' && show_nonthree)
whirl_set(1, 0); whirl_set(1, 0, texture_remap);
else if(uni == 'b') else if(uni == 'b')
whirl_set(1, 1); whirl_set(1, 1, texture_remap);
else if(uni == 'c') else if(uni == 'c' && show_nonthree)
whirl_set(2, 0); whirl_set(2, 0, texture_remap);
else if(uni == 'd') else if(uni == 'd')
whirl_set(3, 0); whirl_set(3, 0, texture_remap);
else if(uni == 'f') else if(uni == 'f' && (show_nonthree || (config_x-config_y)%3 == 0))
whirl_set(config_x, config_y); whirl_set(config_x, config_y, texture_remap);
else if(uni == 'x') else if(uni == 'x')
dialog::editNumber(config_x, 1, 10, 1, 1, "x", helptext()); dialog::editNumber(config_x, 1, 10, 1, 1, "x", helptext());
else if(uni == 'y') else if(uni == 'y')
@ -478,7 +493,7 @@ namespace gp {
}; };
} }
void configure() { void configure(bool texture_remap = false) {
if(gp::on) if(gp::on)
config_x = param.first, config_y = param.second; config_x = param.first, config_y = param.second;
else if(nonbitrunc) else if(nonbitrunc)
@ -486,7 +501,7 @@ namespace gp {
else else
config_x = 1, config_y = 1; config_x = 1, config_y = 1;
param = loc(config_x, config_y); param = loc(config_x, config_y);
pushScreen(gp::show); pushScreen([texture_remap] () { gp::show(texture_remap); });
} }
int compute_dist(cell *c, int master_function(cell*)) { int compute_dist(cell *c, int master_function(cell*)) {

View File

@ -740,7 +740,7 @@ extern videopar vid;
extern vector< function<void()> > screens; extern vector< function<void()> > screens;
template<class T> void pushScreen(T& x) { screens.push_back(x); } template<class T> void pushScreen(const T& x) { screens.push_back(x); }
inline void popScreen() { screens.pop_back(); } inline void popScreen() { screens.pop_back(); }
inline void popScreenAll() { while(size(screens)>1) popScreen(); } inline void popScreenAll() { while(size(screens)>1) popScreen(); }
@ -2988,7 +2988,7 @@ namespace gp {
extern string operation_name(); extern string operation_name();
extern int pseudohept_val(cell *); extern int pseudohept_val(cell *);
extern int last_dir(cell *c); extern int last_dir(cell *c);
extern void configure(); extern void configure(bool texture_remap);
extern ld alpha; extern ld alpha;
extern transmatrix Tf[8][32][32][6]; extern transmatrix Tf[8][32][32][6];

View File

@ -1535,11 +1535,16 @@ namespace patterns {
} }
dialog::addBoolItem(s, geometry == g.geo && nonbitrunc == g.nonbitru && whichPattern == g.whichPattern && subpattern_flags == g.subpattern_flags, 'a'+j); dialog::addBoolItem(s, geometry == g.geo && nonbitrunc == g.nonbitru && whichPattern == g.whichPattern && subpattern_flags == g.subpattern_flags, 'a'+j);
} }
dialog::addBreak(100); bool have_goldberg = S3 == 3 && among(cgroup, cpFootball, cpThree) && !euclid;
if(have_goldberg) {
dialog::addBoolItem("Goldberg", gp::on, 'G');
dialog::lastItem().value = gp::operation_name();
}
else dialog::addBreak(100);
dialog::addItem("more tuning", 'r'); dialog::addItem("more tuning", 'r');
dialog::display(); dialog::display();
keyhandler = [] (int sym, int uni) { keyhandler = [have_goldberg] (int sym, int uni) {
if(uni == 'r') if(uni == 'r')
pushScreen(showPattern); pushScreen(showPattern);
else if(uni >= '0' && uni < '0' + size(cpatterns)) else if(uni >= '0' && uni < '0' + size(cpatterns))
@ -1551,6 +1556,7 @@ namespace patterns {
#endif #endif
auto &g = cpatterns[cgroup].geometries[uni - 'a']; auto &g = cpatterns[cgroup].geometries[uni - 'a'];
if(g.geo != geometry) { targetgeometry = g.geo; restartGame(rg::geometry, false, true); } if(g.geo != geometry) { targetgeometry = g.geo; restartGame(rg::geometry, false, true); }
if(gp::on) restartGame(rg::gp, false, true);
if(g.nonbitru != nonbitrunc) restartGame(rg::bitrunc, false, true); if(g.nonbitru != nonbitrunc) restartGame(rg::bitrunc, false, true);
whichPattern = g.whichPattern; whichPattern = g.whichPattern;
subpattern_flags = g.subpattern_flags; subpattern_flags = g.subpattern_flags;
@ -1558,6 +1564,8 @@ namespace patterns {
texture::config.remap(old_tstate, old_tstate_max); texture::config.remap(old_tstate, old_tstate_max);
#endif #endif
} }
else if(uni == 'G' && have_goldberg)
gp::configure(true);
else if(doexiton(sym, uni)) else if(doexiton(sym, uni))
popScreen(); popScreen();
}; };
@ -1568,7 +1576,8 @@ namespace patterns {
for(int i=0; i<size(cpatterns); i++) for(int i=0; i<size(cpatterns); i++)
for(int j=0; j<size(cpatterns[i].geometries); j++) { for(int j=0; j<size(cpatterns[i].geometries); j++) {
auto &g = cpatterns[i].geometries[j]; auto &g = cpatterns[i].geometries[j];
if(geometry == g.geo && nonbitrunc == g.nonbitru && whichPattern == g.whichPattern && subpattern_flags == g.subpattern_flags) bool xnonbitrunc = gp::on ? gp_threecolor() : nonbitrunc;
if(geometry == g.geo && xnonbitrunc == g.nonbitru && whichPattern == g.whichPattern && subpattern_flags == g.subpattern_flags)
cgroup = cpatterntype(i); cgroup = cpatterntype(i);
} }
old_cgroup = cgroup; old_cgroup = cgroup;