UnderlayEvent

This event type is fired when the program is about to change the underlay - the image layer displayed at the bottom of the screen, under the wheel icons. PinballY checks for a change of underlay image every time a new game is selected in the wheel UI, since the underlay image for a game depends on its system.

The event target for this event type is the mainWindow object.

The UnderlayEvent class has only one subtype:

As with most event types, an UnderlayEvent fires before the system carries out its normal handling for the command. This allows you to block the underlay change entirely by calling preventDefault() on the event object in your handler. For example, if you simply want to prevent system-triggered underlay changes across the board (which you might wish to do if you're creating your own custom way of selecting the underlay to use on each game change), you could do this:

mainWindow.on("underlaychange", ev => { ev.preventDefault(); });

You can also change the image file that the system loads, if you allow the event to proceed. The filename property of the event object (passed as a parameter to your event handler) contains the full filename (with directory path and extension) of the image file that the system intends to load, as a string. You can change the property to a new string with a different filename, in which case the system will load that file instead. For example, this adds an alternating "-blue" or "-red" suffix to the name of the file that the system was planning to load.

let suffix = ["-blue$1", "-red$1"]; mainWindow.on("underlaychange", ev => { ev.filename = ev.filename.replace(/(\.\w+)$/, suffix[0]); suffix.push(suffix.shift()); });

Properties