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 »

Ok, just seeing you set your element to invisible - which means all it's child will not be visible as well. If you want a not-visible element which still acts as parent then use a static-text without background drawing
OK, so I changed the hole thing to:

Code: Select all

gui::IGUIStaticText *tex = GetGUIEnv()->addStaticText(L"", core::rect<s32>(core::vector2di(0,0), options.Screen));
GetGUIEnv()->loadGUI(filepath.c_str(), tex);
loadGUI() just reads the .xml-file and adds the gui elements accordingly. If I don´t use that, no element are loaded I think.
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 »

Yeah, I suppose it does that. I just wasn't sure before if it causes any troubles, but it was the setVisible(false) I had missed. What I meant was - for testing you can also add gui-elements manually in code. That reduces the places where it can go wrong until it works.
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 »

Anyway, it doesn´t seem to work. Are you sure this is the right way to scale the gui? I just wonder why this isn´t done automatically when a device with a certain size is created...
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 »

I don't know _what_ is not working. It does not scale automatically - what it does depends on alignment settings as I wrote - unless you set those correct for each element it will just have it's defaults which are not scale but staying in position relative to left-top. If you have a child with alignment set to scale and you scale it's parent element then yes - I'm pretty sure the child will scale.
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 »

what it does depends on alignment settings as I wrote
I think those are correct, let me make a concrete example:

Code: Select all

<element type="image">
 
                <attributes>
                        <int name="Id" value="10" />
                        <stringw name="Caption" value="" />
                        <rect name="Rect" value="0, 0, 1024, 768" />
                        <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="" />
                        <texture name="Texture" value="image.png" />
                        <bool name="UseAlphaChannel" value="true" />
                        <color name="Color" value="ffffffff" />
                        <bool name="ScaleImage" value="true" />
                </attributes>
I think the alignments are set correctly and ScaleImage is also enabled. Is there anything wrong about this?
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 set all 4 alignment values to upperLeft, that means - all borders will stay in their position relative top the upperLeft corner. Which means no scaling. Try the others and watch how it changes:"lowerRight", "center", "scale".
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 tried some, but it seems as if there is still no GUI drawn. You said they stay in position, but wouldn´t that mean that I would be able to see them (also not scaled)?
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 »

Well - that has no effect on visibility. If that is still missing then solve that first! I already mentioned above that setVisible(false) which you used will make it invisible (well, what else...). Don't know if you still have that. And if not - try hardcoding it first before using xml-loading (also recommended above already) as that reduces the number of things that can go wrong.
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 already mentioned above that setVisible(false) which you used will make it invisible (well, what else...). Don't know if you still have that.
No, I don´t.
And if not - try hardcoding it first before using xml-loading (also recommended above already) as that reduces the number of things that can go wrong.
OK, you´re right. I tried to simple add a button manually (parent also tex). This works. But as soon as the GUI-file is loaded, this button is either deleted or invisible and no GUI is shown any more. I jumped into CGUIEnvironment::readGUIElement(io::IXMLReader* reader, IGUIElement* node) with the debugger, but the GUI elements are correctly created with tex as the root. Any ideas? (btw: thanks so far 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 »

Hm, I have to reproduce this first here. Can you tell me which Irrlicht version you are using? And might take a while - I have to finish something else first.
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 just saw that tex is invisible if I have a look at it in CGUIEnvironment::readGUIElement(io::IXMLReader* reader, IGUIElement* node) . This is stange somehow as I now even explicitly set it to be visible. Code looks like this:

Code: Select all

gui::IGUIStaticText *tex = GetGUIEnv()->addStaticText(L"", core::rect<s32>(core::vector2di(0,0), options.Screen));
tex->setVisible(true);
GetGUIEnv()->addButton(core::rect<s32>(core::vector2di(0,0), core::dimension2di(20,20)), tex);  
GetGUIEnv()->loadGUI(filepath.c_str(), tex);
If I don´t right the last line, I will see the button. If I do, I won´t.
Can you tell me which Irrlicht version you are using?
Surely, it´s 1.5.

EDIT:
I just figured out why that is the case:
If the parent get´s into CGUIEnvironment::readGUIElement(), it is handled just like a guiElement which is in the GUI-file. So within while(reader->read()), node->deserializeAttributes(attr); is called which set visibility to false. As this element is not part of the read file, FileSystem->createEmptyAttributes(Driver) is used to generate dummy values.

Here is the callstack:

Code: Select all

        Irrlicht.dll!irr::gui::IGUIElement::setVisible(bool visible=false)  Line 468    C++
        Irrlicht.dll!irr::gui::IGUIElement::deserializeAttributes(irr::io::IAttributes * in=0x03161638, irr::io::SAttributeReadWriteOptions * options=0x00000000)  Line 841 + 0x3b bytes        C++
        Irrlicht.dll!irr::gui::CGUIStaticText::deserializeAttributes(irr::io::IAttributes * in=0x03161638, irr::io::SAttributeReadWriteOptions * options=0x00000000)  Line 443  C++
>       Irrlicht.dll!irr::gui::CGUIEnvironment::readGUIElement(irr::io::IIrrXMLReader<wchar_t,irr::IReferenceCounted> * reader=0x031602b8, irr::gui::IGUIElement * node=0x0316b3b0)  Line 817 + 0x2d bytes      C++
        Irrlicht.dll!irr::gui::CGUIEnvironment::loadGUI(irr::io::IReadFile * file=0x0316c458, irr::gui::IGUIElement * parent=0x0316b3b0)  Line 757 + 0x1a bytes C++
        Irrlicht.dll!irr::gui::CGUIEnvironment::loadGUI(const char * filename=0x02bc6368, irr::gui::IGUIElement * parent=0x0316b3b0)  Line 728 + 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 »

setVisible should be set to the value which "Visible" has. But also note that new elements are always drawn on top - so maybe the elements you load hide the button?

And please consider updating - 1.5 is old. We're at 1.7.2 by now (and I recommend even using svn release branch for 1.7 which has a lot more bugfixes since then). Although I guess it's not your problem here.
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 »

setVisible should be set to the value which "Visible" has.
Yes, but isn´t this false after

Code: Select all

io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver);
attr->read(reader, true);
?
But also note that new elements are always drawn on top
The point is: I don´t see any GUI.

I think that really is the problem, as this code:

Code: Select all

gui::IGUIStaticText *tex = GetGUIEnv()->addStaticText(L"", core::rect<s32>(core::vector2di(0,0), options.Screen));
tex->setVisible(true);
GetGUIEnv()->addButton(core::rect<s32>(core::vector2di(0,0), core::dimension2di(20,20)), tex);
        
GetGUIEnv()->loadGUI(filepath.c_str(), tex);
tex->setVisible(true);
tex->setMinSize(options.Screen);
at least let´s me see a black screen instead of the colour I use at driver->beginScene(). May it be the case that I don´t see the rest of the GUI because when the children of my root are created, this is invisible and they inherit this value?


EDIT:
I also had to notice that the size was reset to a dummy value. Therefore I made some quick change to void CGUIEnvironment::readGUIElement(io::IXMLReader* reader, IGUIElement* node):

Code: Select all

case io::EXN_ELEMENT:
                        if (!wcscmp(L"attributes", reader->getNodeName()))
                        {
                                // read attributes
                                io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver);
                                
                                attr->read(reader, true);
                                attr->addBool("Visible", true); //!!!
                                attr->addRect("Rect", core::recti(0,0,800,600)); //!!!
                                
                                if (node)
                                        node->deserializeAttributes(attr);
 
                                
                                attr->drop();
                        }
After those changes, I can see the GUI again, so it there seems to be a strong link between my problem and that dummy-value-reset which seems to take place. Or am I wrong?
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:
setVisible should be set to the value which "Visible" has.
Yes, but isn´t this false after

Code: Select all

io::IAttributes* attr = FileSystem->createEmptyAttributes(Driver);
attr->read(reader, true);
?
It should have whatever value it reads in attr->read.
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.
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
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 »

I think it's this problem, fixed (already 3 years ago) here: http://irrlicht.svn.sourceforge.net/vie ... threv=2091

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.
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