Author Topic: SCI 1.1 - Refresh Inventory Screen  (Read 2300 times)

0 Members and 1 Guest are viewing this topic.

Offline gumby

SCI 1.1 - Refresh Inventory Screen
« on: February 13, 2021, 02:15:37 PM »
I have a scenario where interacting with an inventory item on the inventory screen needs to change the currently displayed view for the item.  For example, the action being taken within the inventory screen is turning on a flashlight.  I want to swap out the view of the flashlight being off to a view of the flashlight being on.

A kludgey solution is to hide and show the inventory screen, but this also introduces a flicker-effect because the window is being torn down and redisplayed:

Code: [Select]
   (gInv hide:)
   (gInv show:)

What's the correct way to do this?  Is there a built-in way to ask the inventory screen to refresh itself?  Or should I instead reference the view within the inventory screen, change the view and call forceUpd - or something along these lines?


In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Kawa

Re: SCI 1.1 - Refresh Inventory Screen
« Reply #1 on: February 13, 2021, 03:44:37 PM »
In my quick experimentation, having the InvItem in question calling (self show:) was the easiest, most hassle-free method. The only problem is that it drew on top of the old icon.

Here's what I ended up doing:
Code: [Select]
(instance testItem of InvItem
;...
(method (doVerb theVerb)
(if (== theVerb V_OTHERITEM) ; or whatever, V_DO I don't care.
(++ cel) ; or whatever other way you want to turn the flashlight on I guess?

(Graph grFILL_BOX (- nsTop 1) (- nsLeft 1) (+ nsBottom 0) (+ nsRight 0) 1 backgroundColorOfTheInventoryPanel -1 -1)
(DrawCel view loop cel nsLeft nsTop -1)
(Graph grUPDATE_BOX (- nsTop 1) (- nsLeft 1) (+ nsBottom 1) (+ nsRight 1) 1)
)
)
)

Offline gumby

Re: SCI 1.1 - Refresh Inventory Screen
« Reply #2 on: February 13, 2021, 05:55:34 PM »
Thank you Kawa, I had not considered hooking into the InventoryItem and get it done with a doVerb method - works perfectly.  You are the man.
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Collector

Re: SCI 1.1 - Refresh Inventory Screen
« Reply #3 on: February 14, 2021, 06:44:43 PM »
Sounds like you have it solved, but since it is a view could you have two loops for the item, one loop off and another on?
KQII Remake Pic

Offline Kawa

Re: SCI 1.1 - Refresh Inventory Screen
« Reply #4 on: February 14, 2021, 07:38:27 PM »
In my example I changed the cel but no matter which of the three you change -- view, loop, or cel -- the problem was refreshing its appearance in the inventory window.


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

Page created in 0.042 seconds with 24 queries.