* `formname`: name passed to `on_player_receive_fields` callbacks.
It should follow the `"modname:<whatever>"` naming convention
* `formspec`: formspec to display
+* `minetest.close_formspec(playername, formname)`
+ * `playername`: name of player to close formspec
+ * `formname`: has to exactly match the one given in show_formspec, or the formspec will
+ not close.
+ * calling show_formspec(playername, formname, "") is equal to this expression
+ * to close a formspec regardless of the formname, call
+ minetest.close_formspec(playername, ""). USE THIS ONLY WHEN ABSOLUTELY NECESSARY!
* `minetest.formspec_escape(string)`: returns a string
* escapes the characters "[", "]", "\", "," and ";", which can not be used in formspecs
* `minetest.explode_table_event(string)`: returns a table
(*cur_formspec)->setFormSource(fs_src);
(*cur_formspec)->setTextDest(txt_dest);
}
+
}
#ifdef __ANDROID__
ChatBackend *chat_backend;
GUIFormSpecMenu *current_formspec;
+ //default: "". If other than "", empty show_formspec packets will only close the formspec when the formname matches
+ std::string cur_formname;
EventManager *eventmgr;
QuicktuneShortcutter *quicktune;
soundmaker(NULL),
chat_backend(NULL),
current_formspec(NULL),
+ cur_formname(""),
eventmgr(NULL),
quicktune(NULL),
gui_chat_console(NULL),
create_formspec_menu(¤t_formspec, client, gamedef, texture_src,
device, &input->joystick, fs_src, txt_dst, client);
+ cur_formname = "";
InventoryLocation inventoryloc;
inventoryloc.setCurrentPlayer();
player->hurt_tilt_strength = 0;
} else if (event.type == CE_SHOW_FORMSPEC) {
- FormspecFormSource *fs_src =
- new FormspecFormSource(*(event.show_formspec.formspec));
- TextDestPlayerInventory *txt_dst =
- new TextDestPlayerInventory(client, *(event.show_formspec.formname));
-
- create_formspec_menu(¤t_formspec, client, gamedef,
- texture_src, device, &input->joystick,
- fs_src, txt_dst, client);
+ if (*(event.show_formspec.formspec) == "") {
+ if (current_formspec && ( *(event.show_formspec.formname) == "" || *(event.show_formspec.formname) == cur_formname) ){
+ current_formspec->quitMenu();
+ }
+ } else {
+ FormspecFormSource *fs_src =
+ new FormspecFormSource(*(event.show_formspec.formspec));
+ TextDestPlayerInventory *txt_dst =
+ new TextDestPlayerInventory(client, *(event.show_formspec.formname));
+
+ create_formspec_menu(¤t_formspec, client, gamedef,
+ texture_src, device, &input->joystick,
+ fs_src, txt_dst, client);
+ cur_formname = *(event.show_formspec.formname);
+ }
delete(event.show_formspec.formspec);
delete(event.show_formspec.formname);
create_formspec_menu(¤t_formspec, client, gamedef,
texture_src, device, &input->joystick, fs_src, txt_dst, client);
+ cur_formname = "";
current_formspec->setFormSpec(meta->getString("formspec"), inventoryloc);
} else {