summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2010-12-23 17:09:49 +0200
committerPerttu Ahola <celeron55@gmail.com>2010-12-23 17:09:49 +0200
commit7e490e72139fbfe12535c71b27228dd82ef0250b (patch)
tree0ffc37e46140755192e04b88d82ae4daeb290b41
parent2816d8f638de2f7f06ca1086d1c8846e8971f421 (diff)
downloadminetest-7e490e72139fbfe12535c71b27228dd82ef0250b.tar.gz
minetest-7e490e72139fbfe12535c71b27228dd82ef0250b.tar.bz2
minetest-7e490e72139fbfe12535c71b27228dd82ef0250b.zip
work-in-progress gui system updating + some settings system updating
-rw-r--r--Makefile2
-rw-r--r--src/guiPauseMenu.cpp3
-rw-r--r--src/guiPauseMenu.h1
-rw-r--r--src/guiTextInputMenu.cpp168
-rw-r--r--src/guiTextInputMenu.h59
-rw-r--r--src/main.cpp296
-rw-r--r--src/mapblockobject.h5
-rw-r--r--src/modalMenu.h33
-rw-r--r--src/utility.h14
9 files changed, 339 insertions, 242 deletions
diff --git a/Makefile b/Makefile
index 25e58a99a..39ab17059 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
# It's usually sufficient to change just the target name and source file list
# and be sure that CXX is set to a valid compiler
TARGET = test
-SOURCE_FILES = guiInventoryMenu.cpp irrlichtwrapper.cpp guiPauseMenu.cpp defaultsettings.cpp mapnode.cpp tile.cpp voxel.cpp mapblockobject.cpp inventory.cpp debug.cpp serialization.cpp light.cpp filesys.cpp connection.cpp environment.cpp client.cpp server.cpp socket.cpp mapblock.cpp mapsector.cpp heightmap.cpp map.cpp player.cpp utility.cpp main.cpp test.cpp
+SOURCE_FILES = guiTextInputMenu.cpp guiInventoryMenu.cpp irrlichtwrapper.cpp guiPauseMenu.cpp defaultsettings.cpp mapnode.cpp tile.cpp voxel.cpp mapblockobject.cpp inventory.cpp debug.cpp serialization.cpp light.cpp filesys.cpp connection.cpp environment.cpp client.cpp server.cpp socket.cpp mapblock.cpp mapsector.cpp heightmap.cpp map.cpp player.cpp utility.cpp main.cpp test.cpp
SOURCES = $(addprefix src/, $(SOURCE_FILES))
BUILD_DIR = build
OBJECTS = $(addprefix $(BUILD_DIR)/, $(SOURCE_FILES:.cpp=.o))
diff --git a/src/guiPauseMenu.cpp b/src/guiPauseMenu.cpp
index ed4f0cd6f..2a0b3cb0c 100644
--- a/src/guiPauseMenu.cpp
+++ b/src/guiPauseMenu.cpp
@@ -17,7 +17,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
#include "guiPauseMenu.h"
#include "debug.h"
#include "serialization.h"
@@ -174,7 +173,7 @@ bool GUIPauseMenu::OnEvent(const SEvent& event)
}
}
}
-
+
return Parent ? Parent->OnEvent(event) : false;
}
diff --git a/src/guiPauseMenu.h b/src/guiPauseMenu.h
index 7c37af8ef..187d20edb 100644
--- a/src/guiPauseMenu.h
+++ b/src/guiPauseMenu.h
@@ -17,7 +17,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
#ifndef GUIPAUSEMENU_HEADER
#define GUIPAUSEMENU_HEADER
diff --git a/src/guiTextInputMenu.cpp b/src/guiTextInputMenu.cpp
new file mode 100644
index 000000000..8a9da3489
--- /dev/null
+++ b/src/guiTextInputMenu.cpp
@@ -0,0 +1,168 @@
+/*
+Minetest-c55
+Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#include "guiTextInputMenu.h"
+#include "debug.h"
+#include "serialization.h"
+#include <string>
+
+GUITextInputMenu::GUITextInputMenu(gui::IGUIEnvironment* env,
+ gui::IGUIElement* parent, s32 id,
+ int *active_menu_count,
+ TextDest *dest,
+ std::wstring initial_text
+):
+ GUIModalMenu(env, parent, id, active_menu_count),
+ m_dest(dest),
+ m_initial_text(initial_text)
+{
+}
+
+GUITextInputMenu::~GUITextInputMenu()
+{
+ removeChildren();
+}
+
+void GUITextInputMenu::removeChildren()
+{
+ {
+ gui::IGUIElement *e = getElementFromId(256);
+ if(e != NULL)
+ e->remove();
+ }
+ {
+ gui::IGUIElement *e = getElementFromId(257);
+ if(e != NULL)
+ e->remove();
+ }
+}
+
+void GUITextInputMenu::regenerateGui(v2u32 screensize)
+{
+ std::wstring text;
+
+ {
+ gui::IGUIElement *e = getElementFromId(256);
+ if(e != NULL)
+ {
+ text = e->getText();
+ }
+ else
+ {
+ text = m_initial_text;
+ m_initial_text = L"";
+ }
+ }
+
+ /*
+ Remove stuff
+ */
+ removeChildren();
+
+ /*
+ Calculate new sizes and positions
+ */
+ core::rect<s32> rect(
+ screensize.X/2 - 580/2,
+ screensize.Y/2 - 300/2,
+ screensize.X/2 + 580/2,
+ screensize.Y/2 + 300/2
+ );
+
+ DesiredRect = rect;
+ recalculateAbsolutePosition(false);
+
+ v2s32 size = rect.getSize();
+
+ /*
+ Add stuff
+ */
+ {
+ core::rect<s32> rect(0, 0, 300, 30);
+ rect = rect + v2s32(size.X/2-300/2, size.Y/2-30/2-25);
+ gui::IGUIElement *e =
+ Environment->addEditBox(text.c_str(), rect, true, this, 256);
+ Environment->setFocus(e);
+ }
+ {
+ core::rect<s32> rect(0, 0, 140, 30);
+ rect = rect + v2s32(size.X/2-140/2, size.Y/2-30/2+25);
+ Environment->addButton(rect, this, 257, L"Proceed");
+ }
+}
+
+void GUITextInputMenu::drawMenu()
+{
+ gui::IGUISkin* skin = Environment->getSkin();
+ if (!skin)
+ return;
+ video::IVideoDriver* driver = Environment->getVideoDriver();
+
+ video::SColor bgcolor(140,0,0,0);
+ driver->draw2DRectangle(bgcolor, AbsoluteRect, &AbsoluteClippingRect);
+
+ gui::IGUIElement::draw();
+}
+
+bool GUITextInputMenu::OnEvent(const SEvent& event)
+{
+ if(event.EventType==EET_KEY_INPUT_EVENT)
+ {
+ if(event.KeyInput.Key==KEY_ESCAPE && event.KeyInput.PressedDown)
+ {
+ quitMenu();
+ return true;
+ }
+ }
+ if(event.EventType==EET_GUI_EVENT)
+ {
+ if(event.GUIEvent.EventType==gui::EGET_ELEMENT_FOCUS_LOST
+ && isVisible())
+ {
+ if(!canTakeFocus(event.GUIEvent.Element))
+ {
+ dstream<<"GUITextInputMenu: Not allowing focus change."
+ <<std::endl;
+ // Returning true disables focus change
+ return true;
+ }
+ }
+ if(event.GUIEvent.EventType==gui::EGET_BUTTON_CLICKED)
+ {
+ switch(event.GUIEvent.Caller->getID())
+ {
+ case 257:
+ if(m_dest)
+ {
+ gui::IGUIElement *e = getElementFromId(256);
+ if(e != NULL)
+ {
+ m_dest->gotText(e->getText());
+ }
+ delete m_dest;
+ }
+ quitMenu();
+ break;
+ }
+ }
+ }
+
+ return Parent ? Parent->OnEvent(event) : false;
+}
+
diff --git a/src/guiTextInputMenu.h b/src/guiTextInputMenu.h
new file mode 100644
index 000000000..2efc190ca
--- /dev/null
+++ b/src/guiTextInputMenu.h
@@ -0,0 +1,59 @@
+/*
+Minetest-c55
+Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#ifndef GUITEXTINPUTMENU_HEADER
+#define GUITEXTINPUTMENU_HEADER
+
+#include "common_irrlicht.h"
+#include "modalMenu.h"
+#include "utility.h"
+#include <string>
+
+struct TextDest
+{
+ virtual void gotText(std::wstring text) = 0;
+};
+
+class GUITextInputMenu : public GUIModalMenu
+{
+public:
+ GUITextInputMenu(gui::IGUIEnvironment* env,
+ gui::IGUIElement* parent, s32 id,
+ int *active_menu_count,
+ TextDest *dest,
+ std::wstring initial_text);
+ ~GUITextInputMenu();
+
+ void removeChildren();
+ /*
+ Remove and re-add (or reposition) stuff
+ */
+ void regenerateGui(v2u32 screensize);
+
+ void drawMenu();
+
+ bool OnEvent(const SEvent& event);
+
+private:
+ TextDest *m_dest;
+ std::wstring m_initial_text;
+};
+
+#endif
+
diff --git a/src/main.cpp b/src/main.cpp
index 4d8a952ba..fe0bfb09c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -224,11 +224,12 @@ TODO: Convert the text input system to use a modal menu... or something
#include "constants.h"
#include "strfnd.h"
#include "porting.h"
-#include "guiPauseMenu.h"
#include "irrlichtwrapper.h"
#include "gettime.h"
#include "porting.h"
+#include "guiPauseMenu.h"
#include "guiInventoryMenu.h"
+#include "guiTextInputMenu.h"
IrrlichtWrapper *g_irrlicht;
@@ -287,12 +288,6 @@ Queue<InventoryAction*> inventory_action_queue;
// This is a copy of the inventory that the client's environment has
Inventory local_inventory;
-std::wstring g_text_buffer;
-bool g_text_buffer_accepted = false;
-
-// When true, the mouse and keyboard are grabbed
-bool g_game_focused = true;
-
/*
Debug streams
*/
@@ -334,6 +329,15 @@ public:
// This is the one method that we have to implement
virtual bool OnEvent(const SEvent& event)
{
+ /*
+ React to nothing here if a menu is active
+ */
+ if(noMenuActive() == false)
+ {
+ clearInput();
+ return false;
+ }
+
// Remember whether each key is down or up
if(event.EventType == irr::EET_KEY_INPUT_EVENT)
{
@@ -342,82 +346,46 @@ public:
if(event.KeyInput.PressedDown)
{
//dstream<<"Pressed key: "<<(char)event.KeyInput.Key<<std::endl;
- if(g_game_focused == false)
- {
- s16 key = event.KeyInput.Key;
- if(key == irr::KEY_RETURN || key == irr::KEY_ESCAPE)
- {
- g_text_buffer_accepted = true;
- }
- else if(key == irr::KEY_BACK)
- {
- if(g_text_buffer.size() > 0)
- g_text_buffer = g_text_buffer.substr
- (0, g_text_buffer.size()-1);
- }
- else
- {
- wchar_t wc = event.KeyInput.Char;
- if(wc != 0)
- g_text_buffer += wc;
- }
- }
- //if(pauseMenu != NULL)
+ /*
+ Launch menus
+ */
+
if(guienv != NULL && guiroot != NULL && g_device != NULL)
{
if(event.KeyInput.Key == irr::KEY_ESCAPE)
{
- if(g_game_focused == true && noMenuActive())
- {
- dstream<<DTIME<<"MyEventReceiver: "
- <<"Launching pause menu"<<std::endl;
- // It will delete itself by itself
- GUIPauseMenu *menu = new
- GUIPauseMenu(guienv, guiroot, -1, g_device,
- &g_active_menu_count);
- menu->drop();
- return true;
- }
+ dstream<<DTIME<<"MyEventReceiver: "
+ <<"Launching pause menu"<<std::endl;
+ // It will delete itself by itself
+ (new GUIPauseMenu(guienv, guiroot, -1, g_device,
+ &g_active_menu_count))->drop();
+ return true;
}
- }
-
- //if(inventoryMenu != NULL)
- if(guienv != NULL && guiroot != NULL && g_device != NULL)
- {
if(event.KeyInput.Key == irr::KEY_KEY_I)
{
- if(g_game_focused == true && noMenuActive())
- {
- dstream<<DTIME<<"MyEventReceiver: "
- <<"Launching inventory"<<std::endl;
- GUIInventoryMenu *inventoryMenu = new
- GUIInventoryMenu(guienv, guiroot, -1,
- &local_inventory, &inventory_action_queue,
- &g_active_menu_count);
- inventoryMenu->drop();
- return true;
- }
+ dstream<<DTIME<<"MyEventReceiver: "
+ <<"Launching inventory"<<std::endl;
+ (new GUIInventoryMenu(guienv, guiroot, -1,
+ &local_inventory, &inventory_action_queue,
+ &g_active_menu_count))->drop();
+ return true;
}
}
// Material selection
if(event.KeyInput.Key == irr::KEY_KEY_F)
{
- if(g_game_focused == true)
- {
- if(g_selected_item < PLAYER_INVENTORY_SIZE-1)
- g_selected_item++;
- else
- g_selected_item = 0;
- dstream<<DTIME<<"Selected item: "
- <<g_selected_item<<std::endl;
- }
+ if(g_selected_item < PLAYER_INVENTORY_SIZE-1)
+ g_selected_item++;
+ else
+ g_selected_item = 0;
+ dstream<<DTIME<<"Selected item: "
+ <<g_selected_item<<std::endl;
}
// Viewing range selection
- if(event.KeyInput.Key == irr::KEY_KEY_R
- && g_game_focused)
+ if(event.KeyInput.Key == irr::KEY_KEY_R)
{
JMutexAutoLock lock(g_range_mutex);
if(g_viewing_range_all)
@@ -433,8 +401,7 @@ public:
}
// Print debug stacks
- if(event.KeyInput.Key == irr::KEY_KEY_P
- && g_game_focused)
+ if(event.KeyInput.Key == irr::KEY_KEY_P)
{
dstream<<"-----------------------------------------"
<<std::endl;
@@ -508,10 +475,11 @@ public:
return keyIsDown[keyCode];
}
- MyEventReceiver()
+ void clearInput()
{
for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
keyIsDown[i] = false;
+
leftclicked = false;
rightclicked = false;
leftreleased = false;
@@ -522,6 +490,11 @@ public:
right_active = false;
}
+ MyEventReceiver()
+ {
+ clearInput();
+ }
+
bool leftclicked;
bool rightclicked;
bool leftreleased;
@@ -574,17 +547,6 @@ public:
InputHandler *g_input = NULL;
-void focusGame()
-{
- g_input->clear();
- g_game_focused = true;
-}
-
-void unFocusGame()
-{
- g_game_focused = false;
-}
-
class RealInputHandler : public InputHandler
{
public:
@@ -617,14 +579,10 @@ public:
virtual bool getLeftClicked()
{
- if(g_game_focused == false)
- return false;
return m_receiver->leftclicked;
}
virtual bool getRightClicked()
{
- if(g_game_focused == false)
- return false;
return m_receiver->rightclicked;
}
virtual void resetLeftClicked()
@@ -638,14 +596,10 @@ public:
virtual bool getLeftReleased()
{
- if(g_game_focused == false)
- return false;
return m_receiver->leftreleased;
}
virtual bool getRightReleased()
{
- if(g_game_focused == false)
- return false;
return m_receiver->rightreleased;
}
virtual void resetLeftReleased()
@@ -1015,11 +969,6 @@ private:
Text input system
*/
-struct TextDest
-{
- virtual void sendText(std::string text) = 0;
-};
-
struct TextDestSign : public TextDest
{
TextDestSign(v3s16 blockpos, s16 id, Client *client)
@@ -1028,11 +977,12 @@ struct TextDestSign : public TextDest
m_id = id;
m_client = client;
}
- void sendText(std::string text)
+ void gotText(std::wstring text)
{
+ std::string ntext = wide_to_narrow(text);
dstream<<"Changing text of a sign object: "
- <<text<<std::endl;
- m_client->sendSignText(m_blockpos, m_id, text);
+ <<ntext<<std::endl;
+ m_client->sendSignText(m_blockpos, m_id, ntext);
}
v3s16 m_blockpos;
@@ -1040,39 +990,6 @@ struct TextDestSign : public TextDest
Client *m_client;
};
-struct TextInput
-{
- TextDest *dest;
- gui::IGUIStaticText* guitext;
- /*std::wstring buffer;
- bool buffer_accepted;*/
-
- TextInput()
- {
- dest = NULL;
- guitext = NULL;
- //buffer_accepted = false;
- }
-
- void start(TextDest *a_dest)
- {
- unFocusGame();
-
- guitext = guienv->addStaticText(L"",
- core::rect<s32>(150,100,550,120),
- true, // border?
- false, // wordwrap?
- NULL);
-
- guitext->setDrawBackground(true);
-
- g_text_buffer = L"";
- g_text_buffer_accepted = false;
-
- dest = a_dest;
- }
-};
-
int main(int argc, char *argv[])
{
/*
@@ -1318,15 +1235,18 @@ int main(int argc, char *argv[])
{
snprintf(connect_name, 100, "%s", cmd_args.get("address").c_str());
}
- else if(g_settings.get("address") != "" && is_yes(g_settings.get("host_game")) == false)
- {
- std::cout<<g_settings.get("address")<<std::endl;
- snprintf(connect_name, 100, "%s", g_settings.get("address").c_str());
- }
- else
+ else if(is_yes(g_settings.get("host_game")) == false)
{
- std::cout<<"Address to connect to [empty = host a game]: ";
- std::cin.getline(connect_name, 100);
+ if(g_settings.get("address") != "")
+ {
+ std::cout<<g_settings.get("address")<<std::endl;
+ snprintf(connect_name, 100, "%s", g_settings.get("address").c_str());
+ }
+ else
+ {
+ std::cout<<"Address to connect to [empty = host a game]: ";
+ std::cin.getline(connect_name, 100);
+ }
}
if(connect_name[0] == 0){
@@ -1545,9 +1465,6 @@ int main(int argc, char *argv[])
Add some gui stuff
*/
- // Text input system
- TextInput text_input;
-
GUIQuickInventory *quick_inventory = new GUIQuickInventory
(guienv, NULL, v2s32(10, 70), 5, &local_inventory);
@@ -1559,15 +1476,9 @@ int main(int argc, char *argv[])
guiroot = guienv->addStaticText(L"",
core::rect<s32>(0, 0, 10000, 10000));
- // Pause menu
- //pauseMenu = new GUIPauseMenu(guienv, root, -1, device);
-
- // Inventory menu
- /*inventoryMenu = new GUIInventoryMenu(guienv, guiroot, -1, &local_inventory,
- &inventory_action_queue);*/
-
- //pauseMenu->launch();
- //inventoryMenu->launch();
+ // Test the text input system
+ /*(new GUITextInputMenu(guienv, guiroot, -1, &g_active_menu_count,
+ NULL))->drop();*/
// First line of debug text
gui::IGUIStaticText *guitext = guienv->addStaticText(
@@ -1619,9 +1530,6 @@ int main(int argc, char *argv[])
v2u32 screensize = driver->getScreenSize();
core::vector2d<s32> displaycenter(screensize.X/2,screensize.Y/2);
- /*pauseMenu->resizeGui();
- inventoryMenu->resizeGui();*/
-
// Hilight boxes collected during the loop and displayed
core::list< core::aabbox3d<f32> > hilightboxes;
@@ -1652,7 +1560,6 @@ int main(int argc, char *argv[])
Viewing range
*/
- //updateViewingRange(dtime, &client);
updateViewingRange(busytime, &client);
/*
@@ -1772,23 +1679,9 @@ int main(int argc, char *argv[])
g_input->step(dtime);
/*
- Special keys
- */
- /*if(g_esc_pressed)
- {
- break;
- }*/
- /*if(g_i_pressed)
- {
- inventoryMenu->setVisible(true);
- g_i_pressed = false;
- }*/
-
- /*
Player speed control
*/
- if(g_game_focused)
{
/*bool a_up,
bool a_down,
@@ -1810,14 +1703,7 @@ int main(int argc, char *argv[])
);
client.setPlayerControl(control);
}
- else
- {
- // Set every key to inactive
- PlayerControl control;
- client.setPlayerControl(control);
- }
- //timer1.stop();
/*
Process environment
*/
@@ -1842,11 +1728,7 @@ int main(int argc, char *argv[])
Mouse and camera control
*/
- if((device->isWindowActive()
- && g_game_focused
- && noMenuActive()
- )
- || random_input)
+ if((device->isWindowActive() && noMenuActive()) || random_input)
{
if(!random_input)
device->getCursorControl()->setVisible(false);
@@ -1940,16 +1822,24 @@ int main(int argc, char *argv[])
if(selected_object->getTypeId() == MAPBLOCKOBJECT_TYPE_SIGN)
{
dstream<<"Sign object right-clicked"<<std::endl;
+
+ if(random_input == false)
+ {
+ // Get a new text for it
- text_input.start(new TextDestSign(
- selected_object->getBlock()->getPos(),
- selected_object->getId(),
- &client));
+ TextDest *dest = new TextDestSign(
+ selected_object->getBlock()->getPos(),
+ selected_object->getId(),
+ &client);
- if(random_input)
- {
- g_text_buffer = L"ASD LOL 8)";
- g_text_buffer_accepted = true;
+ SignObject *sign_object = (SignObject*)selected_object;
+
+ std::wstring wtext =
+ narrow_to_wide(sign_object->getText());
+
+ (new GUITextInputMenu(guienv, guiroot, -1,
+ &g_active_menu_count, dest,
+ wtext))->drop();
}
}
/*
@@ -2328,38 +2218,6 @@ int main(int argc, char *argv[])
delete a;
}
- if(text_input.guitext != NULL)
- {
- /*wchar_t temptext[100];
- swprintf(temptext, 100,
- SWPRINTF_CHARSTRING,
- g_text_buffer.substr(0,99).c_str()
- );*/
- text_input.guitext->setText(g_text_buffer.c_str());
- }
-
- /*
- Text input stuff
- */
- if(text_input.guitext != NULL && g_text_buffer_accepted)
- {
- text_input.guitext->remove();
- text_input.guitext = NULL;
-
- if(text_input.dest != NULL)
- {
- std::string text = wide_to_narrow(g_text_buffer);
- dstream<<"Sending text: "<<text<<std::endl;
- text_input.dest->sendText(text);
- delete text_input.dest;
- text_input.dest = NULL;
- }
-
- focusGame();
- }
-
- //guiupdatetimer.stop();
-
/*
Drawing begins
*/
diff --git a/src/mapblockobject.h b/src/mapblockobject.h
index 30fa797f4..a65ffd8e8 100644
--- a/src/mapblockobject.h
+++ b/src/mapblockobject.h
@@ -531,6 +531,11 @@ public:
setBlockChanged();
}
+ std::string getText()
+ {
+ return m_text;
+ }
+
void setYaw(f32 yaw)
{
m_yaw = yaw;
diff --git a/src/modalMenu.h b/src/modalMenu.h
index 3706d86dc..e2e8b29f6 100644
--- a/src/modalMenu.h
+++ b/src/modalMenu.h
@@ -22,7 +22,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common_irrlicht.h"
-//TODO: Change GUIElement private
+/*
+ Remember to drop() the menu after creating, so that it can
+ remove itself when it wants to.
+*/
+
class GUIModalMenu : public gui::IGUIElement
{
public:
@@ -50,18 +54,6 @@ public:
return (e && (e == this || isMyChild(e))) || m_allow_focus_removal;
}
- void quitMenu()
- {
- m_allow_focus_removal = true;
- // This removes Environment's grab on us
- Environment->removeFocus(this);
- this->remove();
- }
-
- virtual void regenerateGui(v2u32 screensize) = 0;
-
- virtual void drawMenu() = 0;
-
void draw()
{
if(!IsVisible)
@@ -78,10 +70,25 @@ public:
drawMenu();
}
+ /*
+ This should be called when the menu wants to quit
+ */
+ void quitMenu()
+ {
+ m_allow_focus_removal = true;
+ // This removes Environment's grab on us
+ Environment->removeFocus(this);
+ this->remove();
+ }
+
+ virtual void regenerateGui(v2u32 screensize) = 0;
+ virtual void drawMenu() = 0;
virtual bool OnEvent(const SEvent& event) { return false; };
private:
int *m_active_menu_count;
+ // This might be necessary to expose to the implementation if it
+ // wants to launch other menus
bool m_allow_focus_removal;
v2u32 m_screensize_old;
};
diff --git a/src/utility.h b/src/utility.h
index 4e2e132e9..bcdcd1550 100644
--- a/src/utility.h
+++ b/src/utility.h
@@ -1009,10 +1009,11 @@ public:
// Asks if empty
bool getBoolAsk(std::string name, std::string question, bool def)
{
- std::string s = get(name);
- if(s != "")
- return is_yes(s);
+ // If it is in settings
+ if(m_settings.find(name))
+ return getBool(name);
+ std::string s;
char templine[10];
std::cout<<question<<" [y/N]: ";
std::cin.getline(templine, 10);
@@ -1039,10 +1040,11 @@ public:
u16 getU16Ask(std::string name, std::string question, u16 def)
{
- std::string s = get(name);
- if(s != "")
- return stoi(s, 0, 65535);
+ // If it is in settings
+ if(m_settings.find(name))
+ return getU16(name);
+ std::string s;
char templine[10];
std::cout<<question<<" ["<<def<<"]: ";
std::cin.getline(templine, 10);