summaryrefslogtreecommitdiff
path: root/src/guiFormSpecMenu.h
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2017-06-03 14:55:10 -0400
committerShadowNinja <shadowninja@minetest.net>2017-06-03 14:55:10 -0400
commitcaecdb681c428c1aab9c0f7eec2570c0460f995c (patch)
treee5115982ea59bbf2343ba9b35bc4a0cfbb56f407 /src/guiFormSpecMenu.h
parent81d56b94919dceb7b2e51d70b21a7ca22f852bd5 (diff)
parent80dc961d24e1964e25d57039ddb2ba639f9f4d22 (diff)
downloadminetest-caecdb681c428c1aab9c0f7eec2570c0460f995c.tar.gz
minetest-caecdb681c428c1aab9c0f7eec2570c0460f995c.tar.bz2
minetest-caecdb681c428c1aab9c0f7eec2570c0460f995c.zip
Merge 0.4.16 into stable-0.4
Diffstat (limited to 'src/guiFormSpecMenu.h')
-rw-r--r--src/guiFormSpecMenu.h177
1 files changed, 93 insertions, 84 deletions
diff --git a/src/guiFormSpecMenu.h b/src/guiFormSpecMenu.h
index 95df11e6a..9eaf60ac6 100644
--- a/src/guiFormSpecMenu.h
+++ b/src/guiFormSpecMenu.h
@@ -25,7 +25,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <stack>
#include "irrlichttypes_extrabloated.h"
-#include "inventory.h"
#include "inventorymanager.h"
#include "modalMenu.h"
#include "guiTable.h"
@@ -34,7 +33,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/string.h"
#include "util/enriched_string.h"
-class IGameDef;
class InventoryManager;
class ISimpleTextureSource;
class Client;
@@ -57,12 +55,10 @@ typedef enum {
struct TextDest
{
- virtual ~TextDest() {};
+ virtual ~TextDest() {}
// This is deprecated I guess? -celeron55
- virtual void gotText(std::wstring text){}
+ virtual void gotText(const std::wstring &text) {}
virtual void gotText(const StringMap &fields) = 0;
- virtual void setFormName(std::string formname)
- { m_formname = formname;};
std::string m_formname;
};
@@ -73,30 +69,29 @@ public:
virtual ~IFormSource(){}
virtual std::string getForm() = 0;
// Fill in variables in field text
- virtual std::string resolveText(std::string str){ return str; }
+ virtual std::string resolveText(const std::string &str) { return str; }
};
class GUIFormSpecMenu : public GUIModalMenu
{
struct ItemSpec
{
- ItemSpec()
+ ItemSpec() :
+ i(-1)
{
- i = -1;
}
+
ItemSpec(const InventoryLocation &a_inventoryloc,
const std::string &a_listname,
- s32 a_i)
- {
- inventoryloc = a_inventoryloc;
- listname = a_listname;
- i = a_i;
- }
- bool isValid() const
+ s32 a_i) :
+ inventoryloc(a_inventoryloc),
+ listname(a_listname),
+ i(a_i)
{
- return i != -1;
}
+ bool isValid() const { return i != -1; }
+
InventoryLocation inventoryloc;
std::string listname;
s32 i;
@@ -146,7 +141,8 @@ class GUIFormSpecMenu : public GUIModalMenu
ImageDrawSpec():
parent_button(NULL),
clip(false)
- {}
+ {
+ }
ImageDrawSpec(const std::string &a_name,
const std::string &a_item_name,
@@ -159,7 +155,8 @@ class GUIFormSpecMenu : public GUIModalMenu
geom(a_geom),
scale(true),
clip(false)
- {}
+ {
+ }
ImageDrawSpec(const std::string &a_name,
const std::string &a_item_name,
@@ -171,7 +168,8 @@ class GUIFormSpecMenu : public GUIModalMenu
geom(a_geom),
scale(true),
clip(false)
- {}
+ {
+ }
ImageDrawSpec(const std::string &a_name,
const v2s32 &a_pos, const v2s32 &a_geom, bool clip=false):
@@ -181,7 +179,8 @@ class GUIFormSpecMenu : public GUIModalMenu
geom(a_geom),
scale(true),
clip(clip)
- {}
+ {
+ }
ImageDrawSpec(const std::string &a_name,
const v2s32 &a_pos):
@@ -190,7 +189,8 @@ class GUIFormSpecMenu : public GUIModalMenu
pos(a_pos),
scale(false),
clip(false)
- {}
+ {
+ }
std::string name;
std::string item_name;
@@ -210,14 +210,14 @@ class GUIFormSpecMenu : public GUIModalMenu
const std::wstring &default_text, int id) :
fname(name),
flabel(label),
+ fdefault(unescape_enriched(default_text)),
fid(id),
send(false),
ftype(f_Unknown),
is_exit(false)
{
- //flabel = unescape_enriched(label);
- fdefault = unescape_enriched(default_text);
}
+
std::string fname;
std::wstring flabel;
std::wstring fdefault;
@@ -228,7 +228,8 @@ class GUIFormSpecMenu : public GUIModalMenu
core::rect<s32> rect;
};
- struct BoxDrawSpec {
+ struct BoxDrawSpec
+ {
BoxDrawSpec(v2s32 a_pos, v2s32 a_geom,irr::video::SColor a_color):
pos(a_pos),
geom(a_geom),
@@ -240,45 +241,46 @@ class GUIFormSpecMenu : public GUIModalMenu
irr::video::SColor color;
};
- struct TooltipSpec {
- TooltipSpec()
- {
- }
- TooltipSpec(std::string a_tooltip, irr::video::SColor a_bgcolor,
+ struct TooltipSpec
+ {
+ TooltipSpec() {}
+ TooltipSpec(const std::string &a_tooltip, irr::video::SColor a_bgcolor,
irr::video::SColor a_color):
+ tooltip(utf8_to_wide(a_tooltip)),
bgcolor(a_bgcolor),
color(a_color)
{
- //tooltip = unescape_enriched(utf8_to_wide(a_tooltip));
- tooltip = utf8_to_wide(a_tooltip);
}
+
std::wstring tooltip;
irr::video::SColor bgcolor;
irr::video::SColor color;
};
- struct StaticTextSpec {
+ struct StaticTextSpec
+ {
StaticTextSpec():
parent_button(NULL)
{
}
+
StaticTextSpec(const std::wstring &a_text,
const core::rect<s32> &a_rect):
+ text(a_text),
rect(a_rect),
parent_button(NULL)
{
- //text = unescape_enriched(a_text);
- text = a_text;
}
+
StaticTextSpec(const std::wstring &a_text,
const core::rect<s32> &a_rect,
gui::IGUIButton *a_parent_button):
+ text(a_text),
rect(a_rect),
parent_button(a_parent_button)
{
- //text = unescape_enriched(a_text);
- text = a_text;
}
+
std::wstring text;
core::rect<s32> rect;
gui::IGUIButton *parent_button;
@@ -289,18 +291,16 @@ public:
JoystickController *joystick,
gui::IGUIElement* parent, s32 id,
IMenuManager *menumgr,
- InventoryManager *invmgr,
- IGameDef *gamedef,
+ Client *client,
ISimpleTextureSource *tsrc,
IFormSource* fs_src,
TextDest* txt_dst,
- Client* client,
bool remap_dbl_click = true);
~GUIFormSpecMenu();
void setFormSpec(const std::string &formspec_string,
- InventoryLocation current_inventory_location)
+ const InventoryLocation &current_inventory_location)
{
m_formspec_string = formspec_string;
m_current_inventory_location = current_inventory_location;
@@ -339,7 +339,7 @@ public:
void removeChildren();
void setInitialFocus();
- void setFocus(std::string &elementname)
+ void setFocus(const std::string &elementname)
{
m_focused_element = elementname;
}
@@ -384,7 +384,6 @@ protected:
irr::IrrlichtDevice* m_device;
InventoryManager *m_invmgr;
- IGameDef *m_gamedef;
ISimpleTextureSource *m_tsrc;
Client *m_client;
@@ -421,8 +420,8 @@ protected:
v2s32 m_old_pointer; // Mouse position after previous mouse event
gui::IGUIStaticText *m_tooltip_element;
- u32 m_tooltip_show_delay;
- s32 m_hovered_time;
+ u64 m_tooltip_show_delay;
+ u64 m_hovered_time;
s32 m_old_tooltip_id;
std::wstring m_old_tooltip;
@@ -452,6 +451,8 @@ private:
bool explicit_size;
v2f invsize;
v2s32 size;
+ v2f32 offset;
+ v2f32 anchor;
core::rect<s32> rect;
v2s32 basepos;
v2u32 screensize;
@@ -472,44 +473,53 @@ private:
fs_key_pendig current_keys_pending;
std::string current_field_enter_pending;
- void parseElement(parserData* data, std::string element);
+ void parseElement(parserData* data, const std::string &element);
- void parseSize(parserData* data, std::string element);
- void parseContainer(parserData* data, std::string element);
+ void parseSize(parserData* data, const std::string &element);
+ void parseContainer(parserData* data, const std::string &element);
void parseContainerEnd(parserData* data);
- void parseList(parserData* data, std::string element);
- void parseListRing(parserData* data, std::string element);
- void parseCheckbox(parserData* data, std::string element);
- void parseImage(parserData* data, std::string element);
- void parseItemImage(parserData* data,std::string element);
- void parseButton(parserData* data,std::string element,std::string typ);
- void parseBackground(parserData* data,std::string element);
- void parseTableOptions(parserData* data,std::string element);
- void parseTableColumns(parserData* data,std::string element);
- void parseTable(parserData* data,std::string element);
- void parseTextList(parserData* data,std::string element);
- void parseDropDown(parserData* data,std::string element);
+ void parseList(parserData* data, const std::string &element);
+ void parseListRing(parserData* data, const std::string &element);
+ void parseCheckbox(parserData* data, const std::string &element);
+ void parseImage(parserData* data, const std::string &element);
+ void parseItemImage(parserData* data, const std::string &element);
+ void parseButton(parserData* data, const std::string &element,
+ const std::string &typ);
+ void parseBackground(parserData* data, const std::string &element);
+ void parseTableOptions(parserData* data, const std::string &element);
+ void parseTableColumns(parserData* data, const std::string &element);
+ void parseTable(parserData* data, const std::string &element);
+ void parseTextList(parserData* data, const std::string &element);
+ void parseDropDown(parserData* data, const std::string &element);
void parseFieldCloseOnEnter(parserData *data, const std::string &element);
- void parsePwdField(parserData* data,std::string element);
- void parseField(parserData* data,std::string element,std::string type);
+ void parsePwdField(parserData* data, const std::string &element);
+ void parseField(parserData* data, const std::string &element, const std::string &type);
void parseSimpleField(parserData* data,std::vector<std::string> &parts);
void parseTextArea(parserData* data,std::vector<std::string>& parts,
- std::string type);
- void parseLabel(parserData* data,std::string element);
- void parseVertLabel(parserData* data,std::string element);
- void parseImageButton(parserData* data,std::string element,std::string type);
- void parseItemImageButton(parserData* data,std::string element);
- void parseTabHeader(parserData* data,std::string element);
- void parseBox(parserData* data,std::string element);
- void parseBackgroundColor(parserData* data,std::string element);
- void parseListColors(parserData* data,std::string element);
- void parseTooltip(parserData* data,std::string element);
- bool parseVersionDirect(std::string data);
- bool parseSizeDirect(parserData* data, std::string element);
- void parseScrollBar(parserData* data, std::string element);
+ const std::string &type);
+ void parseLabel(parserData* data, const std::string &element);
+ void parseVertLabel(parserData* data, const std::string &element);
+ void parseImageButton(parserData* data, const std::string &element,
+ const std::string &type);
+ void parseItemImageButton(parserData* data, const std::string &element);
+ void parseTabHeader(parserData* data, const std::string &element);
+ void parseBox(parserData* data, const std::string &element);
+ void parseBackgroundColor(parserData* data, const std::string &element);
+ void parseListColors(parserData* data, const std::string &element);
+ void parseTooltip(parserData* data, const std::string &element);
+ bool parseVersionDirect(const std::string &data);
+ bool parseSizeDirect(parserData* data, const std::string &element);
+ void parseScrollBar(parserData* data, const std::string &element);
+ bool parsePositionDirect(parserData *data, const std::string &element);
+ void parsePosition(parserData *data, const std::string &element);
+ bool parseAnchorDirect(parserData *data, const std::string &element);
+ void parseAnchor(parserData *data, const std::string &element);
void tryClose();
+ void showTooltip(const std::wstring &text, const irr::video::SColor &color,
+ const irr::video::SColor &bgcolor);
+
/**
* check if event is part of a double click
* @param event event to evaluate
@@ -520,7 +530,7 @@ private:
struct clickpos
{
v2s32 pos;
- s32 time;
+ s64 time;
};
clickpos m_doubleclickdetect[2];
@@ -547,23 +557,22 @@ private:
class FormspecFormSource: public IFormSource
{
public:
- FormspecFormSource(std::string formspec)
+ FormspecFormSource(const std::string &formspec):
+ m_formspec(formspec)
{
- m_formspec = formspec;
}
~FormspecFormSource()
- {}
-
- void setForm(std::string formspec) {
- m_formspec = FORMSPEC_VERSION_STRING + formspec;
+ {
}
- std::string getForm()
+ void setForm(const std::string &formspec)
{
- return m_formspec;
+ m_formspec = FORMSPEC_VERSION_STRING + formspec;
}
+ std::string getForm() { return m_formspec; }
+
std::string m_formspec;
};