diff options
author | RealBadAngel <maciej.kasatkin@o2.pl> | 2016-02-09 06:06:10 +0100 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2016-02-09 03:03:55 -0500 |
commit | baa7c8f8ad4e5717e324948c85d3da6bbbf17c16 (patch) | |
tree | af5e590989a44c5b1c45b05629afc6f41272be36 | |
parent | eb3840a3f88dd9902ff1c5ea50d90a7f33e08d82 (diff) | |
download | minetest-baa7c8f8ad4e5717e324948c85d3da6bbbf17c16.tar.gz minetest-baa7c8f8ad4e5717e324948c85d3da6bbbf17c16.tar.bz2 minetest-baa7c8f8ad4e5717e324948c85d3da6bbbf17c16.zip |
FormSpec: Add StaticTextSpec and superimpose over item image buttons
-rw-r--r-- | src/guiFormSpecMenu.cpp | 18 | ||||
-rw-r--r-- | src/guiFormSpecMenu.h | 15 |
2 files changed, 32 insertions, 1 deletions
diff --git a/src/guiFormSpecMenu.cpp b/src/guiFormSpecMenu.cpp index 116688e95..226cc6cf0 100644 --- a/src/guiFormSpecMenu.cpp +++ b/src/guiFormSpecMenu.cpp @@ -1497,7 +1497,7 @@ void GUIFormSpecMenu::parseItemImageButton(parserData* data,std::string element) 258 + m_fields.size() ); - gui::IGUIButton *e = Environment->addButton(rect, this, spec.fid, spec.flabel.c_str()); + gui::IGUIButton *e = Environment->addButton(rect, this, spec.fid, L""); if (spec.fname == data->focused_fieldname) { Environment->setFocus(e); @@ -1515,6 +1515,12 @@ void GUIFormSpecMenu::parseItemImageButton(parserData* data,std::string element) pos.X += stof(v_pos[0]) * (float) spacing.X; pos.Y += stof(v_pos[1]) * (float) spacing.Y; m_itemimages.push_back(ImageDrawSpec("", item_name, pos, geom)); + + StaticTextSpec label_spec( + utf8_to_wide(label), + rect + ); + m_static_texts.push_back(label_spec); return; } errorstream<< "Invalid ItemImagebutton element(" << parts.size() << "): '" << element << "'" << std::endl; @@ -1883,6 +1889,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize) m_boxes.clear(); m_tooltips.clear(); m_inventory_rings.clear(); + m_static_texts.clear(); // Set default values (fits old formspec values) m_bgcolor = video::SColor(140,0,0,0); @@ -2463,6 +2470,15 @@ void GUIFormSpecMenu::drawMenu() #endif /* + Draw static text elements + */ + for (u32 i = 0; i < m_static_texts.size(); i++) { + const StaticTextSpec &spec = m_static_texts[i]; + video::SColor color(255, 255, 255, 255); + m_font->draw(spec.text.c_str(), spec.rect, color, true, true, &spec.rect); + } + + /* Draw fields/buttons tooltips */ gui::IGUIElement *hovered = diff --git a/src/guiFormSpecMenu.h b/src/guiFormSpecMenu.h index 9b892f192..0677e87a6 100644 --- a/src/guiFormSpecMenu.h +++ b/src/guiFormSpecMenu.h @@ -228,6 +228,20 @@ class GUIFormSpecMenu : public GUIModalMenu irr::video::SColor color; }; + struct StaticTextSpec { + StaticTextSpec() + { + } + StaticTextSpec(const std::wstring &a_text, + const core::rect<s32> &a_rect): + text(a_text), + rect(a_rect) + { + } + std::wstring text; + core::rect<s32> rect; + }; + public: GUIFormSpecMenu(irr::IrrlichtDevice* dev, gui::IGUIElement* parent, s32 id, @@ -339,6 +353,7 @@ protected: std::vector<ImageDrawSpec> m_itemimages; std::vector<BoxDrawSpec> m_boxes; std::vector<FieldSpec> m_fields; + std::vector<StaticTextSpec> m_static_texts; std::vector<std::pair<FieldSpec,GUITable*> > m_tables; std::vector<std::pair<FieldSpec,gui::IGUICheckBox*> > m_checkboxes; std::map<std::string, TooltipSpec> m_tooltips; |