Topic: Reading two buttons at the same time.
I need the event receiver to read two or more buttons at the same time.
I know I post on here alot, and everyone has been great, but i'm still confused by the event receiver. The Irrlicht tutorials only demonstrate pressing one button at a time. So how could my code understand multiple input at the same time, including the GUI?
Thank you.
Global CNT:Int = 0
Global ListBox:T_irrIGUIListBox
Type MyEventReceiver Extends T_irrIEventReceiver
Method OnEvent:Int(event:T_irrSEvent)
'---------------- Input Events -----------------
If (event.GetEventType()=EET_KEY_INPUT_EVENT and event.GetKeyPressedDown()=True)
Local Key:Int=event.GetKeyInputKey()
Select Key
'Thrust
'Forward
Case EKEY_UP
' thrust:Int = 1
Return True
'Retro
Case EKEY_DOWN
' retro:Int = 1
Return True
'Action Primary
Case EKEY_SPACE
Ammo:-1
Return True
Default
Return False
EndSelect
EndIf
'----------------- GUI Events ------------------
If (event.GetEventType()=EET_GUI_EVENT)
Local id:Int = event.GetGUIEventCaller().GetID()
Local GUI:T_irrIGUIEnvironment = device.GetGUIEnvironment()
Local EvType:Int=event.GetGUIEventType()
Select EvType
rem
If a scrollbar changed its scroll position, And it is 'our'
scrollbar (the one with id 104), Then we change the
transparency of all gui elements. This is a very easy task:
There is a skin Object, in which all color settings are stored.
We simply go through all colors stored in the skin And change
their alpha value.
endrem
Case EGET_SCROLL_BAR_CHANGED
If (id = 104)
Local Pos:Int = T_irrIGUIScrollBar.CreateFromHandle(event.GetGUIEventCaller().handle,False).GetPos()
Local I:Int
For I=0 To EGDC_COUNT-1
Local Col:T_irrSColor = GUI.GetSkin().GetColor(I)
Col.SetAlpha(Pos)
GUI.GetSkin().SetColor(I,Col)
Next
EndIf
rem
If a button was clicked, it could be one of 'our'
three buttons. If it is the first, we shut down the engine.
If it is the second, we create a little window with some
text on it. We also add a String To the list box To Log
what happened. And If it is the third button, we create
a file open dialog, And add also this as String To the list box.
That's all for the event receiver.
endrem
Case EGET_BUTTON_CLICKED
If (id = 103)
device.CloseDevice()
Return True
EndIf
If (id = 102)
ListBox.AddItem("Window created")
CNT :+ 30
If (CNT > 200)
CNT = 0
EndIf
Local Window:T_irrIGUIWindow = GUI.AddWindow( ..
T_irrRect_S32.CreateFromVals(100 + CNT, 100 + CNT, 300 + CNT, 200 + CNT), ..
False, .. ' modal?
"Test window")
GUI.AddStaticText("Please close me", ..
T_irrRect_S32.CreateFromVals(35,35,140,50), ..
True, .. ' border?
False, .. ' wordwrap?
Window)
Return True
EndIf
If (id = 101)
ListBox.AddItem("File open");
GUI.AddFileOpenDialog("Please choose a file.")
Return True
EndIf
EndSelect
EndIf
Return False
EndMethod
' we must override the generate function in order for instantiation to work properly
' must return T_irrIEventReceiver
Function Generate:T_irrIEventReceiver()
Return T_irrIEventReceiver(New MyEventReceiver)
EndFunction
EndType