Keyboard interaction with current menu-item done!

This commit is contained in:
Ruben Müller 2011-08-19 14:46:13 +02:00
parent 232def5197
commit 36ac144842
5 changed files with 53 additions and 24 deletions

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.purebasic.com/namespace" version="1.0" creator="PureBasic 4.51 (Linux - x64)"> <project xmlns="http://www.purebasic.com/namespace" version="1.0" creator="PureBasic 4.51 (MacOS X - x86)">
<section name="config"> <section name="config">
<options closefiles="1" openmode="0" name="Pongr"/> <options closefiles="1" openmode="4" name="Pongr"/>
<comment> <comment>
First project from Ruben and Aaron Mueller First project from Ruben and Aaron Mueller
</comment> </comment>
@ -10,28 +10,28 @@
<section name="data"> <section name="data">
<explorer view="../../../" pattern="0"/> <explorer view="../../../" pattern="0"/>
<log show="1"/> <log show="1"/>
<lastopen date="2011-01-22 03:17" user="aaron" host="deskFu"/> <lastopen date="2011-08-18 12:51" user="rubenmueller" host="localhost"/>
</section> </section>
<section name="files"> <section name="files">
<file name="src/Main.pb"> <file name="src/Main.pb">
<config load="0" scan="1" panel="1" warn="1" lastopen="1"/> <config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
<fingerprint md5="29e4b25d47252dd54c24d6985d0e0b94"/> <fingerprint md5="d1f3164bb5fec7361255de01f9092ae7"/>
</file> </file>
<file name="src/Structs.pbi"> <file name="src/Structs.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1"/> <config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
<fingerprint md5="3f6fdbb23e900f0a334f07d26355f27f"/> <fingerprint md5="3f6fdbb23e900f0a334f07d26355f27f"/>
</file> </file>
<file name="src/Draw.pbi"> <file name="src/Draw.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1"/> <config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
<fingerprint md5="104d355e87b74fa0e87bef35d6f6d748"/> <fingerprint md5="9224465e12cc31c27a387b1e9d602a77"/>
</file> </file>
<file name="src/Events.pbi"> <file name="src/Events.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1"/> <config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
<fingerprint md5="938263b937dde78242133aac1b4dbb97"/> <fingerprint md5="9dd147e52792042f4e79268cca55cb49"/>
</file> </file>
<file name="src/Globals.pbi"> <file name="src/Globals.pbi">
<config load="0" scan="1" panel="1" warn="1" lastopen="1"/> <config load="0" scan="1" panel="1" warn="1" lastopen="0"/>
<fingerprint md5="768cb291ebd658155da6c8419e722db8"/> <fingerprint md5="5abb967324ded5ac249dc8b4ac43531a"/>
</file> </file>
</section> </section>
<section name="targets"> <section name="targets">
@ -39,8 +39,8 @@
<inputfile value="src/Main.pb"/> <inputfile value="src/Main.pb"/>
<outputfile value="build/pongr"/> <outputfile value="build/pongr"/>
<executable value="build/pongr"/> <executable value="build/pongr"/>
<options thread="1" xpskin="1" debug="1"/> <options thread="1" xpskin="1"/>
<compilecount enable="1" value="50"/> <compilecount enable="1" value="54"/>
<buildcount enable="1" value="4"/> <buildcount enable="1" value="4"/>
</target> </target>
</section> </section>

View file

@ -1,15 +1,43 @@
; In this file, we handle alle the events ; In this file, we handle alle the events
Procedure HandleEventMenu() Procedure HandleEventMenu()
If KeyboardReleased(#PB_Key_U) Define ActiveMenu_Index.i = ListIndex(*ActiveMenu\Entries())
Debug "U pressed"
If KeyboardReleased(#PB_Key_Up)
Menu_GotoCurrent()
*ActiveMenu\Entries()\Selected = #False
If ListIndex(*ActiveMenu\Entries()) = 0
LastElement(*ActiveMenu\Entries())
Else
PreviousElement(*ActiveMenu\Entries())
EndIf
*ActiveMenu\Entries()\Selected = #True
EndIf
If KeyboardReleased(#PB_Key_Down)
Menu_GotoCurrent()
*ActiveMenu\Entries()\Selected = #False
If ListIndex(*ActiveMenu\Entries()) = (ListSize(*ActiveMenu\Entries())-1)
FirstElement(*ActiveMenu\Entries())
Else
NextElement(*ActiveMenu\Entries())
EndIf
*ActiveMenu\Entries()\Selected = #True
EndIf
If KeyboardReleased(#PB_Key_Return)
Debug "Return!"
EndIf EndIf
EndProcedure EndProcedure
Procedure HandleEventRunningGame() Procedure HandleEventRunningGame()
EndProcedure EndProcedure
; IDE Options = PureBasic 4.51 (Linux - x64) ; IDE Options = PureBasic 4.51 (MacOS X - x86)
; CursorPosition = 2 ; CursorPosition = 32
; Folding = - ; Folding = -
; EnableUnicode ; EnableUnicode
; EnableThread ; EnableThread

1
pongr/src/Functions.pbi Normal file
View file

@ -0,0 +1 @@
; This file holds all the functions If it gets too big, ; we can split it in categories ; ***************************************************************************** ; * Menu Procedure Menu_GotoCurrent() If *ActiveMenu\Entries()\Selected <> #True FirstElement(*ActiveMenu\Entries()); ForEach *ActiveMenu\Entries() If *ActiveMenu\Entries()\Selected = #True Break EndIf Next EndIf EndProcedure ; ***************************************************************************** ; IDE Options = PureBasic 4.51 (MacOS X - x86) ; CursorPosition = 13 ; Folding = - ; EnableXP

View file

@ -7,6 +7,7 @@ EnableExplicit
XIncludeFile "Structs.pbi" XIncludeFile "Structs.pbi"
XIncludeFile "Globals.pbi" XIncludeFile "Globals.pbi"
XIncludeFile "Draw.pbi" XIncludeFile "Draw.pbi"
XIncludeFile "Functions.pbi"
XIncludeFile "Events.pbi" XIncludeFile "Events.pbi"
; Initialize all the variables and stuff. I think we refactor this ; Initialize all the variables and stuff. I think we refactor this
@ -77,7 +78,6 @@ If InitSprite() = 0 Or InitKeyboard() = 0
End End
EndIf EndIf
; Start the main loop which will create the window, wait for events and draw things ; Start the main loop which will create the window, wait for events and draw things
; on the screen. To escape from this loop, press ESC or close the window. ; on the screen. To escape from this loop, press ESC or close the window.
If OpenWindow(0, 0, 0, Screen\Width, Screen\Height, title, #PB_Window_ScreenCentered) If OpenWindow(0, 0, 0, Screen\Width, Screen\Height, title, #PB_Window_ScreenCentered)
@ -116,9 +116,9 @@ If OpenWindow(0, 0, 0, Screen\Width, Screen\Height, title, #PB_Window_ScreenCent
Delay(1) Delay(1)
Until KeyboardPushed(#PB_Key_Escape) Until KeyboardPushed(#PB_Key_Escape)
EndIf EndIf
; IDE Options = PureBasic 4.51 (Linux - x64) ; IDE Options = PureBasic 4.51 (MacOS X - x86)
; CursorPosition = 37 ; CursorPosition = 5
; FirstLine = 11 ; FirstLine = 4
; EnableXP ; EnableXP
; EnableCompileCount = 0 ; EnableCompileCount = 0
; EnableBuildCount = 0 ; EnableBuildCount = 0

View file

@ -31,8 +31,8 @@ Structure GameMenu
Title.s Title.s
List Entries.GameMenuItem() List Entries.GameMenuItem()
EndStructure EndStructure
; IDE Options = PureBasic 4.51 (Linux - x64) ; IDE Options = PureBasic 4.51 (MacOS X - x86)
; CursorPosition = 12 ; CursorPosition = 32
; EnableUnicode ; EnableUnicode
; EnableThread ; EnableThread
; EnableXP ; EnableXP