it doesn't seem as if anyone would care but i tried improving Klaskers ImageGUI in the last days.
I now reads from zip file holding a xml and all the textures. Also it is easier to inegrate as you now only need that one Class not others to load the config.
The skin-file can also load fonts and smiliar.
I would like this to get as Irrlicht-friendly as possible and see it in vanillla irrlicht, but I don't know what bitplane thinks about such a ImageGUI.
This is how creating the skin looks like
Code: Select all
skin = new irr::gui::CImageGUISkin(irrGui , "default.skin");
irrGui->setSkin(skin);
Code: Select all
CImageGUISkin::CImageGUISkin( IGUIEnvironment* guiEnv, core::stringc filePath)
{
VideoDriver = guiEnv->getVideoDriver();
FallbackSkin = guiEnv->getSkin();
FallbackSkin->grab();
//! Load the config
guiEnv->getFileSystem()->addZipFileArchive(filePath.c_str());
io::IXMLReader* xml = guiEnv->getFileSystem()->createXMLReader("guiskin.xml");
//! Pointer to the current style
SImageGUIElementStyle* currentElement = 0;
while(xml && xml->read())
{
switch(xml->getNodeType())
{
case io::EXN_ELEMENT:
{
//! New Element to read
if(core::stringw("element") == xml->getNodeName())
{
core::stringw name = xml->getAttributeValue(L"name");
if(name == core::stringw("SunkenPane"))
currentElement = &Config.SunkenPane;
else if(name == core::stringw("Window"))
currentElement = &Config.Window;
else if(name == core::stringw("Button"))
currentElement = &Config.Button;
else if(name == core::stringw("ButtonPressed"))
currentElement = &Config.ButtonPressed;
else if(name == core::stringw("ProgressBar"))
currentElement = &Config.ProgressBar;
else if(name == core::stringw("ProgressBarFilled"))
currentElement = &Config.ProgressBarFilled;
}
else if(core::stringw("dstBorder") == xml->getNodeName())
{
if(currentElement)
{
currentElement->DstBorder.Top = xml->getAttributeValueAsInt(L"top");
currentElement->DstBorder.Left = xml->getAttributeValueAsInt(L"left");
currentElement->DstBorder.Bottom = xml->getAttributeValueAsInt(L"bottom");
currentElement->DstBorder.Right = xml->getAttributeValueAsInt(L"right");
}
}
else if(core::stringw("srcBorder") == xml->getNodeName())
{
if(currentElement)
{
currentElement->SrcBorder.Top = xml->getAttributeValueAsInt(L"top");
currentElement->SrcBorder.Left = xml->getAttributeValueAsInt(L"left");
currentElement->SrcBorder.Bottom = xml->getAttributeValueAsInt(L"bottom");
currentElement->SrcBorder.Right = xml->getAttributeValueAsInt(L"right");
}
}
else if(core::stringw("srcBorder") == xml->getNodeName())
{
if(currentElement)
{
currentElement->SrcBorder.Top = xml->getAttributeValueAsInt(L"top");
currentElement->SrcBorder.Left = xml->getAttributeValueAsInt(L"left");
currentElement->SrcBorder.Bottom = xml->getAttributeValueAsInt(L"bottom");
currentElement->SrcBorder.Right = xml->getAttributeValueAsInt(L"right");
}
}
else if(core::stringw("color") == xml->getNodeName())
{
if(currentElement)
{
currentElement->Color = video::SColor(
xml->getAttributeValueAsInt(L"alpha"),
xml->getAttributeValueAsInt(L"red"),
xml->getAttributeValueAsInt(L"green"),
xml->getAttributeValueAsInt(L"blue"));
}
}
else if(core::stringw("texture") == xml->getNodeName())
{
if(currentElement)
{
currentElement->Texture = VideoDriver->getTexture( core::stringc( xml->getAttributeValue(L"file") ).c_str() );
}
}
else if(core::stringw("font") == xml->getNodeName())
{
irr::gui::IGUIFont* font = guiEnv->getFont( core::stringc( xml->getAttributeValue(L"file") ).c_str() );
if(font)
{
if(core::stringw("default") == xml->getAttributeValue(L"type"))
this->setFont(font, EGDF_DEFAULT);
else if(core::stringw("button") == xml->getAttributeValue(L"type"))
this->setFont(font, EGDF_BUTTON);
else if(core::stringw("window") == xml->getAttributeValue(L"type"))
this->setFont(font, EGDF_WINDOW);
else if(core::stringw("menu") == xml->getAttributeValue(L"type"))
this->setFont(font, EGDF_MENU);
else if(core::stringw("tooltip") == xml->getAttributeValue(L"type"))
this->setFont(font, EGDF_TOOLTIP);
}
}
break;
}
case io::EXN_ELEMENT_END:
{
//! Finished reading one elemnt
if(core::stringw("element") == xml->getNodeName())
currentElement = 0;
break;
}
case io::EXN_TEXT:
case io::EXN_NONE:
case io::EXN_COMMENT:
case io::EXN_CDATA:
case io::EXN_UNKNOWN:
break;
}
}
if(xml)
xml->drop();
}http://uploaded.to/?id=7phyd7
Greets,
Halan
Ps: As i mentioned in the other threads. I would like to have sperate methods to draw CheckBoxes and LoadingBars. Also im wondering if clipRects.h is still needed as Klaskers calls it a bug-fix.
EDIT: i just saw that theres still a defenition of loadConfig in the header. You can remove that as it isn't needed anymore.