From a7f1e560c5ddeacd15bf23bf013c64c121301e6f Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 30 Aug 2018 19:14:04 +0200 Subject: [PATCH] subcodes can be (de)selected in the pattern selection --- floorshapes.cpp | 2 +- graph.cpp | 18 +++++++++++------- hyper.h | 1 + mapeditor.cpp | 2 +- pattern2.cpp | 36 +++++++++++++++++++++++++----------- textures.cpp | 8 ++------ 6 files changed, 41 insertions(+), 26 deletions(-) diff --git a/floorshapes.cpp b/floorshapes.cpp index 69f7ba08..9bd77447 100644 --- a/floorshapes.cpp +++ b/floorshapes.cpp @@ -551,7 +551,7 @@ namespace gp { int get_plainshape_id(cell *c) { int siid, sidir; if(geosupport_threecolor() == 2) { - auto si = patterns::getpatterninfo(c, patterns::PAT_COLORING, 0); + auto si = patterns::getpatterninfo(c, patterns::PAT_COLORING, patterns::SPF_NO_SUBCODES); siid = si.id>>2; // if(siid == 2) si.dir++; // if(siid != pattern_threecolor(c)) printf("threecolor mismatch\n"); diff --git a/graph.cpp b/graph.cpp index 56d9d653..8933d6c9 100644 --- a/graph.cpp +++ b/graph.cpp @@ -3478,6 +3478,10 @@ void draw_wall(cell *c, const transmatrix& V, int wcol, int& zcol, int ct6, int bool just_gmatrix; +int colorhash(int i) { + return (i * 0x471211 + i*i*0x124159 + i*i*i*0x982165) & 0xFFFFFF; + } + void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { #if CAP_TEXTURE @@ -3793,7 +3797,6 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { poly_outline = OUTLINE_DEFAULT; if(!wmascii) { - int gc; // floor @@ -3821,8 +3824,8 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { } #if CAP_EDIT - else if(mapeditor::haveUserShape(mapeditor::sgFloor, gc = si.id + patterns::subcode(c, si))) { - qfi.usershape = gc; + else if(mapeditor::haveUserShape(mapeditor::sgFloor, si.id)) { + qfi.usershape = si.id; qfi.spin = applyPatterndir(c, si); } @@ -4232,8 +4235,9 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { si.dir += si.symmetries; } - string label = its(si.id); - queuestr(V, .5, label, 0xFF000000 + forecolor); + string label = its(si.id & 255); + int col = forecolor ^ colorhash(si.id >> 8); + queuestr(V, .5, label, 0xFF000000 + col); } #endif @@ -4806,7 +4810,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { } } - else if(isGravityLand(cwt.at->land)) { + else if(isGravityLand(cwt.at->land) && cwt.at->land != laMountain) { if(cwt.at->land == laDungeon) rev = true; if(conformal::do_rotate >= 1) if(!straightDownSeek || edgeDepth(c) < edgeDepth(straightDownSeek)) { @@ -4816,7 +4820,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { } else if(c->master->alt && cwt.at->master->alt && - (cwt.at->land == laMountain || + ((cwt.at->land == laMountain && conformal::do_rotate >= 1)|| (conformal::do_rotate >= 2 && (cwt.at->land == laTemple || cwt.at->land == laWhirlpool || (cheater && (cwt.at->land == laClearing || cwt.at->land == laCaribbean || diff --git a/hyper.h b/hyper.h index e0ee1d98..78598a4b 100644 --- a/hyper.h +++ b/hyper.h @@ -1074,6 +1074,7 @@ namespace patterns { static const int SPF_FOOTBALL = 256; static const int SPF_FULLSYM = 512; static const int SPF_DOCKS = 1024; + static const int SPF_NO_SUBCODES = 2048; static const int SPF_SYM0123 = SPF_SYM01 | SPF_SYM02 | SPF_SYM03; diff --git a/mapeditor.cpp b/mapeditor.cpp index 4ea7a687..bf670df6 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -541,7 +541,7 @@ namespace mapeditor { if(drawcell->monst) return drawcell->monst; if(drawcell->item) return drawcell->item; auto si = patterns::getpatterninfo0(drawcell); - return si.id + patterns::subcode(drawcell, si); + return si.id; } bool editingShape(eShapegroup group, int id) { diff --git a/pattern2.cpp b/pattern2.cpp index 10e2444e..c87443ae 100644 --- a/pattern2.cpp +++ b/pattern2.cpp @@ -875,6 +875,18 @@ namespace patterns { } patterninfo getpatterninfo(cell *c, ePattern pat, int sub) { + if(!(sub & SPF_NO_SUBCODES)) { + auto si = getpatterninfo(c, pat, sub | SPF_NO_SUBCODES); + if(IRREGULAR) + si.id += irr::cellindex[c] << 8; + else if(archimedean) + si.id += (arcm::id_of(c->master) << 8) + (arcm::parent_index_of(c->master) << 16); + else if(GOLDBERG) { + if(c == c->master->c7) si.id += (fixdir(si.dir, c) << 8); + else si.id += (get_code(gp::get_local_info(c)) << 16) | (fixdir(si.dir, c) << 8); + } + return si; + } bool symRotation = sub & SPF_ROT; // bool sym0 = sub & (SPF_SYM01 | SPF_SYM02 | SPF_SYM03); @@ -1555,6 +1567,8 @@ namespace patterns { dialog::addBoolItem(XLAT("single type"), (whichPattern == PAT_SINGLETYPE), PAT_SINGLETYPE); + dialog::addBreak(50); + if( (whichPattern == PAT_EMERALD && (stdhyperbolic || a38)) || (whichPattern == PAT_PALACE && stdhyperbolic) || @@ -1618,6 +1632,11 @@ namespace patterns { if(a38 && whichPattern == PAT_COLORING) dialog::addBoolItem(XLAT("Docks pattern"), subpattern_flags & SPF_DOCKS, '@'); + + if(whichPattern && (IRREGULAR || GOLDBERG || archimedean)) + dialog::addBoolItem(XLAT("remove complete classification"), subpattern_flags & SPF_NO_SUBCODES, '#'); + + dialog::addBreak(50); dialog::addBoolItem(XLAT("display pattern codes (full)"), displaycodes, 'd'); @@ -1678,6 +1697,11 @@ namespace patterns { REMAP_TEXTURE; } + else if(uni == '#') { + subpattern_flags ^= SPF_NO_SUBCODES; + REMAP_TEXTURE; + } + else if(uni == '6' || uni == '7' || uni == '8' || uni == '9') { if(whichShape == uni) whichShape = 0; else whichShape = uni; @@ -1901,17 +1925,7 @@ namespace patterns { void pushChangeablePatterns() { pushScreen(showChangeablePatterns); computeCgroup(); - } - - int subcode(cell *c, const patterninfo& si) { - if(IRREGULAR) - return irr::cellindex[c] << 8; - else if(archimedean) - return (arcm::id_of(c->master) << 8) + (arcm::parent_index_of(c->master) << 16); - else if(!GOLDBERG) return 0; - else if(c == c->master->c7) return (fixdir(si.dir, c) << 8); - else return (get_code(gp::get_local_info(c)) << 16) | (fixdir(si.dir, c) << 8); - } + } } bool is_master(cell *c) { diff --git a/textures.cpp b/textures.cpp index 1a69a351..34b99793 100644 --- a/textures.cpp +++ b/textures.cpp @@ -342,7 +342,7 @@ bool texture_config::apply(cell *c, const transmatrix &V, int col) { return false; } try { - auto& mi = texture_map.at(si.id + patterns::subcode(c, si)); + auto& mi = texture_map.at(si.id); set_floor(shFullFloor); qfi.tinf = &mi; @@ -420,8 +420,6 @@ void texture_config::perform_mapping() { // int sgn = sphere ? -1 : 1; - si.id += patterns::subcode(c, si); - if(!texture_map.count(si.id)) replace = true; else if(hdist0(p.second*sphereflip * C0) < hdist0(texture_map[si.id].M * sphereflip * C0)) @@ -1452,10 +1450,8 @@ void texture_config::true_remap() { missing_cells_known.clear(); for(cell *c: dcal) { auto si = patterns::getpatterninfo0(c); - int oldid = si.id; + int oldid = patterns::getpatterninfo(c, patterns::whichPattern, patterns::subpattern_flags | patterns::SPF_NO_SUBCODES).id; - si.id += patterns::subcode(c, si); - if(texture_map.count(si.id)) continue; int pshift = 0;