(version 2)
(include "sci.sh")
(exports
    0 Teller
)
(use "Main")
(use "GloryWindow")
(use "IconI")
(use "GameControls")
(use "Obj")
(script 23)



(procedure (localproc_077b param1 param2 param3)
    Memory(6 + param1 (* 2 param2) param3)
)


(class TellerIcon of IconI
    (properties
        view 935
        loop 2
        cel 0
        nsLeft 0
        nsTop 15
        nsRight 0
        nsBottom 0
        state $0000
        cursor -1
        type $4000
        message -1
        modifiers $0000
        signal $0101
        maskView 361
        maskLoop 3
        maskCel 0
        highlightColor 0
        lowlightColor 0
        noun 0
        modNum 0
        helpVerb 0
        myHandle 0
        value 0
        notEgo 0
        myTeller 0
    )

    (method (show)
        (var temp0[15])
        (if (notEgo)
            Message(0 23 0 0 1 1 @temp0)
            Display(@temp0 100 15 5 102 17)
        )
        = nsRight 80
        = nsBottom (+ nsTop 15)
        DrawCel(view loop cel nsLeft nsTop -1)
        Display(myHandle 100 20 + nsTop 3 102 17)
        (if (& signal $0004)
            (self:mask())
        )
        (if (gPseudoMouse and (send gPseudoMouse:respondsTo(#stop)))
            (send gPseudoMouse:stop())
        )
    )


    (method (select)
        (send myTeller:iconValue(value))
        (send ((send myTeller:theControls)):state((& (send ((send myTeller:theControls)):state) $ffdf)))
        (if (((== self (send ((send myTeller:theControls)):at(0))) or (== self (send ((send myTeller:theControls)):at(1)))) and not notEgo)
            (send gOwner:
                addHonor(1)
                useSkill(13 10)
            )
        )(else
            (send gOwner:useSkill(13 5))
        )
    )


    (method (highlight param1)
        (var temp0)
        (if (param1)
            DrawCel(view loop 1 nsLeft nsTop -1)
            = temp0 46
        )(else
            DrawCel(view loop 0 nsLeft nsTop -1)
            = temp0 17
        )
        Display(myHandle 100 20 + nsTop 3 102 temp0)
    )

)
(class public Teller of Obj
    (properties
        query 0
        curArray 0
        arrays 0
        keys 0
        client 0
        iconValue 0
        theControls 0
    )

    (method (init theClient theCurArray theArrays theKeys)
        = client theClient
        = curArray theCurArray
        = arrays theArrays
        (if (> paramTotal 3)
            = keys theKeys
        )
        (send client:actions(self))
        (super:init())
    )


    (method (respond)
        = query 0
        (self:showDialog())
        (if ((<> query -999) and iconValue)
            = query iconValue
        )
        (if (not query or (== query -999))
            return 1
        )(else
            (if (== query 999)
                (self:doParent())
                return 0
            )(else
                (if ((< query 0) and not (self:doChild(query)))
                    return 1
                )
            )
        )
        = query Abs(query)
        (if (query)
            (send gQg3Messager:say((send client:noun) 5 query 0))
        )
        return 1
    )


    (method (showDialog param1)
        (self:doDialog(
            (if (== proc999_6(arrays 0) curArray)
                1
            )(else
                0
            )
 rest param1))
    )


    (method (doDialog param1)
        (var temp0, temp1, temp2, temp3, newTellerIcon, temp5, temp6, temp7, temp8, newList, temp10, temp11, temp12, temp13, temp14, temp15[30], temp45)
        = temp45 150
        = temp3 0
        = temp0 param1[temp3]
        = temp5 5
        = temp8 0
        = newTellerIcon 0
        = newList (List:new())
        (send (= theControls (GameControls:new())):window((send ((GloryWindow:new())):
                top(40)
                left(85)
                bottom(140)
                right(235)
                priority(15)
                yourself()
            )
))
        (if (<> client gOwner)
            = temp5 (+ temp5 15)
        )
        = temp2 1
        (while (<> proc999_6(curArray temp2) 999)
            = temp6 1
            = temp3 1
            (while (temp6 and (< temp3 paramTotal))
                (if ((== proc999_6(curArray temp2) param1[temp3]) and not param1[(+ temp3 1)])
                    = temp6 0
                )
                = temp3 (+ temp3 2)
            )
            (if (temp6)
                = temp7 proc999_6(curArray temp2)
                = temp14 (self:getSeqNum(Abs(temp7)))
                = temp13 Message(2 gClientModNum (send client:noun) 2 Abs(temp7) temp14)
                (if (not temp13)
                    break
                )
                = temp1 Memory(2 temp13)
                = temp13 (+ (* temp13 7) 20)
                (if (> temp13 temp45)
                    = temp45 temp13
                )
                (send newList:add(temp1))
                Message(0 gClientModNum (send client:noun) 2 Abs(temp7) temp14 temp1)
                = newTellerIcon (TellerIcon:new())
                (send newTellerIcon:
                    myHandle(temp1)
                    value(temp7)
                    nsTop(temp5)
                    myTeller(self)
                )
                (if (<> client gOwner)
                    (send newTellerIcon:notEgo(1))
                )
                (send theControls:add(newTellerIcon))
                ++temp8
                = temp5 (+ temp5 15)
            )
            ++temp2
        )
        (if (not IsObject(newTellerIcon))
            (if (== client gOwner)
                (send client:doVerb(2))
            )(else
                (send gQg3Messager:say(1 6 0 0 0 23))
            )
            (send ((send theControls:window)):dispose())
            (send theControls:dispose())
            (send newList:dispose())
            return -999
        )
        = newTellerIcon (TellerIcon:new())
        (if (not temp0)
            Message(0 23 0 0 2 1 @temp15)
            (send newTellerIcon:
                myHandle(@temp15)
                value(999)
                nsTop(temp5)
                myTeller(self)
            )
        )(else
            Message(0 23 0 0 3 1 @temp15)
            (send newTellerIcon:
                myHandle(@temp15)
                value(-999)
                nsTop(temp5)
                myTeller(self)
            )
        )
        (send theControls:add(newTellerIcon))
        (send ((send theControls:window)):
            top(- 60 (* 7 temp8))
            bottom(- (+ temp5 80) (* 7 temp8))
            left(- 160 (/ temp45 2))
            right(+ 160 (/ temp45 2))
        )
        (send theControls:
            init()
            show()
            dispose()
        )
        = temp10 FirstNode((send newList:elements))
        (while (temp10)
            = temp11 NextNode(temp10)
            = temp12 NodeValue(temp10)
            (if (not temp12)
                break
            )
            Memory(3 temp12)
            = temp10 temp11
        )
        return (send newList:dispose())
    )


    (method (getSeqNum)
        return 1
    )


    (method (doChild param1)
        (var temp0)
        = temp0 0
        (while (++temp0)
            (if (== proc999_6(keys ++temp0) param1)
                (self:stuffArray(proc999_6(arrays temp0) 1))
                return 1
            )
            < proc999_6(keys temp0) 999
        )
        return 1
    )


    (method (doParent)
        (self:stuffArray(proc999_6(curArray 0) 0))
    )


    (method (stuffArray theCurArray param2)
        (if (param2)
            localproc_077b(theCurArray 0 curArray)
        )
        = curArray theCurArray
        return param2
    )


    (method (doVerb theVerb)
        (var clientModNum)
        return 
            (if (IsObject(client) and (== theVerb 2))
                = iconValue 0
                (while (1)
                    (if ((self:respond()))
                        break
                    )
                )
            )(else
                (if (== client gOwner)
                    (send client:doVerb(theVerb))
                )(else
                    (if (IsObject(client))
                        (if (> (send client:modNum) -1)
                            = clientModNum (send client:modNum)
                        )(else
                            = clientModNum gClientModNum
                        )
                        (if (Message(2 clientModNum (send client:noun) theVerb 0 1))
                            (send gQg3Messager:say((send client:noun) theVerb 0 0 clientModNum))
                            return 1
                        )
                    )
                    (if (== theVerb 2)
                        (send gQg3Messager:say(1 2 0 0 0 23))
                    )(else
                        (if (== theVerb 1)
                            (send gQg3Messager:say(1 1 0 0 0 23))
                        )(else
                            (if (== theVerb 4)
                                (send gQg3Messager:say(1 4 0 0 0 23))
                            )(else
                                (if (proc999_5(theVerb 80 78 76 82 81 83 66 86 84 88 75 85 87 77 79))
                                    (send gQg3Messager:say(2 6 7 0 0 23))
                                )(else
                                    (if (proc999_5(theVerb 30 59 47 49 54 45 39 51 10 31))
                                        (send gQg3Messager:say(2 6 4 0 0 23))
                                    )(else
                                        (if (proc999_5(theVerb 11 20 12 13 56 33))
                                            (send gQg3Messager:say(2 6 6 0 0 23))
                                        )(else
                                            (send gQg3Messager:say(2 6 5 0 0 23))
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
    )


    (method (cue)
    )

)
