Difference between revisions of "Options Menu"

1,368 bytes added ,  23:12, 3 July 2012
imported>Threedee
imported>Threedee
Line 115: Line 115:


<source lang="papyrus">ScriptName OptionsMenuScript extends ObjectReference
<source lang="papyrus">ScriptName OptionsMenuScript extends ObjectReference
{Presents a multilevel looped menu when this item is equipped}
;===================================================


Actor Property PlayerREF Auto
Message Property MainMenuMESG Auto ; main menu messagebox
Armor Property MenuARMO Auto ; Playable apparel item
Message Property OptionsMenu00MESG Auto ; submenu page 1 messagebox
Message Property OptionsMenu00MESG Auto
Message Property OptionsMenu01MESG Auto ; submenu page 2 messagebox
Message Property OptionsMenu01MESG Auto
Message Property OptionsMenu02MESG Auto ; submenu page 3 messagebox
Message Property OptionsMenu02MESG Auto
 
Armor MenuARMO
bool abMenu
;===================================================


Event OnEquipped(Actor akActor)
Event OnEquipped(Actor akActor)
If akActor == PlayerREF
If akActor == Game.GetPlayer()
Game.DisablePlayerControls(False, False, False, False, False, True) ; Momentarily disable other menus
menuARMO = self as Armor ; cast self as Armor
PlayerREF.EquipItem(MenuARMO, True, True) ; Prevent unequip/reequip in favorites until the current menu is resolved
akActor.UnequipItem(menuARMO, False, True) ; Silently unequip this item
Utility.Wait(0.01) ; This ensures equipping the token from the favorites menu works
abMenu = TRUE
PlayerREF.UnequipItem(MenuARMO, False, True) ; Silently unequip item
Game.DisablePlayerControls(False, False, False, False, False, True) ; Temporarily disable other menus
Game.EnablePlayerControls(False, False, False, False, False, True) ; Undo DisablePlayerControls
Menu()
Menu()
Game.EnablePlayerControls(False, False, False, False, False, True) ; Re-enable Player controls
EndIf
EndIf
EndEvent
EndEvent
;===================================================
Function Menu()


Function Menu(Int aiMessage = 0, Int aiButton = 0, Bool abMenu = True)
While abMenu
While abMenu
If aiButton == -1 ; Wait for input
int aiButton = MainMenuMESG.Show()
ElseIf aiMessage == 0
 
aiButton = OptionsMenu00MESG.Show()
If aiButton == 0
If aiButton == 0
Submenu00() ; goto submenu00
ElseIf aiButton == 1
ElseIf aiButton == 1
ElseIf aiButton == 2
Submenu01() ; goto submenu01
ElseIf aiButton == 3
ElseIf aiButton == 2
ElseIf aiButton == 4
Submenu02() ; goto submenu02
ElseIf aiButton == 5
ElseIf aiButton == 3 ; quit
ElseIf aiButton == 6
Return ; exits the menu function and while loop
ElseIf aiButton == 7
ElseIf aiButton == 8 ; More
aiMessage = 1
ElseIf aiButton == 9 ; Done
abMenu = False
EndIf
ElseIf aiMessage == 1
aiButton = OptionsMenu01MESG.Show()
If aiButton == 0
ElseIf aiButton == 1
ElseIf aiButton == 2
ElseIf aiButton == 3
ElseIf aiButton == 4
ElseIf aiButton == 5
ElseIf aiButton == 6
ElseIf aiButton == 7 ; Back
aiMessage = 0
ElseIf aiButton == 8 ; More
aiMessage = 2
ElseIf aiButton == 9 ; Done
abMenu = False
EndIf
ElseIf aiMessage == 2
aiButton = OptionsMenu02MESG.Show()
If aiButton == 0
ElseIf aiButton == 1
ElseIf aiButton == 2
ElseIf aiButton == 3
ElseIf aiButton == 4
ElseIf aiButton == 5
ElseIf aiButton == 6
ElseIf aiButton == 7
ElseIf aiButton == 8 ; Back
aiMessage = 1
ElseIf aiButton == 9 ; Done
abMenu = False
EndIf
EndIf
EndIf
Menu() ; loops the main menu
EndWhile
EndWhile
EndFunction
;===================================================
Function Submenu00
int aiButton = OptionsMenu00MESG.Show()
If aiButton == 0
; do stuff here
ElseIf aiButton == 1
; do stuff here
ElseIf aiButton == 2
; do stuff here
ElseIf aiButton == 3
; do stuff here
ElseIf aiButton == 4
; do stuff here
ElseIf aiButton == 5
; do stuff here
ElseIf aiButton == 6
; do stuff here
ElseIf aiButton == 7
Submenu01() ; More - goto submenu01
ElseIf aiButton == 8 ; Return to main menu
Return
ElseIf aiButton == 9 ; Done - exit from all menus
abMenu = FALSE ; stop the while loop
Return
EndIf
Submenu00() ; loops this submenu
EndFunction
;===================================================
Function Submenu01
int aiButton = OptionsMenu01MESG.Show()
If aiButton == 0 ; Back - goto submenu00
Submenu00()
ElseIf aiButton == 1
; do stuff here
ElseIf aiButton == 2
; do stuff here
ElseIf aiButton == 3
; do stuff here
ElseIf aiButton == 4
; do stuff here
ElseIf aiButton == 5
; do stuff here
ElseIf aiButton == 6
; do stuff here
ElseIf aiButton == 7
Submenu02() ; More - goto submenu02
ElseIf aiButton == 8 ; Return to main menu
Return
ElseIf aiButton == 9 ; Done - exit from all menus
abMenu = FALSE ; stop the while loop
Return
EndIf
Submenu01() ; loops this submenu
EndFunction
;===================================================
Function Submenu02
int aiButton = OptionsMenu02MESG.Show()
If aiButton == 0 ; Back - goto submenu00
Submenu01()
ElseIf aiButton == 1
; do stuff here
ElseIf aiButton == 2
; do stuff here
ElseIf aiButton == 3
; do stuff here
ElseIf aiButton == 4
; do stuff here
ElseIf aiButton == 5
; do stuff here
ElseIf aiButton == 6
; do stuff here
ElseIf aiButton == 7
; do stuff here
ElseIf aiButton == 8 ; Return to main menu
Return
ElseIf aiButton == 9 ; Done - exit from all menus
abMenu = FALSE ; stop the while loop
Return
EndIf
Submenu02() ; loops this submenu
EndFunction
;===================================================
EndFunction</source>
EndFunction</source>


Anonymous user