dice values are now editable in Shift+G

This commit is contained in:
Zeno Rogue 2021-06-16 13:13:13 +02:00
parent 41e11a63dc
commit c953b2dda6
2 changed files with 38 additions and 0 deletions

View File

@ -959,6 +959,8 @@ EX namespace dice {
vector<die_structure*> die_list = {&d4, &d6, &d8, &d12, &d20};
#if HDR
extern vector<struct die_structure*> die_list;
struct die_data {
struct die_structure *which;
int val; /* the current face value */
@ -967,6 +969,10 @@ EX namespace dice {
int happy();
};
#endif
EX int shape_faces(die_structure *w) { return w->faces; }
EX string die_name(die_structure *w) { return its(w->faces); }
int die_data::happy() {
if(val == which->faces-1) return 1;

View File

@ -403,6 +403,38 @@ struct debugScreen {
dialog::use_hexeditor();
});
}
if(dice::on(what)) {
dialog::addSelItem(XLAT("die shape"), dice::die_name(dice::data[what].which), 'A');
dialog::add_action_push([what] {
dialog::init("die shape");
char key = 'a';
for(auto shape: dice::die_list) {
dialog::addItem(dice::die_name(shape), key++);
dialog::add_action([what, shape] {
dice::data[what].which = shape;
dice::data[what].val = 0;
popScreen();
});
}
dialog::display();
});
dialog::addSelItem(XLAT("die face"), its(dice::data[what].val), 'B');
dialog::add_action([what] {
auto& dd = dice::data[what];
int maxv = shape_faces(dd.which)-1;
dialog::editNumber(dd.val, 0, maxv, 1, 0, XLAT("die face"), "");
dialog::bound_low(0);
dialog::bound_up(maxv);
});
dialog::addSelItem(XLAT("die direction"), its(dice::data[what].dir), 'C');
dialog::add_action([what] {
auto& dd = dice::data[what];
dialog::editNumber(dd.dir, 0, what->type-1, 1, dd.dir, XLAT("die direction"), "");
dialog::bound_low(0);
dialog::bound_up(what->type-1);
});
dialog::addBoolItem_action(XLAT("die mirror status"), dice::data[what].mirrored, 'D');
}
dialog::addBreak(50);
if(show_debug_data) {