^ label is the text on the label
^ Position and size units are inventory slots
-button[<X>,<Y>;<W>,<H>;<name>;<label>]
+button[<X>,<Y>;<W>,<H>;<name>;<label>;<tooltip>]
^ Clickable button. When clicked, fields will be sent.
^ x, y and name work as per field
^ w and h are the size of the button
^ label is the text on the button
^ Position and size units are inventory slots
+^ tooltip is optional
image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]
^ x, y, w, h, and name work as per button
^ texture name is the filename of an image
^ Position and size units are inventory slots
-image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>]
-^ x, y, w, h, and name work as per button
-^ texture name is the filename of an image
-^ Position and size units are inventory slots
-^ noclip true meand imagebutton doesn't need to be within specified formsize
-^ drawborder draw button bodrer or not
-
image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>]
+image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>;<tooltip>]
^ x, y, w, h, and name work as per button
^ texture name is the filename of an image
^ Position and size units are inventory slots
^ noclip true meand imagebutton doesn't need to be within specified formsize
^ drawborder draw button bodrer or not
^ pressed texture name is the filename of an image on pressed state
+^ tooltip is optional
item_image_button[<X>,<Y>;<W>,<H>;<item name>;<name>;<label>]
^ x, y, w, h, name and label work as per button
^ index of currently selected dropdown item
^ color in hexadecimal format RRGGBB (only)
-checkbox[<X>,<Y>;<name>;<label>;<selected>]
+checkbox[<X>,<Y>;<name>;<label>;<selected>;<tooltip>]
^ show a checkbox
^ x and y position of checkbox
^ name fieldname data is transfered to lua
^ label to be shown left of checkbox
^ selected (optional) true/false
+^ tooltip (optional)
table[<X>,<Y>;<W>,<H>;<name>;<cell 1>,<cell 2>,...,<cell n>;<selected idx>]
^ show scrollable table using options defined by the previous tableoptions[]
<< parts[b] << "\"" << std::endl; \
return; \
}
-
-extern gui::IGUIEnvironment* guienv;
-
/*
GUIFormSpecMenu
*/
m_form_src(fsrc),
m_text_dst(tdst),
m_ext_ptr(ext_ptr),
- m_font(guienv->getSkin()->getFont())
+ m_font(dev->getGUIEnvironment()->getSkin()->getFont())
{
current_keys_pending.key_down = false;
current_keys_pending.key_up = false;
{
std::vector<std::string> parts = split(element,';');
- if ((parts.size() == 3) || (parts.size() == 4)) {
+ if ((parts.size() >= 3) || (parts.size() <= 5)) {
std::vector<std::string> v_pos = split(parts[0],',');
std::string name = parts[1];
std::string label = parts[2];
std::string selected = "";
-
- if (parts.size() == 4)
- selected = parts[3];
-
+
+ if (parts.size() >= 4)
+ selected = parts[3];
+
MY_CHECKPOS("checkbox",0);
v2s32 pos = padding;
if (spec.fname == data->focused_fieldname) {
Environment->setFocus(e);
}
-
+ if (parts.size() >= 5)
+ spec.tooltip = parts[4];
m_checkboxes.push_back(std::pair<FieldSpec,gui::IGUICheckBox*>(spec,e));
m_fields.push_back(spec);
return;
{
std::vector<std::string> parts = split(element,';');
- if (parts.size() == 4) {
+ if (parts.size() == 4 || parts.size() == 5) {
std::vector<std::string> v_pos = split(parts[0],',');
std::vector<std::string> v_geom = split(parts[1],',');
std::string name = parts[2];
if (spec.fname == data->focused_fieldname) {
Environment->setFocus(e);
}
-
+ if (parts.size() >= 5)
+ spec.tooltip = parts[4];
+
m_fields.push_back(spec);
return;
}
{
std::vector<std::string> parts = split(element,';');
- if (parts.size() == 3) {
+ if (parts.size() == 3 || parts.size() == 4) {
parseSimpleField(data,parts);
return;
}
{
std::vector<std::string> parts = split(element,';');
- if ((parts.size() == 5) || (parts.size() == 7) || (parts.size() == 8)) {
+ if (((parts.size() >= 5) && (parts.size() <= 9)) && (parts.size() != 6)) {
std::vector<std::string> v_pos = split(parts[0],',');
std::vector<std::string> v_geom = split(parts[1],',');
std::string image_name = parts[2];
geom.X = (stof(v_geom[0]) * (float)spacing.X)-(spacing.X-imgsize.X);
geom.Y = (stof(v_geom[1]) * (float)spacing.Y)-(spacing.Y-imgsize.Y);
- bool noclip = false;
+ bool noclip = false;
bool drawborder = true;
-
- if ((parts.size() >= 7)) {
+ std::string pressed_image_name = "";
+
+ if (parts.size() >= 7) {
if (parts[5] == "true")
noclip = true;
-
if (parts[6] == "false")
drawborder = false;
}
-
- std::string pressed_image_name = "";
-
- if ((parts.size() == 8)) {
+
+ if (parts.size() >= 8) {
pressed_image_name = parts[7];
}
video::ITexture *texture = 0;
video::ITexture *pressed_texture = 0;
texture = m_tsrc->getTexture(image_name);
- if (parts.size() == 8)
+ if (pressed_image_name != "")
pressed_texture = m_tsrc->getTexture(pressed_image_name);
else
pressed_texture = texture;
if (spec.fname == data->focused_fieldname) {
Environment->setFocus(e);
}
+ if (parts.size() >= 9)
+ spec.tooltip = parts[8];
e->setUseAlphaChannel(true);
e->setImage(texture);
spec.ftype = f_Button;
rect+=data->basepos-padding;
spec.rect=rect;
- if (tooltip!="")
- spec.tooltip=tooltip;
+ spec.tooltip = tooltip;
m_fields.push_back(spec);
return;
}
/*
Draw fields/buttons tooltips
*/
- for(u32 i=0; i<m_fields.size(); i++)
- {
- const FieldSpec &spec = m_fields[i];
- if (spec.tooltip != "")
- {
- core::rect<s32> rect = spec.rect;
- if (rect.isPointInside(m_pointer))
- {
+ gui::IGUIElement *hovered =
+ Environment->getRootGUIElement()->getElementFromPoint(m_pointer);
+
+ if (hovered != NULL) {
+ s32 id = hovered->getID();
+ for(std::vector<FieldSpec>::iterator iter = m_fields.begin();
+ iter != m_fields.end(); iter++) {
+ if ( (iter->fid == id) && (iter->tooltip != "") ) {
m_tooltip_element->setVisible(true);
this->bringToFront(m_tooltip_element);
- m_tooltip_element->setText(narrow_to_wide(spec.tooltip).c_str());
+ m_tooltip_element->setText(narrow_to_wide(iter->tooltip).c_str());
s32 tooltip_x = m_pointer.X + 15;
s32 tooltip_y = m_pointer.Y + 15;
s32 tooltip_width = m_tooltip_element->getTextWidth() + 15;
- s32 tooltip_height = m_tooltip_element->getTextHeight() + 5;
+ if (tooltip_x + tooltip_width > (s32)screenSize.X)
+ tooltip_x = (s32)screenSize.X - tooltip_width - 15;
+ int lines_count = 1;
+ size_t i = 0;
+ while ((i = iter->tooltip.find("\n", i)) != std::string::npos) {
+ lines_count++;
+ i += 2;
+ }
+ s32 tooltip_height = m_tooltip_element->getTextHeight() * lines_count + 5;
m_tooltip_element->setRelativePosition(core::rect<s32>(
core::position2d<s32>(tooltip_x, tooltip_y),
core::dimension2d<s32>(tooltip_width, tooltip_height)));
+ break;
}
}
}