(version 2)
(include "sci.sh")
(exports
    0 TitleButton
)
(use "Main")
(use "Class_255_0")
(use "User")
(use "PicView")
(use "Obj")
(script 87)


(local
    local0[4] = (58 161 58 161 )
    local4[4] = (146 146 165 165 )
    local8
    local9
    local10

)
(procedure (localproc_0518 param1 param2)
    = param1 local8
    (highLight:
        x(local0[local8])
        y(local4[param1])
    )
    (if (== paramTotal 2)
        = local10 param2
        = local8 local10
        (highLight:
            x(local0[local10])
            y(local4[local8])
        )
        (TitleButton:changeState(1))
    )
)


(procedure (localproc_0556)
    proc0_7()
    Display(87 1 100 76 149 105 4 102 14)
    Display(87 2 100 179 149 105 4 102 14)
    Display(87 3 100 84 168 105 4 102 14)
    Display(87 4 100 173 168 105 4 102 14)
)


(instance public TitleButton of Script
    (properties)

    (method (init param1)
        Animate((send gCast:elements) 1)
        (super:init(rest param1))
        = global108 1
        (User:mapKeyToDir(0))
        (send gAddToPics:
            add(b0 b1 b2 b3)
            eachElementDo(#init)
            doit()
        )
        = local8 0
        (highLight:
            init()
            x(local0[local8])
            y(local4[local8])
        )
        localproc_0556()
    )


    (method (doit param1)
        (super:doit(rest param1))
        (if (<> local9 local8)
            = local9 local8
            = local8 local9
            localproc_0518(local8)
        )
        (if (<> gCursorNumber gGCursorNumber)
            = gCursorNumber gGCursorNumber
            SetCursor(gGCursorNumber HaveMouse())
        )
    )


    (method (dispose)
        DisposeScript(87)
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                0
            )
            (case 1
                = cycles 2
            )
            (case 2
                (if (== local8 3)
                    (self:state(0))
                    (User:mapKeyToDir(1))
                    (send gGame:restore())
                    (User:mapKeyToDir(0))
                )(else
                    (send (ScriptID(86 1)):changeState(3))
                )
            )
            (case 3
                (User:mapKeyToDir(1))
                = global108 0
                (switch (local10)
                    (case 0
                        (send global2:newRoom(200))
                    )
                    (case 1
                        (send global2:newRoom(1))
                    )
                    (case 2
                        (send global2:newRoom(84))
                    )
                )
            )
        )
    )


    (method (handleEvent pEvent)
        (super:handleEvent(pEvent))
        (if ((send pEvent:claimed))
            return 
        )
        (switch ((send pEvent:type))
            (case 4
                (switch ((send pEvent:message))
                    (case 19712
                        (if ((== local8 0) or (== local8 2))
                            ++local8
                        )(else
                            --local8
                        )
                    )
                    (case 19200
                        (if ((== local8 1) or (== local8 3))
                            --local8
                        )(else
                            ++local8
                        )
                    )
                    (case 18432
                        (if (<= local8 1)
                            = local8 (+ local8 2)
                        )(else
                            = local8 (- local8 2)
                        )
                    )
                    (case 20480
                        (if (>= local8 2)
                            = local8 (- local8 2)
                        )(else
                            = local8 (+ local8 2)
                        )
                    )
                    (case 9
                        (if (== local8 3)
                            = local8 0
                        )(else
                            = local8 (+ local8 1)
                        )
                    )
                    (case 3840
                        (if (== local8 0)
                            = local8 3
                        )(else
                            = local8 (- local8 1)
                        )
                    )
                    (case 13
                        localproc_0518(local8 local8)
                    )
                    (case 15360
                        (super:handleEvent(pEvent))
                    )
                    (default 
                        proc255_0(87 0)
                    )
                )
            )
            (case 1
                (if (proc255_5(b0 pEvent))
                    localproc_0518(0 0)
                )(else
                    (if (proc255_5(b1 pEvent))
                        localproc_0518(1 1)
                    )(else
                        (if (proc255_5(b2 pEvent))
                            localproc_0518(2 2)
                        )(else
                            (if (proc255_5(b3 pEvent))
                                localproc_0518(3 3)
                            )(else
                                proc255_0(87 0)
                            )
                        )
                    )
                )
            )
        )
    )

)
(instance b0 of View
    (properties
        x 58
        y 146
        view 950
        loop 1
    )
)
(instance b1 of View
    (properties
        x 161
        y 146
        view 950
        loop 1
    )
)
(instance b2 of View
    (properties
        x 58
        y 165
        view 950
        loop 1
    )
)
(instance b3 of View
    (properties
        x 161
        y 165
        view 950
        loop 1
    )
)
(instance highLight of View
    (properties
        view 950
        loop 2
        signal $5800
    )
)
