(include "sci.sh")
(use "Main")
(use "n255")
(use "DIcon")
(use "InvI")
(script 16)


(local
    newDButton
    local1[2]

)
(procedure public (proc16_1)
)


(procedure public (proc16_2)
)


(instance public dInvD of Dialog
    (properties)

    (method (init)
        (var temp0, temp1, temp2, temp3, newDText, gSq5InvFirst, temp6)
        = temp2 (= temp0 (= temp1 4))
        = temp3 0
        = gSq5InvFirst (send gSq5Inv:first())
        (while (gSq5InvFirst)
            = temp6 NodeValue(gSq5InvFirst)
            ++temp3
            (if ((send temp6:isKindOf(InvI)))
                (self:add((send ((= newDText (DText:new()))):
                        value(temp6)
                        text((send temp6:name))
                        nsLeft(temp0)
                        nsTop(temp1)
                        state(3)
                        font(global23)
                        setSize()
                        yourself()
                    )
))
            )
            (if (< temp2 (- (send newDText:nsRight) (send newDText:nsLeft)))
                = temp2 (- (send newDText:nsRight) (send newDText:nsLeft))
            )
            (if (> (= temp1 (+ temp1 (+ (- (send newDText:nsBottom) (send newDText:nsTop)) 1))) 140)
                = temp1 4
                = temp0 (+ temp0 (+ temp2 10))
                = temp2 0
            )
            = gSq5InvFirst (send gSq5Inv:next(gSq5InvFirst))
        )
        = window gSq5Win
        (self:setSize())
        = newDButton (DButton:new())
        (send newDButton:
            text("All Done!")
            setSize()
            moveTo(- nsRight (+ 4 (send newDButton:nsRight)) nsBottom)
        )
        (send newDButton:move((- (send newDButton:nsLeft) (send newDButton:nsRight)) 0))
        (self:
            add(newDButton)
            setSize()
            center()
        )
        return temp3
    )


    (method (doit)
        (var temp0)
        (asm
            pushi   #init
            pushi   0
            self    4
            pushi   #open
            pushi   2
            pushi   4
            pushi   15
            self    8
            lal     local0
            sat     temp0
code_0167:  pushi   #doit
            pushi   1
            lst     temp0
            super   Dialog, 6
            sat     temp0
            not     
            bt      code_0182
            lst     temp0
            ldi     65535
            eq?     
            bt      code_0182
            lst     temp0
            lal     local0
            eq?     
            bnt     code_0184
code_0182:  jmp     code_019f
code_0184:  pushi   #get
            pushi   1
            pushi   #indexOf
            pushi   1
            pushi   #value
            pushi   0
            lat     temp0
            send    4
            push    
            lag     gSq5Inv
            send    6
            push    
            lag     gEgo
            send    6
            jmp     code_0167
code_019f:  pushi   #eachElementDo
            pushi   2
            pushi   111
            pushi   1
            pushi   111
            pushi   0
            self    12
            ret     
        )
    )


    (method (handleEvent pEvent)
        (var pEventMessage, pEventType)
        = pEventMessage (send pEvent:message)
        (switch (= pEventType (send pEvent:type))
            (case 4
                (
                (switch (pEventMessage)
                    (case 18432
                        (= pEventMessage 3840  )
                    )
                    (case 20480
                        (= pEventMessage 9 )
                    )
                )
  )
            )
            (case 64
                (
                (switch (pEventMessage)
                    (case 1
                        (= pEventMessage 3840 = pEventType 4  )
                    )
                    (case 5
                        (= pEventMessage 9 = pEventType 4 )
                    )
                )
 )
            )
        )
        (send pEvent:
            type(pEventType)
            message(pEventMessage)
        )
        (super:handleEvent(pEvent))
    )

)
