@@ -572,7 +572,7 @@ void GUIFormSpecMenu::parseItemImage(parserData* data,std::string element)
572
572
573
573
if (!data->explicit_size )
574
574
warningstream<<" invalid use of item_image without a size[] element" <<std::endl;
575
- m_itemimages.push_back (ImageDrawSpec (name, pos, geom));
575
+ m_itemimages.push_back (ImageDrawSpec (" " , name, pos, geom));
576
576
return ;
577
577
}
578
578
errorstream<< " Invalid ItemImage element(" << parts.size () << " ): '" << element << " '" << std::endl;
@@ -1483,7 +1483,6 @@ void GUIFormSpecMenu::parseItemImageButton(parserData* data,std::string element)
1483
1483
IItemDefManager *idef = m_gamedef->idef ();
1484
1484
ItemStack item;
1485
1485
item.deSerialize (item_name, idef);
1486
- video::ITexture *texture = idef->getInventoryTexture (item.getDefinition (idef).name , m_gamedef);
1487
1486
1488
1487
m_tooltips[name] =
1489
1488
TooltipSpec (item.getDefinition (idef).description ,
@@ -1505,13 +1504,17 @@ void GUIFormSpecMenu::parseItemImageButton(parserData* data,std::string element)
1505
1504
}
1506
1505
1507
1506
e->setUseAlphaChannel (true );
1508
- e->setImage (guiScalingImageButton (Environment->getVideoDriver (), texture , geom.X , geom.Y ));
1509
- e->setPressedImage (guiScalingImageButton (Environment->getVideoDriver (), texture , geom.X , geom.Y ));
1507
+ e->setImage (guiScalingImageButton (Environment->getVideoDriver (), NULL , geom.X , geom.Y ));
1508
+ e->setPressedImage (guiScalingImageButton (Environment->getVideoDriver (), NULL , geom.X , geom.Y ));
1510
1509
e->setScaleImage (true );
1511
1510
spec.ftype = f_Button;
1512
1511
rect+=data->basepos -padding;
1513
1512
spec.rect =rect;
1514
1513
m_fields.push_back (spec);
1514
+ pos = padding + AbsoluteRect.UpperLeftCorner ;
1515
+ pos.X += stof (v_pos[0 ]) * (float ) spacing.X ;
1516
+ pos.Y += stof (v_pos[1 ]) * (float ) spacing.Y ;
1517
+ m_itemimages.push_back (ImageDrawSpec (" " , item_name, pos, geom));
1515
1518
return ;
1516
1519
}
1517
1520
errorstream<< " Invalid ItemImagebutton element(" << parts.size () << " ): '" << element << " '" << std::endl;
@@ -2151,7 +2154,8 @@ GUIFormSpecMenu::ItemSpec GUIFormSpecMenu::getItemAtPos(v2s32 p) const
2151
2154
return ItemSpec (InventoryLocation (), " " , -1 );
2152
2155
}
2153
2156
2154
- void GUIFormSpecMenu::drawList (const ListDrawSpec &s, int phase)
2157
+ void GUIFormSpecMenu::drawList (const ListDrawSpec &s, int phase,
2158
+ bool &item_hovered)
2155
2159
{
2156
2160
video::IVideoDriver* driver = Environment->getVideoDriver ();
2157
2161
@@ -2193,12 +2197,13 @@ void GUIFormSpecMenu::drawList(const ListDrawSpec &s, int phase)
2193
2197
&& m_selected_item->i == item_i;
2194
2198
bool hovering = rect.isPointInside (m_pointer);
2195
2199
2196
- if (phase == 0 )
2197
- {
2198
- if (hovering)
2200
+ if (phase == 0 ) {
2201
+ if (hovering) {
2202
+ item_hovered = true ;
2199
2203
driver->draw2DRectangle (m_slotbg_h, rect, &AbsoluteClippingRect);
2200
- else
2204
+ } else {
2201
2205
driver->draw2DRectangle (m_slotbg_n, rect, &AbsoluteClippingRect);
2206
+ }
2202
2207
}
2203
2208
2204
2209
// Draw inv slot borders
@@ -2232,7 +2237,8 @@ void GUIFormSpecMenu::drawList(const ListDrawSpec &s, int phase)
2232
2237
if (!item.empty ())
2233
2238
{
2234
2239
drawItemStack (driver, m_font, item,
2235
- rect, &AbsoluteClippingRect, m_gamedef);
2240
+ rect, &AbsoluteClippingRect, m_gamedef,
2241
+ selected, hovering, false );
2236
2242
}
2237
2243
2238
2244
// Draw tooltip
@@ -2273,11 +2279,15 @@ void GUIFormSpecMenu::drawList(const ListDrawSpec &s, int phase)
2273
2279
2274
2280
void GUIFormSpecMenu::drawSelectedItem ()
2275
2281
{
2276
- if (!m_selected_item)
2277
- return ;
2278
-
2279
2282
video::IVideoDriver* driver = Environment->getVideoDriver ();
2280
2283
2284
+ if (!m_selected_item) {
2285
+ drawItemStack (driver, m_font, ItemStack (),
2286
+ core::rect<s32>(v2s32 (0 , 0 ), v2s32 (0 , 0 )),
2287
+ NULL , m_gamedef, false , false , true );
2288
+ return ;
2289
+ }
2290
+
2281
2291
Inventory *inv = m_invmgr->getInventory (m_selected_item->inventoryloc );
2282
2292
sanity_check (inv);
2283
2293
InventoryList *list = inv->getList (m_selected_item->listname );
@@ -2287,7 +2297,7 @@ void GUIFormSpecMenu::drawSelectedItem()
2287
2297
2288
2298
core::rect<s32> imgrect (0 ,0 ,imgsize.X ,imgsize.Y );
2289
2299
core::rect<s32> rect = imgrect + (m_pointer - imgrect.getCenter ());
2290
- drawItemStack (driver, m_font, stack, rect, NULL , m_gamedef);
2300
+ drawItemStack (driver, m_font, stack, rect, NULL , m_gamedef, false , false , true );
2291
2301
}
2292
2302
2293
2303
void GUIFormSpecMenu::drawMenu ()
@@ -2369,6 +2379,12 @@ void GUIFormSpecMenu::drawMenu()
2369
2379
2370
2380
driver->draw2DRectangle (todraw, rect, 0 );
2371
2381
}
2382
+
2383
+ /*
2384
+ Call base class
2385
+ */
2386
+ gui::IGUIElement::draw ();
2387
+
2372
2388
/*
2373
2389
Draw images
2374
2390
*/
@@ -2413,36 +2429,31 @@ void GUIFormSpecMenu::drawMenu()
2413
2429
const ImageDrawSpec &spec = m_itemimages[i];
2414
2430
IItemDefManager *idef = m_gamedef->idef ();
2415
2431
ItemStack item;
2416
- item.deSerialize (spec.name , idef);
2417
- video::ITexture *texture = idef->getInventoryTexture (item.getDefinition (idef).name , m_gamedef);
2418
- // Image size on screen
2432
+ item.deSerialize (spec.item_name , idef);
2419
2433
core::rect<s32> imgrect (0 , 0 , spec.geom .X , spec.geom .Y );
2420
- // Image rectangle on screen
2434
+ // Viewport rectangle on screen
2421
2435
core::rect<s32> rect = imgrect + spec.pos ;
2422
- const video::SColor color (255 ,255 ,255 ,255 );
2423
- const video::SColor colors[] = {color,color,color,color};
2424
- draw2DImageFilterScaled (driver, texture, rect,
2425
- core::rect<s32>(core::position2d<s32>(0 ,0 ),
2426
- core::dimension2di (texture->getOriginalSize ())),
2427
- NULL /* &AbsoluteClippingRect*/ , colors, true );
2436
+ drawItemStack (driver, m_font, item, rect, &AbsoluteClippingRect,
2437
+ m_gamedef, false , false , false );
2428
2438
}
2429
2439
2430
2440
/*
2431
2441
Draw items
2432
2442
Phase 0: Item slot rectangles
2433
2443
Phase 1: Item images; prepare tooltip
2434
2444
*/
2435
- int start_phase=0 ;
2436
- for (int phase=start_phase; phase<=1 ; phase++)
2437
- for (u32 i=0 ; i<m_inventorylists.size (); i++)
2438
- {
2439
- drawList (m_inventorylists[i], phase);
2445
+ bool item_hovered = false ;
2446
+ int start_phase = 0 ;
2447
+ for (int phase = start_phase; phase <= 1 ; phase++) {
2448
+ for (u32 i = 0 ; i < m_inventorylists.size (); i++) {
2449
+ drawList (m_inventorylists[i], phase, item_hovered);
2450
+ }
2451
+ }
2452
+ if (!item_hovered) {
2453
+ drawItemStack (driver, m_font, ItemStack (),
2454
+ core::rect<s32>(v2s32 (0 , 0 ), v2s32 (0 , 0 )),
2455
+ NULL , m_gamedef, false , true , false );
2440
2456
}
2441
-
2442
- /*
2443
- Call base class
2444
- */
2445
- gui::IGUIElement::draw ();
2446
2457
2447
2458
/* TODO find way to show tooltips on touchscreen */
2448
2459
#ifndef HAVE_TOUCHSCREENGUI
0 commit comments