(include "sci.sh")
(use "Main")
(use "SQ5ControlItem")
(use "Print")
(use "Slider")
(use "BorderWindow")
(use "IconI")
(use "GameControls")
(use "Obj")
(script 24)



(class SQ5ControlItem of ControlIcon
    (properties
        view -1
        loop -1
        cel -1
        nsLeft 0
        nsTop -1
        nsRight 0
        nsBottom 0
        state 0
        cursor -1
        type 16384
        message -1
        modifiers 0
        signal 1
        maskView 0
        maskLoop 0
        maskCel 0
        highlightColor 0
        lowlightColor 0
        noun 0
        modNum 0
        helpVerb 0
        theObj 0
        selector 0
    )

    (method (select param1)
        (super:select(rest param1))
        (self:doit())
    )

)
(instance gameControls of GameControls
    (properties)

    (method (dispatchEvent param1)
        (var gSq5WinEraseOnly, temp1, temp2, temp3[50], temp53, temp54)
        = temp53 (send param1:type)
        = temp54 (send param1:message)
        return 
            (if (& temp53 $2000)
                (if ((= temp1 (self:firstTrue(226 param1))) and (send ((= temp1 (self:firstTrue(226 param1)))):helpVerb))
                    = temp2 GetPort()
                    (if ((send gSq5Win:respondsTo(244)))
                        = gSq5WinEraseOnly (send gSq5Win:eraseOnly)
                        (send gSq5Win:eraseOnly(1))
                        (Print:
                            font(gFont)
                            width(250)
                            addText((send temp1:noun) (send temp1:helpVerb) 0 1 0 0 (send temp1:modNum))
                            init()
                        )
                        (send gSq5Win:eraseOnly(gSq5WinEraseOnly))
                    )(else
                        (Print:
                            font(gFont)
                            width(250)
                            addText((send temp1:noun) (send temp1:helpVerb) 0 1 0 0 (send temp1:modNum))
                            init()
                        )
                    )
                    SetPort(temp2)
                )
                (if (helpIconItem)
                    (send helpIconItem:signal((& (send helpIconItem:signal) $ffef)))
                )
                (send gSQ5:setCursor(999))
                return 0
            )(else
                (if (& temp53 $0040)
                    (switch (temp54)
                        (case 5
                            (if (IsObject(highlightedIcon) and (send highlightedIcon:respondsTo(198)))
                                (send highlightedIcon:retreat())
                                return 0
                            )(else
                                (if (not IsObject(highlightedIcon) or (& (send highlightedIcon:signal) $0100))
                                    (self:advance())
                                    return 0
                                )
                            )
                        )
                        (case 1
                            (if (IsObject(highlightedIcon) and (send highlightedIcon:respondsTo(197)))
                                (send highlightedIcon:advance())
                                return 0
                            )(else
                                (if (not IsObject(highlightedIcon) or (& (send highlightedIcon:signal) $0100))
                                    (self:retreat())
                                    return 0
                                )
                            )
                        )
                        (default 
                            (super:dispatchEvent(param1))
                        )
                    )
                )(else
                    (super:dispatchEvent(param1))
                )
            )
    )

)
(instance public gameControlCode of Code
    (properties)

    (method (doit)
        = gGameControls gameControls
        (send gGameControls:
            add(detailSlider (volumeSlider:
                    theObj(gSQ5)
                    selector(389)
                    yourself()
                )
 (speedSlider:
                    theObj(gEgo)
                    selector(324)
                    yourself()
                )
 (iconSave:
                    theObj(gSQ5)
                    selector(75)
                    yourself()
                )
 (iconRestore:
                    theObj(gSQ5)
                    selector(76)
                    yourself()
                )
 (iconRestart:
                    theObj(gSQ5)
                    selector(101)
                    yourself()
                )
 (iconQuit:
                    theObj(gSQ5)
                    selector(100)
                    yourself()
                )
 iconOk (iconAbout:
                    theObj(gSQ5)
                    selector(668)
                    yourself()
                )
 iconHelp)
            eachElementDo(219 0)
            eachElementDo(220 4)
            eachElementDo(222 0)
            eachElementDo(223 5)
            helpIconItem(iconHelp)
            window(gcWin)
            curIcon(iconSave)
            state(2048)
            show()
        )
    )

)
(instance public gcWin of BorderWindow
    (properties)

    (method (open)
        (var temp0, temp1[25], temp26[25], temp51)
        = temp51 -1
        (self:
            top(/ (- 200 (+ CelHigh(995 1 1) 6)) 2)
            left(/ (- 320 (+ 151 CelWide(995 0 1))) 2)
            bottom(+ (+ CelHigh(995 1 1) 6) (/ (- 200 (+ CelHigh(995 1 1) 6)) 2))
            right(+ (+ 151 CelWide(995 0 1)) (/ (- 320 (+ 151 CelWide(995 0 1))) 2))
            priority(temp51)
        )
        (super:open())
        DrawCel(995 0 5 + (/ (- (- (+ 151 CelWide(995 0 1)) (+ 4 CelWide(995 1 1))) CelWide(995 0 5)) 2) (+ 4 CelWide(995 1 1)) 3 temp51)
        DrawCel(995 1 1 4 3 temp51)
        DrawCel(995 1 0 94 38 temp51)
        DrawCel(995 1 0 135 38 temp51)
        DrawCel(995 0 4 63 proc0_12(- (- 37 (+ CelHigh(995 0 4) 3)) 9 - 37 (+ CelHigh(995 0 4) 3) - 37 (+ CelHigh(995 0 4) 3) - 37 (+ CelHigh(995 0 4) 3) - 37 (+ CelHigh(995 0 4) 3)) temp51)
        DrawCel(995 0 3 101 proc0_12(- (- 37 (+ CelHigh(995 0 4) 3)) 9 - 37 (+ CelHigh(995 0 4) 3) - 37 (+ CelHigh(995 0 4) 3) - 37 (+ CelHigh(995 0 4) 3) - 37 (+ CelHigh(995 0 4) 3)) temp51)
        DrawCel(995 0 2 proc0_12(140 146 146 146 146) proc0_12(- (- 37 (+ CelHigh(995 0 4) 3)) 9 - 37 (+ CelHigh(995 0 4) 3) - 37 (+ CelHigh(995 0 4) 3) - 37 (+ CelHigh(995 0 4) 3) - 37 (+ CelHigh(995 0 4) 3)) temp51)
        DrawCel(995 9 0 + 5 CelWide(995 1 1) + 38 CelHigh(995 0 1) temp51)
        Graph(12 12 1 15 + 151 CelWide(995 0 1) 1)
        GetMessage(0 0 18 0 1 1 @temp1)
        Format(@temp26 "%d %s %d" global15 @temp1 global16)
        Display(@temp26 105 gFont 100 + (+ 5 CelWide(995 1 1)) 6 + (+ 38 CelHigh(995 0 1)) 15)
        SetPort(0)
    )

)
(instance detailSlider of Slider
    (properties
        view 995
        loop 0
        cel 1
        nsLeft 139
        nsTop 73
        signal 128
        noun 5
        helpVerb 5
        sliderView 995
        bottomValue 1
        topValue 3
    )

    (method (doit param1)
        (if (paramTotal)
            (send gSQ5:detailLevel(param1))
        )
        (send gSQ5:detailLevel())
    )

)
(instance volumeSlider of Slider
    (properties
        view 995
        loop 0
        cel 1
        nsLeft 179
        nsTop 73
        signal 128
        noun 24
        helpVerb 5
        sliderView 995
        topValue 15
    )
)
(instance speedSlider of Slider
    (properties
        view 995
        loop 0
        cel 1
        nsLeft 219
        nsTop 73
        signal 128
        noun 25
        helpVerb 5
        sliderView 995
        bottomValue 15
    )

    (method (doit param1)
        (if (paramTotal)
            (send gEgo:setSpeed(param1))
        )
        return gGEgoMoveSpeed
    )


    (method (show param1)
        (if (not (send gUser:controls))
            = signal 132
        )(else
            = signal 128
        )
        (super:show(rest param1))
    )


    (method (mask)
    )


    (method (move param1)
        (if ((send gUser:controls))
            (super:move(rest param1))
        )
    )

)
(instance iconSave of SQ5ControlItem
    (properties
        view 995
        loop 2
        cel 0
        nsLeft 80
        nsTop 42
        message 8
        signal 451
        noun 23
        helpVerb 5
    )
)
(instance iconRestore of SQ5ControlItem
    (properties
        view 995
        loop 3
        cel 0
        nsLeft 80
        nsTop 62
        message 8
        signal 451
        noun 21
        helpVerb 5
    )
)
(instance iconRestart of SQ5ControlItem
    (properties
        view 995
        loop SQ5ControlItem
        cel 0
        nsLeft 80
        nsTop 82
        message 8
        signal 451
        noun 20
        helpVerb 5
    )
)
(instance iconQuit of SQ5ControlItem
    (properties
        view 995
        loop 5
        cel 0
        nsLeft 80
        nsTop 102
        message 8
        signal 451
        noun 19
        helpVerb 5
    )
)
(instance iconAbout of SQ5ControlItem
    (properties
        view 995
        loop 6
        cel 0
        nsLeft 80
        nsTop gcWin
        message 8
        signal 451
        noun 1
        helpVerb 5
    )
)
(instance iconHelp of IconI
    (properties
        view 995
        loop 7
        cel 0
        nsLeft 106
        nsTop gcWin
        cursor 989
        message 5
        signal 387
        noun 7
        helpVerb 5
    )
)
(instance iconOk of IconI
    (properties
        view 995
        loop 8
        cel 0
        nsLeft 80
        nsTop 122
        cursor 989
        message 8
        signal 451
        noun 17
        helpVerb 5
    )
)
