From bfacda7207144a1bcf8ea97ff176324cc5d6b1f0 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 27 May 2024 13:37:18 +0200 Subject: [PATCH] ccolor:: live_canvas feature --- config.cpp | 18 +++++------------- mapeffects.cpp | 6 ++++++ pattern2.cpp | 1 + 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/config.cpp b/config.cpp index d9cd87de..563f0100 100644 --- a/config.cpp +++ b/config.cpp @@ -3293,6 +3293,8 @@ EX int config3 = addHook(hooks_configfile, 100, [] { }); param_ccolor(ccolor::which, "pattern"); + param_b(ccolor::live_canvas, "live_canvas") + -> editable("apply color/pattern changes to canvas automatically", 'l'); param_str(ccolor::color_formula, "color_formula"); }); @@ -3383,19 +3385,7 @@ EX void showCustomizeChar() { }; } -EX void refresh_canvas() { - manual_celllister cl; - cl.add(cwt.at); - - int at = 0; - while(at < isize(cl.lst)) { - cell *c2 = cl.lst[at]; - c2->landparam = ccolor::generateCanvas(c2); - at++; - - forCellEx(c3, c2) cl.add(c3); - } - } +EX void refresh_canvas() { ccolor::live_canvas = true; } EX color_t addalpha(color_t c) { return (c << 8) | 0xFF; } @@ -3489,6 +3479,8 @@ EX void show_color_dialog() { dialog::addItem(XLAT("unreversed colors"), 'U'); dialog::add_action_push([] { edit_color_table(ccolor::shape.ctab, refresh_canvas, true); }); } + + add_edit(ccolor::live_canvas); } if(cwt.at->land == laMinefield) { diff --git a/mapeffects.cpp b/mapeffects.cpp index dd4d5305..d5c1e89c 100644 --- a/mapeffects.cpp +++ b/mapeffects.cpp @@ -744,6 +744,12 @@ EX void checkTide(cell *c) { else if(c->wall == waMagma) c->wall = waNone; } #endif + if(c->land == laCanvas && ccolor::live_canvas) { + color_t col = ccolor::generateCanvas(c); + c->landparam = col; + c->wall = canvas_default_wall; + if(col & 0x1000000) c->wall = waWaxWall; + } } EX bool makeNoMonster(cell *c) { diff --git a/pattern2.cpp b/pattern2.cpp index de0f555d..4ac5a31e 100644 --- a/pattern2.cpp +++ b/pattern2.cpp @@ -1565,6 +1565,7 @@ EX namespace ccolor { EX int jhole = 0; EX int jblock = 0; EX int rwalls = 50; + EX bool live_canvas; EX void edit_rwalls() { dialog::editNumber(rwalls, 0, 100, 10, 50, XLAT("probability of a wall (%)"), "");