mjrgh / PinballY

A table browser and launcher ("front end") for virtual pinball cabinets.
Other
46 stars 22 forks source link

Optional Launch Command in Table Menu for POV Edit mode 10.7 #179

Open dcbenji opened 3 years ago

dcbenji commented 3 years ago

Hello, with vpx 10.7 it’s possible to launch a table in a new POV Edit mode via a launch command. It works fine if I add this to the system launch properties but I would like to add this as an alternative launch option per table in the table menu. Another possible solution would be to have a menu item that launched the 'choose system' menu so that I could have a duplicate vpx system with the alternate launch command configured in it available as an option. any direction or advice here would be appreciated.

mjrgh commented 3 years ago

Here are some leads for you:

http://mjrnet.org/pinscape/downloads/PinballY/Help/CustomPlayModesExample.html https://github.com/PinballY/PinballY-Addons-and-Examples/tree/main/two-tables-one-wheel

dcbenji commented 3 years ago

Here are some leads for you:

http://mjrnet.org/pinscape/downloads/PinballY/Help/CustomPlayModesExample.html https://github.com/PinballY/PinballY-Addons-and-Examples/tree/main/two-tables-one-wheel

Thank you! this is what i came up with based on your example page. I'm probably doing something obviously wrong but i'm not very good at coding. Currently nothing happens to the pinballY menu at all and nothing is printed to the log either:

let playNormalCommand = command.allocate("PlayNormal");
let editPovCommand = command.allocate("EditPov");

mainWindow.on("menuopen", ev => {
    if (ev.id == "main") {
        // it's the main menu - check the current game's system
        let game = gameList.getWheelGame(0) || { };
        let sys = game.system || { };
        if (/VPinballX7\.exe$/i.test(sys.processName)) {
            // it's FX3 - add our new commands just before the existing Play command
            ev.addMenuItem(command.PlayGame, [
                { title: "Play - Classic Physics", cmd: PlayNormalCommand },
                { title: "Play - New Physics", cmd: editPovCommand }
            ]);

            // now delete the boring old regular Play command
            ev.deleteMenuItem(command.PlayGame);
        }
    }
});

mainWindow.on("command", ev => {
    // check for a launch command
    let extra = undefined;
    if (ev.id == playNormalCommand) {
        extra = "";  // add the classic physics option code
    }
    else if (ev.id == editPovCommand) {
        extra = "/minimized -PovEdit"; // this is the default, so there's nothing new to add
    }

    // if we found a launch command, do the launch!
    if (extra !== undefined) {
        // get the game and system information
        let game = gameList.getWheelGame(0) || { };
        let sys = game.system || { };

        // launch it with the extra options
        mainWindow.playGame(game, {
            command: ev.id,
            overrides: { params: extra + sys.params }
        });
    }
});
timhobbs commented 2 years ago

realize this is old but i have a script that does this in my repo: https://github.com/timhobbs/PinballY-Scripts

mase76 commented 2 days ago

Running the POV editor within PBY operators menu would be a great feature. I could add a further system which runs in POV mode, but then everybody could alter the POV settings.

mjrgh commented 2 days ago

You can edit the Operator Menu from javascript just like the main menu, so a little tweaking to the scripts above should let you trigger the POV mode over there.