Author Topic: [SOLVED] SCI0 - How can I use the ESC button for non-menubar stuff  (Read 1561 times)

0 Members and 1 Guest are viewing this topic.

Offline Doan Sephim

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?
« Last Edit: October 29, 2022, 10:35:14 PM by Doan Sephim »


Artificial Intelligence Competition

Offline Kawa

Re: SCI0 - How can I use the ESC button for non-menubar stuff
« Reply #1 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.

Offline Doan Sephim

Re: SCI0 - How can I use the ESC button for non-menubar stuff
« Reply #2 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 👍

Offline MusicallyInspired

Re: SCI0 - How can I use the ESC button for non-menubar stuff
« Reply #3 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?
Brass Lantern Prop Competition

Offline Doan Sephim

Re: SCI0 - How can I use the ESC button for non-menubar stuff
« Reply #4 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!

Offline Doan Sephim

Re: SCI0 - How can I use the ESC button for non-menubar stuff
« Reply #5 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)


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

Page created in 0.041 seconds with 23 queries.