(version 2)
(include "sci.sh")
(exports
    0 debugHandler
)
(use "Main")
(use "NameFeatureCode")
(use "Class_255_0")
(use "Print")
(use "ClickMenu")
(use "DlgWindow")
(use "Class_948_0")
(use "CueObj")
(use "SysWindow")
(use "User")
(use "View")
(use "Obj")
(script 10)


(local
    local0[27]

)
(procedure (localproc_0052)
    (if (proc999_5((send global2:style) 11 12 13 14))
        (send global2:
            reflectPosn((send global2:east) 100)
            style(100)
        )
    )
)


(instance public debugHandler of Feature
    (properties)

    (method (init)
        (super:init())
        (send gOldMH:addToFront(self))
        (send gOldKH:addToFront(self))
    )


    (method (dispose)
        (send gOldMH:delete(self))
        (send gOldKH:delete(self))
        (super:dispose())
        DisposeScript(974)
        DisposeScript(10)
        DisposeScript(25)
    )


    (method (handleEvent pEvent)
        (var temp0[160], temp160, newEvent, gOldCastFirst, theGFont, temp164, temp165, temp166, temp167, temp168, temp169, temp170, temp171, temp172, temp173, temp174, temp175, temp176, temp177, temp178)
        (switch ((send pEvent:type))
            (case 4
                (send pEvent:claimed(1))
                (switch ((send pEvent:message))
                    (case 7680
                        = gOldCastFirst (send gOldCast:first())
                        (while (gOldCastFirst)
                            = temp164 NodeValue(gOldCastFirst)
                            Format(@temp0 "class: %s\nview: %d\nloop: %d\ncel: %d\nposn: %d %d %d\nheading: %d\npri: %d\nsignal: $%x\nillBits: $%x\n" (send ((send temp164:{-super-})):name) (send temp164:view) (send temp164:loop) (send temp164:cel) (send temp164:x) (send temp164:y) (send temp164:z) (send temp164:heading) (send temp164:priority) (send temp164:signal) 
                                (if ((send temp164:isKindOf(Actor)))
                                    (send temp164:illegalBits)
                                )(else
                                    -1
                                )
)
                            (if (not (Print:
                                addText(@temp0)
                                window(SysWindow)
                                addTitle((send temp164:name))
                                addIcon((send temp164:view) (send temp164:loop) (send temp164:cel) + (Print:x) 80 (Print:y))
                                init()
                            )
)
                                break
                            )
                            = gOldCastFirst (send gOldCast:next(gOldCastFirst))
                        )
                    )
                    (case 12288
                        (PolyEdit:doit())
                    )
                    (case 11776
                        localproc_0052()
                        Show(4)
                    )
                    (case 8192
                        (DialogEditor:doit())
                    )
                    (case 8448
                        (send gOldFeatures:eachElementDo(#perform ScriptID(25 2) 0))
                        (send gOldCast:eachElementDo(#perform ScriptID(25 2) 1))
                        (FP:init())
                    )
                    (case 8704
                        = temp0 0
                        proc921_2(@temp0 6 "Variable No.")
                        = gOldCastFirst ReadNumber(@temp0)
                        = temp0 0
                        proc921_2(@temp0 6 "Value")
                        = gEgo[gOldCastFirst] ReadNumber(@temp0)
                        = temp0 0
                    )
                    (case 8960
                        = temp0 0
                        (Print:
                            addText("Global number:")
                            addEdit(@temp0 6 0 12)
                            init()
                        )
                        = gOldCastFirst ReadNumber(@temp0)
                        (if (IsObject(gEgo[gOldCastFirst]))
                            Format(@temp0 " Global %d: %s " gOldCastFirst (send gEgo[gOldCastFirst]:name))
                        )(else
                            Format(@temp0 " Global %d: %d " gOldCastFirst gEgo[gOldCastFirst])
                        )
                        proc921_0(@temp0)
                    )
                    (case 5888
                        (send (ScriptID(25 0)):doit())
                    )
                    (case 9216
                        (NameFeatureCode:init())
                    )
                    (case 9472
                        = temp160 GetPort()
                        SetPort(0)
                        = temp171 5
                        = temp172 16
                        = temp167 15
                        = temp168 80
                        = temp170 (+ temp167 (* 34 temp171))
                        = temp169 (+ temp168 (* 10 temp172))
                        = temp165 Graph(grSAVE_BOX temp167 temp168 temp170 temp169 1)
                        Graph(grFILL_BOX temp167 temp168 temp170 temp169 1 255)
                        = temp166 0
                        (while (< temp166 256)
                            Graph(grFILL_BOX + (+ temp167 temp171) (* temp171 (/ temp166 8)) + (+ temp168 temp172) (* 16 (% temp166 8)) + (+ (+ temp167 temp171) temp171) (* temp171 (/ temp166 8)) + (+ (+ temp168 temp172) temp172) (* temp172 (% temp166 8)) 1 temp166)
                            ++temp166
                        )
                        Graph(grUPDATE_BOX temp167 temp168 temp170 temp169 1)
                        (while (TRUE)
                            = newEvent (Event:new())
                            (if ((== (send newEvent:type) 1) or (== (send newEvent:type) 4))
                                break
                            )
                            (send newEvent:dispose())
                        )
                        (send newEvent:dispose())
                        Graph(grRESTORE_BOX temp165)
                        Graph(grUPDATE_BOX temp167 temp168 temp170 temp169 1)
                        SetPort(temp160)
                    )
                    (case 9728
                        = temp0 0
                        = gOldCastFirst proc255_1("Flag No.")
                        proc0_3(gOldCastFirst)
                    )
                    (case 12800
                        = temp0 0
                        = gOldCastFirst proc255_1("Flag No.")
                        proc0_4(gOldCastFirst)
                    )
                    (case 12544
                        = temp0 0
                        = gOldCastFirst proc255_1("Flag No.")
                        Format(@temp0 "%d" proc0_2(gOldCastFirst))
                        proc921_0(@temp0)
                    )
                    (case 6144
                        (send (ScriptID(952)):doit(@global42 0))
                    )
                    (case 6400
                        localproc_0052()
                        Show(2)
                    )
                    (case 4096
                        (send gGame:scaler(1))
                    )
                    (case 4864
                        Format(@temp0 10 1 (send global2:name) gNumber (send global2:initialized) (send global2:style) (send global2:alterEgo) (send global2:south) (send global2:picAngle) (send global2:west) (send global2:setRegions()) 
                            (if (IsObject((send global2:script)))
                                (send ((send global2:script)):name)
                            )(else
                                "..none.."
                            )
)
                        (Print:
                            width(120)
                            addText(@temp0)
                            init()
                        )
                        (send gGame:masterVolume())
                    )
                    (case 7936
                        = temp0 0
                        (if ((Print:
                            addText(" Which Format?")
                            addButton(0 "String" 0 12)
                            addButton(1 "Message" 50 12)
                            init()
                        )
)
                            = temp174 proc255_1("Noun?" 0)
                            = temp175 proc255_1("Verb?" 0)
                            = temp176 proc255_1("Case?" 0)
                            = temp177 proc255_1("Sequence?" 0)
                            Message(msgGET temp174 temp175 temp176 temp177 @temp0)
                        )(else
                            proc921_2(@temp0 50 "String to display?")
                        )
                        = temp167 proc255_1("Y Parameter?" 0)
                        = temp168 proc255_1("X Parameter?" 0)
                        = gOldCastFirst proc255_1("Box Width?" 0)
                        = theGFont proc255_1("Font Number?" 0)
                        (if (not theGFont)
                            = theGFont gFont
                        )
                        (Print:
                            posn(temp168 temp167)
                            width(gOldCastFirst)
                            font(theGFont)
                            addText(@temp0)
                            init()
                        )
                    )
                    (case 5120
                        (if (gDialog)
                            (send gDialog:dispose())
                        )
                        = gOldCastFirst proc255_1("Teleport to")
                        (if (> gOldCastFirst 0)
                            (send global2:showMem(gOldCastFirst))
                        )
                    )
                    (case 5632
                        (User:
                            canInput(1)
                            canControl(1)
                        )
                        (send gIconBar:enable(0 1 2 3 5 6))
                    )
                    (case 12032
                        Show(1)
                        (send gOldATPs:doit())
                    )
                    (case 4352
                        (Class_948_0:doit())
                    )
                    (case 11520
                        = global4 1
                    )
                    (case 11264
                        = global4 1
                    )
                    (case 63
                        proc921_0("Debug options:      (Page 1 of 5)\n\n   A - Show cast\n   B - Polygon editor\n   C - Show control map\n   D - Dialog Editor\n   E - Every puzzle can be found\n   F - Show feature outlines\n   G - Set global\n")
                        proc921_0("Debug options:      (Page 2 of 5)\n\n   H - Show global\n   I - Get inventory item\n   J - Justify text on screen\n   K - Show palette\n   L - Set flag\n   M - Clear flag\n   N - Show flag\n")
                        proc921_0("Debug options:      (Page 3 of 5)\n\n   O - QA Note Logger\n   P - Show priority map\n   Q - Set Detail to 1\n   R - Show room info/free memory\n   S - Show a string or message\n   T - Teleport\n   U - Give HandsOn\n")
                        proc921_0("Debug options:      (Page 4 of 5)\n\n   V - Show visual map\n   W - Feature writer\n   Y - Stuff or Unstuff a clue\n   X,Z - Quick quit\n")
                        proc921_0("Debug options:      (Page 5 of 5)\n\n  A=Alt, C=Ctrl, L=Left shift, R=Right shift\n\n  Left click:\n    A       Move ego\n    CL      Show ego\n    CR      Show room\n    CA      Show position\n")
                    )
                    (default 
                        (send pEvent:claimed(0))
                    )
                )
            )
            (case 1
                (switch ((send pEvent:modifiers))
                    (case 13
                        0
                    )
                    (case 14
                        0
                    )
                    (case 12
                        (send pEvent:claimed(1))
                        Format(@temp0 10 2 (send pEvent:x) (send pEvent:y))
                        = temp160 (Print:
                                posn(160 10)
                                font(999)
                                modeless(1)
                                addText(@temp0)
                                init()
                            )
                        (while (<> 2 (send ((= newEvent (Event:new()))):type))
                            (send newEvent:dispose())
                        )
                        (send newEvent:dispose())
                        (send temp160:dispose())
                    )
                    (case 5
                        (send pEvent:
                            type(4)
                            message(4864)
                        )
                        (self:handleEvent(pEvent))
                    )
                    (case 9
                        0
                    )
                    (case 10
                        0
                    )
                    (case 1
                        0
                    )
                    (case 2
                        0
                    )
                    (case 4
                        0
                    )
                    (case 8
                        (send pEvent:claimed(1))
                        = temp178 (send gGame:setCursor(996))
                        = temp173 
                            (if (gTheNewDButtonValue)
                            )(else
                                (User:input)
                            )
                        = gOldCastFirst (send temp173:signal)
                        (send temp173:ignoreActors())
                        (while (<> 2 (send ((= newEvent (Event:new()))):type))
                            (send temp173:
                                x((send newEvent:x))
                                y(- (send newEvent:y) 10)
                            )
                            Animate((send gOldCast:elements) 0)
                            (send newEvent:dispose())
                        )
                        (send newEvent:dispose())
                        (send gGame:setCursor(temp178))
                        (send temp173:signal(gOldCastFirst))
                    )
                )
            )
        )
    )

)
