neon_mode is now an enum

This commit is contained in:
Zeno Rogue 2020-03-27 19:38:15 +01:00
parent d68ff2eeda
commit 4d4c904d3b
4 changed files with 50 additions and 35 deletions

View File

@ -588,7 +588,7 @@ void celldrawer::setcolors() {
if(c->wall == waGlass && !wmspatial) fcol = wcol;
if(neon_mode == 4) {
if(neon_mode == eNeon::illustration) {
fcol = highwall(c) ? w_monochromatize(fcol, 0) : w_monochromatize(fcol, 1);
wcol = w_monochromatize(wcol, 0);
if(c->land == laWarpCoast && !pseudohept(c) && c->wall == waNone) fcol = 0x707070;
@ -745,7 +745,7 @@ void celldrawer::draw_wall() {
}
else {
forCellIdEx(c2, i, c)
if(!highwall(c2) || conegraph(c2) || neon_mode == 4) {
if(!highwall(c2) || conegraph(c2) || neon_mode == eNeon::illustration) {
if(placeSidewall(c, i, SIDE_WALL, V, darkena(wcol2, fd, alpha))) break;
}
}
@ -2523,7 +2523,7 @@ void celldrawer::draw() {
ct6 = ctof(c);
#endif
fd = getfd(c);
if(neon_mode == 4) fd = 0;
if(neon_mode == eNeon::illustration) fd = 0;
error = false;
setcolors();

View File

@ -643,7 +643,7 @@ EX void initConfig() {
addsaver(nilv::nilperiod[1], "nilperiod_y");
addsaver(nilv::nilperiod[2], "nilperiod_z");
addsaver(neon_mode, "neon_mode");
addsaverenum(neon_mode, "neon_mode");
addsaver(noshadow, "noshadow");
addsaver(bright, "bright");
addsaver(cblind, "cblind");
@ -1142,16 +1142,15 @@ EX void showGraphConfig() {
}
else dialog::addBreak(100);
dialog::addBoolItem("standard graphics", neon_mode == 0, 'A');
dialog::add_action([] { neon_mode = 0; });
dialog::addBoolItem("neon mode", neon_mode == 1, 'B');
dialog::add_action([] { neon_mode = 1; });
dialog::addBoolItem("no boundary mode", neon_mode == 2, 'C');
dialog::add_action([] { neon_mode = 2; });
dialog::addBoolItem("neon mode II", neon_mode == 3, 'D');
dialog::add_action([] { neon_mode = 3; });
dialog::addBoolItem("illustration mode", neon_mode == 4, 'E');
dialog::add_action([] { neon_mode = 4; });
auto neon_option = [&] (string s, eNeon val, char key) {
dialog::addBoolItem(XLAT(s), neon_mode == val, key);
dialog::add_action([val] { neon_mode = (neon_mode == val) ? eNeon::none : val; });
};
neon_option("neon mode", eNeon::neon, 'B');
neon_option("no boundary mode", eNeon::no_boundary, 'C');
neon_option("neon mode II", eNeon::neon2, 'D');
neon_option("illustration mode", eNeon::illustration, 'E');
dialog::addBreak(100);
dialog::addInfo(XLAT("hint: press Alt while testing modes"));
dialog::addBreak(100);
@ -2526,7 +2525,7 @@ EX int read_config_args() {
}
else if(argis("-neon")) {
PHASEFROM(2);
shift(); neon_mode = argi();
shift(); neon_mode = eNeon(argi());
}
else if(argis("-precw")) {
PHASEFROM(2);

View File

@ -2039,21 +2039,37 @@ template<class T, class... U> T& queuea(PPR prio, U... u) {
}
#endif
EX int neon_mode = 0;
/** colorblind mode */
EX bool cblind;
#if HDR
enum class eNeon { none, neon, no_boundary, neon2, illustration};
#endif
EX eNeon neon_mode;
EX void apply_neon(color_t& col, int& r) {
switch(neon_mode) {
case 0: break;
case 1: poly_outline = col << 8; col = 0; break;
case 2: r = 0; break;
case 3: poly_outline = col << 8; col &= 0xFEFEFE; col >>= 1; break;
case eNeon::none:
case eNeon::illustration:
break;
case eNeon::neon:
poly_outline = col << 8; col = 0;
break;
case eNeon::no_boundary:
r = 0;
break;
case eNeon::neon2:
poly_outline = col << 8; col &= 0xFEFEFE; col >>= 1;
break;
}
}
#if CAP_SHAPES
/** used when neon_mode is eNeon::illustration */
EX color_t magentize(color_t x) {
if(neon_mode != 4) return x;
if(neon_mode != eNeon::illustration) return x;
int green = part(x,2);
int magenta = (part(x, 1) + part(x, 3)) / 2;
int nm = max(magenta, green);
@ -2095,27 +2111,27 @@ EX dqi_poly& queuepolyat(const transmatrix& V, const hpcshape& h, color_t col, P
part(col,1) = b; */
part(col,2) = part(col,3) = (part(col,2) * 2 + part(col,3) + 1)/3;
}
if(neon_mode == 0 || (h.flags & POLY_TRIANGLES)) {
if(neon_mode == eNeon::none || (h.flags & POLY_TRIANGLES)) {
ptd.color = (darkened(col >> 8) << 8) + (col & 0xFF);
ptd.outline = poly_outline;
}
else switch(neon_mode) {
case 1:
case eNeon::neon:
ptd.color = (poly_outline & 0xFFFFFF00) | (col & 0xFF);
ptd.outline = (darkened(col >> 8) << 8) | (col & 0xFF);
if(col == 0xFF) ptd.outline = 0xFFFFFFFF;
break;
case 2:
case eNeon::no_boundary:
ptd.color = (darkened(col >> 8) << 8) + (col & 0xFF);
ptd.outline = 0;
break;
case 3:
case eNeon::neon2:
ptd.color = (darkened(col >> 8) << 8) + (col & 0xFF) + ((col & 0xFF) >> 2);
ptd.outline = (darkened(col >> 8) << 8) + (col & 0xFF);
if(col == 0xFF) ptd.outline = 0xFFFFFFFF;
if(poly_outline != 0xFF) ptd.outline = poly_outline;
break;
case 4: {
case eNeon::illustration: {
if(poly_outline && (poly_outline>>8) != bordcolor) {
ptd.color = magentize(col);
ptd.outline = 0xFF;
@ -2128,6 +2144,7 @@ EX dqi_poly& queuepolyat(const transmatrix& V, const hpcshape& h, color_t col, P
if(ptd.outline & 0xFF) ptd.outline |= 0xFF;
break;
}
case eNeon::none: ;
}
ptd.linewidth = vid.linewidth;
ptd.flags = h.flags;
@ -2254,24 +2271,24 @@ EX void queuestr(const transmatrix& V, double size, const string& chr, color_t c
EX void queuestrn(const transmatrix& V, double size, const string& chr, color_t col, int frame IS(0), int align IS(8)) {
switch(neon_mode) {
case 0:
case eNeon::none:
queuestr(V, size, chr, col, frame, align);
break;
case 1: {
case eNeon::neon: {
dynamicval<color_t> c(poly_outline, col << 8);
queuestr(V, size, chr, 0, frame, align);
break;
}
case 2: {
case eNeon::no_boundary: {
queuestr(V, size, chr, col, 0, align);
break;
}
case 3: {
case eNeon::neon2: {
dynamicval<color_t> c(poly_outline, (col << 8) | 0xFF);
queuestr(V, size, chr, (col & 0xFEFEFE) >> 1, frame, align);
break;
}
case 4: {
case eNeon::illustration: {
dynamicval<color_t> c(poly_outline, poly_outline);
if(poly_outline && (poly_outline>>8) != bordcolor) {
col = magentize(col << 8) >> 8;

View File

@ -27,18 +27,17 @@ namespace rg {
static const char dualmode = 'U';
static const char heptagons = '7';
// wrongmode only -- marks 'global' achievements not related to the current mode
/** wrongmode only -- marks 'global' achievements not related to the current mode */
static const char global = 'x';
// wrongmode only -- change vid.scfg.players then restart_game(rg::nothing) instead
/** wrongmode only -- change vid.scfg.players then restart_game(rg::nothing) instead */
static const char multi = 'm';
// wrongmode only -- mark achievements for special geometries/variations
/** wrongmode only -- mark achievements for special geometries/variations */
static const char special_geometry = 'g';
}
#endif
EX bool game_active;
EX bool cblind;
EX bool autocheat;
EX eWall canvas_default_wall = waNone;