Topic: Bugs with addGUIElement

Hello, please, help me smile I'm dont know - this is my error or bug with Irrlicht?

    Field element:IGUIElement, element_name:String
    Field button:IGUIButton[16] , checkbox:IGUICheckBox[16] , colorselectdialog:IGUIColorSelectDialog
    Field combobox:IGUIComboBox[4] , contextmenu:IGUIContextMenu[2] , editbox:IGUIEditBox[16] 
    Field fileopendialog:IGUIFileOpenDialog, image:IGUIImage[32] , inoutfader:IGUIInOutFader[4] 
    Field listbox:IGUIListBox[4] , meshviewer:IGUIMeshViewer[2] , scrollbar:IGUIScrollBar[4] 
    Field statictext:IGUIStaticText[32] , tab:IGUITab[4] , tabcontrol:IGUITabControl[4] 
    Field toolbar:IGUIToolBar[2] , iwindow:IGUIWindow[2] 
Global TGUI_list:TList = New TList

Function Generate_GUI(file_url:String, name_element:String) 
    Local button_var:Int

    Local gui:TGUI = New TGUI
    TGUI_list.AddLast gui
    gui.element_name = name_element:String
    gui.element = env.addGUIElement(gui.element_name) 
    If gui.element = Null
    DebugLog gui.element_name + " ^ Null"
    gui.element.setMinSize(_DIMENSION2DI(app_vars:Int[graphics_width] , app_vars:Int[graphics_height] )) 
    Local xml:TXml = New TXml
    TXml_list.Addlast xml
    xml.file:IXMLReaderUTF8 = current_filesystem.createXMLReaderUTF8(file_url:String) 
        Select xml.file.getNodeType() 
            Case EXN_ELEMENT
                Select xml.file.getNodeName() 
                    Case "gui"
                        Select xml.file.getAttributeValue("type_gui") 
                            Case "button"
                                gui.button[button_var] = env.addButton(_RECTI(Int(xml.file.getAttributeValue("x1")), Int(xml.file.getAttributeValue("y1")), Int(xml.file.getAttributeValue("x2")), Int(xml.file.getAttributeValue("y2"))), gui.element, Int(xml.file.getAttributeValue("id")), xml.file.getAttributeValue("text"), xml.file.getAttributeValue("tooltip")) 
                                DebugLog "button"
                        xml.nodename:String = xml.file.getNodeName() 
                End Select
            Case EXN_TEXT
                Select xml.nodename:String
                    Case "gui"
                        DebugLog xml.file.getNodeData() 
                End Select 
        End Select

On this line:

gui.element.setMinSize(_DIMENSION2DI(app_vars:Int[graphics_width] , app_vars:Int[graphics_height] ))

show this error:

Compiling:main.bmx flat assembler  version 1.67.23  (316651 kilobytes memory)
4 passes, 0.1 seconds, 56317 bytes.
Linking:main.exe Irrlicht Engine version 1.3.1
Microsoft Windows XP Professional Service Pack 2 (Build 2600)
Using renderer: Direct3D 9.0
S3 Graphics Savage/IX 1014 s3gsavmx.dll
DebugLog:test ^ Null
--?BlitzMax Debug Report:
Unhandled Exception:Attempt to access field or method of Null object

Re: Bugs with addGUIElement

greetings smile  what is your call to Generate_GUI() look like?

Re: Bugs with addGUIElement

I'm now to make 3d strategy ( without ambitious smile ) and all options, texts, etc read from XML. Also and GUI - i'm load from XML all buttons, checkbox etc. Function Generate_GUI simple created in lists new list smile and into this new list added all button with element. After, i'm simple make invisible need me element ( and him child as buttons, checkbox etc) and to visible other element ( with child). You think? I'm dont know, thaht i'm write up smile

Re: Bugs with addGUIElement

i see in your debugout the element_name is "test".  the element name must be one of the following:


XML is a good format for that type of thing.  good luck! smile

5 (edited by Serge Petrowski 2007-09-23 21:41:49)

Re: Bugs with addGUIElement

Oops, i'm think, thaht IGUIElement is simple containter for many buttons, combobox etc. smile Thanx! I'm now use "modalScreen", again big thanx! smile