Inventory transparency; very loosely based on sapier's commits.
authorPerttu Ahola <celeron55@gmail.com>
Mon, 22 Aug 2011 21:31:18 +0000 (00:31 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Mon, 22 Aug 2011 21:33:38 +0000 (00:33 +0300)
Also contains some commented-out code for testing out different looks
in the future.

src/game.cpp
src/guiInventoryMenu.cpp

index 7c77996b835275a0086eeb67ae18b5a4ae1d5c08..dc3ed24569cbb56587bd5a5fe449f35fcb69ceb3 100644 (file)
@@ -319,17 +319,61 @@ void draw_hotbar(video::IVideoDriver *driver, gui::IGUIFont *font,
                
                if(g_selected_item == i)
                {
-                       driver->draw2DRectangle(video::SColor(255,255,0,0),
-                                       core::rect<s32>(rect.UpperLeftCorner - v2s32(1,1)*padding,
-                                                       rect.LowerRightCorner + v2s32(1,1)*padding),
-                                       NULL);
-               }
-               else
-               {
-                       video::SColor bgcolor2(128,0,0,0);
-                       driver->draw2DRectangle(bgcolor2, rect, NULL);
+                       video::SColor c_outside(255,255,0,0);
+                       //video::SColor c_outside(255,0,0,0);
+                       //video::SColor c_inside(255,192,192,192);
+                       s32 x1 = rect.UpperLeftCorner.X;
+                       s32 y1 = rect.UpperLeftCorner.Y;
+                       s32 x2 = rect.LowerRightCorner.X;
+                       s32 y2 = rect.LowerRightCorner.Y;
+                       // Black base borders
+                       driver->draw2DRectangle(c_outside,
+                                       core::rect<s32>(
+                                               v2s32(x1 - padding, y1 - padding),
+                                               v2s32(x2 + padding, y1)
+                                       ), NULL);
+                       driver->draw2DRectangle(c_outside,
+                                       core::rect<s32>(
+                                               v2s32(x1 - padding, y2),
+                                               v2s32(x2 + padding, y2 + padding)
+                                       ), NULL);
+                       driver->draw2DRectangle(c_outside,
+                                       core::rect<s32>(
+                                               v2s32(x1 - padding, y1),
+                                               v2s32(x1, y2)
+                                       ), NULL);
+                       driver->draw2DRectangle(c_outside,
+                                       core::rect<s32>(
+                                               v2s32(x2, y1),
+                                               v2s32(x2 + padding, y2)
+                                       ), NULL);
+                       /*// Light inside borders
+                       driver->draw2DRectangle(c_inside,
+                                       core::rect<s32>(
+                                               v2s32(x1 - padding/2, y1 - padding/2),
+                                               v2s32(x2 + padding/2, y1)
+                                       ), NULL);
+                       driver->draw2DRectangle(c_inside,
+                                       core::rect<s32>(
+                                               v2s32(x1 - padding/2, y2),
+                                               v2s32(x2 + padding/2, y2 + padding/2)
+                                       ), NULL);
+                       driver->draw2DRectangle(c_inside,
+                                       core::rect<s32>(
+                                               v2s32(x1 - padding/2, y1),
+                                               v2s32(x1, y2)
+                                       ), NULL);
+                       driver->draw2DRectangle(c_inside,
+                                       core::rect<s32>(
+                                               v2s32(x2, y1),
+                                               v2s32(x2 + padding/2, y2)
+                                       ), NULL);
+                       */
                }
 
+               video::SColor bgcolor2(128,0,0,0);
+               driver->draw2DRectangle(bgcolor2, rect, NULL);
+
                if(item != NULL)
                {
                        drawInventoryItem(driver, font, item, rect, NULL);
index f90a2e95982e48eff57bdcafee53883b0abc2b39..8faf3d005cc46c6f3025453dd3a9f1801a450cc7 100644 (file)
@@ -41,7 +41,7 @@ void drawInventoryItem(video::IVideoDriver *driver,
                driver->draw2DImage(texture, rect,
                        core::rect<s32>(core::position2d<s32>(0,0),
                        core::dimension2di(texture->getOriginalSize())),
-                       clip, colors, false);
+                       clip, colors, true);
        }
        else
        {
@@ -241,22 +241,31 @@ void GUIInventoryMenu::drawList(const ListDrawSpec &s)
                if(m_selected_item != NULL && m_selected_item->listname == s.listname
                                && m_selected_item->i == i)
                {
+                       /*s32 border = imgsize.X/12;
+                       driver->draw2DRectangle(video::SColor(255,192,192,192),
+                                       core::rect<s32>(rect.UpperLeftCorner - v2s32(1,1)*border,
+                                                       rect.LowerRightCorner + v2s32(1,1)*border),
+                                       NULL);
+                       driver->draw2DRectangle(video::SColor(255,0,0,0),
+                                       core::rect<s32>(rect.UpperLeftCorner - v2s32(1,1)*((border+1)/2),
+                                                       rect.LowerRightCorner + v2s32(1,1)*((border+1)/2)),
+                                       NULL);*/
+                       s32 border = 2;
                        driver->draw2DRectangle(video::SColor(255,255,0,0),
-                                       core::rect<s32>(rect.UpperLeftCorner - v2s32(2,2),
-                                                       rect.LowerRightCorner + v2s32(2,2)),
+                                       core::rect<s32>(rect.UpperLeftCorner - v2s32(1,1)*border,
+                                                       rect.LowerRightCorner + v2s32(1,1)*border),
                                        &AbsoluteClippingRect);
                }
 
+               video::SColor bgcolor(255,128,128,128);
+               driver->draw2DRectangle(bgcolor, rect, &AbsoluteClippingRect);
+
                if(item)
                {
                        drawInventoryItem(driver, font, item,
                                        rect, &AbsoluteClippingRect);
                }
-               else
-               {
-                       video::SColor bgcolor(255,128,128,128);
-                       driver->draw2DRectangle(bgcolor, rect, &AbsoluteClippingRect);
-               }
+
        }
 }