(version 2)
(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "Sound")
(use "User")
(script 997)



(class TheMenuBar of Class_255_0
    (properties
        state 0
    )

    (method (init)
        AddMenu("  " "About game`^a :Help`#1 :VaporCalc`^c ")
        AddMenu(" File " "Save Game`#5 :Restore Game`#7 :--! :Restart Game`#9 :Quit`^q ")
        AddMenu(" Action " "Pause Game`^p :Inventory`^I :Retype`#3 :--! :Boss Key`^b ")
        AddMenu(" Speed " "Change...`^s :--! :Faster`+ :Normal`= :Slower`- ")
        AddMenu(" Sound " "Volume...`^v :Sound Off`#2=1 ")
        SetMenu(513 109 'save')
        SetMenu(514 109 'restore')
        SetMenu(516 109 'restart')
        SetMenu(517 109 'quit')
        SetMenu(769 109 'pause')
        SetMenu(770 109 'inventory')
        SetMenu(1028 109 'normal')
        SetMenu(1027 109 'faster')
        SetMenu(1029 109 'slower')
        SetMenu(258 109 'aid')
    )


    (method (handleEvent pEvent)
        (var temp0, temp1, temp2[401])
        (switch ((super:handleEvent(pEvent (User:blocks))))
            (case 257
                proc255_0(Format(@temp2 997 0 global28) 33 3 30 1 80 "Space Quest ")
            )
            (case 258
                proc255_0(997 1 33 3)
            )
            (case 259
                (if ((== gGNorth 900) or (== gGNorth 1))
                    (send pEvent:claimed(0))
                )(else
                    = global251 1
                )
            )
            (case 513
                (if (global193)
                    proc255_0(997 2)
                )(else
                    (send gGame:save())
                )
            )
            (case 514
                (send gGame:restore())
            )
            (case 516
                (if (proc255_0(997 3 80 "Restart" 82 602 1 0 33 300 81 "Restart" 1 81 "Oops" 0))
                    (send gGame:restart())
                )
            )
            (case 517
                (if (<> gGNorth 290)
                    = global4 proc255_0(997 4 80 "Bailing Out?" 82 602 1 0 33 300 81 "Quit" 1 81 "Oops" 0)
                )(else
                    (send pEvent:claimed(0))
                )
            )
            (case 769
                = temp0 (Sound:pause(1))
                proc255_0(997 5 80 "This game is paused." 82 602 1 0 33 300 81 "Ok. I'm back." 1)
                DoSound(6 temp0)
            )
            (case 770
                (send gInv:showSelf(gEgo))
            )
            (case 771
                (send pEvent:
                    claimed(0)
                    type(4)
                    message((User:echo))
                )
            )
            (case 773
                proc255_0(997 6)
                proc255_0(Format(@temp2 "In fact, you don't want your boss to know that you've been playing Space Quest ]I[ for %d hours, %d minutes and %d seconds." global228 global227 global226))
                proc255_0(997 7)
            )
            (case 1025
                = temp1 proc255_3("Speed (1 - 16)?" gNewSpeed)
                (if (<> temp1 -1)
                    (if (< temp1 1)
                        = temp1 1
                    )
                    (if (> temp1 16)
                        = temp1 16
                    )
                    (send gGame:setSpeed(temp1))
                )
            )
            (case 1027
                (if (> gNewSpeed 1)
                    (send gGame:setSpeed(--gNewSpeed))
                )
            )
            (case 1028
                (send gGame:setSpeed(5))
            )
            (case 1029
                (if (< gNewSpeed 16)
                    (send gGame:setSpeed(++gNewSpeed))
                )
            )
            (case 1281
                = temp1 proc255_3("Volume (1 - 16)?" (+ 1 DoSound(8)))
                (if (<> temp1 -1)
                    (if (< --temp1 0)
                        = temp1 0
                    )
                    (if (> temp1 15)
                        = temp1 15
                    )
                    DoSound(8 temp1)
                )
            )
            (case 1282
                (if (GetMenu(1282 113))
                    DoSound(4 0)
                    SetMenu(1282 113 0 110 "Turn on")
                )(else
                    DoSound(4 1)
                    SetMenu(1282 113 1 110 "Turn off")
                )
            )
        )
    )

)
