From 8e5167d72622dec428477a7fff529b7dbc974106 Mon Sep 17 00:00:00 2001 From: RealBadAngel Date: Thu, 8 Nov 2012 19:22:37 +0100 Subject: Adding background to Formspec --- src/guiFormSpecMenu.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'src/guiFormSpecMenu.cpp') diff --git a/src/guiFormSpecMenu.cpp b/src/guiFormSpecMenu.cpp index affbd1a34..7815089b2 100644 --- a/src/guiFormSpecMenu.cpp +++ b/src/guiFormSpecMenu.cpp @@ -199,6 +199,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize) m_inventorylists.clear(); m_images.clear(); + m_backgrounds.clear(); m_fields.clear(); Strfnd f(m_formspec_string); @@ -278,9 +279,26 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize) <<", geom=("<setVisible(false); + /* + Draw backgrounds + */ + for(u32 i=0; itsrc()->getTextureRaw(spec.name); + // Image size on screen + core::rect imgrect(0, 0, spec.geom.X, spec.geom.Y); + // Image rectangle on screen + core::rect rect = imgrect + spec.pos; + const video::SColor color(255,255,255,255); + const video::SColor colors[] = {color,color,color,color}; + driver->draw2DImage(texture, rect, + core::rect(core::position2d(0,0), + core::dimension2di(texture->getOriginalSize())), + NULL/*&AbsoluteClippingRect*/, colors, true); + } + /* Draw images */ @@ -715,8 +753,11 @@ void GUIFormSpecMenu::drawMenu() Draw items Phase 0: Item slot rectangles Phase 1: Item images; prepare tooltip + If backgrounds used, do not draw Item slot rectangles */ - for(int phase=0; phase<=1; phase++) + int start_phase=0; + if (m_backgrounds.size() > 0) start_phase=1; + for(int phase=start_phase; phase<=1; phase++) for(u32 i=0; i