(version 2)
(include "sci.sh")
(exports
    0 rm130
)
(use "Main")
(use "GloryWindow")
(use "IconI")
(use "n958")
(use "GameControls")
(use "SysWindow")
(use "Cycle")
(use "Game")
(use "User")
(use "View")
(use "Obj")
(script 130)


(local
    local0[2]
    local2

)
(procedure (localproc_08e7 param1)
    (send param1:
        init()
        show()
    )
    (if (not local2)
        DrawPic(130 dpCLOSEREOPEN_HCENTER)
        Animate((send gGQg3KDHandler:elements) 0)
        (if (== param1 startPanel)
            localproc_08e7(playPanel)
        )(else
            localproc_08e7(startPanel)
        )
    )
)


(procedure (localproc_0928)
    (var temp0, temp1, temp2, temp3)
    = temp0 GetTime()
    = temp2 5000
    (while (temp2)
        = temp3 102
        --temp2
    )
    = temp2 5000
    (while (temp2)
        Animate()
        --temp2
    )
    = temp1 GetTime()
    = temp3 
        (switch ((/ Abs((- (= temp1 GetTime()) temp0)) 10))
            (case 0
                3
            )
            (case 1
                2
            )
            (case 2
                1
            )
            (default 
                0
            )
        )
)


(instance public rm130 of Rm
    (properties
        picture 1
    )

    (method (init)
        proc0_2()
        SetCursor(0)
        (User:canInput(1))
        (send gQg3MDHandler:add(self))
        (send gQg3KDHandler:add(self))
        (send gMainIconBar:disable())
        SetPort(0 0 200 320 0 0)
        (super:init())
        (if (proc999_5(gGClientModNum 140 54 102 63))
            (III:
                setLoop(4)
                setCel(6)
                x(85)
                y(121)
                init()
            )
            (wagesSign:
                setLoop(0)
                setCel(8)
                init()
            )
            SetPort(0 0 190 320 10 0)
            DrawPic(130 dpOPEN_HCENTER)
            (send gLongSong:changeTo(2))
            (seeMeGo:start(16))
        )
        (self:setScript(seeMeGo))
        = global102 localproc_0928()
    )


    (method (dispose)
        (startPanel:dispose())
        (playPanel:dispose())
        (send gMainIconBar:enable())
        proc958_0(0 956 978)
        (super:dispose())
    )


    (method (handleEvent pEvent param2)
        (if (proc999_5((send pEvent:type) 4 1 256))
            (if (< (seeMeGo:state) 4)
                (send gLongSong:client(0))
                (send gLongSong2:client(0))
                (seeMeGo:
                    seconds(0)
                    cycles(0)
                    ticks(0)
                    changeState(4)
                )
            )(else
                (send gLongSong:client(0))
                (send gLongSong2:client(0))
                (seeMeGo:
                    seconds(0)
                    cycles(0)
                    ticks(0)
                    changeState(18)
                )
            )
            (send pEvent:claimed(1))
        )(else
            (if (== (send pEvent:type) 2)
                (send pEvent:claimed(1))
            )
        )
        (super:handleEvent(pEvent rest param2))
    )

)
(instance seeMeGo of Script
    (properties)

    (method (doit)
        (if (< (self:state) 4)
            Palette(palANIMATE 95 218 -1)
        )
        (super:doit())
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gLongSong:
                    number(1)
                    play(self)
                )
            )
            (case 1
                (glint:
                    init()
                    setCycle(End)
                )
            )
            (case 2
                (glint2:
                    init()
                    setCycle(CT 6 1)
                )
            )
            (case 3
                (glint2:setCycle(End))
            )
            (case 4
                SetPort(0 0 190 320 10 0)
                DrawPic(130 dpOPEN_EDGECENTER)
                (glint:dispose())
                (glint2:dispose())
                (gloryDude:
                    cel(0)
                    init()
                )
                (send gLongSong:
                    number(2)
                    play()
                )
                = seconds 2
            )
            (case 5
                (gloryDude:setCycle(End self))
            )
            (case 6
                (send gLongSong2:
                    number(7)
                    play(self)
                )
                = ticks 15
            )
            (case 7
                (lFx:
                    init()
                    setCycle(Fwd)
                )
            )
            (case 8
                (lFx:dispose())
                (send gLongSong2:
                    number(8)
                    play(self)
                )
                (sFx:
                    init()
                    setPri(14)
                    setCycle(Fwd)
                )
            )
            (case 9
                (sFx:
                    setLoop(2)
                    cel(0)
                    x(206)
                    y(55)
                    setCycle(End self)
                )
                (send gLongSong2:
                    number(11)
                    play()
                )
            )
            (case 10
                (sFx:dispose())
                (beam:
                    init()
                    setPri(14)
                    setCycle(End self)
                )
            )
            (case 11
                (send gLongSong2:
                    number(9)
                    play()
                )
                (beam:dispose())
                (III:
                    init()
                    setCycle(End self)
                )
            )
            (case 12
                (III:setCycle(Beg self))
            )
            (case 13
                (III:
                    x(85)
                    y(121)
                    setLoop(4)
                    cel(0)
                    setCycle(CT 1 1 self)
                )
            )
            (case 14
                Palette(palSET_INTENSITY 0 255 400)
                (III:setCycle(End self))
                Palette(palSET_INTENSITY 0 255 100)
            )
            (case 15
                (wagesSign:
                    init()
                    cycleSpeed(5)
                    setCycle(CT 3 1 self)
                )
            )
            (case 16
                (send gLongSong2:
                    number(131)
                    play()
                )
                (wagesSign:setCycle(End self))
            )
            (case 17
                = ticks 180
            )
            (case 18
                (send gLongSong:hold())
                (gloryDude:dispose())
                (wagesSign:addToPic())
                (III:addToPic())
                (beam:dispose())
                (sFx:dispose())
                (lFx:dispose())
                = cycles 3
            )
            (case 19
                Palette(palSET_INTENSITY 72 255 60)
                SetCursor(1)
                (send gGame:setCursor(global20 1 160 90))
                localproc_08e7(startPanel)
            )
        )
    )

)
(instance III of Prop
    (properties
        x 54
        y 100
        view 134
        loop 5
    )
)
(instance gloryDude of Prop
    (properties
        x 201
        y 135
        view 131
        loop 2
    )
)
(instance wagesSign of Prop
    (properties
        x 260
        y 175
        view 135
        cel 1
    )
)
(instance lFx of Prop
    (properties
        x 204
        y 29
        view 134
    )
)
(instance sFx of Prop
    (properties
        x 203
        y 57
        view 134
        loop 1
    )
)
(instance beam of Prop
    (properties
        x 164
        y 72
        view 134
        loop 3
    )
)
(instance glint of Prop
    (properties
        x 134
        y 34
        view 133
        loop 1
        cycleSpeed 8
    )
)
(instance glint2 of Prop
    (properties
        x 60
        y 155
        view 133
        cycleSpeed 8
    )
)
(instance startWin of Window
    (properties
        top 32
        left 61
        bottom 160
        right 258
        type $0083
    )

    (method (open param1)
        (var temp0)
        (super:open(rest param1))
        Graph(grFILL_BOX 10 10 108 176 1 57 -1)
        Graph(grUPDATE_BOX 9 9 109 175 1)
        DrawCel(132 8 0 1 1 -1)
        DrawCel(132 9 0 1 107 -1)
        = temp0 0
        (while (<= temp0 8)
            DrawCel(132 10 0 6 + (* temp0 11) 12 -1)
            DrawCel(132 10 1 176 + (* temp0 11) 12 -1)
            ++temp0
        )
    )

)
(instance startPanel of GameControls
    (properties)

    (method (init param1)
        = window startWin
        (self:
            add(introItem playItem restoreItem instructItem quitItem)
            eachElementDo(14 387)
        )
        (playItem:signal((| (playItem:signal) $0040)))
        (quitItem:signal((| (quitItem:signal) $0040)))
        (super:init(rest param1))
    )


    (method (dispatchEvent param1)
        = gLastTicks GetTime()
        (super:dispatchEvent(rest param1))
    )

)
(class startItem of IconI
    (properties
        view 132
        loop -1
        cel 0
        nsLeft 24
        nsTop -1
        nsRight 0
        nsBottom 0
        state $0000
        cursor -1
        type $4000
        message -1
        modifiers $0000
        signal $0001
        maskView 0
        maskLoop 0
        maskCel 0
        highlightColor 46
        lowlightColor 57
        noun 0
        modNum 0
        helpVerb 0
    )

    (method (highlight param1)
        (var temp0, temp1, temp2, temp3, temp4)
        = temp4 
            (if (paramTotal and param1)
                highlightColor
            )(else
                lowlightColor
            )
        = temp0 (+ nsTop 1)
        = temp1 (+ nsLeft 1)
        = temp2 (- nsBottom 2)
        = temp3 (- nsRight 2)
        Graph(grDRAW_LINE temp0 temp1 temp0 temp3 temp4 -1 -1)
        Graph(grDRAW_LINE temp0 temp3 temp2 temp3 temp4 -1 -1)
        Graph(grDRAW_LINE temp2 temp3 temp2 temp1 temp4 -1 -1)
        Graph(grDRAW_LINE temp2 temp1 temp0 temp1 temp4 -1 -1)
        Graph(grUPDATE_BOX - nsTop 2 - nsLeft 2 nsBottom + nsRight 3 1)
    )

)
(instance introItem of startItem
    (properties
        loop 0
        nsTop 16
    )

    (method (select param1)
        (if ((super:select(rest param1)))
            = local2 1
            (startPanel:state((& (startPanel:state) $ffdf)))
            (send global2:newRoom(63))
        )
    )

)
(instance playItem of startItem
    (properties
        loop 1
        nsTop 34
    )

    (method (select param1)
        (if ((super:select(rest param1)))
            (startPanel:state((& (startPanel:state) $ffdf)))
        )
    )

)
(instance restoreItem of startItem
    (properties
        loop 2
        nsTop 52
    )

    (method (select param1)
        (if ((super:select(rest param1)))
            Palette(palSET_INTENSITY 72 255 100)
            (send gGame:restore())
            Palette(palSET_INTENSITY 72 255 60)
        )
    )

)
(instance instructItem of startItem
    (properties
        loop 3
        nsTop 70
    )

    (method (select param1)
        (if ((super:select(rest param1)))
            = local2 1
            (startPanel:state((& (startPanel:state) $ffdf)))
            (send global2:newRoom(102))
        )
    )

)
(instance quitItem of startItem
    (properties
        loop 4
        nsTop 88
    )

    (method (select param1)
        (if ((super:select(rest param1)))
            = local2 1
            = global4 1
        )
    )

)
(instance playPanel of GameControls
    (properties)

    (method (init param1)
        = window (send ((GloryWindow:new())):
                top(60)
                left(82)
                bottom(128)
                right(234)
            )
        (self:
            add(createItem importItem cancelItem)
            eachElementDo(14 387)
        )
        (cancelItem:signal((| (cancelItem:signal) $0040)))
        (super:init(rest param1))
    )


    (method (dispatchEvent param1)
        = gLastTicks GetTime()
        (send global2:doit())
        (super:dispatchEvent(rest param1))
    )

)
(instance createItem of startItem
    (properties
        loop 5
        nsLeft 2
        nsTop 5
    )

    (method (select param1)
        (if ((super:select(rest param1)))
            = local2 1
            (playPanel:state((& (playPanel:state) $ffdf)))
            (startPanel:state((& (startPanel:state) $ffdf)))
            (send gLongSong:fade(0 2 5 1))
            (send global2:newRoom(140))
        )
    )

)
(instance importItem of startItem
    (properties
        loop 6
        nsLeft 2
        nsTop 26
    )

    (method (select param1)
        (if ((super:select(rest param1)))
            = local2 1
            (playPanel:state((& (playPanel:state) $ffdf)))
            (startPanel:state((& (startPanel:state) $ffdf)))
            (send global2:newRoom(54))
        )
    )

)
(instance cancelItem of startItem
    (properties
        loop 7
        nsLeft 2
        nsTop 47
    )

    (method (select param1)
        (if ((super:select(rest param1)))
            (playPanel:state((& (startPanel:state) $ffdf)))
        )
    )

)
(instance newMH of EventHandler
    (properties)
)
(instance newKH of EventHandler
    (properties)
)
