From 64fe79b53b03b80b5a3636dfe0d3a2d325306301 Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Sat, 13 Jan 2018 10:34:56 +0100 Subject: Game refactor [2/X]: Various moves (profilergraph, nodePlacementPrediction, create_formspec_menu) * Move profilergraph to dedicated files * Move nodePlacementPrediction to Game class * Rename create_formspec_menu to GUIFormSpecMenu::create --- src/gui/guiFormSpecMenu.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/gui/guiFormSpecMenu.cpp') diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index a59143f77..4acc4b94a 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -57,6 +57,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #if USE_FREETYPE && IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 9 #include "intlGUIEditBox.h" +#include "mainmenumanager.h" + #endif #define MY_CHECKPOS(a,b) \ @@ -129,6 +131,28 @@ GUIFormSpecMenu::~GUIFormSpecMenu() delete m_text_dst; } +void GUIFormSpecMenu::create(GUIFormSpecMenu **cur_formspec, Client *client, + JoystickController *joystick, IFormSource *fs_src, TextDest *txt_dest) +{ + if (*cur_formspec == 0) { + *cur_formspec = new GUIFormSpecMenu(joystick, guiroot, -1, &g_menumgr, + client, client->getTextureSource(), fs_src, txt_dest); + (*cur_formspec)->doPause = false; + + /* + Caution: do not call (*cur_formspec)->drop() here -- + the reference might outlive the menu, so we will + periodically check if *cur_formspec is the only + remaining reference (i.e. the menu was removed) + and delete it in that case. + */ + + } else { + (*cur_formspec)->setFormSource(fs_src); + (*cur_formspec)->setTextDest(txt_dest); + } +} + void GUIFormSpecMenu::removeChildren() { const core::list &children = getChildren(); -- cgit v1.2.3