This worked Perfectly. Here is the code I used for anyone else that might need to use it.
My Handler class:
Code: Select all
Public Class CHandler
Implements Irrlicht.IEventReceiver
Public Function OnEvent(ByVal e As Irrlicht.Event) As Boolean Implements Irrlicht.IEventReceiver.OnEvent
''Handle all of the GUI related events
If e.Type = Irrlicht.EventType.GUIEvent Then
''Store the event's ID
Dim id As Integer = e.GUIEventCaller.ID
''See what kind of event was executed
Select Case e.GUIEventType
''A button was clicked
Case Irrlicht.GUI.GUIEvent.BUTTON_CLICKED
''1001 = MainMenu.Play Game
If id = 1001 Then
MessageBox.Show("Test!")
''1003 = MainMenu.Quit
ElseIf id = 1003 Then
''If true the engine closes the rendering device and the application ends
Menus.MainMenu.Disable()
RenderingDevice.bQuiting = True
End If
End Select
End If
End Function
End Class
My Menu class, this will contain a seperate class for each menu i need created.
Code: Select all
Public Class CMenus
''All of the menu classes
Public MainMenu As New CMainMenu
'Public OptionsMenu as New COptionsMenu
''So we can check which menu is loaded, and skip creating with each of the engines loop cycles
Public CurrentMenu As String = ""
Public Environment As Irrlicht.GUI.IGUIEnvironment
''Sends the Rendering Devices gui environment back to the caller
''Each menu will have it's own environment to modify
Public Function SetEnvironment() As Irrlicht.GUI.IGUIEnvironment
Return RenderingDevice.device.GUIEnvironment
End Function
Public Sub disableMenu()
Environment.RootGUIElement.Visible = False
End Sub
End Class
And then my main menu code.
Code: Select all
Public Class CMainMenu
'Inherits CMenus
''Allows me to show\hide the gui when i want to
Public env As GUI.IGUIEnvironment
Public Sub Show()
Dim Background As Irrlicht.Video.ITexture = RenderingDevice.device.VideoDriver.GetTexture("Background.jpg")
Dim pos As New Position2D
pos.X = RenderingDevice.device.VideoDriver.ScreenSize.Width / 4 * 3
pos.Y = RenderingDevice.device.VideoDriver.ScreenSize.Height / 2
Menus.CurrentMenu = "MainMenu"
env = Menus.SetEnvironment
''disable the camera
CameraFPS.disable(RenderingDevice.device)
''enable the cursor
RenderingDevice.device.CursorControl.Visible = True
''start displaying the objects
' Dim window As Irrlicht.GUI.IGUIElement = Menus.Environment.AddWindow(New Rect(New Position2D(800, 600), New Dimension2D(800, 600)), False, "Trinity", RenderingDevice.device.GUIEnvironment.RootGUIElement, 1000)
''background
env.AddImage(Background, New Position2D(0, 0), False, env.RootGUIElement, 100, Nothing)
''Play game button
env.AddButton(New Rect(pos, New Dimension2D(98, 24)), env.RootGUIElement, 1001, "Play Game")
''options button
pos.Y += pos.Y / 8
RenderingDevice.device.GUIEnvironment.AddButton(New Rect(pos, New Dimension2D(98, 24)), env.RootGUIElement, 1002, "Options")
''Quit button
pos.Y += pos.Y / 8
RenderingDevice.device.GUIEnvironment.AddButton(New Rect(pos, New Dimension2D(98, 24)), env.RootGUIElement, 1003, "Quit")
End Sub
Public Sub Disable()
env.RootGUIElement.Visible = False
End Sub
End Class
Thanks again for all the help!