mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-11 09:50:34 +00:00
onscreen keyboards where applicable
This commit is contained in:
parent
3db34f26ac
commit
c07e22ca5e
@ -1067,6 +1067,11 @@ void show() {
|
||||
edited.compute_geometry();
|
||||
dialog::addSelItem(XLAT("edge length"), fts(edited.edgelength) + (edited.get_class() == gcEuclid ? XLAT(" (arbitrary)") : ""), 0);
|
||||
current.compute_geometry();
|
||||
|
||||
dialog::addBreak(100);
|
||||
dialog::addKeyboardItem("1234567890");
|
||||
dialog::addKeyboardItem("()[]lLhH,");
|
||||
dialog::addKeyboardItem(" \t\b\x1\x2\n");
|
||||
dialog::addBreak(100);
|
||||
}
|
||||
else {
|
||||
|
60
dialogs.cpp
60
dialogs.cpp
@ -166,6 +166,16 @@ namespace dialog {
|
||||
return c;
|
||||
}
|
||||
|
||||
void addKeyboardItem(string keys) {
|
||||
item it;
|
||||
it.type = diKeyboard;
|
||||
it.body = keys;
|
||||
it.color = dialogcolor;
|
||||
it.colors = 0xFF8000;
|
||||
it.scale = 100;
|
||||
items.push_back(it);
|
||||
}
|
||||
|
||||
void addColorItem(string body, int value, int key) {
|
||||
item it;
|
||||
it.type = diItem;
|
||||
@ -417,6 +427,38 @@ namespace dialog {
|
||||
}
|
||||
if(xthis) getcstat = I.key, inslider = true;
|
||||
}
|
||||
else if(I.type == diKeyboard) {
|
||||
int len = 0;
|
||||
for(char c: I.body)
|
||||
if(c == ' ' || c == '\t') len += 3;
|
||||
else len++;
|
||||
int sl, sr;
|
||||
if(current_display->sidescreen)
|
||||
sl = vid.yres + vid.fsize*2, sr = vid.xres - vid.fsize*2;
|
||||
else
|
||||
sl = vid.xres/4, sr = vid.xres*3/4;
|
||||
int pos = 0;
|
||||
for(char c: I.body) {
|
||||
string s = "";
|
||||
s += c;
|
||||
int nlen = 1;
|
||||
if(c == ' ') s = "SPACE", nlen = 3;
|
||||
if(c == '\b') s = "⌫", nlen = 1;
|
||||
if(c == '\r' || c == '\n') s = "⏎", nlen = 1;
|
||||
if(c == 1) s = "←", nlen = 1;
|
||||
if(c == 2) s = "→", nlen = 1;
|
||||
if(c == 3) s = "π";
|
||||
if(c == '\t') s = "CLEAR", nlen = 3;
|
||||
int xpos = sl + (sr-sl) * (pos + nlen/2.) / len;
|
||||
if(displayfr(xpos, mid, 2, dfsize * I.scale/100, s, I.color, 8)) {
|
||||
displayfr(xpos, mid, 2, dfsize * I.scale/100, s, I.colors, 8);
|
||||
if(c == 1) getcstat = SDLK_LEFT;
|
||||
else if(c == 2) getcstat = SDLK_RIGHT;
|
||||
else getcstat = c;
|
||||
}
|
||||
pos += nlen;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -684,6 +726,15 @@ namespace dialog {
|
||||
|
||||
int numberdark;
|
||||
|
||||
void formula_keyboard(bool lr) {
|
||||
addKeyboardItem("1234567890");
|
||||
addKeyboardItem(".+-*/^()\x3");
|
||||
addKeyboardItem("qwertyuiop");
|
||||
addKeyboardItem("asdfghjkl");
|
||||
addKeyboardItem("zxcvbnm,.\b");
|
||||
addKeyboardItem(lr ? " \t\x1\x2" : " \t");
|
||||
}
|
||||
|
||||
void drawNumberDialog() {
|
||||
cmode = sm::NUMBER | dialogflags;
|
||||
gamescreen(numberdark);
|
||||
@ -712,12 +763,15 @@ namespace dialog {
|
||||
|
||||
if(extra_options) extra_options();
|
||||
|
||||
formula_keyboard(false);
|
||||
|
||||
display();
|
||||
|
||||
keyhandler = [] (int sym, int uni) {
|
||||
handleNavigation(sym, uni);
|
||||
if((uni >= '0' && uni <= '9') || among(uni, '.', '+', '-', '*', '/', '^', '(', ')', ',') || (uni >= 'a' && uni <= 'z')) {
|
||||
ne.s += uni;
|
||||
if((uni >= '0' && uni <= '9') || among(uni, '.', '+', '-', '*', '/', '^', '(', ')', ',', 3) || (uni >= 'a' && uni <= 'z')) {
|
||||
if(uni == 3) ne.s += "pi";
|
||||
else ne.s += uni;
|
||||
apply_edit();
|
||||
}
|
||||
else if(uni == '\b' || uni == '\t') {
|
||||
@ -1072,6 +1126,8 @@ namespace dialog {
|
||||
init(ne.title);
|
||||
addInfo(view_edited_string());
|
||||
addBreak(100);
|
||||
formula_keyboard(true);
|
||||
addBreak(100);
|
||||
dialog::addBack();
|
||||
addBreak(100);
|
||||
|
||||
|
3
hyper.h
3
hyper.h
@ -1911,7 +1911,7 @@ namespace dialog {
|
||||
extern color_t dialogcolor;
|
||||
extern int dfsize, dfspace;
|
||||
|
||||
enum tDialogItem {diTitle, diItem, diBreak, diHelp, diInfo, diIntSlider, diSlider, diBigItem};
|
||||
enum tDialogItem {diTitle, diItem, diBreak, diHelp, diInfo, diIntSlider, diSlider, diBigItem, diKeyboard};
|
||||
|
||||
struct item {
|
||||
tDialogItem type;
|
||||
@ -1970,6 +1970,7 @@ namespace dialog {
|
||||
void addHelp(string body);
|
||||
void addInfo(string body, color_t color = dialogcolor);
|
||||
void addItem(string body, int key);
|
||||
void addKeyboardItem(string keys);
|
||||
int addBreak(int val);
|
||||
void addTitle(string body, color_t color, int scale);
|
||||
|
||||
|
@ -295,6 +295,10 @@ int main() {
|
||||
allchars.insert("π");
|
||||
allchars.insert("Θ");
|
||||
allchars.insert("λ");
|
||||
allchars.insert("⌫");
|
||||
allchars.insert("⏎");
|
||||
allchars.insert("←");
|
||||
allchars.insert("→");
|
||||
|
||||
langPL(); langCZ(); langRU();
|
||||
langTR(); langDE(); langPT();
|
||||
|
Loading…
Reference in New Issue
Block a user