dialog:: list used in mapeditor

This commit is contained in:
Zeno Rogue 2022-10-21 11:28:37 +02:00
parent 10e9c0fabe
commit 0fc2dc2d65
1 changed files with 26 additions and 21 deletions

View File

@ -1673,10 +1673,12 @@ EX namespace mapeditor {
} }
void showList() { void showList() {
string caption;
dialog::v.clear(); dialog::v.clear();
if(painttype == 4) painttype = 0; if(painttype == 4) painttype = 0;
switch(painttype) { switch(painttype) {
case 0: case 0:
caption = "monsters";
for(int i=0; i<motypes; i++) { for(int i=0; i<motypes; i++) {
eMonster m = eMonster(i); eMonster m = eMonster(i);
if( if(
@ -1691,12 +1693,15 @@ EX namespace mapeditor {
} }
break; break;
case 1: case 1:
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 2:
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 3:
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;
} }
@ -1704,26 +1709,18 @@ EX namespace mapeditor {
if(dialog::infix != "") mouseovers = dialog::infix; if(dialog::infix != "") mouseovers = dialog::infix;
int q = dialog::v.size(); cmode = 0;
int percolumn = vid.yres / (vid.fsize+5) - 4; gamescreen();
int columns = 1 + (q-1) / percolumn; dialog::init(caption);
if(dialog::infix != "") mouseovers = dialog::infix;
dialog::addBreak(50);
dialog::start_list(900, 900, '1');
for(int i=0; i<q; i++) { for(auto& vi: dialog::v) {
int x = 16 + (vid.xres * (i/percolumn)) / columns; dialog::addItem(vi.first, dialog::list_fake_key++);
int y = (vid.fsize+5) * (i % percolumn) + vid.fsize*2; dialog::add_action([&vi] {
paintwhat = vi.second;
int actkey = 1000 + i; paintwhat_str = vi.first;
string vv = dialog::v[i].first;
if(i < 9) { vv += ": "; vv += ('1' + i); }
displayButton(x, y, vv, actkey, 0);
}
keyhandler = [] (int sym, int uni) {
if(uni >= '1' && uni <= '9') uni = 1000 + uni - '1';
if(sym == SDLK_RETURN || sym == SDLK_KP_ENTER || sym == '-' || sym == SDLK_KP_MINUS) uni = 1000;
for(int z=0; z<isize(dialog::v); z++) if(1000 + z == uni) {
paintwhat = dialog::v[z].second;
paintwhat_str = dialog::v[z].first;
mousepressed = false; mousepressed = false;
popScreen(); popScreen();
@ -1732,8 +1729,16 @@ EX namespace mapeditor {
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.")
); );
return; });
} }
dialog::end_list();
dialog::addBreak(50);
dialog::addBack();
dialog::display();
keyhandler = [] (int sym, int uni) {
dialog::handleNavigation(sym, uni);
if(dialog::editInfix(uni)) ; if(dialog::editInfix(uni)) ;
else if(doexiton(sym, uni)) popScreen(); else if(doexiton(sym, uni)) popScreen();
}; };