From ba972ea8d82ba60cc67ab6fab460735aa2125fe2 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 7 May 2024 22:18:54 +0200 Subject: [PATCH] more settings for minefield graphics --- celldrawer.cpp | 71 ++++++++++++++++++++++++++++++++++++-------------- config.cpp | 10 ++++++- graph.cpp | 7 ++++- help.cpp | 14 +++++++++- 4 files changed, 80 insertions(+), 22 deletions(-) diff --git a/celldrawer.cpp b/celldrawer.cpp index 1814dade..4f0d4266 100644 --- a/celldrawer.cpp +++ b/celldrawer.cpp @@ -94,6 +94,14 @@ void eclectic_red(color_t& col) { constexpr ld spinspeed = .75 / M_PI; +EX color_t apply_mine_knowledge(color_t wcol, cell* c) { + if(mine::marked_safe(c)) + return gradient(wcol, 0x40FF40, 0, 0.2, 1); + if(mine::marked_mine(c)) + return gradient(wcol, 0xFF4040, -1, vid.ispeed ? sintick(100) : 1, 1); + return wcol; + } + void celldrawer::setcolors() { wcol = fcol = winf[c->wall].color; @@ -541,10 +549,7 @@ void celldrawer::setcolors() { case waMineUnknown: case waMineMine: #if CAP_COMPLEX2 - if(mine::marked_safe(c)) - fcol = wcol = gradient(wcol, 0x40FF40, 0, 0.2, 1); - else if(mine::marked_mine(c)) - fcol = wcol = gradient(wcol, 0xFF4040, -1, vid.ispeed ? sintick(100) : 1, 1); + if(!mine_markers) fcol = wcol = apply_mine_knowledge(wcol, c); goto fallthrough; #endif @@ -1379,6 +1384,39 @@ bool celldrawer::set_randompattern_floor() { } EX bool numerical_minefield; +EX int mine_zero_display = 1; +EX bool mine_hollow; +EX bool mine_markers; + +EX void draw_mine_numbers(int mines, const shiftmatrix& V, int ct6) { + auto hollow = [&] (hpcshape& sh, color_t col) { + if(mine_hollow) { + dynamicval dc(poly_outline, col); + queuepoly(V, sh, 0); + } + else + queuepoly(V, sh, col); + }; + if(mines == 0 && mine_zero_display < (WDIM == 3 ? 2 : 1)) return; + if(numerical_minefield) { + string label = its(mines); + queuestr(V, (mines >= 10 ? .5 : 1) * mapfontscale / 100, label, darkened(minecolors[mines]), 8); + } + else { + if(mines >= isize(minecolors)) hollow(cgi.shBigMineMark[ct6], darkena(minecolors[mines/isize(minecolors)], 0, 0xFF)); + hollow(cgi.shMineMark[ct6], darkena(minecolors[mines], 0, 0xFF)); + } + } + +EX void draw_mine_markers(cell *c, const shiftmatrix& V) { + if(mine_markers && !mine::marked_safe(c)) { + color_t col = 0xFF4040; + if(mine::marked_mine(c)) + col = gradient(winf[waMineMine].color, col, -1, vid.ispeed ? sintick(100) : 1, 1); + dynamicval dc(poly_outline, (col << 8) | 0xFF); + queuepoly(V, cgi.shJoint, 0); + } + } void celldrawer::draw_features() { char xch = winf[c->wall].glyph; @@ -1624,18 +1662,12 @@ void celldrawer::draw_features() { case waMineOpen: { int mines = countMinesAround(c); - if(numerical_minefield) { - if(mines) { - string label = its(mines); - queuestr(V, (mines >= 10 ? .5 : 1) * mapfontscale / 100, label, darkened(minecolors[mines]), 8); - } - } - else { - if(mines >= isize(minecolors)) - queuepoly(V, cgi.shBigMineMark[ct6], darkena(minecolors[mines/isize(minecolors)], 0, 0xFF)); - if(mines) - queuepoly(V, cgi.shMineMark[ct6], darkena(minecolors[mines], 0, 0xFF)); - } + draw_mine_numbers(mines, V, ct6); + break; + } + + case waMineUnknown: case waMineMine: { + draw_mine_markers(c, V); break; } @@ -1765,6 +1797,9 @@ void celldrawer::draw_features_and_walls_3d() { if(anyshiftclick) return; } + if(among(c->wall, waMineUnknown, waMineMine)) + draw_mine_markers(c, face_the_player(V)); + if(isWall3(c, wcol)) { if(!no_wall_rendering) { if(c->wall == waChasm && c->land == laMemory && !in_perspective()) { @@ -1874,9 +1909,7 @@ void celldrawer::draw_features_and_walls_3d() { } else { int mines = countMinesAround(c); - if(mines >= isize(minecolors)) - queuepoly(face_the_player(V), cgi.shBigMineMark[0], darkena(minecolors[mines/isize(minecolors)], 0, 0xFF)); - queuepoly(face_the_player(V), cgi.shMineMark[0], darkena(minecolors[mines], 0, 0xFF)); + draw_mine_numbers(mines, face_the_player(V), 0); } } diff --git a/config.cpp b/config.cpp index 8ce65092..3e10481b 100644 --- a/config.cpp +++ b/config.cpp @@ -3121,7 +3121,15 @@ EX int config3 = addHook(hooks_configfile, 100, [] { param_b(vid.fixed_yz, "fixed YZ", true); param_b(frustum_culling, "frustum_culling"); param_b(numerical_minefield, "numerical_minefield") - ->editable("display mine counts numerically", 'n'); + -> editable("toggle numerical display", 'n'); + param_b(mine_hollow, "mine_hollow") + -> editable("hollow mine symbols", 'h'); + param_b(mine_markers, "mine_markers") + -> editable("markers on possible mines", 'm'); + param_i(mine_opacity, "minefield opacity", 255) + ->editable(0, 255, 51, "opacity of undiscovered minefield", "3D modes only\n\n0 = invisible, 255 = fully opaque", 'o'); + param_enum(mine_zero_display, "minefield_zero", "minefield_zero", 1) + ->editable({{"OFF", "never display zeros"}, {"3D", "only in 3D modes"}, {"ON", "always display zeros"}}, "display zeros in minefield", 'z'); param_b(dont_display_minecount, "dont_display_minecount"); #if MAXMDIM >= 4 param_enum(draw_sky, "draw_sky", "draw_sky", skyAutomatic) diff --git a/graph.cpp b/graph.cpp index 1b577455..d8b68c2d 100644 --- a/graph.cpp +++ b/graph.cpp @@ -4028,13 +4028,16 @@ EX int colorhash(color_t i) { return (i * 0x471211 + i*i*0x124159 + i*i*i*0x982165) & 0xFFFFFF; } +EX int mine_opacity = 255; + EX bool isWall3(cell *c, color_t& wcol) { if(c->wall == waRose) { wcol = gradient(0, wcol, -5 - 5 * (7-rosephase), sintick(50 * (8 - rosephase)), 1); } if(isWall(c)) return true; if(c->wall == waChasm && c->land == laMemory && (anyshiftclick || !(cgflags & qFRACTAL))) { wcol = 0x606000; return true; } if(c->wall == waInvisibleFloor) return false; // if(chasmgraph(c)) return true; - if(among(c->wall, waMirror, waCloud, waMineUnknown, waMineMine)) return true; + if(among(c->wall, waMirror, waCloud)) return true; + if(among(c->wall, waMineUnknown, waMineMine) && mine_opacity == 255) return true; return false; } @@ -4077,6 +4080,8 @@ EX color_t transcolor(cell *c, cell *c2, color_t wcol) { } if(among(c->wall, waRubble, waDeadfloor2) && !snakelevel(c2)) return darkena3(winf[c->wall].color, 0, 0x40); if(c->wall == waMagma && c2->wall != waMagma) return darkena3(magma_color(lavatide(c, -1)/4), 0, 0x80); + if(among(c->wall, waMineUnknown, waMineMine) && !among(c2->wall, waMineMine, waMineUnknown) && mine_opacity > 0 && mine_opacity < 255) + return 0xFFFFFF00 | mine_opacity; return 0; } diff --git a/help.cpp b/help.cpp index b309957f..3131dc78 100644 --- a/help.cpp +++ b/help.cpp @@ -553,6 +553,18 @@ EX string generateHelpForItem(eItem it) { return help; } +void mine_dialog() { + cmode = sm::SIDE; + gamescreen(); + dialog::init("Minefield graphics"); + add_edit(numerical_minefield); + add_edit(mine_zero_display); + add_edit(mine_opacity); + add_edit(mine_hollow); + add_edit(mine_markers); + dialog::display(); + } + void addMinefieldExplanation(string& s) { s += XLAT( @@ -568,7 +580,7 @@ void addMinefieldExplanation(string& s) { s += XLAT("Known mines may be marked by touching while in drag mode. Your allies won't step on marked mines."); #endif - help_extensions.push_back(help_extension{'n', XLAT("toggle numerical display"), [] () { numerical_minefield = !numerical_minefield; }}); + help_extensions.push_back(help_extension{'c', XLAT("configure"), [] () { pushScreen(mine_dialog); } }); } EX string generateHelpForWall(eWall w) {