Community

SCI Programming => SCI Syntax Help => Topic started by: Cloudee1 on June 21, 2015, 05:05:04 PM

Title: SCI1.1: Missing something with inventory items
Post by: Cloudee1 on June 21, 2015, 05:05:04 PM
Ok, so I have started adding an item or two to the game and I seem to be missing something. I can't get the look item message to display. As well, the item icons seem to overlap a bit as well... Here is what I have done so far.

First in the messages, I added a new noun N_TOILETPAPER. Then I went in and added a message for V_LOOK, N_TOILETPAPER. I also added a verb, V_TEEPEE but that is irrelevant for now until I am ready to use the item in some way.

Next in the sq5invitem script, I added in the instance for the item.

Code: [Select]
(instance ToiletPaper of Sq5InvItem
    (properties
        view 901
        loop 1
        cursor 901
        message V_TEEPEE
        signal $0002
        noun N_TOILETPAPER
    )
)

And in the same script, up towards the top in the sq5Inv instance of scrollableinventory, I added my instance name to the add list.

Code: [Select]
            add(Money ToiletPaper) // TODO: addmore inventory items

Next I drew the necessary views, in 901 as defined in the instance of the item, and finally in the title screen script I threw in a send gEgo get statement so that I had the item at game start.

Now for the most part everything seems to be working, The item is there in my inventory, I can click on it with the arrow and the cursor changes to it. However, when I click to look at the item, the look item message is not triggered. As well, if you look at the screen shot, when the item is highlighted, it seems to overlap the money item icon a bit. Any ideas why the look item message isn't triggering... and whats up with the overlap?

Title: Re: SCI1.1: Missing something with inventory items
Post by: lskovlun on June 21, 2015, 05:38:11 PM
I'm wondering why you have set message to V_TEEPEE in the instance? You noted that it was irrelevant for the time being. As for the lack of reaction, the most obvious reason would seem to be that the if statement in the default doVerb never succeeds. You can test that by putting a Print in there temporarily.
Title: Re: SCI1.1: Missing something with inventory items
Post by: Kawa on June 21, 2015, 05:38:39 PM
Followed all steps but the verb, with my own crass humor to replace yours... couldn't reproduce either problem.

(http://i.imgur.com/4N0RPdL.png)

Could it be a size thing? That is, could it be that your TP is too large to fit in what the script expects? Coin's 21 pixels wide, and so is my thing (including some padding) so maybe...
Title: Re: SCI1.1: Missing something with inventory items
Post by: Cloudee1 on June 21, 2015, 06:00:20 PM
Quote from: lskovlun
I'm wondering why you have set message to V_TEEPEE in the instance? You noted that it was irrelevant for the time being. As for the lack of reaction, the most obvious reason would seem to be that the if statement in the default doVerb never succeeds. You can test that by putting a Print in there temporarily.

I was really just following the money instance as my guide. I have the verb set up in some other scripts to test it. I am assuming that the message is what sets the cursor to the verb in corresponding room script uses.

Quote from: kawa
Followed all steps but the verb, with my own crass humor to replace yours... couldn't reproduce either problem.

Could it be a size thing? That is, could it be that your TP is too large to fit in what the script expects? Coin's 21 pixels wide, and so is my thing (including some padding) so maybe...

Alas, my view is also 21 pixels wide.

Title: Re: SCI1.1: Missing something with inventory items
Post by: troflip on June 21, 2015, 06:03:17 PM
Can you attach your project so we can take a look?

Is the inventory script still 15, or did you move it around?
Title: Re: SCI1.1: Missing something with inventory items
Post by: Cloudee1 on June 21, 2015, 06:10:27 PM
Well of course I moved it lol. But before you ask, I did make sure to change the message header that is included.

Project attached

Title: Re: SCI1.1: Missing something with inventory items
Post by: troflip on June 21, 2015, 06:22:14 PM
As I suspected, this is related to your script re-arranging. The inventory descriptions are still coming from 15.msg, which you didn't remove.

So somewhere in the code there must be a reference to resource 15 for the inventory messages.

[edit:]

In sq5initem.sc, change this:
Code: [Select]
eachElementDo(#modNum 15)

to this:
Code: [Select]
eachElementDo(#modNum SQ5INVITEM_SCRIPT)

I'll take note of that and put that define in the template game.


Note sure about the black border overlap though...
Title: Re: SCI1.1: Missing something with inventory items
Post by: Cloudee1 on June 21, 2015, 06:29:07 PM
Uh oh, Lars has me now lol

I had suspected as much myself, I just haven't managed to find the reference yet myself. I'm scared it might be somewhere in the assembly code cause so far I haven't found anything but I'm thinking probably invi.sc
Title: Re: SCI1.1: Missing something with inventory items
Post by: troflip on June 21, 2015, 06:36:39 PM
Searching all files for 15, matching whole word, makes it pretty easy to find.

As for the inventory icon border, the coin inventory view has specific offsets for each loop/cel. Your toilet paper just has them at default values (the icon dimensions are also off). That might be the reason? Maybe just copy the view.900 to view.901, and then paste your toilet paper images into it.


If that's the case, that's kind of annoying for someone adding inventory items... maybe the code should be changed to handle things with the default offset.

And yeah, when we are all still learning about how the SCI 1.1 games were set up, re-arranging the scripts just makes more possible things go wrong when trying to debug why something isn't working. So for the official template game, for the foreseeable future, I'm going to keep the scripts numbers exactly the same.
Title: Re: SCI1.1: Missing something with inventory items
Post by: Kawa on June 21, 2015, 06:39:44 PM
As for the inventory icon border, the coin inventory view has offsets for each loop/cel. Your toilet paper just has them at default values. That might be the reason? Maybe just copy the view.900 to view.901, and then paste your toilet paper images into it.
Mine has offset 0?0 though?
Title: Re: SCI1.1: Missing something with inventory items
Post by: Cloudee1 on June 21, 2015, 06:48:27 PM
Yeah, found and fixed the print statement... In the Sq5InvItem script

Code: [Select]
   eachElementDo(#modNum SQ5INVITEM_SCRIPT)

Unfortunately changing the offset had no effect.
Title: Re: SCI1.1: Missing something with inventory items
Post by: troflip on June 21, 2015, 07:22:08 PM
Ok. the highlight thing (actually the inv items are drawn overlapping) might be a bug in the drawInvWindow method. Either improperly decompiled, or maybe it got changed after decompilation or something. I'll add it to the list of bugs to investigate.

Title: Re: SCI1.1: Missing something with inventory items
Post by: Cloudee1 on June 24, 2015, 08:21:32 AM
Ok, this will hopefully be my last question about the general functionality of inventory items.

I am having trouble combining two items. The anticipated result being to put the initial 2 and to get a 3rd.

So here is what I have going on... There is the ToiletPaper item

Code: [Select]
//****************************************************
(instance ToiletPaper of Sq5InvItem
    (properties
        view 1001
        loop 0
        cel ITEM_TOILETPAPER
        message V_TEEPEE
        signal $0002
        noun N_TOILETPAPER
    )
  (method (init)
  = cursor toiletpaperCursor
  (super:init())
  )
)
(instance toiletpaperCursor of Cursor(properties view 1000 loop 0 cel ITEM_TOILETPAPER))

and there's the FilledBasket item, which is what I am hoping to get out of combining the two items.

Code: [Select]
(instance FilledBasket of Sq5InvItem
    (properties
        view 1001
        loop 0
        cel ITEM_FILLEDBASKET
        message V_FBASKET
        signal $0002
        noun N_FBASKET
    )
  (method (init)
  = cursor fullbasketCursor
  (super:init())
  )
)
(instance fullbasketCursor of Cursor(properties view 1000 loop 0 cel ITEM_FILLEDBASKET))

and then there is the EmptyBasket item. This is where I am attempting to code the combination of the two items. I spent several hours last night trying to get this to work right... and for the most part this sort of does. But not really.

I included a doVerb method in the item instance and when the verb is the toilet paper verb, I attempt to swap the items around. If I include the print or the testmessager as part of the verb case, bad things happen, so you'll notice that I do still include the super doverb in the case just to get the dialog to occur. Also, I would rather refresh the inventory window than close it, but I don't know the best way to accomplish that. And finally, the toilet paper items cursor remains the active cursor. Even though the item gets dropped.

Code: [Select]
(instance EmptyBasket of Sq5InvItem
    (properties
        view 1001
        loop 0
        cel ITEM_EMPTYBASKET
        message V_BASKET
        signal $0002
        noun N_BASKET
    )
  (method (init)
  = cursor emptybasketCursor
  (super:init())
  )
 
  (method (doVerb theVerb param2 param3)
  (switch (theVerb)
      (case V_TEEPEE
        // (send gTestMessager:say(N_BASKET V_TEEPEE 0)) // Noun, Verb, Condition

      //     (Print:addText("You wisely throw the toilet paper into the empty basket.")
      //           init()
      //      )
          (send gEgo:put(ITEM_TOILETPAPER))
          (send gEgo:put(ITEM_EMPTYBASKET))
          (send gEgo:get(ITEM_FILLEDBASKET))
        (super:doVerb(theVerb param2 rest param3))
          (send gSq5Inv:hide(1))
      )
      (default (super:doVerb(theVerb param2 rest param3)))
    )
  )
)
(instance emptybasketCursor of Cursor(properties view 1000 loop 0 cel ITEM_EMPTYBASKET))

Has anyone else managed to successfully combine two items. This was as close as I could come on my own.
Title: Re: SCI1.1: Missing something with inventory items
Post by: Cloudee1 on June 24, 2015, 09:45:45 PM
So I lied about that being my last question regarding inventory items... Which I still haven't figured out yet.

But anyway, I have another one. So we start off with money as a built in inventory item. That's all fine and dandy but we are going to need a way to know how much money we have, or rocks, or empty potion bottles etc.

I am just 20 pixels from having this sorted out but I just can't seem to get it done. Again, this is something I have spent a couple of hours trying to sort out and again. This is as close as I can come on my own.

So first, in the main script I added a global variable to keep track of just how much cash we currently have on hand.
Code: [Select]
  gTotalMoney= 150

Then again, I added a doVerb method to the money items instance.
Code: [Select]
(instance Money of Sq5InvItem
    (properties
        view 1001
        loop 0   // icon view
        cel ITEM_MONEY   // icon cel
        message V_PAY
        signal $0002
        noun N_MONEY
    )
    (method (init)
  = cursor moneyCursor
    (super:init())
    )

    (method (doVerb theVerb param2)
    (var temp0,temp1,tempStr1[40], dialog)
    (if(not modNum)
       = modNum gModNum
    )
        (switch (theVerb)
            (case V_LOOK
            (if (== gTotalMoney 1)
              Format(@tempStr1 "You have %d single solitary dollar." gTotalMoney)
                )
                (else
              Format(@tempStr1 "You have %d bucks." gTotalMoney)
                )
                = temp1 CelWide(view loop cel)
                = temp0 GetPort()
                      (Print:
                        addIcon(view loop cel 1 1)
                        addText(@tempStr1)
                        init()
                      )
                SetPort(temp0)
            )
            (default
                (super:doVerb(theVerb param2))

            )
        )
    )

)
(instance moneyCursor of Cursor(properties view 1000 loop 0 cel ITEM_MONEY))

As you can see in the screenshot, I am so close... but the text and the icon overlap. Please help.... With this and the last issue. They are really driving me bananas
Title: Re: SCI1.1: Missing something with inventory items
Post by: troflip on June 24, 2015, 10:32:04 PM
It looks like you're passing 1 and 1 for the position of the icon.
What happens if you change those numbers so it is positioned below the text?

Also, do you really need that GetPort/SetPort stuff?
Title: Re: SCI1.1: Missing something with inventory items
Post by: Cloudee1 on June 24, 2015, 10:53:07 PM
The get port and set port is absolutely important... I don't know what it does lol, but without it. Well check out the first screenshot. After looking at the money, things get pretty funky.

... and actually, adding in a couple of parameters to the addText call and tweaking the two on the addIcon seems to have really straightened things out.

Code: [Select]
                      (Print:
                        addText(@tempStr1 25 5)
                        addIcon(view loop cel 0 -5)
                        init()
                      )

By the way, it was for this little tidbit that I was attempting to use a text resource to answer your question posed in the other thread.

Now I guess all that is left to do is manage to combine two items.
Title: Re: SCI1.1: Missing something with inventory items
Post by: Cloudee1 on June 25, 2015, 01:12:33 AM
Holy crap, it worked....  ;D

When clicking on the empty trash can with the toilet paper, the toilet paper and empty trashcan go away and the filled trash can item is gotten. The inventory screen refreshes and the tp cursor goes away. There is a momentary flicker as the screen refreshes, but I don't know that that is avoidable.

Hooray! I still haven't tried to get the print message to display again, but as of right this moment I don't really care. Time for a cigarette and to hit the hay.

Code: [Select]
(instance EmptyBasket of Sq5InvItem
    (properties
        view 1001
        loop 0
        cel ITEM_EMPTYBASKET
        message V_BASKET
        signal $0002
        noun N_BASKET
    )
  (method (init)
  = cursor emptybasketCursor
  (super:init())
  )
 
  (method (doVerb theVerb param2 param3)
  (var temp0, tempStr1[40])
  (switch (theVerb)
      (case V_TEEPEE
          (sq5Inv:hide())
          (send gEgo:put(ITEM_TOILETPAPER 1))
          (send gEgo:put(ITEM_EMPTYBASKET 1))
          (send gEgo:get(ITEM_FILLEDBASKET 1))
          (sq5Inv:curIcon(0)show(gEgo))
      )
      (default (super:doVerb(theVerb param2 rest param3)))
    )
  )
)
(instance emptybasketCursor of Cursor(properties view 1000 loop 0 cel ITEM_EMPTYBASKET))
Title: Re: SCI1.1: Missing something with inventory items
Post by: Kawa on June 25, 2015, 06:22:28 AM
Congratulations on seemingly solving your programming problems, Cloud.
Title: Re: SCI1.1: Missing something with inventory items
Post by: Kawa on January 21, 2016, 05:18:20 PM
Old thread, but still: if you want to add some padding between inventory items, I found a nice lead.

Try finding these lines in ScrollableInventory::drawInvWindow:
Code: [Select]
(if (-- theNumCols)
(= temp16 (+ temp16 theTheTheTheCurPos)) ; <--
else
(= theNumCols numCols)
(= temp17 (+ temp17 theTheTheCurPos)) ; <--
(= temp16 temp18)
)
I've confirmed that adding a bit extra to temp16 and 17 there effectively pads out the items a bit. Something like (= temp16 (+ (+ temp16 theTheTheTheCurPos)) 4) or whatnot.

They overlap because InvI::highlight draws outside of the item's nsRect (among other reasons, maybe) which causes the "highlight rectangle on neighboring items" thing.

I'm gonna try and figure out better variable names now, good night.

Edit: considering these lines identify basically as (= theY (+ theY theTallest)), I can suggest this instead:
After the first while loop, which (among other things) determines the values for theTallest/theTheTheCurPos and theWidest/theTheTheTheCurPos, why not do this instead?
Code: [Select]
(self next: scrollableInventoryFirst)
)
)
(= theTheTheCurPos (+ theTheTheCurPos 4)) ; <-- theTallest, add this.
(= theTheTheTheCurPos (+ theTheTheTheCurPos 4)) ; <-- theWidest, add this.
(if (not (items size?))
Title: Re: SCI1.1: Missing something with inventory items
Post by: OmerMor on January 22, 2016, 03:58:54 AM
Kawa,
if you want better variable names, perhaps the original source here could help you:
Code: [Select]
;;;;
;;;;  INVENT.SC
;;;;
;;;;  (c) Sierra On-Line, Inc, 1992
;;;;
;;;;  Author:  Unkown
;;;;  Updated:
;;;;     Brian K. Hughes
;;;;     July 24, 1992
;;;;
;;;;  Classes:
;;;;     InvItem
;;;;     Inventory


(script# INVENT)


(local
   numCols
)

(class InvItem kindof IconItem
   ;;; An InvItem is something which can be owned by an object in an
   ;;; adventure game.

   (properties
      -info-      $8004    ;(| CLASSBIT NODISPLAY)
      name        "InvI"   ;my literal name
      owner       0        ;who owns this item
      view        0        ;picture of the item
      loop        0
      cel         0
      nsLeft      0
      nsTop       0
      nsRight     0
      nsBottom    0
      state       0
      cursor      ARROW_CURSOR ;cursor # (mouse cursor representation of item)
      script      0        ;a script that can control the item
      signal      0
      value       0
      message     NULL     ;verb this item gives
      noun        NULL     ;noun we respond to
      modNum      -1       ;module from which we get our messages
   )

   (methods
      onMe              ;select icon if event's x/y is in icon's rectangle
      highlight         ;draw/erase selector box
      select            ;process item selection
      ownedBy           ;return TRUE if owned by given object
      drawSelf          ;display this item
      moveTo            ;change ownership of this item
      showSelf          ;show and identify item
      doit              ;manipulate item
      useit             ;use one inventory item on another
      changeState       ;go to new state in item's script
      doVerb            ;handle verbs
   )


   (method (onMe event)
      (return
         (and
            (super onMe: event)
            (not (& signal DISABLED))
         )
      )
   )

   (method (doVerb theVerb &tmp tut)
      (if (== modNum -1)
         (= modNum curRoomNum)
      )

      ; If we're not a Print-only game and if there is a message, tell
      ;  the messager to go for it

      (if (and msgType
               (Message MsgGet modNum noun theVerb NULL 1)
            )
         (messager say: noun theVerb NULL NULL NULL modNum)
      )

      ; If there's a tutorial running, take care of it
      (if (and (= tut (theGame script?))
               (tut isKindOf: Tutorial)
         )
         (cond
            ((!= (tut nextItem?) self)
               (tut report: self)
            )
            ((!= (tut nextAction?) theVerb)
               (tut report: theVerb)
            )
            (else
               (tut cue:)
            )
         )
      )
   )

   (method (highlight  tOrF &tmp t l b r sColor)
      (if (== highlightColor -1)(return))
      (= sColor (if (and argc tOrF) highlightColor else lowlightColor))
      ;** Draw or erase selector box based on setting of selected state
      (= t (- nsTop 2))
      (= l (- nsLeft 2))
      (= b (+ nsBottom 1))
      (= r (+ nsRight 1))

      (Graph GDrawLine t l t r  sColor -1 -1)
      (Graph GDrawLine t r b r  sColor -1 -1)
      (Graph GDrawLine b r b l  sColor -1 -1)
      (Graph GDrawLine b l t l  sColor -1 -1)
      (Graph GShowBits (- nsTop 2) (- nsLeft 2) (+ nsBottom 2) (+ nsRight 2) VMAP)
   )

   (method (show &tmp iconNo iX tmpX celWide)
      (DrawCel view loop cel nsLeft nsTop -1)
   )

   (method (ownedBy id)
      ;** return TRUE if this item owned by passed object ID
      (return (== owner id))
   )
   

   (method (moveTo id)
      ;** set item's "owner" to passed object ID
      (= owner id)
      (if (and
            value
            (== id ego)
         )
         (theGame changeScore: value)
         (= value 0)
      )
      (return self)
   )

)

(class Inventory kindof IconBar
   ;;; This is the set of all inventory items in the game.

   (properties
      name              "Inv"
      normalHeading     "You are carrying:"
      heading           0
      empty             "nothing!"
      highlightedIcon   0
      curIcon           0
      window            0
      iconBarInvItem    0
      okButton          NULL
      selectIcon        NULL
   )

   (methods
      showSelf       ;display inventory owned by an object
      ownedBy        ;return InvItem owned by an object
      highlight
      select
      advance
      retreat
      drawInvWindow
   )

   (method (drawInvWindow whom selection
                  &tmp
                  numOwned tallestInv  widestInv
                  numIcons tallestIcon iconBarWidth
                  cWide cHigh node obj invW invH
                  iTop iLeft iBottom iRight
                  numRows atX atY firstX i invWin
                  [buffer 50]
            )

      ;** init positioning vars
      (= numOwned
         (= tallestInv 
            (= widestInv
               (= numIcons
                  (= tallestIcon
                     (= iconBarWidth 0)
                  )
               )
            )
         )
      )

      ;** search inventory items for those owned by this character
      ;** and find the dimensions and numbers for determining the
      ;** window size
      (for  ((= node (self first:)))
            node
            ((= node (self next: node)))
         (if ((= obj (NodeValue node)) isKindOf: InvItem)
            (if   (obj ownedBy:whom)
               (obj signal: (& (obj signal?) (~ DISABLED)))
               (++ numOwned)
               (if (> (= cWide (CelWide (obj view?)(obj loop?)(obj cel?))) widestInv)
                  (= widestInv cWide)
               )
               (if (> (= cHigh (CelHigh (obj view?)(obj loop?)(obj cel?))) tallestInv)
                  (= tallestInv cHigh)
               )
            else
               (obj signal: (| (obj signal?) DISABLED))
            )
         else  ;; some other kind of icon
            (++ numIcons)
            (+= iconBarWidth (CelWide (obj view?)(obj loop?)(obj cel?)))
            (if (> (= cHigh (CelHigh (obj view?)(obj loop?)(obj cel?))) tallestIcon)
               (= tallestIcon cHigh)
            )
         )
      )
      (if (not numOwned)
         (Print
            addTextF:   {%s %s} normalHeading empty,
            init:
         )
         (return FALSE)
      )
      (= numRows (Sqrt numOwned))
      ;; I want the truncated Square root, not the rounded
      (if (> (* numRows numRows) numOwned)
         (-- numRows)
      )
      ;;HOOK
      (if (> numRows 3) (= numRows 3))
      (= numCols (/ numOwned numRows))
      (if (< (* numRows numCols) numOwned)
         (++ numCols)
      )
      (= invW (Max (+ 4 iconBarWidth) (* numCols (+ 4 widestInv))))
      (= invH (* numRows (+ 4 tallestInv)))
      (= iTop (/ (- 190 invH) 2))
      (= iLeft (/ (- 320 invW) 2))
      (= iBottom (+ iTop invH))
      (= iRight (+ iLeft invW))
      (if (= invWin (self window?))
         (invWin
            top:     iTop,
            left:    iLeft,
            right:   iRight,
            bottom:  iBottom,
            open:
         )
      )
      (= i numCols)
      ;** check to see if there is something to draw
      (if numOwned

         ;** compute window position of first item
         (= atY
            (+ 2
               (if (invWin respondsTo: #yOffset)
                  (invWin yOffset:)
               ; else 0
               )
            )
         )
         (= firstX
            (= atX
               (+ 4
                  (if (invWin respondsTo: #xOffset)
                     (invWin xOffset:)
                  ; else 0
                  )
               )
            )
         )
         ;** draw active items
         (for  ((= node (self first:)))
            node
            ((= node (self next: node)))

         ;** see if this item is active
            (if (and
                  (not (& ((= obj (NodeValue node)) signal?) DISABLED))
                  (obj isKindOf: InvItem)
               )

               ;** compute window position of variable position items
               (if (not (& (obj signal?) FIXED_POSN))
                  (obj
                     nsLeft:
                        (+ atX
                           (/
                              (- widestInv
                                 (= cWide (CelWide (obj view?)(obj loop?)(obj cel?)))
                              )
                              2
                           )
                        ),
                     nsTop:     
                        (+ atY
                           (/
                              (- tallestInv
                                 (= cHigh (CelHigh (obj view?)(obj loop?)(obj cel?)))
                              )
                              2
                           )
                        )
                  )
                  (obj
                     nsRight: (+ (obj nsLeft?) cWide),
                     nsBottom: (+ (obj nsTop?) cHigh)
                  )
                  ;** see if a line of items is complete
                  (if (-- i)
                     (+= atX widestInv)
                  else
                     ;** compute window position of next line
                     (= i numCols)
                     (+= atY tallestInv)
                     (= atX firstX)
                  )
               else
                  ;** set position of fixed position item
                  (= atX   (obj nsLeft?))
                  (= atY   (obj nsTop?))
               )

               ;** draw the item in the window
               (obj  show:)
               ;** see if item is the current selection and the window was
               ;** invoked from the keyboard
               (if (== obj selection)
                  ;** draw selector box around item and set current node to item
                  (obj highlight:)
               )
            )
         )
      )
      (= atX   (/ (- (- (invWin right?) (invWin left?)) iconBarWidth) 2))
      (= invH (- (invWin bottom?) (invWin top?)))
      (= atY $7fff)
      (for  ((= node (self first:)))
            node
            ((= node (self next: node)))
         (if (not ((= obj (NodeValue node)) isKindOf: InvItem))
            (obj nsTop: 0)
            (= cWide (CelWide (obj view?)(obj loop?)(obj cel?)))
            (= cHigh (CelHigh (obj view?)(obj loop?)(obj cel?)))
            (if (not (& (obj signal?) FIXED_POSN))
               (if (== atY $7fff)
                  (= atY (- invH cHigh))
               )
               (obj
                  nsLeft:     atX,
                  nsTop:      atY,
                  nsBottom:   invH ,
                  nsRight:    (+ atX cWide) ,
               )
            )
            (= atX (+ (obj nsLeft?) cWide))
            (= atY (obj nsTop?))
            (obj
               signal:  (& (obj signal?) (~ DISABLED)),
               show:
            )
         )
      )
      (return TRUE)
   )


   (method (init)
      (= heading normalHeading)
   )


   (method (ownedBy whom)
     
      ;** Return the first item in inventory which is owned by `whom'
      (return (self firstTrue: #ownedBy: whom))
   )

     
   (method (showSelf who)
      (sounds pause:)
      (if (and pMouse (pMouse respondsTo: #stop))
         (pMouse stop:)
      )
      (if (theIconBar height?)
         (theIconBar hide:)
      )
      (if (not window?)
         (= window (SysWindow new:))
      )
      (if (window window?)
         (window dispose:)
         (= window 0)
      )
      (if (not okButton)
         (= okButton (NodeValue (self first?)))
      )
      (= curIcon NULL)
      (if (self show: (if argc who else ego))
         (self doit:)
      )
   )

   (method (show who &tmp pnv diw)
      (theGame setCursor:
         (if curIcon
            (curIcon cursor?)
         else
            (selectIcon cursor?)
         )
      )
      (= pnv (PicNotValid))
      (PicNotValid FALSE)
      (|= state IB_ACTIVE)
      (if (not (= diw (self drawInvWindow (if argc who else ego) (theIconBar curIcon?))))
         (&= state (~ IB_ACTIVE))
      )
      (PicNotValid pnv)
      (return diw)
   )

   (method (advance amount &tmp theIcon toMove highlightedNo nextIcon)
      (= toMove (if argc amount else 1))
      (= highlightedNo (self indexOf: highlightedIcon))
      (= nextIcon (+ toMove highlightedNo))
      (repeat
         (= theIcon
            (self at:
               (if (<= nextIcon size)
                  nextIcon
               else
                  (mod nextIcon (- size 1))
               )
            )
         )
         (if (not (IsObject theIcon))
            (= theIcon (NodeValue (self first:)))
         )
         (if (not (& (theIcon signal?) DISABLED))
            (break)
         else
            (++ nextIcon)
         )
      )
      (self highlight:theIcon TRUE)
   )

   (method (retreat amount &tmp theIcon toMove highlightedNo nextIcon)
      (= toMove (if argc amount else 1))
      (= highlightedNo (self indexOf: highlightedIcon))
      (= nextIcon (- highlightedNo toMove))
      (repeat
         (= theIcon
            (self at: nextIcon)
         )
         (if (not (IsObject theIcon))
            (= theIcon (NodeValue (self last:)))
         )
         (if (not (& (theIcon signal?) DISABLED))
            (break)
         else
            (-- nextIcon)
         )
      )
      (self highlight:theIcon TRUE)
   )
   
   (procedure (FindIcon hIcon y1 y2 &tmp thisIcon theY theX)
      (= theX (+ (/ (- (hIcon nsRight?) (hIcon nsLeft?)) 2) (hIcon nsLeft?)))
      (for  ((= theY y1))
            (>= (Abs (- theY y2)) 4)
            ((if (< y1 y2) (+= theY 4) else (-= theY 4)))
         (if (= thisIcon
               (self firstTrue: #onMe:
                  (((user curEvent?) new:)
                     x:       theX,
                     y:       theY,
                     yourself:
                  )
               )
            )
            (return thisIcon)
         )
      )
   )

   (method (doit &tmp thisIcon event eType eMsg eMod node newIcon eO
                     oldPort keyInvoked [buffer 50] tut
      )
      ;; eat all events in queue
      (while ((= event ((user curEvent?) new:)) type?))

      (while (& state IB_ACTIVE)
         (= event ((user curEvent?) new:))
         (= mouseX   (event x?))
         (= mouseY   (event y?))
         (= eType    (event type?))
         (= eMsg     (event message?))
         (= eMod     (event modifiers?))
         (= keyInvoked FALSE)
         (event localize:)

         ; if curIcon use it as an event conditioner
         (if (and
               curIcon
               (not eMod)
               (!= curIcon selectIcon)
               (or
                  (== eType mouseDown)
                  (and
                     (== eType keyDown)
                     (== eMsg ENTER)
                     (= keyInvoked TRUE)
                  )
                  (and
                     (== eType joyDown)
                     (= keyInvoked TRUE)
                  )
               )
            )
            (if (or
                  (!= curIcon helpIconItem)
                  (& (helpIconItem signal?) TRANSLATOR)
               )
               (event
                  type:    userEvent,     ;BKH Should this be helpEvent?
                  message: (curIcon message?)
               )
            )
         )

         (MapKeyToDir event)

         ; In case of a direction event, refresh the temps
         (= eType (event type?))
         (= eMsg  (event message?))

         ; So we can get cues from Messager & such
         (if cuees
            (cuees eachElementDo: #doit)
         )

         ; If there's a tutorial running, give it a doit
         (if (and (= tut (theGame script?))
                  (tut isKindOf: Tutorial)
            )
            (tut doit:)
         )

         (cond
            (fastCast
               (fastCast handleEvent: event)
            )

            ((and (== eType mouseDown) eMod)
               (self advanceCurIcon:)
               (event claimed: TRUE)
            )

            ;; highlight the appropriate icon
            ((and
                  (== eType nullEvt)   
                  (= thisIcon (self firstTrue: #onMe event))
                  (!= thisIcon highlightedIcon)
               )
               (self highlight: thisIcon)
            )

            ;; selection was made
            ((or
                  (== eType mouseDown)
                  (and
                     (== eType keyDown)
                     (== eMsg ENTER)
                  )
                  (== eType joyDown)

               )
               (cond
                  ((and
                        (IsObject highlightedIcon)
                        (self select: highlightedIcon (== eType mouseDown))
                     )
                     (cond
                        ((== highlightedIcon okButton)
                           (event claimed: TRUE)
                           (break)
                        )
                        ((== highlightedIcon helpIconItem)
                           (if (!= (highlightedIcon cursor?) -1)
                              (theGame setCursor: (helpIconItem cursor?))
                           )
                           (cond
                              ((& state NOCLICKHELP)
                                 (self noClickHelp:)
                              )
                              (helpIconItem
                                 (helpIconItem signal:(| (helpIconItem signal?) TRANSLATOR))
                              )
                           )
                        )
                        (else
                           (= curIcon highlightedIcon)
                           (theGame setCursor: (curIcon cursor?))
                        )
                     )
                  )
               )
            )

            ;; advance or retreat from dir keys or joyStick?
            ((& eType direction)
               (switch eMsg
                  (dirE
                     (self advance:)
                  )
                  (dirW
                     (self retreat:)
                  )
                  (dirN
                     (if (and
                           highlightedIcon
                           (= thisIcon
                              (FindIcon highlightedIcon (- (highlightedIcon nsTop?) 1) 0)
                           )
                        )
                        (self highlight: thisIcon TRUE)
                     else
                        (self retreat:)
                     )
                  )
                  (dirS
                     (if (and
                           highlightedIcon
                           (= thisIcon
                              (FindIcon highlightedIcon (+ (highlightedIcon nsBottom?) 1) (window bottom?))
                           )
                        )
                        (self highlight: thisIcon TRUE)
                     else
                        (self advance:)
                     )
                  )
                  (dirStop
                     (if (& eType keyDown)
                        (self advanceCurIcon:)
                     )
                  )
               )
            )

            ((== eType keyDown)
               (switch eMsg
                  (TAB
                     (self advance:)
                  )
                  (SHIFTTAB
                     (self retreat:)
                  )
                  (ESC
                     (break)
                  )
               )
            )

            ((& eType userEvent)
               (if (= thisIcon (self firstTrue: #onMe event))
                  (cond
                     ((& eType helpEvent)
                        (if (and thisIcon (thisIcon noun?))
                           (if (Message MsgGet (thisIcon modNum?) (thisIcon noun?) (thisIcon helpVerb?) NULL 1 @buffer)
                              (if (systemWindow respondsTo: #eraseOnly)
                                 (= eO (systemWindow eraseOnly?))
                                 (systemWindow eraseOnly: TRUE)
                                 (Prints @buffer)
                                 (systemWindow eraseOnly: eO)
                              else
                                 (Prints @buffer)
                              )
                           )
                        )
;                       (if helpIconItem
                           (helpIconItem signal: (& (helpIconItem signal?) (~ TRANSLATOR)))
;                       )
                        (theGame setCursor: ARROW_CURSOR)
                     )
                     ((== thisIcon okButton)
                        (event claimed: TRUE)
                        (break)
                     )
                     ((not (thisIcon isKindOf: InvItem))
                        (if (self select: thisIcon (not keyInvoked))
                           (= curIcon thisIcon)
                           (theGame setCursor: (curIcon cursor?))
                           (if (== thisIcon helpIconItem)
                              (if (& state NOCLICKHELP)
                                 (self noClickHelp:)
                              else
                                 (helpIconItem signal:(| (helpIconItem signal?) TRANSLATOR))
                              )
                           )
                        )
                     )
                     (curIcon
                        (if (systemWindow respondsTo: #eraseOnly)
                           (= eO (systemWindow eraseOnly?))
                           (systemWindow eraseOnly: TRUE)
                        ) 
                        (if (curIcon isKindOf: InvItem)
                           (thisIcon doVerb: (curIcon message?))
                        else
                           (thisIcon doVerb: (event message?))
                        )
                        (if (systemWindow respondsTo: #eraseOnly)
                           (systemWindow eraseOnly: eO)
                        )
                     )
                  )
               )
            )
         )
      )
      (self hide:)
   )
   

   (method (hide &tmp theCurs)
      (if (& state IB_ACTIVE)
         (sounds pause: FALSE)
         (&= state (~ IB_ACTIVE))
      )
      (if window   
         (window dispose:)
      )
      (if (and (IsObject curIcon?)
               (curIcon isKindOf: InvItem)
            )
         ;; if we had no curInvIcon, enable the use since we now have one
         (if (not (theIconBar curInvIcon?))
            (theIconBar enable: (theIconBar useIconItem?))
         )
         ;; set the useIcon window to the current inv item
         (theIconBar
            curIcon:
               ((theIconBar useIconItem?)
                  cursor: (curIcon cursor?),
                  yourself?
               ),
            curInvIcon: curIcon
         )
         (if (= theCurs ((theIconBar curIcon?) cursor?))
            (theGame setCursor: theCurs)
         )
      )
   )
)
Title: Re: SCI1.1: Missing something with inventory items
Post by: Cloudee1 on January 22, 2016, 08:41:25 AM
I have noticed that too, that the highlight draws around the outside of the view. My solution was just to add a bit of padding to the cels.

I followed your lead here and went into the scrollableInventory script except I just added 2 to the celWide, and celHigh results in the drawInvWindow method...
Code: [Select]
                    = theTheTheTheTheCurPos_2 (+ CelWide((send temp9:view) (send temp9:loop) (send temp9:cel)) 2) // added the plus 2
                    (if (> theTheTheTheTheCurPos_2 theTheTheTheCurPos)
                        = theTheTheTheCurPos theTheTheTheTheCurPos_2
                    )
                    = theTheTheTheCurPos_2 (+ CelHigh((send temp9:view) (send temp9:loop) (send temp9:cel)) 2)// added the plus 2
                    (if (> theTheTheTheCurPos_2 theTheTheCurPos)
                        = theTheTheCurPos theTheTheTheCurPos_2
                    )

Here is the before and after results. Perfect fix, thanks Kawa for bringing this back up.
Title: Re: SCI1.1: Missing something with inventory items
Post by: lskovlun on January 22, 2016, 09:24:47 AM
Is the pink background intentional?
Title: Re: SCI1.1: Missing something with inventory items
Post by: Cloudee1 on January 22, 2016, 02:08:43 PM
Yes it is, that shows me and everyone else where the edges of the cel end. So in the top half, you'll see that the icon cels are butted up against each other. So when the highlight border is drawn around the cel, it overlaps the cels next to it. In the bottom image, the cels are generated with the space between them so the highlight has a place set aside for it.