From 26fe57ef9229f14544f43e8b722de38937593e59 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 17 Jan 2019 00:59:45 +0100 Subject: [PATCH] mapeditor:: an option to change new canvas cells without clearing the map --- mapeditor.cpp | 3 +++ pattern2.cpp | 52 +++++++++++++++++++++++++++++++++------------------ 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/mapeditor.cpp b/mapeditor.cpp index b4e62204..1bc1fc6d 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -1960,6 +1960,9 @@ namespace mapeditor { dialog::add_action([] () { autocheat = true; }); dialog::addInfo("(unlock all, allow cheats, normal character display)"); + dialog::addItem("change the pattern/color of new Canvas cells", 'c'); + dialog::add_action([] () { pushScreen(patterns::showPrePatternNoninstant); }); + dialog::addBack(); dialog::display(); } diff --git a/pattern2.cpp b/pattern2.cpp index e39aac4d..ee8bdc28 100644 --- a/pattern2.cpp +++ b/pattern2.cpp @@ -1443,7 +1443,7 @@ namespace patterns { return canvasback; } - void showPrePattern() { + void showPrePatternP(bool instant) { cmode = sm::SIDE | sm::MAYDARK; gamescreen(0); @@ -1502,7 +1502,7 @@ namespace patterns { dialog::display(); - keyhandler = [] (int sym, int uni) { + keyhandler = [instant] (int sym, int uni) { dialog::handleNavigation(sym, uni); if(uni == 'g') { static unsigned c = (canvasback << 8) | 0xFF; @@ -1510,21 +1510,30 @@ namespace patterns { 6, 0xFFFFFFFF, 0x101010FF, 0x404040FF, 0x808080FF, 0x800000FF, unsigned(linf[laCanvas].color >> 2) << 8 }; dialog::openColorDialog(c, canvasbacks); - dialog::reaction = [] () { - stop_game(); - whichCanvas = 'g'; - canvasback = c >> 8; - firstland = specialland = laCanvas; - randomPatternsMode = false; - start_game(); + dialog::reaction = [instant] () { + if(instant) { + stop_game(); + whichCanvas = 'g'; + canvasback = c >> 8; + firstland = specialland = laCanvas; + randomPatternsMode = false; + start_game(); + } + else { + whichCanvas = 'g'; + canvasback = c >> 8; + } }; } else if(uni == 'i') { - stop_game(); - canvas_invisible = !canvas_invisible; - firstland = specialland = laCanvas; - randomPatternsMode = false; - start_game(); + if(instant) { + stop_game(); + canvas_invisible = !canvas_invisible; + firstland = specialland = laCanvas; + randomPatternsMode = false; + start_game(); + } + else canvas_invisible = !canvas_invisible; } else if(uni == 'f') { @@ -1550,12 +1559,15 @@ namespace patterns { } else if((uni >= 'a' && uni <= 'z') || (uni >= 'A' && uni <= 'Z')) { - stop_game(); + if(instant) + stop_game(); whichCanvas = uni; subcanvas = rand(); - firstland = specialland = laCanvas; - randomPatternsMode = false; - start_game(); + if(instant) { + firstland = specialland = laCanvas; + randomPatternsMode = false; + start_game(); + } if(uni == 'x' || uni == 'z' || uni == 't') whichPattern = PAT_ZEBRA, subpattern_flags = SPF_SYM0123 | SPF_ROT; if(uni == 'e') @@ -1568,6 +1580,10 @@ namespace patterns { else if(doexiton(sym, uni)) popScreen(); }; } + + void showPrePattern() { showPrePatternP(true); } + void showPrePatternNoninstant() { showPrePatternP(false); } + #if CAP_TEXTURE #define REMAP_TEXTURE texture::config.remap()