Skip to content

Commit

Permalink
Merge pull request #20 from ManCaveMedia/main
Browse files Browse the repository at this point in the history
Loop through header options per player, even better fix for #12
  • Loading branch information
jonahhb committed Feb 15, 2024
2 parents d7e4e5b + a01620b commit 7c98820
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions com.f1-tools.mvf1.sdPlugin/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let driver_images = {
'Next Page': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAABxAAAAcQEcP4B3AAAAd0lEQVRYhe3YsQ2AMAxEUYtJGIVRMgqbMGJG+JQRhAZjlFi611v6krszE2mAFdiBbXTLI6DSlNE9HXpldNMFUBQZQZFRFBlFkVEUGUWRUbJEHrfA+uZ++SsshalfrDgvxXkpzktxXorzUtwXU8eZ5Zjf5h4wJaMT77i5qyCzaMMAAAAASUVORK5CYII='
};
const driver_header_options = ['NONE', 'OBC_LIVE_TIMING', 'DRIVER_HEADER'];
let driver_header_mode = 0;
let driver_header_mode = {};

/**
* The first event fired when Stream Deck starts
Expand Down Expand Up @@ -487,13 +487,15 @@ function doTileAction(device, driver) {
multi_action_device_data[device].tile_caller ===
'com.f1-tools.mvf1.driver-header'
) {
// there's no way to know the current driver header mode for the current player,
// so let's just loop through the available options,
// starting where we left off last time we used this (for any player) or at 0.
driver_header_mode++;
if (driver_header_mode >= driver_header_options.length){
driver_header_mode = 0;
}
// there's no way to know the current driver header mode for the given player,
// so let's loop through the available options, starting at the second option.
if (driver_header_mode[driver.id] === undefined){
driver_header_mode[driver.id]=1;
} else if (driver_header_mode[driver.id] + 1 >= driver_header_options.length){
driver_header_mode[driver.id]=0;
} else {
driver_header_mode[driver.id]++;
}
graphql(
`
mutation PlayerSetDriverHeaderMode(
Expand All @@ -506,7 +508,7 @@ function doTileAction(device, driver) {
)
}
`,
{ playerSetDriverHeaderModeId: driver.id, mode: driver_header_options[driver_header_mode] }
{ playerSetDriverHeaderModeId: driver.id, mode: driver_header_options[driver_header_mode[driver.id]] }
);
} else if (
defined_id &&
Expand Down
2 changes: 1 addition & 1 deletion com.f1-tools.mvf1.sdPlugin/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"Name": "MVF1",
"Icon": "actions/assets/PNG/mv_logo",
"URL": "https://github.com/f1-tools/MVF1-Streamdeck",
"Version": "1.1.0",
"Version": "1.1.1",
"Software": {
"MinimumVersion": "5.0"
},
Expand Down

0 comments on commit 7c98820

Please sign in to comment.