diff -Nauwr Irrlicht/CGUIEnvironment.cpp IrrlichtK0.5/CGUIEnvironment.cpp --- Irrlicht/CGUIEnvironment.cpp 2005-05-25 18:43:26.000000000 +0200 +++ IrrlichtK0.5/CGUIEnvironment.cpp 2005-05-29 14:17:01.000000000 +0200 @@ -25,6 +25,7 @@ #include "CGUIComboBox.h" #include "CGUIMenu.h" #include "CGUIToolBar.h" +#include "CGUILoadBar.h" #include "BuildInFont.h" #include "os.h" @@ -581,6 +582,16 @@ } +//! Adds a Load Bar to the environment. +IGUILoadBar* CGUIEnvironment::addLoadBar(const core::rect& rectangle, + IGUIElement* parent, bool vis,s32 TotalNum, s32 id) +{ + IGUILoadBar* l = new CGUILoadBar(this, parent ? parent : this, rectangle,vis,TotalNum, id); + + l->drop(); + return l; +} + //! returns the font diff -Nauwr Irrlicht/CGUIEnvironment.h IrrlichtK0.5/CGUIEnvironment.h --- Irrlicht/CGUIEnvironment.h 2005-05-25 18:43:26.000000000 +0200 +++ IrrlichtK0.5/CGUIEnvironment.h 2005-05-29 14:08:47.000000000 +0200 @@ -113,6 +113,9 @@ //! Adds a combo box to the environment. virtual IGUIComboBox* addComboBox(const core::rect& rectangle, IGUIElement* parent=0, s32 id=-1); + //! Adds a Load Bar to the environment. + virtual IGUILoadBar* addLoadBar(const core::rect& rectangle, + IGUIElement* parent=0, bool vis=true,s32 TotalNum=7, s32 id=-1); //! sets the focus to an element virtual void setFocus(IGUIElement* element); diff -Nauwr Irrlicht/CGUILoadBar.cpp IrrlichtK0.5/CGUILoadBar.cpp --- Irrlicht/CGUILoadBar.cpp 1970-01-01 01:00:00.000000000 +0100 +++ IrrlichtK0.5/CGUILoadBar.cpp 2005-05-29 14:16:39.000000000 +0200 @@ -0,0 +1,103 @@ +#include "CGUILoadBar.h" +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" + +namespace irr +{ +namespace gui +{ + //! constructor +CGUILoadBar::CGUILoadBar(IGUIEnvironment* environment, IGUIElement* parent, core::rect rectangle,bool vis,s32 TotalNum, s32 id) +: IGUILoadBar(environment, parent, id, rectangle,vis,TotalNum), + Percent(0),Border(true),isVisible(vis),AbsoluteBorderRect(rectangle),BorderRect(rectangle), + MaxNum(TotalNum),isDone(false),loadcolor(video::SColor(255,0,80,150)) +{ + + #ifdef _DEBUG + setDebugName("CGUILoadBar"); + #endif +} +//! destructor +CGUILoadBar::~CGUILoadBar() +{ + +} + +void CGUILoadBar::draw() +{ + if (!IsVisible) + return; + IGUISkin* skin = Environment->getSkin(); + irr::video::IVideoDriver* driver = Environment->getVideoDriver(); + + if (Border) + { + BorderRect.LowerRightCorner.Y = BorderRect.UpperLeftCorner.Y + 1; + driver->draw2DRectangle(skin->getColor(EGDC_3D_SHADOW), BorderRect, &AbsoluteBorderRect); + + BorderRect.LowerRightCorner.Y = AbsoluteBorderRect.LowerRightCorner.Y; + BorderRect.LowerRightCorner.X = BorderRect.UpperLeftCorner.X + 1; + driver->draw2DRectangle(skin->getColor(EGDC_3D_SHADOW), BorderRect, &AbsoluteBorderRect); + + BorderRect = AbsoluteBorderRect; + BorderRect.UpperLeftCorner.X = BorderRect.LowerRightCorner.X - 1; + driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), BorderRect, &AbsoluteBorderRect); + + BorderRect = AbsoluteBorderRect; + BorderRect.UpperLeftCorner.Y = AbsoluteBorderRect.LowerRightCorner.Y - 1; + BorderRect.LowerRightCorner.Y = AbsoluteBorderRect.LowerRightCorner.Y; + driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), BorderRect, &AbsoluteBorderRect); + + BorderRect = AbsoluteBorderRect; + BorderRect.UpperLeftCorner.X += 3; + } + + //if(Percent == 0) { return; } + MaxNum = AbsoluteBorderRect.LowerRightCorner.X - 1; + PercentNum = (Percent * MaxNum) / 100; + PercentNum += BorderRect.UpperLeftCorner.X; + + LoadRect = BorderRect; + LoadRect.UpperLeftCorner.X = BorderRect.UpperLeftCorner.X; + LoadRect.LowerRightCorner.X = PercentNum; + LoadRect.LowerRightCorner.Y -= 1; + + driver->draw2DRectangle(loadcolor,LoadRect,&AbsoluteBorderRect); + + + if(Percent == 100) + { isDone = true; } + + + IGUIElement::draw(); +} + +void CGUILoadBar::setVisible(bool v) +{ + isVisible = v; +} + +void CGUILoadBar::setPercent(s32 p) +{ + Percent = p; +} + +void CGUILoadBar::setColor(video::SColor color) +{ + loadcolor=color; +} + +s32 CGUILoadBar::getPercent() +{ + return Percent; +} + +bool CGUILoadBar::isComplete() +{ + return isDone; +} + + +} // end namespace gui +} // end namespace irr diff -Nauwr Irrlicht/CGUILoadBar.h IrrlichtK0.5/CGUILoadBar.h --- Irrlicht/CGUILoadBar.h 1970-01-01 01:00:00.000000000 +0100 +++ IrrlichtK0.5/CGUILoadBar.h 2005-05-29 14:17:37.000000000 +0200 @@ -0,0 +1,61 @@ +#ifndef __C_GUI_LOADBAR_H_INCLUDED__ +#define __C_GUI_LOADBAR_H_INCLUDED__ + +#include "IGUILoadBar.h" +#include "SColor.h" + + +namespace irr +{ +namespace gui +{ + class CGUILoadBar : public IGUILoadBar + { + public: + + //! constructor + CGUILoadBar(IGUIEnvironment* environment, IGUIElement* parent, core::rect rectangle,bool vis=true,s32 TotalNum=7, s32 id=-1); + + //! destructor + ~CGUILoadBar(); + + virtual void draw(); + + virtual void setVisible(bool v=true); + + virtual void setPercent(s32 p=0); + + virtual void setColor(video::SColor color); + + virtual s32 getPercent(); + + virtual bool isComplete(); + + private: + + // Percentage of loading bar. + s32 Percent; + s32 PercentNum; + s32 MaxNum; //The far right X pos of the border + + //Visible? + bool isVisible; + bool isDone; + + //Draw border? + bool Border; + core::rect BorderRect; + core::rect AbsoluteBorderRect; + + //Loading bar rectangle + core::rect LoadRect; + //Loading color + video::SColor loadcolor; + + }; + + +} // end namespace gui +} // end namespace irr + +#endif diff -Nauwr Irrlicht/include/IGUIEnvironment.h IrrlichtK0.5/include/IGUIEnvironment.h --- Irrlicht/include/IGUIEnvironment.h 2005-05-25 18:56:38.000000000 +0200 +++ IrrlichtK0.5/include/IGUIEnvironment.h 2005-05-29 14:06:33.000000000 +0200 @@ -40,6 +40,7 @@ class IGUIContextMenu; class IGUIComboBox; class IGUIToolBar; +class IGUILoadBar; //! GUI Environment. Used as factory and manager of all other GUI elements. class IGUIEnvironment : public IUnknown @@ -271,6 +272,13 @@ \param id is a s32 to identify the combo box. */ virtual IGUIComboBox* addComboBox(const core::rect& rectangle, IGUIElement* parent=0, s32 id=-1) = 0; + + //! Adds an loadbar element. + //! \return + //! Returns a pointer to the created loadbar. Returns 0 if an error occured. + //! This pointer should not be dropped. See IUnknown::drop() for more information. + virtual IGUILoadBar* addLoadBar(const core::rect& rectangle, + IGUIElement* parent=0, bool vis=true,s32 TotalNum=7, s32 id=-1) = 0; }; diff -Nauwr Irrlicht/include/IGUILoadBar.h IrrlichtK0.5/include/IGUILoadBar.h --- Irrlicht/include/IGUILoadBar.h 1970-01-01 01:00:00.000000000 +0100 +++ IrrlichtK0.5/include/IGUILoadBar.h 2005-05-29 14:02:37.000000000 +0200 @@ -0,0 +1,38 @@ +#ifndef __I_GUI_LOADBAR_H_INCLUDED__ +#define __I_GUI_LOADBAR_H_INCLUDED__ + +#include "IGUIElement.h" +#include "SColor.h" + +namespace irr +{ + +namespace gui +{ + class IGUILoadBar : public IGUIElement + { + public: + //! constructor + IGUILoadBar(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle,bool vis,s32 TotalNum) + : IGUIElement(EGUIET_LOADBAR, environment, parent, id, rectangle) {} + //! destructor + ~IGUILoadBar() {}; + + virtual void setVisible(bool v)=0; + + virtual void setPercent(s32 p)=0; + + virtual void setColor(video::SColor color)=0; + + virtual s32 getPercent()=0; + + virtual bool isComplete()=0; + + + }; + + +} // end namespace gui +} // end namespace irr + +#endif diff -Nauwr Irrlicht/include/EGUIElementTypes.h IrrlichtK0.5/include/EGUIElementTypes.h --- Irrlicht/include/EGUIElementTypes.h 2005-11-29 15:56:22.199099792 +0100 +++ IrrlichtK0.5/include/EGUIElementTypes.h 2005-11-29 15:56:38.770758292 +0100 @@ -68,6 +68,9 @@ //! A window EGUIET_WINDOW, + //! A LoadBar + EGUIET_LOADBAR, + //! Not an element, amount of elements in there EGUIET_COUNT };