aboutsummaryrefslogtreecommitdiff
path: root/src/guiFormSpecMenu.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/guiFormSpecMenu.h')
-rw-r--r--src/guiFormSpecMenu.h98
1 files changed, 59 insertions, 39 deletions
diff --git a/src/guiFormSpecMenu.h b/src/guiFormSpecMenu.h
index ef230c81c..95df11e6a 100644
--- a/src/guiFormSpecMenu.h
+++ b/src/guiFormSpecMenu.h
@@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define GUIINVENTORYMENU_HEADER
#include <utility>
+#include <stack>
#include "irrlichttypes_extrabloated.h"
#include "inventory.h"
@@ -29,7 +30,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "modalMenu.h"
#include "guiTable.h"
#include "network/networkprotocol.h"
+#include "client/joystick_controller.h"
#include "util/string.h"
+#include "util/enriched_string.h"
class IGameDef;
class InventoryManager;
@@ -141,9 +144,10 @@ class GUIFormSpecMenu : public GUIModalMenu
struct ImageDrawSpec
{
ImageDrawSpec():
- parent_button(NULL)
- {
- }
+ parent_button(NULL),
+ clip(false)
+ {}
+
ImageDrawSpec(const std::string &a_name,
const std::string &a_item_name,
gui::IGUIButton *a_parent_button,
@@ -153,9 +157,10 @@ class GUIFormSpecMenu : public GUIModalMenu
parent_button(a_parent_button),
pos(a_pos),
geom(a_geom),
- scale(true)
- {
- }
+ scale(true),
+ clip(false)
+ {}
+
ImageDrawSpec(const std::string &a_name,
const std::string &a_item_name,
const v2s32 &a_pos, const v2s32 &a_geom):
@@ -164,32 +169,36 @@ class GUIFormSpecMenu : public GUIModalMenu
parent_button(NULL),
pos(a_pos),
geom(a_geom),
- scale(true)
- {
- }
+ scale(true),
+ clip(false)
+ {}
+
ImageDrawSpec(const std::string &a_name,
- const v2s32 &a_pos, const v2s32 &a_geom):
+ const v2s32 &a_pos, const v2s32 &a_geom, bool clip=false):
name(a_name),
parent_button(NULL),
pos(a_pos),
geom(a_geom),
- scale(true)
- {
- }
+ scale(true),
+ clip(clip)
+ {}
+
ImageDrawSpec(const std::string &a_name,
const v2s32 &a_pos):
name(a_name),
parent_button(NULL),
pos(a_pos),
- scale(false)
- {
- }
+ scale(false),
+ clip(false)
+ {}
+
std::string name;
std::string item_name;
gui::IGUIButton *parent_button;
v2s32 pos;
v2s32 geom;
bool scale;
+ bool clip;
};
struct FieldSpec
@@ -200,13 +209,14 @@ class GUIFormSpecMenu : public GUIModalMenu
FieldSpec(const std::string &name, const std::wstring &label,
const std::wstring &default_text, int id) :
fname(name),
- fid(id)
+ flabel(label),
+ fid(id),
+ send(false),
+ ftype(f_Unknown),
+ is_exit(false)
{
- flabel = unescape_enriched(label);
+ //flabel = unescape_enriched(label);
fdefault = unescape_enriched(default_text);
- send = false;
- ftype = f_Unknown;
- is_exit = false;
}
std::string fname;
std::wstring flabel;
@@ -239,7 +249,8 @@ class GUIFormSpecMenu : public GUIModalMenu
bgcolor(a_bgcolor),
color(a_color)
{
- tooltip = unescape_enriched(utf8_to_wide(a_tooltip));
+ //tooltip = unescape_enriched(utf8_to_wide(a_tooltip));
+ tooltip = utf8_to_wide(a_tooltip);
}
std::wstring tooltip;
irr::video::SColor bgcolor;
@@ -256,7 +267,8 @@ class GUIFormSpecMenu : public GUIModalMenu
rect(a_rect),
parent_button(NULL)
{
- text = unescape_enriched(a_text);
+ //text = unescape_enriched(a_text);
+ text = a_text;
}
StaticTextSpec(const std::wstring &a_text,
const core::rect<s32> &a_rect,
@@ -264,7 +276,8 @@ class GUIFormSpecMenu : public GUIModalMenu
rect(a_rect),
parent_button(a_parent_button)
{
- text = unescape_enriched(a_text);
+ //text = unescape_enriched(a_text);
+ text = a_text;
}
std::wstring text;
core::rect<s32> rect;
@@ -273,6 +286,7 @@ class GUIFormSpecMenu : public GUIModalMenu
public:
GUIFormSpecMenu(irr::IrrlichtDevice* dev,
+ JoystickController *joystick,
gui::IGUIElement* parent, s32 id,
IMenuManager *menumgr,
InventoryManager *invmgr,
@@ -365,6 +379,8 @@ protected:
v2s32 spacing;
v2s32 imgsize;
v2s32 offset;
+ v2s32 pos_offset;
+ std::stack<v2s32> container_stack;
irr::IrrlichtDevice* m_device;
InventoryManager *m_invmgr;
@@ -382,6 +398,7 @@ protected:
std::vector<ImageDrawSpec> m_images;
std::vector<ImageDrawSpec> m_itemimages;
std::vector<BoxDrawSpec> m_boxes;
+ UNORDERED_MAP<std::string, bool> field_close_on_enter;
std::vector<FieldSpec> m_fields;
std::vector<StaticTextSpec> m_static_texts;
std::vector<std::pair<FieldSpec,GUITable*> > m_tables;
@@ -391,8 +408,6 @@ protected:
std::vector<std::pair<FieldSpec, std::vector<std::string> > > m_dropdowns;
ItemSpec *m_selected_item;
- f32 m_timer1;
- f32 m_timer2;
u32 m_selected_amount;
bool m_selected_dragging;
@@ -419,7 +434,6 @@ protected:
bool m_bgfullscreen;
bool m_slotborder;
- bool m_clipbackground;
video::SColor m_bgcolor;
video::SColor m_slotbg_n;
video::SColor m_slotbg_h;
@@ -428,10 +442,11 @@ protected:
video::SColor m_default_tooltip_color;
private:
- IFormSource *m_form_src;
- TextDest *m_text_dst;
- unsigned int m_formspec_version;
- std::string m_focused_element;
+ IFormSource *m_form_src;
+ TextDest *m_text_dst;
+ unsigned int m_formspec_version;
+ std::string m_focused_element;
+ JoystickController *m_joystick;
typedef struct {
bool explicit_size;
@@ -444,7 +459,7 @@ private:
GUITable::TableOptions table_options;
GUITable::TableColumns table_columns;
// used to restore table selection/scroll/treeview state
- std::map<std::string, GUITable::DynamicData> table_dyndata;
+ UNORDERED_MAP<std::string, GUITable::DynamicData> table_dyndata;
} parserData;
typedef struct {
@@ -455,14 +470,17 @@ private:
} fs_key_pendig;
fs_key_pendig current_keys_pending;
+ std::string current_field_enter_pending;
- void parseElement(parserData* data,std::string element);
+ void parseElement(parserData* data, std::string element);
- void parseSize(parserData* data,std::string element);
- 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 parseSize(parserData* data, std::string element);
+ void parseContainer(parserData* data, 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);
@@ -471,6 +489,7 @@ private:
void parseTable(parserData* data,std::string element);
void parseTextList(parserData* data,std::string element);
void parseDropDown(parserData* data,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 parseSimpleField(parserData* data,std::vector<std::string> &parts);
@@ -489,6 +508,8 @@ private:
bool parseSizeDirect(parserData* data, std::string element);
void parseScrollBar(parserData* data, std::string element);
+ void tryClose();
+
/**
* check if event is part of a double click
* @param event event to evaluate
@@ -547,4 +568,3 @@ public:
};
#endif
-