Author Topic: Where is the inventory window drawn?  (Read 2081 times)

0 Members and 1 Guest are viewing this topic.

Offline MusicallyInspired

Where is the inventory window drawn?
« on: April 28, 2019, 12:28:07 AM »
I want to move the inventory item list sub-window (insetwindow?) to the top of the inventory GUI window and move the control buttons to the bottom instead. Trying to find where this is laid out. I'm worried this happens in the ScrollableInventory script which is largely unintelligible at the moment and has a lot of disassembly code.


Brass Lantern Prop Competition

Offline Kawa

Re: Where is the inventory window drawn?
« Reply #1 on: April 28, 2019, 08:01:06 AM »
The InsetWindow class is what actually draws the panel, its position determined by the xOffset/yOffset properties. As for the assembly code, you don't need to worry: the important part is in ScrollableInventory::drawInvWindow. Which is a mess and a half of guessed variable names but still!

In an otherwise untouched ScrollableInventory.sc, around line 1322 it runs through all the objects that were added, checks if they're inventory items or not, and places them accordingly:
Code: [Select]
(= temp17 32767)
(if firstThru
  (= scrollableInventoryFirst (self first:))
  (while scrollableInventoryFirst
    (= temp9 (NodeValue scrollableInventoryFirst))

    (if (not (temp9 isKindOf: InventoryItem))
      ; This is a button
      (= theTheTheTheTheCurPos_2
        (CelWide (temp9 view?) (temp9 loop?) (temp9 cel?))
      )
      (= theTheTheTheCurPos_2
        (CelHigh (temp9 view?) (temp9 loop?) (temp9 cel?))
      )
      (if (not (& (temp9 signal?) $0080)) ;icFIXED
        ; If we haven't decided the height of the iconbar,
        ; do so now.
        (if (== temp17 32767)
          (= temp17 (- temp11 theTheTheTheCurPos_2))
          ; ...so that's a pretty good hint I guess.
          ; that's actually (= atY (- invH cHigh))
        )
        ; Place the button along the top.
        (temp9
          nsLeft: temp16
          nsTop: temp17
          nsBottom: (+ temp17 theTheTheTheCurPos_2)
          nsRight: (+ temp16 theTheTheTheTheCurPos_2)
        )
      )
      (= temp16 (+ (temp9 nsLeft?) theTheTheTheTheCurPos_2))
      (= temp17 (temp9 nsTop?))
      (temp9 signal: (& (temp9 signal?) $fffb))
      (temp9 show:)
    )
    (= scrollableInventoryFirst
      (self next: scrollableInventoryFirst)
    )
  )
)

Now, right before that it tries to lay out the items, and that quite explicitly according to the InsetWindow's offsets. It uses temp17/atY for that, but then reuses it -- after all, it'll point at the last item's coordinate in the grid, not the top of the window.


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.061 seconds with 24 queries.