forked from Mirrorlandia_minetest/minetest
Send a on_receive_fields event when formspec is closed, with fields.quit = "true"
This commit is contained in:
parent
06a5eceb81
commit
0b78889289
@ -2041,12 +2041,16 @@ ItemStack GUIFormSpecMenu::verifySelectedItem()
|
|||||||
return ItemStack();
|
return ItemStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUIFormSpecMenu::acceptInput()
|
void GUIFormSpecMenu::acceptInput(bool quit=false)
|
||||||
{
|
{
|
||||||
if(m_text_dst)
|
if(m_text_dst)
|
||||||
{
|
{
|
||||||
std::map<std::string, std::string> fields;
|
std::map<std::string, std::string> fields;
|
||||||
|
|
||||||
|
if (quit) {
|
||||||
|
fields["quit"] = "true";
|
||||||
|
}
|
||||||
|
|
||||||
if (current_keys_pending.key_down) {
|
if (current_keys_pending.key_down) {
|
||||||
fields["key_down"] = "true";
|
fields["key_down"] = "true";
|
||||||
current_keys_pending.key_down = false;
|
current_keys_pending.key_down = false;
|
||||||
@ -2188,10 +2192,12 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
|
|||||||
if (event.KeyInput.PressedDown && (kp == EscapeKey ||
|
if (event.KeyInput.PressedDown && (kp == EscapeKey ||
|
||||||
kp == getKeySetting("keymap_inventory")))
|
kp == getKeySetting("keymap_inventory")))
|
||||||
{
|
{
|
||||||
if (m_allowclose)
|
if (m_allowclose) {
|
||||||
|
acceptInput(true);
|
||||||
quitMenu();
|
quitMenu();
|
||||||
else
|
} else {
|
||||||
m_text_dst->gotText(narrow_to_wide("MenuQuit"));
|
m_text_dst->gotText(narrow_to_wide("MenuQuit"));
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (event.KeyInput.PressedDown &&
|
if (event.KeyInput.PressedDown &&
|
||||||
@ -2204,7 +2210,7 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
|
|||||||
switch (event.KeyInput.Key) {
|
switch (event.KeyInput.Key) {
|
||||||
case KEY_RETURN:
|
case KEY_RETURN:
|
||||||
if (m_allowclose) {
|
if (m_allowclose) {
|
||||||
acceptInput();
|
acceptInput(true);
|
||||||
quitMenu();
|
quitMenu();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2551,11 +2557,13 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
|
|||||||
unsigned int btn_id = event.GUIEvent.Caller->getID();
|
unsigned int btn_id = event.GUIEvent.Caller->getID();
|
||||||
|
|
||||||
if (btn_id == 257) {
|
if (btn_id == 257) {
|
||||||
acceptInput();
|
if (m_allowclose) {
|
||||||
if (m_allowclose)
|
acceptInput(true);
|
||||||
quitMenu();
|
quitMenu();
|
||||||
else
|
} else {
|
||||||
|
acceptInput();
|
||||||
m_text_dst->gotText(narrow_to_wide("ExitButton"));
|
m_text_dst->gotText(narrow_to_wide("ExitButton"));
|
||||||
|
}
|
||||||
// quitMenu deallocates menu
|
// quitMenu deallocates menu
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2572,10 +2580,12 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
|
|||||||
s.send = true;
|
s.send = true;
|
||||||
acceptInput();
|
acceptInput();
|
||||||
if(s.is_exit){
|
if(s.is_exit){
|
||||||
if (m_allowclose)
|
if (m_allowclose) {
|
||||||
|
acceptInput(true);
|
||||||
quitMenu();
|
quitMenu();
|
||||||
else
|
} else {
|
||||||
m_text_dst->gotText(narrow_to_wide("ExitButton"));
|
m_text_dst->gotText(narrow_to_wide("ExitButton"));
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
s.send = false;
|
s.send = false;
|
||||||
@ -2590,7 +2600,7 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (m_allowclose) {
|
if (m_allowclose) {
|
||||||
acceptInput();
|
acceptInput(true);
|
||||||
quitMenu();
|
quitMenu();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -227,7 +227,7 @@ public:
|
|||||||
void updateSelectedItem();
|
void updateSelectedItem();
|
||||||
ItemStack verifySelectedItem();
|
ItemStack verifySelectedItem();
|
||||||
|
|
||||||
void acceptInput();
|
void acceptInput(bool quit);
|
||||||
bool preprocessEvent(const SEvent& event);
|
bool preprocessEvent(const SEvent& event);
|
||||||
bool OnEvent(const SEvent& event);
|
bool OnEvent(const SEvent& event);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user