1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-11-26 10:24:49 +00:00

Merge pull request #479 from josephcsible/ePainttype

Make painttype an enum
This commit is contained in:
Zeno Rogue
2025-10-19 11:55:01 +02:00
committed by GitHub

View File

@@ -1330,7 +1330,8 @@ EX namespace mapeditor {
#if CAP_EDIT #if CAP_EDIT
int paintwhat = 0; int paintwhat = 0;
int paintwhat_alt_wall = 0; int paintwhat_alt_wall = 0;
int painttype = 0; enum class ePainttype { monsters, items, lands, walls, copy, boundary, paint, select, teleport };
ePainttype painttype = ePainttype::monsters;
int paintstatueid = 0; int paintstatueid = 0;
int radius = 0; int radius = 0;
string paintwhat_str = "clear monster"; string paintwhat_str = "clear monster";
@@ -1465,8 +1466,8 @@ EX namespace mapeditor {
if(anyshiftclick) { if(anyshiftclick) {
dialog::addInfo( dialog::addInfo(
(painttype == 6 && (GDIM == 3)) ? "wall" : (painttype == ePainttype::paint && (GDIM == 3)) ? "wall" :
painttype == 3 ? XLATN(winf[paintwhat_alt_wall].name) : "clear"); painttype == ePainttype::walls ? XLATN(winf[paintwhat_alt_wall].name) : "clear");
} }
else else
dialog::addInfo(paintwhat_str); dialog::addInfo(paintwhat_str);
@@ -1476,39 +1477,39 @@ EX namespace mapeditor {
dialog::add_action([] { dialog::add_action([] {
dialog::editNumber(radius, 0, 9, 1, 1, XLAT("radius"), ""); dialog::editNumber(radius, 0, 9, 1, 1, XLAT("radius"), "");
}); });
dialog::addBoolItem(XLAT("boundary"), painttype == 5, 'b'); dialog::addBoolItem(XLAT("boundary"), painttype == ePainttype::boundary, 'b');
dialog::add_action([] { painttype = 5, paintwhat_str = XLAT("boundary"); }); dialog::add_action([] { painttype = ePainttype::boundary, paintwhat_str = XLAT("boundary"); });
dialog::addBoolItem(XLAT("monsters"), painttype == 0, 'm'); dialog::addBoolItem(XLAT("monsters"), painttype == ePainttype::monsters, 'm');
dialog::add_action([] { pushScreen(showList), painttype = 0, dialog::infix = ""; }); dialog::add_action([] { pushScreen(showList), painttype = ePainttype::monsters, dialog::infix = ""; });
dialog::addBoolItem(XLAT("items"), painttype == 1, 'i'); dialog::addBoolItem(XLAT("items"), painttype == ePainttype::items, 'i');
dialog::add_action([] { pushScreen(showList), painttype = 1, dialog::infix = ""; }); dialog::add_action([] { pushScreen(showList), painttype = ePainttype::items, dialog::infix = ""; });
dialog::addBoolItem(XLAT("lands"), painttype == 2, 'l'); dialog::addBoolItem(XLAT("lands"), painttype == ePainttype::lands, 'l');
dialog::add_action([] { pushScreen(showList), painttype = 2, dialog::infix = ""; }); dialog::add_action([] { pushScreen(showList), painttype = ePainttype::lands, dialog::infix = ""; });
dialog::addBoolItem(XLAT("walls"), painttype == 3, 'w'); dialog::addBoolItem(XLAT("walls"), painttype == ePainttype::walls, 'w');
dialog::add_action([] { pushScreen(showList), painttype = 3, dialog::infix = ""; }); dialog::add_action([] { pushScreen(showList), painttype = ePainttype::walls, dialog::infix = ""; });
dialog::addBoolItem(XLAT("paint"), painttype == 6, 'w'); dialog::addBoolItem(XLAT("paint"), painttype == ePainttype::paint, 'w');
dialog::add_action([] { dialog::add_action([] {
painttype = 6; painttype = ePainttype::paint;
paintwhat_str = "paint"; paintwhat_str = "paint";
dialog::openColorDialog((unsigned&)(paintwhat = (painttype ==6 ? paintwhat : 0x808080))); dialog::openColorDialog((unsigned&)(paintwhat = (painttype == ePainttype::paint ? paintwhat : 0x808080)));
}); });
dialog::addBoolItem(XLAT("copy"), painttype == 4, 'c'); dialog::addBoolItem(XLAT("copy"), painttype == ePainttype::copy, 'c');
dialog::add_action([] { dialog::add_action([] {
if(mouseover) { copysource = mouseover_cw(true); painttype = 4; paintwhat_str = XLAT("copying"); } if(mouseover) { copysource = mouseover_cw(true); painttype = ePainttype::copy; paintwhat_str = XLAT("copying"); }
else { painttype = 7; paintwhat_str = XLAT("select area to copy"); } else { painttype = ePainttype::select; paintwhat_str = XLAT("select area to copy"); }
}); });
dialog::addBoolItem(XLAT("teleport player"), painttype == 8, 't'); dialog::addBoolItem(XLAT("teleport player"), painttype == ePainttype::teleport, 't');
dialog::add_action([] { dialog::add_action([] {
if(mouseover) { if(mouseover) {
playermoved = true; playermoved = true;
cwt = mouseover_cw(true); cwt = mouseover_cw(true);
} }
else { painttype = 8; paintwhat_str = XLAT("teleport where"); } else { painttype = ePainttype::teleport; paintwhat_str = XLAT("teleport where"); }
}); });
if(painttype == 4) { if(painttype == ePainttype::copy) {
dialog::addBoolItem_action(XLAT("flip"), copysource.mirrored, 'f'); dialog::addBoolItem_action(XLAT("flip"), copysource.mirrored, 'f');
} }
else if(painttype == 3) { else if(painttype == ePainttype::walls) {
dialog::addItem(XLAT("set Shift+click"), 'z'); dialog::addItem(XLAT("set Shift+click"), 'z');
dialog::add_action([] { paintwhat_alt_wall = paintwhat; }); dialog::add_action([] { paintwhat_alt_wall = paintwhat; });
} }
@@ -1660,8 +1661,8 @@ EX namespace mapeditor {
if(!show_menu) { if(!show_menu) {
if(anyshiftclick) { if(anyshiftclick) {
displayfr(8, 8 + fs, 2, vid.fsize, displayfr(8, 8 + fs, 2, vid.fsize,
(painttype == 6 && (GDIM == 3)) ? "wall" : (painttype == ePainttype::paint && (GDIM == 3)) ? "wall" :
painttype == 3 ? XLATN(winf[paintwhat_alt_wall].name) : "clear", painttype == ePainttype::walls ? XLATN(winf[paintwhat_alt_wall].name) : "clear",
forecolor, 0); forecolor, 0);
} }
else else
@@ -1705,7 +1706,7 @@ EX namespace mapeditor {
int cdir = where.first.spin; int cdir = where.first.spin;
saveUndo(c); saveUndo(c);
switch(painttype) { switch(painttype) {
case 0: { case ePainttype::monsters: {
if(anyshiftclick) { c->monst = moNone; mirror::destroyKilled(); break; } if(anyshiftclick) { c->monst = moNone; mirror::destroyKilled(); break; }
eMonster last = c->monst; eMonster last = c->monst;
c->monst = eMonster(paintwhat); c->monst = eMonster(paintwhat);
@@ -1736,7 +1737,7 @@ EX namespace mapeditor {
mirror::destroyKilled(); mirror::destroyKilled();
break; break;
} }
case 1: { case ePainttype::items: {
if(anyshiftclick) { c->item = itNone; break; } if(anyshiftclick) { c->item = itNone; break; }
eItem last = c->item; eItem last = c->item;
c->item = eItem(paintwhat); c->item = eItem(paintwhat);
@@ -1744,7 +1745,7 @@ EX namespace mapeditor {
tortoise::babymap[c] = getBits(c) ^ (last == itBabyTortoise ? tortoise::getRandomBits() : 0); tortoise::babymap[c] = getBits(c) ^ (last == itBabyTortoise ? tortoise::getRandomBits() : 0);
break; break;
} }
case 2: { case ePainttype::lands: {
if(anyshiftclick) { c->land = laNone; c->wall = waNone; map_version++; break; } if(anyshiftclick) { c->land = laNone; c->wall = waNone; map_version++; break; }
eLand last = c->land; eLand last = c->land;
c->land = eLand(paintwhat); c->land = eLand(paintwhat);
@@ -1760,7 +1761,7 @@ EX namespace mapeditor {
c->landparam = 0; c->landparam = 0;
break; break;
} }
case 3: { case ePainttype::walls: {
eWall last = c->wall; eWall last = c->wall;
c->wall = eWall(anyshiftclick ? paintwhat_alt_wall : paintwhat); c->wall = eWall(anyshiftclick ? paintwhat_alt_wall : paintwhat);
map_version++; map_version++;
@@ -1785,7 +1786,7 @@ EX namespace mapeditor {
break; break;
} }
case 5: case ePainttype::boundary:
map_version++; map_version++;
c->land = laNone; c->land = laNone;
c->wall = waNone; c->wall = waNone;
@@ -1794,13 +1795,13 @@ EX namespace mapeditor {
c->landparam = 0; c->landparam = 0;
// c->tmp = -1; // c->tmp = -1;
break; break;
case 6: case ePainttype::paint:
map_version++; map_version++;
c->land = laCanvas; c->land = laCanvas;
c->wall = ((GDIM == 3) ^ anyshiftclick) ? waWaxWall : waNone; c->wall = ((GDIM == 3) ^ anyshiftclick) ? waWaxWall : waNone;
c->landparam = paintwhat >> 8; c->landparam = paintwhat >> 8;
break; break;
case 4: { case ePainttype::copy: {
map_version++; map_version++;
cell *copywhat = where.second.at; cell *copywhat = where.second.at;
c->wall = copywhat->wall; c->wall = copywhat->wall;
@@ -1816,14 +1817,14 @@ EX namespace mapeditor {
else c->mondir = gmod((where.first.mirrored == where.second.mirrored ? 1 : -1) * (copywhat->mondir - where.second.spin) + cdir, c->type); else c->mondir = gmod((where.first.mirrored == where.second.mirrored ? 1 : -1) * (copywhat->mondir - where.second.spin) + cdir, c->type);
break; break;
} }
case 7: case ePainttype::select:
if(c) { if(c) {
copysource = c; copysource = c;
painttype = 4; painttype = ePainttype::copy;
paintwhat_str = XLAT("copying"); paintwhat_str = XLAT("copying");
} }
break; break;
case 8: case ePainttype::teleport:
playermoved = true; playermoved = true;
cwt = c; cwt = c;
break; break;
@@ -1836,7 +1837,7 @@ EX namespace mapeditor {
void list_spill(cellwalker tgt, cellwalker src, manual_celllister& cl) { void list_spill(cellwalker tgt, cellwalker src, manual_celllister& cl) {
spill_list.clear(); spill_list.clear();
spill_list.emplace_back(tgt, src); spill_list.emplace_back(tgt, src);
if(painttype == 7) return; if(painttype == ePainttype::select) return;
int crad = 0, nextstepat = 0; int crad = 0, nextstepat = 0;
for(int i=0; i<isize(spill_list); i++) { for(int i=0; i<isize(spill_list); i++) {
if(i == nextstepat) { if(i == nextstepat) {
@@ -1859,13 +1860,13 @@ EX namespace mapeditor {
void editAt(cellwalker where, manual_celllister& cl) { void editAt(cellwalker where, manual_celllister& cl) {
if(painttype == 4 && radius) { if(painttype == ePainttype::copy && radius) {
if(where.at->type != copysource.at->type) return; if(where.at->type != copysource.at->type) return;
if(where.spin<0) where.spin=0; if(where.spin<0) where.spin=0;
if(BITRUNCATED && !ctof(mouseover) && ((where.spin&1) != (copysource.spin&1))) if(BITRUNCATED && !ctof(mouseover) && ((where.spin&1) != (copysource.spin&1)))
where += 1; where += 1;
} }
if(painttype != 4) copysource.at = NULL; if(painttype != ePainttype::copy) copysource.at = NULL;
list_spill(where, copysource, cl); list_spill(where, copysource, cl);
for(auto& st: spill_list) for(auto& st: spill_list)
@@ -1958,9 +1959,9 @@ EX namespace mapeditor {
EX void showList() { EX void showList() {
string caption; string caption;
dialog::v.clear(); dialog::v.clear();
if(painttype == 4) painttype = 0; if(painttype == ePainttype::copy) painttype = ePainttype::monsters;
switch(painttype) { switch(painttype) {
case 0: case ePainttype::monsters:
caption = "monsters"; caption = "monsters";
for(int i=0; i<motypes; i++) { for(int i=0; i<motypes; i++) {
eMonster m = eMonster(i); eMonster m = eMonster(i);
@@ -1975,18 +1976,24 @@ EX namespace mapeditor {
else dialog::vpush(i, minf[i].name); else dialog::vpush(i, minf[i].name);
} }
break; break;
case 1: case ePainttype::items:
caption = "items"; caption = "items";
for(int i=0; i<ittypes; i++) dialog::vpush(i, iinf[i].name); for(int i=0; i<ittypes; i++) dialog::vpush(i, iinf[i].name);
break; break;
case 2: case ePainttype::lands:
caption = "lands"; caption = "lands";
for(int i=0; i<landtypes; i++) dialog::vpush(i, linf[i].name); for(int i=0; i<landtypes; i++) dialog::vpush(i, linf[i].name);
break; break;
case 3: case ePainttype::walls:
caption = "walls"; caption = "walls";
for(int i=0; i<walltypes; i++) if(i != waChasmD) dialog::vpush(i, winf[i].name); for(int i=0; i<walltypes; i++) if(i != waChasmD) dialog::vpush(i, winf[i].name);
break; break;
case ePainttype::copy:
case ePainttype::boundary:
case ePainttype::paint:
case ePainttype::select:
case ePainttype::teleport:
break;
} }
// sort(v.begin(), v.end()); // sort(v.begin(), v.end());
@@ -2008,7 +2015,7 @@ EX namespace mapeditor {
mousepressed = false; mousepressed = false;
popScreen(); popScreen();
if(painttype == 3 && paintwhat == waEditStatue) if(painttype == ePainttype::walls && paintwhat == waEditStatue)
dialog::editNumber(paintstatueid, 0, 127, 1, 1, XLAT1("editable statue"), dialog::editNumber(paintstatueid, 0, 127, 1, 1, XLAT1("editable statue"),
XLAT("These statues are designed to have their graphics edited in the Vector Graphics Editor. Each number has its own, separate graphics.") XLAT("These statues are designed to have their graphics edited in the Vector Graphics Editor. Each number has its own, separate graphics.")
); );
@@ -3087,8 +3094,8 @@ EX namespace mapeditor {
} }
auto hooks = addHook(hooks_clearmemory, 0, [] () { auto hooks = addHook(hooks_clearmemory, 0, [] () {
if(mapeditor::painttype == 4) if(mapeditor::painttype == ePainttype::copy)
mapeditor::painttype = 0, mapeditor::paintwhat = 0, mapeditor::painttype = ePainttype::monsters, mapeditor::paintwhat = 0,
mapeditor::paintwhat_str = "clear monster"; mapeditor::paintwhat_str = "clear monster";
mapeditor::copysource.at = NULL; mapeditor::copysource.at = NULL;
mapeditor::undo.clear(); mapeditor::undo.clear();