From 36ac144842cd643b11afcf1db249c37dc9ab6075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ruben=20Mu=CC=88ller?= Date: Fri, 19 Aug 2011 14:46:13 +0200 Subject: [PATCH] Keyboard interaction with current menu-item done! --- pongr/pongr.pbp | 28 ++++++++++++++-------------- pongr/src/Events.pbi | 36 ++++++++++++++++++++++++++++++++---- pongr/src/Functions.pbi | 1 + pongr/src/Main.pb | 8 ++++---- pongr/src/Structs.pbi | 4 ++-- 5 files changed, 53 insertions(+), 24 deletions(-) create mode 100644 pongr/src/Functions.pbi diff --git a/pongr/pongr.pbp b/pongr/pongr.pbp index 700621c..2b381e8 100644 --- a/pongr/pongr.pbp +++ b/pongr/pongr.pbp @@ -1,8 +1,8 @@ - +
- + First project from Ruben and Aaron Mueller @@ -10,28 +10,28 @@
- +
- - + + - + - - + + - - + + - - + +
@@ -39,8 +39,8 @@ - - + +
diff --git a/pongr/src/Events.pbi b/pongr/src/Events.pbi index c86481d..8e98cd3 100644 --- a/pongr/src/Events.pbi +++ b/pongr/src/Events.pbi @@ -1,15 +1,43 @@ ; In this file, we handle alle the events Procedure HandleEventMenu() - If KeyboardReleased(#PB_Key_U) - Debug "U pressed" + Define ActiveMenu_Index.i = ListIndex(*ActiveMenu\Entries()) + + 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 EndProcedure Procedure HandleEventRunningGame() EndProcedure -; IDE Options = PureBasic 4.51 (Linux - x64) -; CursorPosition = 2 +; IDE Options = PureBasic 4.51 (MacOS X - x86) +; CursorPosition = 32 ; Folding = - ; EnableUnicode ; EnableThread diff --git a/pongr/src/Functions.pbi b/pongr/src/Functions.pbi new file mode 100644 index 0000000..5e9a352 --- /dev/null +++ b/pongr/src/Functions.pbi @@ -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 \ No newline at end of file diff --git a/pongr/src/Main.pb b/pongr/src/Main.pb index 9a33848..e3f40d7 100644 --- a/pongr/src/Main.pb +++ b/pongr/src/Main.pb @@ -7,6 +7,7 @@ EnableExplicit XIncludeFile "Structs.pbi" XIncludeFile "Globals.pbi" XIncludeFile "Draw.pbi" +XIncludeFile "Functions.pbi" XIncludeFile "Events.pbi" ; Initialize all the variables and stuff. I think we refactor this @@ -77,7 +78,6 @@ If InitSprite() = 0 Or InitKeyboard() = 0 End EndIf - ; 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. 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) Until KeyboardPushed(#PB_Key_Escape) EndIf -; IDE Options = PureBasic 4.51 (Linux - x64) -; CursorPosition = 37 -; FirstLine = 11 +; IDE Options = PureBasic 4.51 (MacOS X - x86) +; CursorPosition = 5 +; FirstLine = 4 ; EnableXP ; EnableCompileCount = 0 ; EnableBuildCount = 0 \ No newline at end of file diff --git a/pongr/src/Structs.pbi b/pongr/src/Structs.pbi index e4629d3..a974420 100644 --- a/pongr/src/Structs.pbi +++ b/pongr/src/Structs.pbi @@ -31,8 +31,8 @@ Structure GameMenu Title.s List Entries.GameMenuItem() EndStructure -; IDE Options = PureBasic 4.51 (Linux - x64) -; CursorPosition = 12 +; IDE Options = PureBasic 4.51 (MacOS X - x86) +; CursorPosition = 32 ; EnableUnicode ; EnableThread ; EnableXP