@@ -1205,6 +1205,7 @@ static inline void create_formspec_menu(GUIFormSpecMenu **cur_formspec,
1205
1205
(*cur_formspec)->setFormSource (fs_src);
1206
1206
(*cur_formspec)->setTextDest (txt_dest);
1207
1207
}
1208
+
1208
1209
}
1209
1210
1210
1211
#ifdef __ANDROID__
@@ -1753,6 +1754,8 @@ class Game {
1753
1754
ChatBackend *chat_backend;
1754
1755
1755
1756
GUIFormSpecMenu *current_formspec;
1757
+ // default: "". If other than "", empty show_formspec packets will only close the formspec when the formname matches
1758
+ std::string cur_formname;
1756
1759
1757
1760
EventManager *eventmgr;
1758
1761
QuicktuneShortcutter *quicktune;
@@ -1841,6 +1844,7 @@ Game::Game() :
1841
1844
soundmaker(NULL ),
1842
1845
chat_backend(NULL ),
1843
1846
current_formspec(NULL ),
1847
+ cur_formname(" " ),
1844
1848
eventmgr(NULL ),
1845
1849
quicktune(NULL ),
1846
1850
gui_chat_console(NULL ),
@@ -3005,6 +3009,7 @@ void Game::openInventory()
3005
3009
3006
3010
create_formspec_menu (¤t_formspec, client, gamedef, texture_src,
3007
3011
device, &input->joystick , fs_src, txt_dst, client);
3012
+ cur_formname = " " ;
3008
3013
3009
3014
InventoryLocation inventoryloc;
3010
3015
inventoryloc.setCurrentPlayer ();
@@ -3484,14 +3489,21 @@ void Game::processClientEvents(CameraOrientation *cam, float *damage_flash)
3484
3489
player->hurt_tilt_strength = 0 ;
3485
3490
3486
3491
} else if (event.type == CE_SHOW_FORMSPEC) {
3487
- FormspecFormSource *fs_src =
3488
- new FormspecFormSource (*(event.show_formspec .formspec ));
3489
- TextDestPlayerInventory *txt_dst =
3490
- new TextDestPlayerInventory (client, *(event.show_formspec .formname ));
3491
-
3492
- create_formspec_menu (¤t_formspec, client, gamedef,
3493
- texture_src, device, &input->joystick ,
3494
- fs_src, txt_dst, client);
3492
+ if (*(event.show_formspec .formspec ) == " " ) {
3493
+ if (current_formspec && ( *(event.show_formspec .formname ) == " " || *(event.show_formspec .formname ) == cur_formname) ){
3494
+ current_formspec->quitMenu ();
3495
+ }
3496
+ } else {
3497
+ FormspecFormSource *fs_src =
3498
+ new FormspecFormSource (*(event.show_formspec .formspec ));
3499
+ TextDestPlayerInventory *txt_dst =
3500
+ new TextDestPlayerInventory (client, *(event.show_formspec .formname ));
3501
+
3502
+ create_formspec_menu (¤t_formspec, client, gamedef,
3503
+ texture_src, device, &input->joystick ,
3504
+ fs_src, txt_dst, client);
3505
+ cur_formname = *(event.show_formspec .formname );
3506
+ }
3495
3507
3496
3508
delete (event.show_formspec .formspec );
3497
3509
delete (event.show_formspec .formname );
@@ -3955,6 +3967,7 @@ void Game::handlePointingAtNode(GameRunData *runData,
3955
3967
3956
3968
create_formspec_menu (¤t_formspec, client, gamedef,
3957
3969
texture_src, device, &input->joystick , fs_src, txt_dst, client);
3970
+ cur_formname = " " ;
3958
3971
3959
3972
current_formspec->setFormSpec (meta->getString (" formspec" ), inventoryloc);
3960
3973
} else {
0 commit comments