void GUIFormSpecMenu::parseList(parserData* data,std::string element)
{
if (m_gamedef == 0) {
- errorstream<<"WARNING: invalid use of 'list' with m_gamedef==0"<<std::endl;
+ warningstream<<"invalid use of 'list' with m_gamedef==0"<<std::endl;
return;
}
}
if(!data->explicit_size)
- errorstream<<"WARNING: invalid use of list without a size[] element"<<std::endl;
+ warningstream<<"invalid use of list without a size[] element"<<std::endl;
m_inventorylists.push_back(ListDrawSpec(loc, listname, pos, geom, start_i));
return;
}
if (parts.size() >= 5) {
std::vector<std::string> v_pos = split(parts[0],',');
std::vector<std::string> v_dim = split(parts[1],',');
- std::string name = parts[2];
+ std::string name = parts[3];
std::string value = parts[4];
MY_CHECKPOS("scrollbar",0);
geom.Y = stof(v_geom[1]) * (float)imgsize.Y;
if(!data->explicit_size)
- errorstream<<"WARNING: invalid use of image without a size[] element"<<std::endl;
+ warningstream<<"invalid use of image without a size[] element"<<std::endl;
m_images.push_back(ImageDrawSpec(name, pos, geom));
return;
}
pos.Y += stof(v_pos[1]) * (float) spacing.Y;
if(!data->explicit_size)
- errorstream<<"WARNING: invalid use of image without a size[] element"<<std::endl;
+ warningstream<<"invalid use of image without a size[] element"<<std::endl;
m_images.push_back(ImageDrawSpec(name, pos));
return;
}
geom.Y = stof(v_geom[1]) * (float)imgsize.Y;
if(!data->explicit_size)
- errorstream<<"WARNING: invalid use of item_image without a size[] element"<<std::endl;
- m_itemimages.push_back(ImageDrawSpec(name, pos, geom));
+ warningstream<<"invalid use of item_image without a size[] element"<<std::endl;
+ m_itemimages.push_back(ImageDrawSpec("", name, pos, geom));
return;
}
errorstream<< "Invalid ItemImage element(" << parts.size() << "): '" << element << "'" << std::endl;
pos.X + geom.X, pos.Y + m_btn_height);
if(!data->explicit_size)
- errorstream<<"WARNING: invalid use of button without a size[] element"<<std::endl;
+ warningstream<<"invalid use of button without a size[] element"<<std::endl;
label = unescape_string(label);
}
if(!data->explicit_size)
- errorstream<<"WARNING: invalid use of background without a size[] element"<<std::endl;
+ warningstream<<"invalid use of background without a size[] element"<<std::endl;
m_backgrounds.push_back(ImageDrawSpec(name, pos, geom));
return;
}
core::rect<s32> rect;
if(data->explicit_size)
- errorstream<<"WARNING: invalid use of unpositioned \"field\" in inventory"<<std::endl;
+ warningstream<<"invalid use of unpositioned \"field\" in inventory"<<std::endl;
v2s32 pos = padding + AbsoluteRect.UpperLeftCorner;
pos.Y = ((m_fields.size()+2)*60);
if (g_settings->getBool("freetype")) {
e = (gui::IGUIElement *) new gui::intlGUIEditBox(spec.fdefault.c_str(),
true, Environment, this, spec.fid, rect);
+ e->drop();
} else {
#else
{
core::rect<s32> rect = core::rect<s32>(pos.X, pos.Y, pos.X+geom.X, pos.Y+geom.Y);
if(!data->explicit_size)
- errorstream<<"WARNING: invalid use of positioned "<<type<<" without a size[] element"<<std::endl;
+ warningstream<<"invalid use of positioned "<<type<<" without a size[] element"<<std::endl;
if(m_form_src)
default_val = m_form_src->resolveText(default_val);
if (g_settings->getBool("freetype")) {
e = (gui::IGUIEditBox *) new gui::intlGUIEditBox(spec.fdefault.c_str(),
true, Environment, this, spec.fid, rect);
+ e->drop();
} else {
#else
{
pos.Y += (stof(v_pos[1]) + 7.0/30.0) * (float)spacing.Y;
if(!data->explicit_size)
- errorstream<<"WARNING: invalid use of label without a size[] element"<<std::endl;
+ warningstream<<"invalid use of label without a size[] element"<<std::endl;
text = unescape_string(text);
std::vector<std::string> lines = split(text, '\n');
//actually text.length() would be correct but adding +1 avoids to break all mods
if(!data->explicit_size)
- errorstream<<"WARNING: invalid use of label without a size[] element"<<std::endl;
+ warningstream<<"invalid use of label without a size[] element"<<std::endl;
std::wstring label = L"";
core::rect<s32> rect = core::rect<s32>(pos.X, pos.Y, pos.X+geom.X, pos.Y+geom.Y);
if(!data->explicit_size)
- errorstream<<"WARNING: invalid use of image_button without a size[] element"<<std::endl;
+ warningstream<<"invalid use of image_button without a size[] element"<<std::endl;
image_name = unescape_string(image_name);
pressed_image_name = unescape_string(pressed_image_name);
{
if (m_gamedef == 0) {
- errorstream <<
- "WARNING: invalid use of item_image_button with m_gamedef==0"
- << std::endl;
+ warningstream << "invalid use of item_image_button with m_gamedef==0"
+ << std::endl;
return;
}
core::rect<s32> rect = core::rect<s32>(pos.X, pos.Y, pos.X+geom.X, pos.Y+geom.Y);
if(!data->explicit_size)
- errorstream<<"WARNING: invalid use of item_image_button without a size[] element"<<std::endl;
+ warningstream<<"invalid use of item_image_button without a size[] element"<<std::endl;
IItemDefManager *idef = m_gamedef->idef();
ItemStack item;
item.deSerialize(item_name, idef);
- video::ITexture *texture = idef->getInventoryTexture(item.getDefinition(idef).name, m_gamedef);
m_tooltips[name] =
TooltipSpec(item.getDefinition(idef).description,
}
e->setUseAlphaChannel(true);
- e->setImage(guiScalingImageButton(Environment->getVideoDriver(), texture, geom.X, geom.Y));
- e->setPressedImage(guiScalingImageButton(Environment->getVideoDriver(), texture, geom.X, geom.Y));
+ e->setImage(guiScalingImageButton(Environment->getVideoDriver(), NULL, geom.X, geom.Y));
+ e->setPressedImage(guiScalingImageButton(Environment->getVideoDriver(), NULL, geom.X, geom.Y));
e->setScaleImage(true);
spec.ftype = f_Button;
rect+=data->basepos-padding;
spec.rect=rect;
m_fields.push_back(spec);
+ pos = padding + AbsoluteRect.UpperLeftCorner;
+ 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));
return;
}
errorstream<< "Invalid ItemImagebutton element(" << parts.size() << "): '" << element << "'" << std::endl;
m_fields.clear();
m_boxes.clear();
m_tooltips.clear();
+ m_inventory_rings.clear();
// Set default values (fits old formspec values)
m_bgcolor = video::SColor(140,0,0,0);
}
for(std::vector<FieldSpec>::iterator iter = m_fields.begin();
- iter != m_fields.end(); iter++) {
+ iter != m_fields.end(); ++iter) {
if (iter->fname != fieldname) {
continue;
return ItemSpec(InventoryLocation(), "", -1);
}
-void GUIFormSpecMenu::drawList(const ListDrawSpec &s, int phase)
+void GUIFormSpecMenu::drawList(const ListDrawSpec &s, int phase,
+ bool &item_hovered)
{
video::IVideoDriver* driver = Environment->getVideoDriver();
Inventory *inv = m_invmgr->getInventory(s.inventoryloc);
if(!inv){
- infostream<<"GUIFormSpecMenu::drawList(): WARNING: "
+ warningstream<<"GUIFormSpecMenu::drawList(): "
<<"The inventory location "
<<"\""<<s.inventoryloc.dump()<<"\" doesn't exist"
<<std::endl;
}
InventoryList *ilist = inv->getList(s.listname);
if(!ilist){
- infostream<<"GUIFormSpecMenu::drawList(): WARNING: "
+ warningstream<<"GUIFormSpecMenu::drawList(): "
<<"The inventory list \""<<s.listname<<"\" @ \""
<<s.inventoryloc.dump()<<"\" doesn't exist"
<<std::endl;
&& m_selected_item->listname == s.listname
&& m_selected_item->i == item_i;
bool hovering = rect.isPointInside(m_pointer);
+ ItemRotationKind rotation_kind = selected ? IT_ROT_SELECTED :
+ (hovering ? IT_ROT_HOVERED : IT_ROT_NONE);
- if(phase == 0)
- {
- if(hovering)
+ if (phase == 0) {
+ if (hovering) {
+ item_hovered = true;
driver->draw2DRectangle(m_slotbg_h, rect, &AbsoluteClippingRect);
- else
+ } else {
driver->draw2DRectangle(m_slotbg_n, rect, &AbsoluteClippingRect);
+ }
}
//Draw inv slot borders
if(!item.empty())
{
drawItemStack(driver, m_font, item,
- rect, &AbsoluteClippingRect, m_gamedef);
+ rect, &AbsoluteClippingRect, m_gamedef,
+ rotation_kind);
}
// Draw tooltip
void GUIFormSpecMenu::drawSelectedItem()
{
- if(!m_selected_item)
- return;
-
video::IVideoDriver* driver = Environment->getVideoDriver();
+ if (!m_selected_item) {
+ drawItemStack(driver, m_font, ItemStack(),
+ core::rect<s32>(v2s32(0, 0), v2s32(0, 0)),
+ NULL, m_gamedef, IT_ROT_DRAGGED);
+ return;
+ }
+
Inventory *inv = m_invmgr->getInventory(m_selected_item->inventoryloc);
sanity_check(inv);
InventoryList *list = inv->getList(m_selected_item->listname);
core::rect<s32> imgrect(0,0,imgsize.X,imgsize.Y);
core::rect<s32> rect = imgrect + (m_pointer - imgrect.getCenter());
- drawItemStack(driver, m_font, stack, rect, NULL, m_gamedef);
+ drawItemStack(driver, m_font, stack, rect, NULL, m_gamedef, IT_ROT_DRAGGED);
}
void GUIFormSpecMenu::drawMenu()
driver->draw2DRectangle(todraw, rect, 0);
}
+
+ /*
+ Call base class
+ */
+ gui::IGUIElement::draw();
+
/*
Draw images
*/
const ImageDrawSpec &spec = m_itemimages[i];
IItemDefManager *idef = m_gamedef->idef();
ItemStack item;
- item.deSerialize(spec.name, idef);
- video::ITexture *texture = idef->getInventoryTexture(item.getDefinition(idef).name, m_gamedef);
- // Image size on screen
+ item.deSerialize(spec.item_name, idef);
core::rect<s32> imgrect(0, 0, spec.geom.X, spec.geom.Y);
- // Image rectangle on screen
+ // Viewport rectangle on screen
core::rect<s32> rect = imgrect + spec.pos;
- const video::SColor color(255,255,255,255);
- const video::SColor colors[] = {color,color,color,color};
- draw2DImageFilterScaled(driver, texture, rect,
- core::rect<s32>(core::position2d<s32>(0,0),
- core::dimension2di(texture->getOriginalSize())),
- NULL/*&AbsoluteClippingRect*/, colors, true);
+ drawItemStack(driver, m_font, item, rect, &AbsoluteClippingRect,
+ m_gamedef, IT_ROT_NONE);
}
/*
Phase 0: Item slot rectangles
Phase 1: Item images; prepare tooltip
*/
- int start_phase=0;
- for(int phase=start_phase; phase<=1; phase++)
- for(u32 i=0; i<m_inventorylists.size(); i++)
- {
- drawList(m_inventorylists[i], phase);
+ bool item_hovered = false;
+ int start_phase = 0;
+ for (int phase = start_phase; phase <= 1; phase++) {
+ for (u32 i = 0; i < m_inventorylists.size(); i++) {
+ drawList(m_inventorylists[i], phase, item_hovered);
+ }
+ }
+ if (!item_hovered) {
+ drawItemStack(driver, m_font, ItemStack(),
+ core::rect<s32>(v2s32(0, 0), v2s32(0, 0)),
+ NULL, m_gamedef, IT_ROT_HOVERED);
}
-
- /*
- Call base class
- */
- gui::IGUIElement::draw();
/* TODO find way to show tooltips on touchscreen */
#ifndef HAVE_TOUCHSCREENGUI
if (id != -1 && delta >= m_tooltip_show_delay) {
for(std::vector<FieldSpec>::iterator iter = m_fields.begin();
- iter != m_fields.end(); iter++) {
+ iter != m_fields.end(); ++iter) {
if ( (iter->fid == id) && (m_tooltips[iter->fname].tooltip != "") ){
if (m_old_tooltip != m_tooltips[iter->fname].tooltip) {
m_old_tooltip = m_tooltips[iter->fname].tooltip;
break;
ItemStack stack_from = list_from->getItem(s.i);
assert(shift_move_amount <= stack_from.count);
-
- // find a place (or more than one) to add the new item
- u32 ilt_size = list_to->getSize();
- ItemStack leftover;
- for (u32 slot_to = 0; slot_to < ilt_size
- && shift_move_amount > 0; slot_to++) {
- list_to->itemFits(slot_to, stack_from, &leftover);
- if (leftover.count < stack_from.count) {
- infostream << "Handing IACTION_MOVE to manager" << std::endl;
- IMoveAction *a = new IMoveAction();
- a->count = MYMIN(shift_move_amount,
- (u32) (stack_from.count - leftover.count));
- shift_move_amount -= a->count;
- a->from_inv = s.inventoryloc;
- a->from_list = s.listname;
- a->from_i = s.i;
- a->to_inv = to_inv_sp.inventoryloc;
- a->to_list = to_inv_sp.listname;
- a->to_i = slot_to;
- m_invmgr->inventoryAction(a);
- stack_from = leftover;
+ if (m_client->getProtoVersion() >= 25) {
+ infostream << "Handing IACTION_MOVE to manager" << std::endl;
+ IMoveAction *a = new IMoveAction();
+ a->count = shift_move_amount;
+ a->from_inv = s.inventoryloc;
+ a->from_list = s.listname;
+ a->from_i = s.i;
+ a->to_inv = to_inv_sp.inventoryloc;
+ a->to_list = to_inv_sp.listname;
+ a->move_somewhere = true;
+ m_invmgr->inventoryAction(a);
+ } else {
+ // find a place (or more than one) to add the new item
+ u32 ilt_size = list_to->getSize();
+ ItemStack leftover;
+ for (u32 slot_to = 0; slot_to < ilt_size
+ && shift_move_amount > 0; slot_to++) {
+ list_to->itemFits(slot_to, stack_from, &leftover);
+ if (leftover.count < stack_from.count) {
+ infostream << "Handing IACTION_MOVE to manager" << std::endl;
+ IMoveAction *a = new IMoveAction();
+ a->count = MYMIN(shift_move_amount,
+ (u32) (stack_from.count - leftover.count));
+ shift_move_amount -= a->count;
+ a->from_inv = s.inventoryloc;
+ a->from_list = s.listname;
+ a->from_i = s.i;
+ a->to_inv = to_inv_sp.inventoryloc;
+ a->to_list = to_inv_sp.listname;
+ a->to_i = slot_to;
+ m_invmgr->inventoryAction(a);
+ stack_from = leftover;
+ }
}
}
} while (0);
-
} else if (drop_amount > 0) {
m_selected_content_guess = ItemStack(); // Clear
std::string GUIFormSpecMenu::getNameByID(s32 id)
{
for(std::vector<FieldSpec>::iterator iter = m_fields.begin();
- iter != m_fields.end(); iter++) {
+ iter != m_fields.end(); ++iter) {
if (iter->fid == id) {
return iter->fname;
}
std::wstring GUIFormSpecMenu::getLabelByID(s32 id)
{
for(std::vector<FieldSpec>::iterator iter = m_fields.begin();
- iter != m_fields.end(); iter++) {
+ iter != m_fields.end(); ++iter) {
if (iter->fid == id) {
return iter->flabel;
}