mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-10-24 02:17:40 +00:00
fixed file dialog closing incorrectly
This commit is contained in:
17
dialogs.cpp
17
dialogs.cpp
@@ -55,7 +55,8 @@ EX namespace dialog {
|
|||||||
reaction_t reaction_final;
|
reaction_t reaction_final;
|
||||||
reaction_t extra_options;
|
reaction_t extra_options;
|
||||||
virtual void draw() = 0;
|
virtual void draw() = 0;
|
||||||
void operator() () { draw(); }
|
bool closed;
|
||||||
|
void operator() () { if(closed) popfinal(); else draw(); }
|
||||||
virtual ~extdialog() {};
|
virtual ~extdialog() {};
|
||||||
extdialog();
|
extdialog();
|
||||||
/** Pop screen, then call the final reaction. A bit more complex because it eeds to backup reaction_final due to popScreen */
|
/** Pop screen, then call the final reaction. A bit more complex because it eeds to backup reaction_final due to popScreen */
|
||||||
@@ -1612,6 +1613,7 @@ EX namespace dialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extdialog::extdialog() {
|
extdialog::extdialog() {
|
||||||
|
closed = false;
|
||||||
dialogflags = 0;
|
dialogflags = 0;
|
||||||
if(cmode & sm::SIDE) dialogflags |= sm::MAYDARK | sm::SIDE;
|
if(cmode & sm::SIDE) dialogflags |= sm::MAYDARK | sm::SIDE;
|
||||||
reaction = reaction_t();
|
reaction = reaction_t();
|
||||||
@@ -1689,12 +1691,11 @@ EX namespace dialog {
|
|||||||
|
|
||||||
bool_reaction_t file_action;
|
bool_reaction_t file_action;
|
||||||
|
|
||||||
void handleKeyFile(int sym, int uni);
|
|
||||||
|
|
||||||
bool search_mode;
|
bool search_mode;
|
||||||
|
|
||||||
struct file_dialog : extdialog {
|
struct file_dialog : extdialog {
|
||||||
void draw() override;
|
void draw() override;
|
||||||
|
void handleKey(int sym, int uni);
|
||||||
};
|
};
|
||||||
|
|
||||||
void file_dialog::draw() {
|
void file_dialog::draw() {
|
||||||
@@ -1744,7 +1745,7 @@ EX namespace dialog {
|
|||||||
dialog::lastItem().color = vv.second;
|
dialog::lastItem().color = vv.second;
|
||||||
string vf = vv.first;
|
string vf = vv.first;
|
||||||
bool dir = vv.second == CDIR;
|
bool dir = vv.second == CDIR;
|
||||||
dialog::add_action([vf, dir] {
|
dialog::add_action([vf, dir, this] {
|
||||||
string& s(*cfileptr);
|
string& s(*cfileptr);
|
||||||
string where = "", what = s, whereparent = "../";
|
string where = "", what = s, whereparent = "../";
|
||||||
string last = "";
|
string last = "";
|
||||||
@@ -1775,7 +1776,7 @@ EX namespace dialog {
|
|||||||
str1 = where + vf;
|
str1 = where + vf;
|
||||||
if(s == str1) {
|
if(s == str1) {
|
||||||
bool ac = file_action();
|
bool ac = file_action();
|
||||||
if(ac) popScreen();
|
if(ac) closed = true;
|
||||||
}
|
}
|
||||||
s = str1;
|
s = str1;
|
||||||
}
|
}
|
||||||
@@ -1798,10 +1799,10 @@ EX namespace dialog {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
keyhandler = handleKeyFile;
|
keyhandler = [this] (int sym, int uni) { handleKey(sym, uni); };
|
||||||
}
|
}
|
||||||
|
|
||||||
EX void handleKeyFile(int sym, int uni) {
|
void file_dialog::handleKey(int sym, int uni) {
|
||||||
handleNavigation(sym, uni);
|
handleNavigation(sym, uni);
|
||||||
string& s(*cfileptr);
|
string& s(*cfileptr);
|
||||||
int i = isize(s) - (editext?0:4);
|
int i = isize(s) - (editext?0:4);
|
||||||
@@ -1811,7 +1812,7 @@ EX namespace dialog {
|
|||||||
}
|
}
|
||||||
else if(sym == SDLK_RETURN || sym == SDLK_KP_ENTER) {
|
else if(sym == SDLK_RETURN || sym == SDLK_KP_ENTER) {
|
||||||
bool ac = file_action();
|
bool ac = file_action();
|
||||||
if(ac) popScreen();
|
if(ac) closed = true;
|
||||||
}
|
}
|
||||||
else if(sym == SDLK_BACKSPACE && i) {
|
else if(sym == SDLK_BACKSPACE && i) {
|
||||||
int len = utfsize_before(s, i);
|
int len = utfsize_before(s, i);
|
||||||
|
|||||||
Reference in New Issue
Block a user