Initial commit
This commit is contained in:
161
Menu_old.pbi
Normal file
161
Menu_old.pbi
Normal file
@@ -0,0 +1,161 @@
|
||||
Declare InitGameMode(Mode.l)
|
||||
|
||||
Structure MenuOption
|
||||
X.f
|
||||
Y.f
|
||||
Width.l
|
||||
*ChoiceIndex
|
||||
ChoiceIndexType.l
|
||||
String.s
|
||||
Choices.s
|
||||
GoToMode.l
|
||||
SendGUIEvent.l
|
||||
EndStructure
|
||||
|
||||
Structure Menu
|
||||
MenuTitle.s
|
||||
*Obj
|
||||
X.f
|
||||
Y.f
|
||||
Width.l
|
||||
OptionIndex.l
|
||||
List MenuOption.MenuOption()
|
||||
EndStructure
|
||||
|
||||
Global Menu.Menu
|
||||
|
||||
Procedure NewMenu(MenuTitle.s,DefaultOptionIndex.l=0)
|
||||
Menu\MenuTitle=MenuTitle
|
||||
Menu\OptionIndex=DefaultOptionIndex
|
||||
ClearList(Menu\MenuOption())
|
||||
Menu\Obj=NewSprite(-1,0,0,0,0,255,1)
|
||||
EndProcedure
|
||||
|
||||
Procedure AddMenuOption(String.s,GoToMode.l=-1,SendGUIEvent.l=-1,Choices.s="",*ChoiceIndex=-1,ChoiceIndexType.l=#PB_Long)
|
||||
Protected *MenuOption=AddElement(Menu\MenuOption())
|
||||
Menu\MenuOption()\String=String
|
||||
Menu\MenuOption()\Choices=Choices
|
||||
Menu\MenuOption()\ChoiceIndex=*ChoiceIndex
|
||||
Menu\MenuOption()\ChoiceIndexType=ChoiceIndexType
|
||||
Menu\MenuOption()\GoToMode=GoToMode
|
||||
Menu\MenuOption()\SendGUIEvent=SendGUIEvent
|
||||
ProcedureReturn *MenuOption
|
||||
EndProcedure
|
||||
|
||||
Procedure StartMenu()
|
||||
Addmove(Menu\Obj,0,@Menu\Y,ScreenHeight(),GUI\BlockSize*2,2000,#Easing_ElasticEaseOut)
|
||||
Protected Spacing.l,StartY.l
|
||||
Spacing=((GUI\ScreenHeight-5)/ListSize(Menu\MenuOption()))*GUI\BlockSize
|
||||
If Spacing>GUI\BlockSize:Spacing=GUI\BlockSize:EndIf
|
||||
StartY=(ScreenHeight()-5*GUI\BlockSize-ListSize(Menu\MenuOption())*Spacing)/2
|
||||
Protected ChoiceIndex.l
|
||||
ForEach Menu\MenuOption()
|
||||
ChoiceIndex=1
|
||||
DrawingBitmapFont(0)
|
||||
Protected String.s=Menu\MenuOption()\String
|
||||
If Menu\MenuOption()\Choices<>""
|
||||
String=String+" : "+StringField(Menu\MenuOption()\Choices,ChoiceIndex+1,"|")
|
||||
EndIf
|
||||
Menu\MenuOption()\Width=TextBitmapWidth(String)
|
||||
Menu\MenuOption()\X=(ScreenWidth()-Menu\MenuOption()\Width)/2
|
||||
Menu\MenuOption()\Y=3*GUI\BlockSize+StartY+ListIndex(Menu\MenuOption())*Spacing
|
||||
|
||||
If ListIndex(Menu\MenuOption())%2
|
||||
Addmove(Menu\Obj,0,@Menu\MenuOption()\X,ScreenWidth(),Menu\MenuOption()\X,2000,#Easing_ElasticEaseOut)
|
||||
Else
|
||||
Addmove(Menu\Obj,0,@Menu\MenuOption()\X,-Menu\MenuOption()\Width,Menu\MenuOption()\X,2000,#Easing_ElasticEaseOut)
|
||||
EndIf
|
||||
Next
|
||||
StartMove(Menu\Obj)
|
||||
EndProcedure
|
||||
|
||||
Procedure FinalizeMenu()
|
||||
DrawingBitmapFont(1)
|
||||
Menu\Width=TextBitmapWidth(Menu\MenuTitle)
|
||||
Menu\X=(ScreenWidth()-Menu\Width)/2
|
||||
DrawingBitmapFont(0)
|
||||
StartMenu()
|
||||
EndProcedure
|
||||
|
||||
Procedure EndMenu(Mode.l=-1)
|
||||
If Mode<>-1
|
||||
Mode=1000+Mode
|
||||
EndIf
|
||||
Addmove(Menu\Obj,0,@Menu\Y,GUI\BlockSize*2,ScreenHeight(),2000,#Easing_ElasticEaseOut,Mode)
|
||||
|
||||
ForEach Menu\MenuOption()
|
||||
If ListIndex(Menu\MenuOption())%2
|
||||
Addmove(Menu\Obj,0,@Menu\MenuOption()\X,Menu\MenuOption()\X,ScreenWidth(),2000,#Easing_ElasticEaseOut)
|
||||
Else
|
||||
Addmove(Menu\Obj,0,@Menu\MenuOption()\X,Menu\MenuOption()\X,-Menu\MenuOption()\Width,2000,#Easing_ElasticEaseOut)
|
||||
EndIf
|
||||
Next
|
||||
StartMove(Menu\Obj)
|
||||
EndProcedure
|
||||
|
||||
Procedure DrawMenu()
|
||||
Protected.l X,Y,Width,Alpha,ChoiceIndex
|
||||
Protected String.s
|
||||
DrawingBitmapFont(1)
|
||||
DrawBitmapText(Menu\X,Menu\Y,Menu\MenuTitle)
|
||||
DrawingBitmapFont(0)
|
||||
|
||||
|
||||
ForEach Menu\MenuOption()
|
||||
String=Menu\MenuOption()\String
|
||||
ChoiceIndex=1;ChoiceIndex
|
||||
If Menu\MenuOption()\Choices<>""
|
||||
String=String+" : "+StringField(Menu\MenuOption()\Choices,ChoiceIndex+1,"|")
|
||||
EndIf
|
||||
If Menu\OptionIndex=ListIndex(Menu\MenuOption())
|
||||
Alpha=255
|
||||
If KeyboardReleased(#PB_Key_Space)
|
||||
If Menu\MenuOption()\Choices<>""
|
||||
ChoiceIndex=ChoiceIndex+1
|
||||
If ChoiceIndex>CountString(Menu\MenuOption()\Choices,"|")
|
||||
ChoiceIndex=0
|
||||
EndIf
|
||||
|
||||
ElseIf Menu\MenuOption()\GoToMode>0
|
||||
EndMenu(Menu\MenuOption()\GoToMode)
|
||||
EndIf
|
||||
If Menu\MenuOption()\SendGUIEvent>-1
|
||||
PostEventGUI(Menu\MenuOption()\SendGUIEvent)
|
||||
EndIf
|
||||
EndIf
|
||||
If Menu\MenuOption()\Choices<>""
|
||||
If KeyboardReleased(#PB_Key_Left) ;And ChoiceIndex>0
|
||||
;TODO
|
||||
ChoiceIndex=ChoiceIndex-1
|
||||
If Menu\MenuOption()\SendGUIEvent>-1
|
||||
PostEventGUI(Menu\MenuOption()\SendGUIEvent)
|
||||
EndIf
|
||||
EndIf
|
||||
|
||||
If KeyboardReleased(#PB_Key_Right) ;And ChoiceIndex<CountString(Menu\MenuOption()\Choices,"|")
|
||||
ChoiceIndex=ChoiceIndex+1
|
||||
If Menu\MenuOption()\SendGUIEvent>-1
|
||||
PostEventGUI(Menu\MenuOption()\SendGUIEvent)
|
||||
EndIf
|
||||
EndIf
|
||||
EndIf
|
||||
Else
|
||||
Alpha=100
|
||||
EndIf
|
||||
DrawBitmapText(Menu\MenuOption()\X,Menu\MenuOption()\Y,String,Alpha)
|
||||
Next
|
||||
If KeyboardReleased(#PB_Key_Up) And Menu\OptionIndex>0
|
||||
|
||||
Menu\OptionIndex=Menu\OptionIndex-1
|
||||
EndIf
|
||||
|
||||
If KeyboardReleased(#PB_Key_Down) And Menu\OptionIndex<ListSize(Menu\MenuOption())-1
|
||||
Menu\OptionIndex=Menu\OptionIndex+1
|
||||
EndIf
|
||||
|
||||
EndProcedure
|
||||
; IDE Options = PureBasic 6.00 Beta 6 (Windows - x64)
|
||||
; CursorPosition = 50
|
||||
; FirstLine = 39
|
||||
; Folding = --
|
||||
; EnableXP
|
Reference in New Issue
Block a user