1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-20 15:40:26 +00:00

custom dialog items

This commit is contained in:
Zeno Rogue 2022-04-16 13:58:26 +02:00
parent 1a55a5cfb2
commit d3fa8a6c2a

View File

@ -17,7 +17,7 @@ EX namespace dialog {
static const int DONT_SHOW = 16; static const int DONT_SHOW = 16;
enum tDialogItem {diTitle, diItem, diBreak, diHelp, diInfo, diIntSlider, diSlider, diBigItem, diKeyboard}; enum tDialogItem {diTitle, diItem, diBreak, diHelp, diInfo, diIntSlider, diSlider, diBigItem, diKeyboard, diCustom};
struct item { struct item {
tDialogItem type; tDialogItem type;
@ -29,6 +29,7 @@ EX namespace dialog {
double param; double param;
int p1, p2, p3; int p1, p2, p3;
int position; int position;
reaction_t customfun;
}; };
struct scaler { struct scaler {
@ -234,6 +235,16 @@ EX namespace dialog {
items.push_back(it); items.push_back(it);
} }
EX void addCustom(int size, reaction_t custom) {
item it;
it.type = diCustom;
it.color = dialogcolor;
it.colors = 0xFF8000;
it.scale = size;
it.customfun = custom;
items.push_back(it);
}
EX void addColorItem(string body, int value, int key) { EX void addColorItem(string body, int value, int key) {
item it; item it;
it.type = diItem; it.type = diItem;
@ -353,7 +364,7 @@ EX namespace dialog {
return y; return y;
} }
EX int tothei, dialogwidth, dfsize, dfspace, leftwidth, rightwidth, innerwidth, itemx, keyx, valuex; EX int tothei, dialogwidth, dfsize, dfspace, leftwidth, rightwidth, innerwidth, itemx, keyx, valuex, top;
EX string highlight_text; EX string highlight_text;
@ -434,7 +445,7 @@ EX namespace dialog {
continue; continue;
} }
int top = tothei; top = tothei;
tothei += dfspace * I.scale / 100; tothei += dfspace * I.scale / 100;
int mid = (top + tothei) / 2; int mid = (top + tothei) / 2;
I.position = mid; I.position = mid;
@ -497,6 +508,9 @@ EX namespace dialog {
} }
if(xthis) getcstat = I.key, inslider = true, slider_x = mousex; if(xthis) getcstat = I.key, inslider = true, slider_x = mousex;
} }
else if(I.type == diCustom) {
I.customfun();
}
else if(I.type == diKeyboard) { else if(I.type == diKeyboard) {
int len = 0; int len = 0;
for(char c: I.body) for(char c: I.body)