Community

SCI Programming => SCI Syntax Help => Topic started by: Doan Sephim on October 28, 2022, 08:54:30 PM

Title: [SOLVED] SCI0 - How can I use the ESC button for non-menubar stuff
Post by: Doan Sephim on October 28, 2022, 08:54:30 PM
I'm not sure where the escape button is bound to the Menubar in the SCI but I'd like to be able to turn that off for the intro to my game and allow the ESC button use for skipping the intro.

I looked in the Menubar and controls script, but I'm not sure I found it. Anyone know where in the template game the ESC button is linked to the menubar?
Title: Re: SCI0 - How can I use the ESC button for non-menubar stuff
Post by: Kawa on October 29, 2022, 09:18:07 AM
In User::handleEvent, it asks TheMenuBar::handleEvent to handle the event first. That in turn boils down to the MenuSelect kernel call, invoked in Controls.sc.

According to the SCI11 source code, which still includes the SCI0 menu bar courtesy of Larry 6 using it, MenuSelect is what initially detects you pressing the Esc key.

Seems to me you might add your own "did we press Esc during the intro" check in MenuBar.sc, right over...
Code: [Select]
(method (handleEvent pEvent &tmp menuItem hGauge newSpeed newVolume wndCol wndBack hPause)
; ...here!
(= menuItem (super handleEvent: pEvent))
(switch menuItem

You could do it in User::handleEvent but it might seem a bit bad form to do game-specific hacks in a system script.
Title: Re: SCI0 - How can I use the ESC button for non-menubar stuff
Post by: Doan Sephim on October 29, 2022, 11:06:32 AM
Interesting. Thanks for the detailed response. I'll try to do it in the menubar script to see what I can come up with. Thanks for the direction 👍
Title: Re: SCI0 - How can I use the ESC button for non-menubar stuff
Post by: MusicallyInspired on October 29, 2022, 01:40:25 PM
Couldn't you just deactivate the menubar (as you would in a cutscene, say) and then capture the ESC key pevent to override?
Title: Re: SCI0 - How can I use the ESC button for non-menubar stuff
Post by: Doan Sephim on October 29, 2022, 10:34:45 PM
Seems to me you might add your own "did we press Esc during the intro" check in MenuBar.sc, right over...
Code: [Select]
(method (handleEvent pEvent &tmp menuItem hGauge newSpeed newVolume wndCol wndBack hPause)
; ...here!
(= menuItem (super handleEvent: pEvent))
(switch menuItem
Yes, this seems to work just as you indicated. Thank you. Looks like an easy fix!
Title: Re: SCI0 - How can I use the ESC button for non-menubar stuff
Post by: Doan Sephim on October 29, 2022, 10:39:51 PM
Couldn't you just deactivate the menubar (as you would in a cutscene, say) and then capture the ESC key pevent to override?
Yes, I now see that I don't need to do anything custom. Apparently it's already build in with:
Code: [Select]
(TheMenuBar state: DISABLED)