Skip to content

Commit baa7c8f

Browse files
RealBadAngelkwolekr
authored andcommittedFeb 9, 2016
FormSpec: Add StaticTextSpec and superimpose over item image buttons
1 parent eb3840a commit baa7c8f

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed
 

‎src/guiFormSpecMenu.cpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -1497,7 +1497,7 @@ void GUIFormSpecMenu::parseItemImageButton(parserData* data,std::string element)
14971497
258 + m_fields.size()
14981498
);
14991499

1500-
gui::IGUIButton *e = Environment->addButton(rect, this, spec.fid, spec.flabel.c_str());
1500+
gui::IGUIButton *e = Environment->addButton(rect, this, spec.fid, L"");
15011501

15021502
if (spec.fname == data->focused_fieldname) {
15031503
Environment->setFocus(e);
@@ -1515,6 +1515,12 @@ void GUIFormSpecMenu::parseItemImageButton(parserData* data,std::string element)
15151515
pos.X += stof(v_pos[0]) * (float) spacing.X;
15161516
pos.Y += stof(v_pos[1]) * (float) spacing.Y;
15171517
m_itemimages.push_back(ImageDrawSpec("", item_name, pos, geom));
1518+
1519+
StaticTextSpec label_spec(
1520+
utf8_to_wide(label),
1521+
rect
1522+
);
1523+
m_static_texts.push_back(label_spec);
15181524
return;
15191525
}
15201526
errorstream<< "Invalid ItemImagebutton element(" << parts.size() << "): '" << element << "'" << std::endl;
@@ -1883,6 +1889,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
18831889
m_boxes.clear();
18841890
m_tooltips.clear();
18851891
m_inventory_rings.clear();
1892+
m_static_texts.clear();
18861893

18871894
// Set default values (fits old formspec values)
18881895
m_bgcolor = video::SColor(140,0,0,0);
@@ -2462,6 +2469,15 @@ void GUIFormSpecMenu::drawMenu()
24622469
m_pointer = m_device->getCursorControl()->getPosition();
24632470
#endif
24642471

2472+
/*
2473+
Draw static text elements
2474+
*/
2475+
for (u32 i = 0; i < m_static_texts.size(); i++) {
2476+
const StaticTextSpec &spec = m_static_texts[i];
2477+
video::SColor color(255, 255, 255, 255);
2478+
m_font->draw(spec.text.c_str(), spec.rect, color, true, true, &spec.rect);
2479+
}
2480+
24652481
/*
24662482
Draw fields/buttons tooltips
24672483
*/

‎src/guiFormSpecMenu.h

+15
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,20 @@ class GUIFormSpecMenu : public GUIModalMenu
228228
irr::video::SColor color;
229229
};
230230

231+
struct StaticTextSpec {
232+
StaticTextSpec()
233+
{
234+
}
235+
StaticTextSpec(const std::wstring &a_text,
236+
const core::rect<s32> &a_rect):
237+
text(a_text),
238+
rect(a_rect)
239+
{
240+
}
241+
std::wstring text;
242+
core::rect<s32> rect;
243+
};
244+
231245
public:
232246
GUIFormSpecMenu(irr::IrrlichtDevice* dev,
233247
gui::IGUIElement* parent, s32 id,
@@ -339,6 +353,7 @@ class GUIFormSpecMenu : public GUIModalMenu
339353
std::vector<ImageDrawSpec> m_itemimages;
340354
std::vector<BoxDrawSpec> m_boxes;
341355
std::vector<FieldSpec> m_fields;
356+
std::vector<StaticTextSpec> m_static_texts;
342357
std::vector<std::pair<FieldSpec,GUITable*> > m_tables;
343358
std::vector<std::pair<FieldSpec,gui::IGUICheckBox*> > m_checkboxes;
344359
std::map<std::string, TooltipSpec> m_tooltips;

0 commit comments

Comments
 (0)
Please sign in to comment.