Advanced GUI-System (Scripting/vector based graphics)

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
badday
Posts: 102
Joined: Mon Aug 16, 2010 1:14 pm

Re: Advanced GUI-System (Scripting/vector based graphics)

Post by badday »

In short - Irrlicht 1.5 is really, really outdated. Please update - we don't have the manpower to keep on backporting bugfixes into such old revisions.
OK, so I followed your advice and updated to version 1.7.2. Unfortunately the problem remains the same :(
But I think your problem is (if I understand you correct), that it also tries to read attributes for the parent? Which it shouldn't I guess.
That´s exactly what I assume, too.

Here is the updated callstack with new line-numbers, maybe you can have a look at it:

Code: Select all

        Irrlicht.dll!irr::gui::IGUIElement::setVisible(bool visible=false)  Line 354    C++
        Irrlicht.dll!irr::gui::IGUIElement::deserializeAttributes(irr::io::IAttributes * in=0x02bd7480, irr::io::SAttributeReadWriteOptions * options=0x00000000)  Line 741 + 0x3b bytes        C++
        Irrlicht.dll!irr::gui::CGUIStaticText::deserializeAttributes(irr::io::IAttributes * in=0x02bd7480, irr::io::SAttributeReadWriteOptions * options=0x00000000)  Line 449  C++
>       Irrlicht.dll!irr::gui::CGUIEnvironment::readGUIElement(irr::io::IIrrXMLReader<wchar_t,irr::IReferenceCounted> * reader=0x02bd65b0, irr::gui::IGUIElement * node=0x02bdc818)  Line 849 + 0x2d bytes      C++
        Irrlicht.dll!irr::gui::CGUIEnvironment::loadGUI(irr::io::IReadFile * file=0x02bfa648, irr::gui::IGUIElement * parent=0x02bdc818)  Line 789 + 0x1a bytes C++
        Irrlicht.dll!irr::gui::CGUIEnvironment::loadGUI(const irr::core::string<char,irr::core::irrAllocator<char> > & filename={...}, irr::gui::IGUIElement * parent=0x02bdc818)  Line 760 + 0x1a bytes        C++
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Advanced GUI-System (Scripting/vector based graphics)

Post by CuteAlien »

badday wrote:
In short - Irrlicht 1.5 is really, really outdated. Please update - we don't have the manpower to keep on backporting bugfixes into such old revisions.
OK, so I followed your advice and updated to version 1.7.2. Unfortunately the problem remains the same :(
Ok, but at least you're now using a version where I no longer think it's an old bug which got fixed already. And it did change some checks for exactly that case since 1.5 - so I rather suspected this to be the problem. I hope you don't accidentally still link to the old version.

My problem now - I need a test to reproduce this. If you already have one to reproduce this it would help, otherwise you will have to wait until I find the time to write one.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
badday
Posts: 102
Joined: Mon Aug 16, 2010 1:14 pm

Re: Advanced GUI-System (Scripting/vector based graphics)

Post by badday »

I hope you don't accidentally still link to the old version.
I don`t think so.
If you already have one to reproduce this it would help
I have not tested this simple test, but I think it should work:

Code: Select all

#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
 
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
 
 
int main()
{
        
        IrrlichtDevice *device =
                createDevice( video::EDT_OPENGL, dimension2d<u32>(640, 480), 16,
                        false, false, false, 0);
 
        if (!device)
                return 1;
 
        
        device->setWindowCaption(L"TEST");
 
        IVideoDriver* driver = device->getVideoDriver();
        ISceneManager* smgr = device->getSceneManager();
        IGUIEnvironment* guienv = device->getGUIEnvironment();
        gui::IGUIStaticText *tex = GetGUIEnv()->addStaticText(L"", core::rect<s32>(core::vector2di(0,0),dimension2d<u32>(640, 480)));
        tex->setVisible(true);
        guienv->loadGUI(L"./irrlicht_example.xml", tex);
        smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
 
        
        while(device->run())
        {       
                driver->beginScene(true, true, SColor(255,100,101,140));
 
                smgr->drawAll();
                guienv->drawAll();
 
                driver->endScene();
        }
        
        device->drop();
        return 0;
}
And irrlicht_example.xml is:
badday
Posts: 102
Joined: Mon Aug 16, 2010 1:14 pm

Re: Advanced GUI-System (Scripting/vector based graphics)

Post by badday »

Code: Select all

<?xml version="1.0"?>
<irr_gui>
 
        <attributes>
                <enum name="Skin" value="windowsMetallic" />
                <color name="3DDarkShadow" value="65323232" />
                <color name="3DShadow" value="65828282" />
                <color name="3DFace" value="65d2d2d2" />
                <color name="3DHighlight" value="65ffffff" />
                <color name="3DLight" value="65d2d2d2" />
                <color name="ActiveBorder" value="65100e73" />
                <color name="ActiveCaption" value="c8ffffff" />
                <color name="AppWorkspace" value="65646464" />
                <color name="ButtonText" value="ffff8000" />
                <color name="GrayText" value="ff804000" />
                <color name="Highlight" value="6508246b" />
                <color name="HighlightText" value="f0ffffff" />
                <color name="InactiveBorder" value="65a5a5a5" />
                <color name="InactiveCaption" value="65d2d2d2" />
                <color name="ToolTip" value="c8000000" />
                <color name="ToolTipBackground" value="c8ffffe1" />
                <color name="ScrollBar" value="65e6e6e6" />
                <color name="Window" value="65ffffff" />
                <color name="WindowSymbol" value="c80a0a0a" />
                <color name="Icon" value="c8ffffff" />
                <color name="IconHighlight" value="c808246b" />
                <int name="ScrollBarSize" value="14" />
                <int name="MenuHeight" value="30" />
                <int name="WindowButtonWidth" value="15" />
                <int name="CheckBoxWidth" value="18" />
                <int name="MessageBoxWidth" value="500" />
                <int name="MessageBoxHeight" value="200" />
                <int name="ButtonWidth" value="80" />
                <int name="ButtonHeight" value="30" />
                <int name="TextDistanceX" value="2" />
                <int name="TextDistanceY" value="0" />
                <stringw name="MessageBoxOkay" value="OK" />
                <stringw name="MessageBoxCancel" value="Cancel" />
                <stringw name="MessageBoxYes" value="Yes" />
                <stringw name="MessageBoxNo" value="No" />
                <stringw name="WindowButtonClose" value="Close" />
                <stringw name="WindowButtonMaximize" value="Maximize" />
                <stringw name="WindowButtonMinimize" value="Minimize" />
                <stringw name="WindowButtonRestore" value="Restore" />
                <int name="windowMaximize" value="225" />
                <int name="windowRestore" value="226" />
                <int name="windowClose" value="227" />
                <int name="windowMinimize" value="228" />
                <int name="windowResize" value="242" />
                <int name="cursorUp" value="229" />
                <int name="cursorDown" value="230" />
                <int name="cursorLeft" value="231" />
                <int name="cursorRight" value="232" />
                <int name="menuMore" value="232" />
                <int name="checkBoxChecked" value="233" />
                <int name="dropDown" value="234" />
                <int name="smallCursorUp" value="235" />
                <int name="smallCursorDown" value="236" />
                <int name="radioButtonChecked" value="237" />
                <int name="moreLeft" value="238" />
                <int name="moreRight" value="239" />
                <int name="moreUp" value="240" />
                <int name="moreDown" value="241" />
                <int name="expand" value="243" />
                <int name="collapse" value="244" />
                <int name="file" value="245" />
                <int name="directory" value="246" />
        </attributes>
 
        <element type="button">
 
                <attributes>
                        <int name="Id" value="101" />
                        <stringw name="Caption" value="EXAMPLE" />
                        <rect name="Rect" value="840, 692, 973, 716" />
                        <position name="MinSize" value="1, 1" />
                        <position name="MaxSize" value="0, 0" />
                        <enum name="LeftAlign" value="upperLeft" />
                        <enum name="RightAlign" value="upperLeft" />
                        <enum name="TopAlign" value="upperLeft" />
                        <enum name="BottomAlign" value="upperLeft" />
                        <bool name="Visible" value="true" />
                        <bool name="Enabled" value="true" />
                        <bool name="TabStop" value="true" />
                        <bool name="TabGroup" value="false" />
                        <int name="TabOrder" value="1" />
                        <bool name="NoClip" value="false" />
                        <stringw name="ToolTipText" value="Some text" />
                        <bool name="PushButton" value="false" />
                        <bool name="Border" value="true" />
                        <bool name="UseAlphaChannel" value="false" />
                        <bool name="ScaleImage" value="false" />
                        <enum name="State" value="buttonNormal" />
                        <texture name="buttonNormal_Image" value="" />
                        <rect name="buttonNormal_ImageRect" value="0, 0, 500, 600" />
                        <bool name="buttonNormal_UseStateColor" value="false" />
                        <color name="buttonNormal_StateColor" value="ff000000" />
                        <texture name="buttonPressed_Image" value="" />
                        <rect name="buttonPressed_ImageRect" value="0, 0, 0, 0" />
                        <bool name="buttonPressed_UseStateColor" value="false" />
                        <color name="buttonPressed_StateColor" value="ff000000" />
                        <texture name="buttonFocused_Image" value="" />
                        <rect name="buttonFocused_ImageRect" value="0, 0, 0, 0" />
                        <bool name="buttonFocused_UseStateColor" value="false" />
                        <color name="buttonFocused_StateColor" value="ff000000" />
                        <texture name="buttonMouseOver_Image" value="" />
                        <rect name="buttonMouseOver_ImageRect" value="0, 0, 0, 0" />
                        <bool name="buttonMouseOver_UseStateColor" value="false" />
                        <color name="buttonMouseOver_StateColor" value="ff000000" />
                </attributes>
 
        </element>      
 
badday
Posts: 102
Joined: Mon Aug 16, 2010 1:14 pm

Re: Advanced GUI-System (Scripting/vector based graphics)

Post by badday »

Code: Select all

<element type="table">
 
                <attributes>
                        <int name="Id" value="103" />
                        <stringw name="Caption" value="Table" />
                        <rect name="Rect" value="100, 70, 930, 200" />
                        <position name="MinSize" value="1, 1" />
                        <position name="MaxSize" value="0, 0" />
                        <enum name="LeftAlign" value="upperLeft" />
                        <enum name="RightAlign" value="upperLeft" />
                        <enum name="TopAlign" value="upperLeft" />
                        <enum name="BottomAlign" value="upperLeft" />
                        <bool name="Visible" value="true" />
                        <bool name="Enabled" value="true" />
                        <bool name="TabStop" value="false" />
                        <bool name="TabGroup" value="false" />
                        <int name="TabOrder" value="-1" />
                        <bool name="NoClip" value="false" />
                        <stringw name="ToolTipText" value="" />
                        <int name="ColumnCount" value="0" />
                        <int name="RowCount" value="0" />
                        <bool name="Clip" value="true" />
                        <bool name="DrawBack" value="false" />
                        <bool name="MoveOverSelect" value="false" />
                        <bool name="ResizableColumns" value="true" />
                        <int name="CellWidthPadding" value="5" />
                        <int name="CellHeightPadding" value="2" />
                        <enum name="CurrentOrdering" value="none" />
                        <int name="DrawFlags" value="7" />
                </attributes>
 
        </element>
 
        <element type="staticText">
 
                <attributes>
                        <int name="Id" value="104" />
                        <stringw name="Caption" value="INFO" />
                        <rect name="Rect" value="102, 50, 300, 65" />
                        <position name="MinSize" value="1, 1" />
                        <position name="MaxSize" value="0, 0" />
                        <enum name="LeftAlign" value="upperLeft" />
                        <enum name="RightAlign" value="upperLeft" />
                        <enum name="TopAlign" value="upperLeft" />
                        <enum name="BottomAlign" value="upperLeft" />
                        <bool name="Visible" value="true" />
                        <bool name="Enabled" value="true" />
                        <bool name="TabStop" value="false" />
                        <bool name="TabGroup" value="false" />
                        <int name="TabOrder" value="-1" />
                        <bool name="NoClip" value="false" />
                        <stringw name="ToolTipText" value="" />
                        <bool name="Border" value="false" />
                        <bool name="OverrideColorEnabled" value="false" />
                        <bool name="WordWrap" value="true" />
                        <bool name="Background" value="false" />
                        <color name="OverrideColor" value="65ffffff" />
                        <enum name="HTextAlign" value="upperLeft" />
                        <enum name="VTextAlign" value="upperLeft" />
                </attributes>
 
        </element>
 
        
 
badday
Posts: 102
Joined: Mon Aug 16, 2010 1:14 pm

Re: Advanced GUI-System (Scripting/vector based graphics)

Post by badday »

Code: Select all

<element type="staticText">
 
                <attributes>
                        <int name="Id" value="105" />
                        <stringw name="Caption" value="THIS AND THAT" />
                        <rect name="Rect" value="418, 20, 720, 35" />
                        <position name="MinSize" value="1, 1" />
                        <position name="MaxSize" value="0, 0" />
                        <enum name="LeftAlign" value="upperLeft" />
                        <enum name="RightAlign" value="upperLeft" />
                        <enum name="TopAlign" value="upperLeft" />
                        <enum name="BottomAlign" value="upperLeft" />
                        <bool name="Visible" value="true" />
                        <bool name="Enabled" value="true" />
                        <bool name="TabStop" value="false" />
                        <bool name="TabGroup" value="false" />
                        <int name="TabOrder" value="-1" />
                        <bool name="NoClip" value="false" />
                        <stringw name="ToolTipText" value="" />
                        <bool name="Border" value="false" />
                        <bool name="OverrideColorEnabled" value="false" />
                        <bool name="WordWrap" value="true" />
                        <bool name="Background" value="false" />
                        <color name="OverrideColor" value="65ffffff" />
                        <enum name="HTextAlign" value="upperLeft" />
                        <enum name="VTextAlign" value="upperLeft" />
                </attributes>
 
        </element>
 
</irr_gui>
 
I hope I didn´t miss anything. Thanks again for your help ;)

(Had to split answer up as I got server error 500 otherwise)
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Advanced GUI-System (Scripting/vector based graphics)

Post by CuteAlien »

Lol, you know you could simply have kicked out a few element from the xml? First get one working, then the next step ;-)

Anyway - the problem is the handling of the root-element of the xml. "irr_gui" can't be used when you serialize into another parent than the usual root (CGUIEnvironment is the usual root). But it seems it's already handled correctly when it has no attributes. So what you have to do is to remove the first attributes block - as that is serialization info for the skin which can only be used by CGUIEnvironment.

Also help yourself and set up a test-project where you can easy test such simple examples. The way I do is that I have one folder parallel to the irrlicht example folders for this. That folder works like the examples (I started by copying one) - so it has a Makefile and project files that just work with a single main.cpp. And each time I test something I name it main.cpp, copy it into that folder and can then do simple tests. And once it runs I rename the main.cpp in case I need it later again. Then you can do a quick-test if it really compiles&runs before asking others for help.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
badday
Posts: 102
Joined: Mon Aug 16, 2010 1:14 pm

Re: Advanced GUI-System (Scripting/vector based graphics)

Post by badday »

Lol, you know you could simply have kicked out a few element from the xml?
Surely, but I thought it might make sense if the behaviour would have been element-type-dependent.
So what you have to do is to remove the first attributes block
OK, that really solved that problem, now GUI is shown.

I´m still not sure which alignment-values I have to set for the child elements. I tried Left and Top-align to be upperLeft and the others to be scale or lowerRight, neither showed an effect. Do I have to set values for my root or different alignment-values for the childs? Do I maybe have to recalculate sizes and positions manually?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Advanced GUI-System (Scripting/vector based graphics)

Post by CuteAlien »

You have to set alignment values for the childs to tell them how they should behave when their parent is resized. So in your case whenever tex is resized all the elements in your xml will behave according to their alignment settings.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
badday
Posts: 102
Joined: Mon Aug 16, 2010 1:14 pm

Re: Advanced GUI-System (Scripting/vector based graphics)

Post by badday »

Ah, OK, I had to resize tex afterwards. My gui-files use a certain resolution per default, so here is the working piece of code:

Code: Select all

//our root
gui::IGUIStaticText *tex = GetGUIEnv()->addStaticText(L"", core::rect<s32>(0,0,1024,768));
tex->setVisible(true);          
//load the gui file and use our root as parent  
GetGUIEnv()->loadGUI(filepath.c_str(), tex);    
//resize our root to the size our user wants to have
tex->setMaxSize(options.Screen);
tex->setMinSize(options.Screen);
Thanks a lot, CuteAlien for being so kind to help me :)
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Advanced GUI-System (Scripting/vector based graphics)

Post by CuteAlien »

Instead of using setMaxSize+setMinSize for resizing you should use setRelativePosition. The other can do this as side-effect, but they are mainly here to work in combination with the alignment values. So you can say - resize with parent, but maximal up to setMaxSize. Or never make an element smaller than setMinSIze on resizing.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply