diff --git a/README.md b/README.md index 9bad8db..42f72de 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A plugin that integrate with Pipelab
Author: Armaldio
Website: https://github.com/CynToolkit/construct-plugin
Addon Url: https://github.com/CynToolkit/construct-plugin
-Download Latest Version : [Version: 2.4.0](https://github.com/CynToolkit/construct-plugin/releases/latest)
+Download Latest Version : [Version: 2.4.1](https://github.com/CynToolkit/construct-plugin/releases/latest)
Made using [c3ide2-framework](https://github.com/ConstructFund/c3ide2-framework)
## Table of Contents @@ -149,6 +149,40 @@ When Download type is Around the user, the offsets are the amount of entries aro | Activate Steam overlay to web page | Activates Steam Overlay web browser directly to the specified URL | URL *(string)*
Mode *(combo)*
| | Activate Steam overlay to store (synchronous) | Activates the Steam Overlay to the Steam store page for the provided app (synchronous) | App ID *(number)*
Flag *(combo)*
Tag *(string)*
| | Activate Steam overlay to store | Activates the Steam Overlay to the Steam store page for the provided app | App ID *(number)*
Flag *(combo)*
| +| Trigger screenshot (synchronous) | Captures the current screen and saves to Steam screenshot library (synchronous) | Tag *(string)*
| +| Trigger screenshot | Captures the current screen and saves to Steam screenshot library | | +| Check DLC is installed (synchronous) | Checks if the user owns and has installed a specific DLC (synchronous) | DLC App ID *(number)*
Tag *(string)*
| +| Check DLC is installed | Checks if the user owns and has installed a specific DLC | DLC App ID *(number)*
| +| Create workshop item (synchronous) | Creates a new workshop item for the specified Steam App ID and returns its ID (synchronous) | App ID *(number)*
Tag *(string)*
| +| Create workshop item | Creates a new workshop item for the specified Steam App ID and returns its ID | App ID *(number)*
| +| Update workshop item (synchronous) | Updates content and metadata of a workshop item. Use the update flags to control which fields are updated. (synchronous) | App ID *(number)*
Item ID *(string)*
Update Title *(boolean)*
Title *(string)*
Update Description *(boolean)*
Description *(string)*
Update Content *(boolean)*
Content Folder Path *(string)*
Change Note *(string)*
Update Preview *(boolean)*
Preview Image Path *(string)*
Update Tags *(boolean)*
Tags *(string)*
Update Visibility *(boolean)*
Visibility *(combo)*
Tag *(string)*
| +| Update workshop item | Updates content and metadata of a workshop item. Use the update flags to control which fields are updated. | App ID *(number)*
Item ID *(string)*
Update Title *(boolean)*
Title *(string)*
Update Description *(boolean)*
Description *(string)*
Update Content *(boolean)*
Content Folder Path *(string)*
Change Note *(string)*
Update Preview *(boolean)*
Preview Image Path *(string)*
Update Tags *(boolean)*
Tags *(string)*
Update Visibility *(boolean)*
Visibility *(combo)*
| +| Get subscribed items with metadata (synchronous) | Gets all subscribed workshop items with their metadata and install info (synchronous) | Tag *(string)*
| +| Get subscribed items with metadata | Gets all subscribed workshop items with their metadata and install info | | +| Download workshop item (synchronous) | Downloads or updates a workshop item (synchronous) | Item ID *(string)*
High Priority *(boolean)*
Tag *(string)*
| +| Download workshop item | Downloads or updates a workshop item | Item ID *(string)*
High Priority *(boolean)*
| +| Delete workshop item (synchronous) | Deletes a workshop item (synchronous) | Item ID *(string)*
Tag *(string)*
| +| Delete workshop item | Deletes a workshop item | Item ID *(string)*
| +| Subscribe to workshop item (synchronous) | Subscribes to a workshop item (synchronous) | Item ID *(string)*
Tag *(string)*
| +| Subscribe to workshop item | Subscribes to a workshop item | Item ID *(string)*
| +| Unsubscribe from workshop item (synchronous) | Unsubscribes from a workshop item (synchronous) | Item ID *(string)*
Tag *(string)*
| +| Unsubscribe from workshop item | Unsubscribes from a workshop item | Item ID *(string)*
| +| Get workshop item state (synchronous) | Gets the state of a workshop item (synchronous) | Item ID *(string)*
Tag *(string)*
| +| Get workshop item state | Gets the state of a workshop item | Item ID *(string)*
| +| Get workshop item install info (synchronous) | Gets the install info of a workshop item (synchronous) | Item ID *(string)*
Tag *(string)*
| +| Get workshop item install info | Gets the install info of a workshop item | Item ID *(string)*
| +| Get workshop item download info (synchronous) | Gets the download info of a workshop item (synchronous) | Item ID *(string)*
Tag *(string)*
| +| Get workshop item download info | Gets the download info of a workshop item | Item ID *(string)*
| +| Get workshop item (synchronous) | Gets a workshop item's metadata (synchronous) | Item ID *(string)*
Tag *(string)*
| +| Get workshop item | Gets a workshop item's metadata | Item ID *(string)*
| +| Get workshop items (synchronous) | Gets multiple workshop items' metadata (synchronous) | Item IDs *(string)*
Tag *(string)*
| +| Get workshop items | Gets multiple workshop items' metadata | Item IDs *(string)*
| +| Get subscribed items (synchronous) | Gets all subscribed workshop item IDs (synchronous) | Tag *(string)*
| +| Get subscribed items | Gets all subscribed workshop item IDs | | +| Get workshop item with metadata (synchronous) | Gets a workshop item with its metadata, state, install info, and download info (synchronous) | Item ID *(string)*
Tag *(string)*
| +| Get workshop item with metadata | Gets a workshop item with its metadata, state, install info, and download info | Item ID *(string)*
| +| Get workshop items with metadata (synchronous) | Gets multiple workshop items with their metadata, state, install info, and download info (synchronous) | Item IDs *(string)*
Tag *(string)*
| +| Get workshop items with metadata | Gets multiple workshop items with their metadata, state, install info, and download info | Item IDs *(string)*
| --- @@ -347,6 +381,74 @@ When Download type is Around the user, the offsets are the amount of entries aro | On any "ActivateToStore" success | Trigger when any of the "ActivateToStore" are executed with success. | | | On "ActivateToStore" error | Trigger when the "ActivateToStore" failed to execute. | Tag *(string)*
| | On any "ActivateToStore" error | Trigger when any of the "ActivateToStore" failed to execute. | | +| On "TriggerScreenshot" success | Trigger when the "TriggerScreenshot" is executed with success. | Tag *(string)*
| +| On any "TriggerScreenshot" success | Trigger when any of the "TriggerScreenshot" are executed with success. | | +| On "TriggerScreenshot" error | Trigger when the "TriggerScreenshot" failed to execute. | Tag *(string)*
| +| On any "TriggerScreenshot" error | Trigger when any of the "TriggerScreenshot" failed to execute. | | +| On "CheckDLCIsInstalled" success | Trigger when the "CheckDLCIsInstalled" is executed with success. | Tag *(string)*
| +| On any "CheckDLCIsInstalled" success | Trigger when any of the "CheckDLCIsInstalled" are executed with success. | | +| On "CheckDLCIsInstalled" error | Trigger when the "CheckDLCIsInstalled" failed to execute. | Tag *(string)*
| +| On any "CheckDLCIsInstalled" error | Trigger when any of the "CheckDLCIsInstalled" failed to execute. | | +| On "CreateWorkshopItem" success | Trigger when the "CreateWorkshopItem" is executed with success. | Tag *(string)*
| +| On any "CreateWorkshopItem" success | Trigger when any of the "CreateWorkshopItem" are executed with success. | | +| On "CreateWorkshopItem" error | Trigger when the "CreateWorkshopItem" failed to execute. | Tag *(string)*
| +| On any "CreateWorkshopItem" error | Trigger when any of the "CreateWorkshopItem" failed to execute. | | +| On "UpdateWorkshopItem" success | Trigger when the "UpdateWorkshopItem" is executed with success. | Tag *(string)*
| +| On any "UpdateWorkshopItem" success | Trigger when any of the "UpdateWorkshopItem" are executed with success. | | +| On "UpdateWorkshopItem" error | Trigger when the "UpdateWorkshopItem" failed to execute. | Tag *(string)*
| +| On any "UpdateWorkshopItem" error | Trigger when any of the "UpdateWorkshopItem" failed to execute. | | +| On "GetSubscribedItemsWithMetadata" success | Trigger when the "GetSubscribedItemsWithMetadata" is executed with success. | Tag *(string)*
| +| On any "GetSubscribedItemsWithMetadata" success | Trigger when any of the "GetSubscribedItemsWithMetadata" are executed with success. | | +| On "GetSubscribedItemsWithMetadata" error | Trigger when the "GetSubscribedItemsWithMetadata" failed to execute. | Tag *(string)*
| +| On any "GetSubscribedItemsWithMetadata" error | Trigger when any of the "GetSubscribedItemsWithMetadata" failed to execute. | | +| On "DownloadWorkshopItem" success | Trigger when the "DownloadWorkshopItem" is executed with success. | Tag *(string)*
| +| On any "DownloadWorkshopItem" success | Trigger when any of the "DownloadWorkshopItem" are executed with success. | | +| On "DownloadWorkshopItem" error | Trigger when the "DownloadWorkshopItem" failed to execute. | Tag *(string)*
| +| On any "DownloadWorkshopItem" error | Trigger when any of the "DownloadWorkshopItem" failed to execute. | | +| On "DeleteWorkshopItem" success | Trigger when the "DeleteWorkshopItem" is executed with success. | Tag *(string)*
| +| On any "DeleteWorkshopItem" success | Trigger when any of the "DeleteWorkshopItem" are executed with success. | | +| On "DeleteWorkshopItem" error | Trigger when the "DeleteWorkshopItem" failed to execute. | Tag *(string)*
| +| On any "DeleteWorkshopItem" error | Trigger when any of the "DeleteWorkshopItem" failed to execute. | | +| On "SubscribeWorkshopItem" success | Trigger when the "SubscribeWorkshopItem" is executed with success. | Tag *(string)*
| +| On any "SubscribeWorkshopItem" success | Trigger when any of the "SubscribeWorkshopItem" are executed with success. | | +| On "SubscribeWorkshopItem" error | Trigger when the "SubscribeWorkshopItem" failed to execute. | Tag *(string)*
| +| On any "SubscribeWorkshopItem" error | Trigger when any of the "SubscribeWorkshopItem" failed to execute. | | +| On "UnsubscribeWorkshopItem" success | Trigger when the "UnsubscribeWorkshopItem" is executed with success. | Tag *(string)*
| +| On any "UnsubscribeWorkshopItem" success | Trigger when any of the "UnsubscribeWorkshopItem" are executed with success. | | +| On "UnsubscribeWorkshopItem" error | Trigger when the "UnsubscribeWorkshopItem" failed to execute. | Tag *(string)*
| +| On any "UnsubscribeWorkshopItem" error | Trigger when any of the "UnsubscribeWorkshopItem" failed to execute. | | +| On "GetWorkshopItemState" success | Trigger when the "GetWorkshopItemState" is executed with success. | Tag *(string)*
| +| On any "GetWorkshopItemState" success | Trigger when any of the "GetWorkshopItemState" are executed with success. | | +| On "GetWorkshopItemState" error | Trigger when the "GetWorkshopItemState" failed to execute. | Tag *(string)*
| +| On any "GetWorkshopItemState" error | Trigger when any of the "GetWorkshopItemState" failed to execute. | | +| On "GetWorkshopItemInstallInfo" success | Trigger when the "GetWorkshopItemInstallInfo" is executed with success. | Tag *(string)*
| +| On any "GetWorkshopItemInstallInfo" success | Trigger when any of the "GetWorkshopItemInstallInfo" are executed with success. | | +| On "GetWorkshopItemInstallInfo" error | Trigger when the "GetWorkshopItemInstallInfo" failed to execute. | Tag *(string)*
| +| On any "GetWorkshopItemInstallInfo" error | Trigger when any of the "GetWorkshopItemInstallInfo" failed to execute. | | +| On "GetWorkshopItemDownloadInfo" success | Trigger when the "GetWorkshopItemDownloadInfo" is executed with success. | Tag *(string)*
| +| On any "GetWorkshopItemDownloadInfo" success | Trigger when any of the "GetWorkshopItemDownloadInfo" are executed with success. | | +| On "GetWorkshopItemDownloadInfo" error | Trigger when the "GetWorkshopItemDownloadInfo" failed to execute. | Tag *(string)*
| +| On any "GetWorkshopItemDownloadInfo" error | Trigger when any of the "GetWorkshopItemDownloadInfo" failed to execute. | | +| On "GetWorkshopItem" success | Trigger when the "GetWorkshopItem" is executed with success. | Tag *(string)*
| +| On any "GetWorkshopItem" success | Trigger when any of the "GetWorkshopItem" are executed with success. | | +| On "GetWorkshopItem" error | Trigger when the "GetWorkshopItem" failed to execute. | Tag *(string)*
| +| On any "GetWorkshopItem" error | Trigger when any of the "GetWorkshopItem" failed to execute. | | +| On "GetWorkshopItems" success | Trigger when the "GetWorkshopItems" is executed with success. | Tag *(string)*
| +| On any "GetWorkshopItems" success | Trigger when any of the "GetWorkshopItems" are executed with success. | | +| On "GetWorkshopItems" error | Trigger when the "GetWorkshopItems" failed to execute. | Tag *(string)*
| +| On any "GetWorkshopItems" error | Trigger when any of the "GetWorkshopItems" failed to execute. | | +| On "GetSubscribedWorkshopItems" success | Trigger when the "GetSubscribedWorkshopItems" is executed with success. | Tag *(string)*
| +| On any "GetSubscribedWorkshopItems" success | Trigger when any of the "GetSubscribedWorkshopItems" are executed with success. | | +| On "GetSubscribedWorkshopItems" error | Trigger when the "GetSubscribedWorkshopItems" failed to execute. | Tag *(string)*
| +| On any "GetSubscribedWorkshopItems" error | Trigger when any of the "GetSubscribedWorkshopItems" failed to execute. | | +| On "GetWorkshopItemWithMetadata" success | Trigger when the "GetWorkshopItemWithMetadata" is executed with success. | Tag *(string)*
| +| On any "GetWorkshopItemWithMetadata" success | Trigger when any of the "GetWorkshopItemWithMetadata" are executed with success. | | +| On "GetWorkshopItemWithMetadata" error | Trigger when the "GetWorkshopItemWithMetadata" failed to execute. | Tag *(string)*
| +| On any "GetWorkshopItemWithMetadata" error | Trigger when any of the "GetWorkshopItemWithMetadata" failed to execute. | | +| On "GetWorkshopItemsWithMetadata" success | Trigger when the "GetWorkshopItemsWithMetadata" is executed with success. | Tag *(string)*
| +| On any "GetWorkshopItemsWithMetadata" success | Trigger when any of the "GetWorkshopItemsWithMetadata" are executed with success. | | +| On "GetWorkshopItemsWithMetadata" error | Trigger when the "GetWorkshopItemsWithMetadata" failed to execute. | Tag *(string)*
| +| On any "GetWorkshopItemsWithMetadata" error | Trigger when any of the "GetWorkshopItemsWithMetadata" failed to execute. | | | Is engine | Return true if the engine running the app is the one selected | Engine *(combo)*
| | Is initialized | Returns true if the Pipelab integration has been initialized | | | Is full screen | Returns true if the window is in full screen mode. | State *(combo)*
| @@ -453,6 +555,62 @@ When Download type is Around the user, the offsets are the amount of entries aro | ActivateToWebPageResult | The result of the "ActivateToWebPage last call" | string | | | ActivateToStoreError | The error of the "ActivateToStore last call" | string | | | ActivateToStoreResult | The result of the "ActivateToStore last call" | string | | +| TriggerScreenshotError | The error of the "TriggerScreenshot last call" | string | | +| TriggerScreenshotResult | The result of the "TriggerScreenshot last call" | string | | +| CheckDLCIsInstalledError | The error of the "CheckDLCIsInstalled last call" | string | | +| CheckDLCIsInstalledResult | The result of the "CheckDLCIsInstalled last call" | string | | +| CreateWorkshopItemError | The error of the "CreateWorkshopItem last call" | string | | +| CreateWorkshopItemResult | The result of the "CreateWorkshopItem last call" | string | | +| UpdateWorkshopItemError | The error of the "UpdateWorkshopItem last call" | string | | +| UpdateWorkshopItemResult | The result of the "UpdateWorkshopItem last call" | string | | +| GetSubscribedItemsWithMetadataError | The error of the "GetSubscribedItemsWithMetadata last call" | string | | +| GetSubscribedItemsWithMetadataResult | The result of the "GetSubscribedItemsWithMetadata last call" | string | | +| DownloadWorkshopItemError | The error of the "DownloadWorkshopItem last call" | string | | +| DownloadWorkshopItemResult | The result of the "DownloadWorkshopItem last call" | string | | +| DeleteWorkshopItemError | The error of the "DeleteWorkshopItem last call" | string | | +| DeleteWorkshopItemResult | The result of the "DeleteWorkshopItem last call" | string | | +| SubscribeWorkshopItemError | The error of the "SubscribeWorkshopItem last call" | string | | +| SubscribeWorkshopItemResult | The result of the "SubscribeWorkshopItem last call" | string | | +| UnsubscribeWorkshopItemError | The error of the "UnsubscribeWorkshopItem last call" | string | | +| UnsubscribeWorkshopItemResult | The result of the "UnsubscribeWorkshopItem last call" | string | | +| GetWorkshopItemStateError | The error of the "GetWorkshopItemState last call" | string | | +| GetWorkshopItemStateResult | The result of the "GetWorkshopItemState last call" | string | | +| GetWorkshopItemInstallInfoError | The error of the "GetWorkshopItemInstallInfo last call" | string | | +| GetWorkshopItemInstallInfoResult | The result of the "GetWorkshopItemInstallInfo last call" | string | | +| GetWorkshopItemDownloadInfoError | The error of the "GetWorkshopItemDownloadInfo last call" | string | | +| GetWorkshopItemDownloadInfoResult | The result of the "GetWorkshopItemDownloadInfo last call" | string | | +| GetWorkshopItemError | The error of the "GetWorkshopItem last call" | string | | +| GetWorkshopItemResult | The result of the "GetWorkshopItem last call" | string | | +| GetWorkshopItemsError | The error of the "GetWorkshopItems last call" | string | | +| GetWorkshopItemsResult | The result of the "GetWorkshopItems last call" | string | | +| GetSubscribedWorkshopItemsError | The error of the "GetSubscribedWorkshopItems last call" | string | | +| GetSubscribedWorkshopItemsResult | The result of the "GetSubscribedWorkshopItems last call" | string | | +| GetWorkshopItemWithMetadataError | The error of the "GetWorkshopItemWithMetadata last call" | string | | +| GetWorkshopItemWithMetadataResult | The result of the "GetWorkshopItemWithMetadata last call" | string | | +| GetWorkshopItemsWithMetadataError | The error of the "GetWorkshopItemsWithMetadata last call" | string | | +| GetWorkshopItemsWithMetadataResult | The result of the "GetWorkshopItemsWithMetadata last call" | string | | +| SubscribedItemsCount | Get the number of subscribed workshop items | number | | +| SubscribedItemIdAt | Get the workshop item ID at the given index | string | Index *(number)*
| +| WorkshopItemTitle | Get the title of a workshop item | string | Item ID *(string)*
| +| WorkshopItemDescription | Get the description of a workshop item | string | Item ID *(string)*
| +| WorkshopItemOwnerSteamId64 | Get the owner's Steam ID64 of a workshop item | string | Item ID *(string)*
| +| WorkshopItemOwnerAccountId | Get the owner's account ID of a workshop item | number | Item ID *(string)*
| +| WorkshopItemTags | Get the tags of a workshop item (comma-separated) | string | Item ID *(string)*
| +| WorkshopItemUpvotes | Get the number of upvotes for a workshop item | number | Item ID *(string)*
| +| WorkshopItemDownvotes | Get the number of downvotes for a workshop item | number | Item ID *(string)*
| +| WorkshopItemPreviewUrl | Get the preview image URL of a workshop item | string | Item ID *(string)*
| +| WorkshopItemUrl | Get the Steam Workshop URL of a workshop item | string | Item ID *(string)*
| +| WorkshopItemTimeCreated | Get the creation timestamp of a workshop item (Unix epoch) | number | Item ID *(string)*
| +| WorkshopItemTimeUpdated | Get the last update timestamp of a workshop item (Unix epoch) | number | Item ID *(string)*
| +| WorkshopItemState | Get the state bitfield of a workshop item | number | Item ID *(string)*
| +| WorkshopItemIsInstalled | Check if a workshop item is installed (returns 0 or 1) | number | Item ID *(string)*
| +| WorkshopItemIsDownloading | Check if a workshop item is downloading (returns 0 or 1) | number | Item ID *(string)*
| +| WorkshopItemNeedsUpdate | Check if a workshop item needs an update (returns 0 or 1) | number | Item ID *(string)*
| +| WorkshopItemInstallFolder | Get the installation folder path of a workshop item | string | Item ID *(string)*
| +| WorkshopItemSizeOnDisk | Get the size on disk of a workshop item in bytes | number | Item ID *(string)*
| +| WorkshopItemTimestamp | Get the install timestamp of a workshop item | number | Item ID *(string)*
| +| WorkshopItemDownloadCurrent | Get the current download progress of a workshop item | number | Item ID *(string)*
| +| WorkshopItemDownloadTotal | Get the total download progress of a workshop item | number | Item ID *(string)*
| | ArgumentAt | Get the argument at the given index. | string | Index *(number)*
| | ArgumentCount | Get the number of arguments. | number | | | AppFolderURL | Return the URL of the folder of the current app. | string | | diff --git a/package.json b/package.json index fa17a1b..7094fba 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ }, "name": "@pipelab/construct-plugin", "description": "Pipelab construct plugin", - "version": "2.4.0", + "version": "2.4.1", "packageManager": "pnpm@9.10.0", "type": "module", "scripts": { diff --git a/src/instance.js b/src/instance.js index 8733f42..2a24999 100644 --- a/src/instance.js +++ b/src/instance.js @@ -2262,6 +2262,930 @@ function getInstanceJs(parentClass, addonTriggers, C3) { _ActivateToStore = this._ActivateToStoreBase _ActivateToStoreSync = this._ActivateToStoreBase + // Steam Screenshots + _TriggerScreenshotBase = this.wrap(super._TriggerScreenshot, async ( + /** @type {Tag} */ tag + ) => { + try { + /** @type {import('@pipelab/core').MakeInputOutput, 'input'>} */ + const order = { + url: '/steam/raw', + body: { + namespace: 'screenshots', + method: 'triggerScreenshot', + args: [], + }, + }; + const answer = await this.ws?.sendAndWaitForResponse(order); + if (answer?.body.success === false) { + throw new Error('Failed') + } + this._TriggerScreenshotResultValue = answer?.body.data + this._TriggerScreenshotErrorValue = '' + + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnTriggerScreenshotSuccess, + C3.Plugins.pipelabv2.Cnds.OnAnyTriggerScreenshotSuccess + ]) + } catch (e) { + if (e instanceof Error) { + this._TriggerScreenshotErrorValue = e.message + this._TriggerScreenshotResultValue = -1 + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnTriggerScreenshotError, + C3.Plugins.pipelabv2.Cnds.OnAnyTriggerScreenshotError + ]) + } + } + }, this.unsupportedEngine) + _TriggerScreenshot = this._TriggerScreenshotBase + _TriggerScreenshotSync = this._TriggerScreenshotBase + + // Steam DLC + _CheckDLCIsInstalledBase = this.wrap(super._CheckDLCIsInstalled, async ( + /** @type {number} */ appId, + /** @type {Tag} */ tag + ) => { + try { + /** @type {import('@pipelab/core').MakeInputOutput, 'input'>} */ + const order = { + url: '/steam/raw', + body: { + namespace: 'apps', + method: 'isDlcInstalled', + args: [appId], + }, + }; + const answer = await this.ws?.sendAndWaitForResponse(order); + if (answer?.body.success === false) { + throw new Error('Failed') + } + this._CheckDLCIsInstalledResultValue = answer?.body.data + this._CheckDLCIsInstalledErrorValue = '' + + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnCheckDLCIsInstalledSuccess, + C3.Plugins.pipelabv2.Cnds.OnAnyCheckDLCIsInstalledSuccess + ]) + } catch (e) { + if (e instanceof Error) { + this._CheckDLCIsInstalledErrorValue = e.message + this._CheckDLCIsInstalledResultValue = false + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnCheckDLCIsInstalledError, + C3.Plugins.pipelabv2.Cnds.OnAnyCheckDLCIsInstalledError + ]) + } + } + }, this.unsupportedEngine) + _CheckDLCIsInstalled = this._CheckDLCIsInstalledBase + _CheckDLCIsInstalledSync = this._CheckDLCIsInstalledBase + + // Steam Workshop + /** @type {Map} */ + _workshopItemsMap = new Map() + /** @type {string[]} */ + _subscribedItemIds = [] + + // Helper functions for modular API calls + /** + * Get the state of a workshop item + * @param {string | number} itemId - The workshop item ID + * @returns {Promise} The item state + */ + async _getItemState(itemId) { + const order = { + url: '/steam/workshop/state', + body: { + itemId + }, + }; + const answer = await this.ws?.sendAndWaitForResponse(order); + return answer?.body.data ?? 0 + } + + /** + * Get the install info of a workshop item + * @param {string | number} itemId - The workshop item ID + * @returns {Promise} The install info + */ + async _getItemInstallInfo(itemId) { + const order = { + url: '/steam/workshop/install-info', + body: { + itemId + }, + }; + const answer = await this.ws?.sendAndWaitForResponse(order); + return answer?.body.data + } + + /** + * Get the download info of a workshop item + * @param {string | number} itemId - The workshop item ID + * @returns {Promise} The download info + */ + async _getItemDownloadInfo(itemId) { + const order = { + url: '/steam/workshop/download-info', + body: { + itemId + }, + }; + const answer = await this.ws?.sendAndWaitForResponse(order); + return answer?.body.data + } + + _CreateWorkshopItemBase = this.wrap(super._CreateWorkshopItem, async ( + /** @type {number} */ appID, + /** @type {Tag} */ tag + ) => { + try { + /** @type {import('@pipelab/core').MakeInputOutput, 'input'>} */ + const order = { + url: '/steam/raw', + body: { + namespace: 'workshop', + method: 'createItem', + args: [appID], + }, + }; + const answer = await this.ws?.sendAndWaitForResponse(order); + if (answer?.body.success === false) { + throw new Error('Failed') + } + const result = answer?.body.data + // @ts-expect-error - API returns UgcResult + this._CreateWorkshopItemResultValue = result?.itemId?.toString() ?? '' + // @ts-expect-error - API returns UgcResult + this._CreateWorkshopItemNeedsAgreementValue = result?.needsToAcceptAgreement ? 1 : 0 + this._CreateWorkshopItemErrorValue = '' + + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnCreateWorkshopItemSuccess, + C3.Plugins.pipelabv2.Cnds.OnAnyCreateWorkshopItemSuccess + ]) + } catch (e) { + if (e instanceof Error) { + this._CreateWorkshopItemErrorValue = e.message + this._CreateWorkshopItemResultValue = '' + this._CreateWorkshopItemNeedsAgreementValue = 0 + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnCreateWorkshopItemError, + C3.Plugins.pipelabv2.Cnds.OnAnyCreateWorkshopItemError + ]) + } + } + }, this.unsupportedEngine) + _CreateWorkshopItem = this._CreateWorkshopItemBase + _CreateWorkshopItemSync = this._CreateWorkshopItemBase + + _UpdateWorkshopItemBase = this.wrap(super._UpdateWorkshopItem, async ( + /** @type {number} */ appID, + /** @type {string} */ itemId, + /** @type {boolean} */ updateTitle, + /** @type {string} */ title, + /** @type {boolean} */ updateDescription, + /** @type {string} */ description, + /** @type {boolean} */ updateContent, + /** @type {string} */ contentFolderPath, + /** @type {string} */ changeNote, + /** @type {boolean} */ updatePreview, + /** @type {string} */ previewImagePath, + /** @type {boolean} */ updateTags, + /** @type {string} */ tags, + /** @type {boolean} */ updateVisibility, + /** @type {number} */ visibility, + /** @type {Tag} */ tag + ) => { + try { + // Build updateDetails object with only the fields that should be updated + /** @type {Record} */ + const updateDetails = {} + + if (updateTitle) { + updateDetails.title = title + } + + if (updateDescription) { + updateDetails.description = description + } + + if (updateContent) { + updateDetails.contentPath = contentFolderPath + } + + if (updatePreview) { + updateDetails.previewPath = previewImagePath + } + + if (updateTags) { + const tagArray = tags.split(',').map(t => t.trim()).filter(t => t.length > 0) + updateDetails.tags = tagArray + } + + if (updateVisibility) { + updateDetails.visibility = visibility + } + + if (changeNote) { + updateDetails.changeNote = changeNote + } + + /** @type {import('@pipelab/core').MakeInputOutput, 'input'>} */ + const order = { + url: '/steam/workshop/update-item', + body: { + itemId, + updateDetails, + appID, + }, + }; + const answer = await this.ws?.sendAndWaitForResponse(order); + if (answer?.body.success === false) { + throw new Error('Failed') + } + const result = answer?.body.data + // @ts-expect-error - API returns UgcResult + this._UpdateWorkshopItemResultValue = result?.itemId?.toString() ?? '' + // @ts-expect-error - API returns UgcResult + this._UpdateWorkshopItemNeedsAgreementValue = result?.needsToAcceptAgreement ? 1 : 0 + this._UpdateWorkshopItemErrorValue = '' + + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnUpdateWorkshopItemSuccess, + C3.Plugins.pipelabv2.Cnds.OnAnyUpdateWorkshopItemSuccess + ]) + } catch (e) { + if (e instanceof Error) { + this._UpdateWorkshopItemErrorValue = e.message + this._UpdateWorkshopItemResultValue = '' + this._UpdateWorkshopItemNeedsAgreementValue = 0 + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnUpdateWorkshopItemError, + C3.Plugins.pipelabv2.Cnds.OnAnyUpdateWorkshopItemError + ]) + } + } + }, this.unsupportedEngine) + _UpdateWorkshopItem = this._UpdateWorkshopItemBase + _UpdateWorkshopItemSync = this._UpdateWorkshopItemBase + + _GetSubscribedItemsWithMetadataBase = this.wrap(super._GetSubscribedItemsWithMetadata, async ( + /** @type {Tag} */ tag + ) => { + try { + // Get subscribed items + /** @type {import('@pipelab/core').MakeInputOutput, 'input'>} */ + const orderSubscribed = { + url: '/steam/raw', + body: { + namespace: 'workshop', + method: 'getSubscribedItems', + args: [false], + }, + }; + const subscribedAnswer = await this.ws?.sendAndWaitForResponse(orderSubscribed); + if (subscribedAnswer?.body.success === false) { + throw new Error('Failed to get subscribed items') + } + + const itemIds = subscribedAnswer?.body.data ?? [] + this._subscribedItemIds = itemIds.map(id => id.toString()) + + if (itemIds.length === 0) { + this._GetSubscribedItemsWithMetadataErrorValue = '' + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnGetSubscribedItemsWithMetadataSuccess, + C3.Plugins.pipelabv2.Cnds.OnAnyGetSubscribedItemsWithMetadataSuccess + ]) + return + } + + // Get metadata for all items + /** @type {import('@pipelab/core').MakeInputOutput, 'input'>} */ + const orderMetadata = { + url: '/steam/workshop/get-items', + body: { + itemIds + } + }; + const metadataAnswer = await this.ws?.sendAndWaitForResponse(orderMetadata); + if (metadataAnswer?.body.success === false) { + throw new Error('Failed to get item metadata') + } + + // @ts-expect-error - API returns WorkshopItemsResult + const items = metadataAnswer?.body.data?.items ?? [] + + // Store items in map and get state/install/download info for each + for (const item of items) { + if (!item) continue + const itemIdStr = item.publishedFileId.toString() + + // Get state and install info using helper functions + const state = await this._getItemState(item.publishedFileId) + const installInfo = await this._getItemInstallInfo(item.publishedFileId) + + // Get download info if downloading + let downloadInfo = null + if (state && (state & 16)) { + downloadInfo = await this._getItemDownloadInfo(item.publishedFileId) + } + + // Store combined data + this._workshopItemsMap.set(itemIdStr, { + ...item, + state, + installInfo, + downloadInfo + }) + } + + this._GetSubscribedItemsWithMetadataErrorValue = '' + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnGetSubscribedItemsWithMetadataSuccess, + C3.Plugins.pipelabv2.Cnds.OnAnyGetSubscribedItemsWithMetadataSuccess + ]) + } catch (e) { + if (e instanceof Error) { + this._GetSubscribedItemsWithMetadataErrorValue = e.message + this._subscribedItemIds = [] + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnGetSubscribedItemsWithMetadataError, + C3.Plugins.pipelabv2.Cnds.OnAnyGetSubscribedItemsWithMetadataError + ]) + } + } + }, this.unsupportedEngine) + _GetSubscribedItemsWithMetadata = this._GetSubscribedItemsWithMetadataBase + _GetSubscribedItemsWithMetadataSync = this._GetSubscribedItemsWithMetadataBase + + _DownloadWorkshopItemBase = this.wrap(super._DownloadWorkshopItem, async ( + /** @type {string} */ itemId, + /** @type {boolean} */ highPriority, + /** @type {Tag} */ tag + ) => { + try { + /** @type {import('@pipelab/core').MakeInputOutput, 'input'>} */ + const order = { + url: '/steam/workshop/download', + body: { + itemId, + highPriority: highPriority ?? false + }, + }; + const answer = await this.ws?.sendAndWaitForResponse(order); + if (answer?.body.success === false) { + throw new Error('Failed') + } + this._DownloadWorkshopItemResultValue = answer?.body.data ? 1 : 0 + this._DownloadWorkshopItemErrorValue = '' + + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnDownloadWorkshopItemSuccess, + C3.Plugins.pipelabv2.Cnds.OnAnyDownloadWorkshopItemSuccess + ]) + } catch (e) { + if (e instanceof Error) { + this._DownloadWorkshopItemErrorValue = e.message + this._DownloadWorkshopItemResultValue = 0 + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnDownloadWorkshopItemError, + C3.Plugins.pipelabv2.Cnds.OnAnyDownloadWorkshopItemError + ]) + } + } + }, this.unsupportedEngine) + _DownloadWorkshopItem = this._DownloadWorkshopItemBase + _DownloadWorkshopItemSync = this._DownloadWorkshopItemBase + + _DeleteWorkshopItemBase = this.wrap(super._DeleteWorkshopItem, async ( + /** @type {string} */ itemId, + /** @type {Tag} */ tag + ) => { + try { + const order = { + url: '/steam/workshop/delete-item', + body: { + itemId + }, + }; + const answer = await this.ws?.sendAndWaitForResponse(order); + if (answer?.body.success === false) { + throw new Error('Failed') + } + this._DeleteWorkshopItemResultValue = answer?.body.data ? 1 : 0 + this._DeleteWorkshopItemErrorValue = '' + + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnDeleteWorkshopItemSuccess, + C3.Plugins.pipelabv2.Cnds.OnAnyDeleteWorkshopItemSuccess + ]) + } catch (e) { + if (e instanceof Error) { + this._DeleteWorkshopItemErrorValue = e.message + this._DeleteWorkshopItemResultValue = 0 + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnDeleteWorkshopItemError, + C3.Plugins.pipelabv2.Cnds.OnAnyDeleteWorkshopItemError + ]) + } + } + }, this.unsupportedEngine) + _DeleteWorkshopItem = this._DeleteWorkshopItemBase + _DeleteWorkshopItemSync = this._DeleteWorkshopItemBase + + _SubscribeWorkshopItemBase = this.wrap(super._SubscribeWorkshopItem, async ( + /** @type {string} */ itemId, + /** @type {Tag} */ tag + ) => { + try { + const order = { + url: '/steam/workshop/subscribe', + body: { + itemId + }, + }; + const answer = await this.ws?.sendAndWaitForResponse(order); + if (answer?.body.success === false) { + throw new Error('Failed') + } + this._SubscribeWorkshopItemResultValue = answer?.body.data ? 1 : 0 + this._SubscribeWorkshopItemErrorValue = '' + + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnSubscribeWorkshopItemSuccess, + C3.Plugins.pipelabv2.Cnds.OnAnySubscribeWorkshopItemSuccess + ]) + } catch (e) { + if (e instanceof Error) { + this._SubscribeWorkshopItemErrorValue = e.message + this._SubscribeWorkshopItemResultValue = 0 + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnSubscribeWorkshopItemError, + C3.Plugins.pipelabv2.Cnds.OnAnySubscribeWorkshopItemError + ]) + } + } + }, this.unsupportedEngine) + _SubscribeWorkshopItem = this._SubscribeWorkshopItemBase + _SubscribeWorkshopItemSync = this._SubscribeWorkshopItemBase + + _UnsubscribeWorkshopItemBase = this.wrap(super._UnsubscribeWorkshopItem, async ( + /** @type {string} */ itemId, + /** @type {Tag} */ tag + ) => { + try { + const order = { + url: '/steam/workshop/unsubscribe', + body: { + itemId + }, + }; + const answer = await this.ws?.sendAndWaitForResponse(order); + if (answer?.body.success === false) { + throw new Error('Failed') + } + this._UnsubscribeWorkshopItemResultValue = answer?.body.data ? 1 : 0 + this._UnsubscribeWorkshopItemErrorValue = '' + + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnUnsubscribeWorkshopItemSuccess, + C3.Plugins.pipelabv2.Cnds.OnAnyUnsubscribeWorkshopItemSuccess + ]) + } catch (e) { + if (e instanceof Error) { + this._UnsubscribeWorkshopItemErrorValue = e.message + this._UnsubscribeWorkshopItemResultValue = 0 + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnUnsubscribeWorkshopItemError, + C3.Plugins.pipelabv2.Cnds.OnAnyUnsubscribeWorkshopItemError + ]) + } + } + }, this.unsupportedEngine) + _UnsubscribeWorkshopItem = this._UnsubscribeWorkshopItemBase + _UnsubscribeWorkshopItemSync = this._UnsubscribeWorkshopItemBase + + _GetWorkshopItemStateBase = this.wrap(super._GetWorkshopItemState, async ( + /** @type {string} */ itemId, + /** @type {Tag} */ tag + ) => { + try { + const order = { + url: '/steam/workshop/state', + body: { + itemId + }, + }; + const answer = await this.ws?.sendAndWaitForResponse(order); + if (answer?.body.success === false) { + throw new Error('Failed') + } + const state = answer?.body.data ?? 0 + this._GetWorkshopItemStateResultValue = state + this._GetWorkshopItemStateErrorValue = '' + + // Update or create item in map with state data + const existingItem = this._workshopItemsMap.get(itemId) + if (existingItem) { + existingItem.state = state + } else { + this._workshopItemsMap.set(itemId, { state }) + } + + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnGetWorkshopItemStateSuccess, + C3.Plugins.pipelabv2.Cnds.OnAnyGetWorkshopItemStateSuccess + ]) + } catch (e) { + if (e instanceof Error) { + this._GetWorkshopItemStateErrorValue = e.message + this._GetWorkshopItemStateResultValue = 0 + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnGetWorkshopItemStateError, + C3.Plugins.pipelabv2.Cnds.OnAnyGetWorkshopItemStateError + ]) + } + } + }, this.unsupportedEngine) + _GetWorkshopItemState = this._GetWorkshopItemStateBase + _GetWorkshopItemStateSync = this._GetWorkshopItemStateBase + + _GetWorkshopItemInstallInfoBase = this.wrap(super._GetWorkshopItemInstallInfo, async ( + /** @type {string} */ itemId, + /** @type {Tag} */ tag + ) => { + try { + const order = { + url: '/steam/workshop/install-info', + body: { + itemId + }, + }; + const answer = await this.ws?.sendAndWaitForResponse(order); + if (answer?.body.success === false) { + throw new Error('Failed') + } + const installInfo = answer?.body.data + // Store in a temporary variable for expressions to access + this._lastInstallInfo = installInfo + this._GetWorkshopItemInstallInfoErrorValue = '' + + // Update or create item in map with install info + const existingItem = this._workshopItemsMap.get(itemId) + if (existingItem) { + existingItem.installInfo = installInfo + } else { + this._workshopItemsMap.set(itemId, { installInfo }) + } + + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnGetWorkshopItemInstallInfoSuccess, + C3.Plugins.pipelabv2.Cnds.OnAnyGetWorkshopItemInstallInfoSuccess + ]) + } catch (e) { + if (e instanceof Error) { + this._GetWorkshopItemInstallInfoErrorValue = e.message + this._lastInstallInfo = null + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnGetWorkshopItemInstallInfoError, + C3.Plugins.pipelabv2.Cnds.OnAnyGetWorkshopItemInstallInfoError + ]) + } + } + }, this.unsupportedEngine) + _GetWorkshopItemInstallInfo = this._GetWorkshopItemInstallInfoBase + _GetWorkshopItemInstallInfoSync = this._GetWorkshopItemInstallInfoBase + + _GetWorkshopItemDownloadInfoBase = this.wrap(super._GetWorkshopItemDownloadInfo, async ( + /** @type {string} */ itemId, + /** @type {Tag} */ tag + ) => { + try { + const order = { + url: '/steam/workshop/download-info', + body: { + itemId + }, + }; + const answer = await this.ws?.sendAndWaitForResponse(order); + if (answer?.body.success === false) { + throw new Error('Failed') + } + const downloadInfo = answer?.body.data + // Store in a temporary variable for expressions to access + this._lastDownloadInfo = downloadInfo + this._GetWorkshopItemDownloadInfoErrorValue = '' + + // Update or create item in map with download info + const existingItem = this._workshopItemsMap.get(itemId) + if (existingItem) { + existingItem.downloadInfo = downloadInfo + } else { + this._workshopItemsMap.set(itemId, { downloadInfo }) + } + + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnGetWorkshopItemDownloadInfoSuccess, + C3.Plugins.pipelabv2.Cnds.OnAnyGetWorkshopItemDownloadInfoSuccess + ]) + } catch (e) { + if (e instanceof Error) { + this._GetWorkshopItemDownloadInfoErrorValue = e.message + this._lastDownloadInfo = null + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnGetWorkshopItemDownloadInfoError, + C3.Plugins.pipelabv2.Cnds.OnAnyGetWorkshopItemDownloadInfoError + ]) + } + } + }, this.unsupportedEngine) + _GetWorkshopItemDownloadInfo = this._GetWorkshopItemDownloadInfoBase + _GetWorkshopItemDownloadInfoSync = this._GetWorkshopItemDownloadInfoBase + + _GetWorkshopItemBase = this.wrap(super._GetWorkshopItem, async ( + /** @type {string} */ itemId, + /** @type {Tag} */ tag + ) => { + try { + const order = { + url: '/steam/workshop/get-item', + body: { + itemId + } + }; + const answer = await this.ws?.sendAndWaitForResponse(order); + if (answer?.body.success === false) { + throw new Error('Failed to get item') + } + + // @ts-expect-error - API returns WorkshopItem + const item = answer?.body.data + + if (item) { + const itemIdStr = item.publishedFileId.toString() + const existingItem = this._workshopItemsMap.get(itemIdStr) + if (existingItem) { + this._workshopItemsMap.set(itemIdStr, {...existingItem, ... item}) + } else { + this._workshopItemsMap.set(itemIdStr, item) + } + } + + this._GetWorkshopItemErrorValue = '' + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnGetWorkshopItemSuccess, + C3.Plugins.pipelabv2.Cnds.OnAnyGetWorkshopItemSuccess + ]) + } catch (e) { + if (e instanceof Error) { + this._GetWorkshopItemErrorValue = e.message + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnGetWorkshopItemError, + C3.Plugins.pipelabv2.Cnds.OnAnyGetWorkshopItemError + ]) + } + } + }, this.unsupportedEngine) + _GetWorkshopItem = this._GetWorkshopItemBase + _GetWorkshopItemSync = this._GetWorkshopItemBase + + _GetWorkshopItemsBase = this.wrap(super._GetWorkshopItems, async ( + /** @type {string} */ itemIds, + /** @type {Tag} */ tag + ) => { + try { + const itemIdArray = itemIds.split(',').map(id => id.trim()).filter(id => id.length > 0) + + if (itemIdArray.length === 0) { + this._GetWorkshopItemsErrorValue = '' + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnGetWorkshopItemsSuccess, + C3.Plugins.pipelabv2.Cnds.OnAnyGetWorkshopItemsSuccess + ]) + return + } + + /** @type {import('@pipelab/core').MakeInputOutput, 'input'>} */ + const order = { + url: '/steam/workshop/get-items', + body: { + itemIds: itemIdArray + } + }; + const answer = await this.ws?.sendAndWaitForResponse(order); + if (answer?.body.success === false) { + throw new Error('Failed to get items') + } + + // @ts-expect-error - API returns WorkshopItemsResult + const items = answer?.body.data?.items ?? [] + + for (const item of items) { + if (!item) continue + const itemIdStr = item.publishedFileId.toString() + const existingItem = this._workshopItemsMap.get(itemIdStr) + if (existingItem) { + this._workshopItemsMap.set(itemIdStr, {...existingItem, ... item}) + } else { + this._workshopItemsMap.set(itemIdStr, item) + } + } + + this._GetWorkshopItemsErrorValue = '' + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnGetWorkshopItemsSuccess, + C3.Plugins.pipelabv2.Cnds.OnAnyGetWorkshopItemsSuccess + ]) + } catch (e) { + if (e instanceof Error) { + this._GetWorkshopItemsErrorValue = e.message + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnGetWorkshopItemsError, + C3.Plugins.pipelabv2.Cnds.OnAnyGetWorkshopItemsError + ]) + } + } + }, this.unsupportedEngine) + _GetWorkshopItems = this._GetWorkshopItemsBase + _GetWorkshopItemsSync = this._GetWorkshopItemsBase + + _GetSubscribedWorkshopItemsBase = this.wrap(super._GetSubscribedWorkshopItems, async ( + /** @type {Tag} */ tag + ) => { + try { + /** @type {import('@pipelab/core').MakeInputOutput, 'input'>} */ + const order = { + url: '/steam/raw', + body: { + namespace: 'workshop', + method: 'getSubscribedItems', + args: [false], + }, + }; + const answer = await this.ws?.sendAndWaitForResponse(order); + if (answer?.body.success === false) { + throw new Error('Failed to get subscribed items') + } + + const itemIds = answer?.body.data ?? [] + this._subscribedItemIds = itemIds.map(id => id.toString()) + + this._GetSubscribedWorkshopItemsErrorValue = '' + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnGetSubscribedWorkshopItemsSuccess, + C3.Plugins.pipelabv2.Cnds.OnAnyGetSubscribedWorkshopItemsSuccess + ]) + } catch (e) { + if (e instanceof Error) { + this._GetSubscribedWorkshopItemsErrorValue = e.message + this._subscribedItemIds = [] + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnGetSubscribedWorkshopItemsError, + C3.Plugins.pipelabv2.Cnds.OnAnyGetSubscribedWorkshopItemsError + ]) + } + } + }, this.unsupportedEngine) + _GetSubscribedWorkshopItems = this._GetSubscribedWorkshopItemsBase + _GetSubscribedWorkshopItemsSync = this._GetSubscribedWorkshopItemsBase + + _GetWorkshopItemWithMetadataBase = this.wrap(super._GetWorkshopItemWithMetadata, async ( + /** @type {string} */ itemId, + /** @type {Tag} */ tag + ) => { + try { + // Get item metadata + const order = { + url: '/steam/workshop/get-item', + body: { + itemId + } + }; + const answer = await this.ws?.sendAndWaitForResponse(order); + if (answer?.body.success === false) { + throw new Error('Failed to get item') + } + + // @ts-expect-error - API returns WorkshopItem + const item = answer?.body.data + + if (item) { + const itemIdStr = item.publishedFileId.toString() + + // Get state and install info + const state = await this._getItemState(item.publishedFileId) + const installInfo = await this._getItemInstallInfo(item.publishedFileId) + + // Get download info if downloading + let downloadInfo = null + if (state && (state & 16)) { + downloadInfo = await this._getItemDownloadInfo(item.publishedFileId) + } + + // Store combined data + this._workshopItemsMap.set(itemIdStr, { + ...item, + state, + installInfo, + downloadInfo + }) + } + + this._GetWorkshopItemWithMetadataErrorValue = '' + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnGetWorkshopItemWithMetadataSuccess, + C3.Plugins.pipelabv2.Cnds.OnAnyGetWorkshopItemWithMetadataSuccess + ]) + } catch (e) { + if (e instanceof Error) { + this._GetWorkshopItemWithMetadataErrorValue = e.message + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnGetWorkshopItemWithMetadataError, + C3.Plugins.pipelabv2.Cnds.OnAnyGetWorkshopItemWithMetadataError + ]) + } + } + }, this.unsupportedEngine) + _GetWorkshopItemWithMetadata = this._GetWorkshopItemWithMetadataBase + _GetWorkshopItemWithMetadataSync = this._GetWorkshopItemWithMetadataBase + + _GetWorkshopItemsWithMetadataBase = this.wrap(super._GetWorkshopItemsWithMetadata, async ( + /** @type {string} */ itemIds, + /** @type {Tag} */ tag + ) => { + try { + const itemIdArray = itemIds.split(',').map(id => id.trim()).filter(id => id.length > 0) + + if (itemIdArray.length === 0) { + this._GetWorkshopItemsWithMetadataErrorValue = '' + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnGetWorkshopItemsWithMetadataSuccess, + C3.Plugins.pipelabv2.Cnds.OnAnyGetWorkshopItemsWithMetadataSuccess + ]) + return + } + + // Get metadata for all items + /** @type {import('@pipelab/core').MakeInputOutput, 'input'>} */ + const order = { + url: '/steam/workshop/get-items', + body: { + itemIds: itemIdArray + } + }; + const answer = await this.ws?.sendAndWaitForResponse(order); + if (answer?.body.success === false) { + throw new Error('Failed to get item metadata') + } + + // @ts-expect-error - API returns WorkshopItemsResult + const items = answer?.body.data?.items ?? [] + + // Get state/install/download info for each item + for (const item of items) { + if (!item) continue + const itemIdStr = item.publishedFileId.toString() + + // Get state and install info + const state = await this._getItemState(item.publishedFileId) + const installInfo = await this._getItemInstallInfo(item.publishedFileId) + + // Get download info if downloading + let downloadInfo = null + if (state && (state & 16)) { + downloadInfo = await this._getItemDownloadInfo(item.publishedFileId) + } + + // Store combined data + this._workshopItemsMap.set(itemIdStr, { + ...item, + state, + installInfo, + downloadInfo + }) + } + + this._GetWorkshopItemsWithMetadataErrorValue = '' + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnGetWorkshopItemsWithMetadataSuccess, + C3.Plugins.pipelabv2.Cnds.OnAnyGetWorkshopItemsWithMetadataSuccess + ]) + } catch (e) { + if (e instanceof Error) { + this._GetWorkshopItemsWithMetadataErrorValue = e.message + await this.trigger(tag, [ + C3.Plugins.pipelabv2.Cnds.OnGetWorkshopItemsWithMetadataError, + C3.Plugins.pipelabv2.Cnds.OnAnyGetWorkshopItemsWithMetadataError + ]) + } + } + }, this.unsupportedEngine) + _GetWorkshopItemsWithMetadata = this._GetWorkshopItemsWithMetadataBase + _GetWorkshopItemsWithMetadataSync = this._GetWorkshopItemsWithMetadataBase + // #region Cnds _OnInitializeSuccess = this.wrap(super._OnInitializeSuccess, (/** @type {Tag} */ tag) => { return this._currentTag === tag; @@ -2636,6 +3560,91 @@ function getInstanceJs(parentClass, addonTriggers, C3) { _OnActivateToStoreError = this.wrap(super._OnActivateToStoreError, (/** @type {Tag} */ tag) => this._currentTag === tag) _OnAnyActivateToStoreError = this.wrap(super._OnAnyActivateToStoreError, () => true) + _OnTriggerScreenshotSuccess = this.wrap(super._OnTriggerScreenshotSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyTriggerScreenshotSuccess = this.wrap(super._OnAnyTriggerScreenshotSuccess, () => true) + _OnTriggerScreenshotError = this.wrap(super._OnTriggerScreenshotError, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyTriggerScreenshotError = this.wrap(super._OnAnyTriggerScreenshotError, () => true) + + _OnCheckDLCIsInstalledSuccess = this.wrap(super._OnCheckDLCIsInstalledSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyCheckDLCIsInstalledSuccess = this.wrap(super._OnAnyCheckDLCIsInstalledSuccess, () => true) + _OnCheckDLCIsInstalledError = this.wrap(super._OnCheckDLCIsInstalledError, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyCheckDLCIsInstalledError = this.wrap(super._OnAnyCheckDLCIsInstalledError, () => true) + + _OnCreateWorkshopItemSuccess = this.wrap(super._OnCreateWorkshopItemSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyCreateWorkshopItemSuccess = this.wrap(super._OnAnyCreateWorkshopItemSuccess, () => true) + _OnCreateWorkshopItemError = this.wrap(super._OnCreateWorkshopItemError, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyCreateWorkshopItemError = this.wrap(super._OnAnyCreateWorkshopItemError, () => true) + + _OnUpdateWorkshopItemSuccess = this.wrap(super._OnUpdateWorkshopItemSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyUpdateWorkshopItemSuccess = this.wrap(super._OnAnyUpdateWorkshopItemSuccess, () => true) + _OnUpdateWorkshopItemError = this.wrap(super._OnUpdateWorkshopItemError, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyUpdateWorkshopItemError = this.wrap(super._OnAnyUpdateWorkshopItemError, () => true) + + _OnGetSubscribedItemsWithMetadataSuccess = this.wrap(super._OnGetSubscribedItemsWithMetadataSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyGetSubscribedItemsWithMetadataSuccess = this.wrap(super._OnAnyGetSubscribedItemsWithMetadataSuccess, () => true) + _OnGetSubscribedItemsWithMetadataError = this.wrap(super._OnGetSubscribedItemsWithMetadataError, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyGetSubscribedItemsWithMetadataError = this.wrap(super._OnAnyGetSubscribedItemsWithMetadataError, () => true) + + _OnDownloadWorkshopItemSuccess = this.wrap(super._OnDownloadWorkshopItemSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyDownloadWorkshopItemSuccess = this.wrap(super._OnAnyDownloadWorkshopItemSuccess, () => true) + _OnDownloadWorkshopItemError = this.wrap(super._OnDownloadWorkshopItemError, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyDownloadWorkshopItemError = this.wrap(super._OnAnyDownloadWorkshopItemError, () => true) + + _OnDeleteWorkshopItemSuccess = this.wrap(super._OnDeleteWorkshopItemSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyDeleteWorkshopItemSuccess = this.wrap(super._OnAnyDeleteWorkshopItemSuccess, () => true) + _OnDeleteWorkshopItemError = this.wrap(super._OnDeleteWorkshopItemError, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyDeleteWorkshopItemError = this.wrap(super._OnAnyDeleteWorkshopItemError, () => true) + + _OnSubscribeWorkshopItemSuccess = this.wrap(super._OnSubscribeWorkshopItemSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnySubscribeWorkshopItemSuccess = this.wrap(super._OnAnySubscribeWorkshopItemSuccess, () => true) + _OnSubscribeWorkshopItemError = this.wrap(super._OnSubscribeWorkshopItemError, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnySubscribeWorkshopItemError = this.wrap(super._OnAnySubscribeWorkshopItemError, () => true) + + _OnUnsubscribeWorkshopItemSuccess = this.wrap(super._OnUnsubscribeWorkshopItemSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyUnsubscribeWorkshopItemSuccess = this.wrap(super._OnAnyUnsubscribeWorkshopItemSuccess, () => true) + _OnUnsubscribeWorkshopItemError = this.wrap(super._OnUnsubscribeWorkshopItemError, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyUnsubscribeWorkshopItemError = this.wrap(super._OnAnyUnsubscribeWorkshopItemError, () => true) + + _OnGetWorkshopItemStateSuccess = this.wrap(super._OnGetWorkshopItemStateSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyGetWorkshopItemStateSuccess = this.wrap(super._OnAnyGetWorkshopItemStateSuccess, () => true) + _OnGetWorkshopItemStateError = this.wrap(super._OnGetWorkshopItemStateError, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyGetWorkshopItemStateError = this.wrap(super._OnAnyGetWorkshopItemStateError, () => true) + + _OnGetWorkshopItemInstallInfoSuccess = this.wrap(super._OnGetWorkshopItemInstallInfoSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyGetWorkshopItemInstallInfoSuccess = this.wrap(super._OnAnyGetWorkshopItemInstallInfoSuccess, () => true) + _OnGetWorkshopItemInstallInfoError = this.wrap(super._OnGetWorkshopItemInstallInfoError, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyGetWorkshopItemInstallInfoError = this.wrap(super._OnAnyGetWorkshopItemInstallInfoError, () => true) + + _OnGetWorkshopItemDownloadInfoSuccess = this.wrap(super._OnGetWorkshopItemDownloadInfoSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyGetWorkshopItemDownloadInfoSuccess = this.wrap(super._OnAnyGetWorkshopItemDownloadInfoSuccess, () => true) + _OnGetWorkshopItemDownloadInfoError = this.wrap(super._OnGetWorkshopItemDownloadInfoError, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyGetWorkshopItemDownloadInfoError = this.wrap(super._OnAnyGetWorkshopItemDownloadInfoError, () => true) + + _OnGetWorkshopItemSuccess = this.wrap(super._OnGetWorkshopItemSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyGetWorkshopItemSuccess = this.wrap(super._OnAnyGetWorkshopItemSuccess, () => true) + _OnGetWorkshopItemError = this.wrap(super._OnGetWorkshopItemError, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyGetWorkshopItemError = this.wrap(super._OnAnyGetWorkshopItemError, () => true) + + _OnGetWorkshopItemsSuccess = this.wrap(super._OnGetWorkshopItemsSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyGetWorkshopItemsSuccess = this.wrap(super._OnAnyGetWorkshopItemsSuccess, () => true) + _OnGetWorkshopItemsError = this.wrap(super._OnGetWorkshopItemsError, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyGetWorkshopItemsError = this.wrap(super._OnAnyGetWorkshopItemsError, () => true) + + _OnGetSubscribedWorkshopItemsSuccess = this.wrap(super._OnGetSubscribedWorkshopItemsSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyGetSubscribedWorkshopItemsSuccess = this.wrap(super._OnAnyGetSubscribedWorkshopItemsSuccess, () => true) + _OnGetSubscribedWorkshopItemsError = this.wrap(super._OnGetSubscribedWorkshopItemsError, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyGetSubscribedWorkshopItemsError = this.wrap(super._OnAnyGetSubscribedWorkshopItemsError, () => true) + + _OnGetWorkshopItemWithMetadataSuccess = this.wrap(super._OnGetWorkshopItemWithMetadataSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyGetWorkshopItemWithMetadataSuccess = this.wrap(super._OnAnyGetWorkshopItemWithMetadataSuccess, () => true) + _OnGetWorkshopItemWithMetadataError = this.wrap(super._OnGetWorkshopItemWithMetadataError, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyGetWorkshopItemWithMetadataError = this.wrap(super._OnAnyGetWorkshopItemWithMetadataError, () => true) + + _OnGetWorkshopItemsWithMetadataSuccess = this.wrap(super._OnGetWorkshopItemsWithMetadataSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyGetWorkshopItemsWithMetadataSuccess = this.wrap(super._OnAnyGetWorkshopItemsWithMetadataSuccess, () => true) + _OnGetWorkshopItemsWithMetadataError = this.wrap(super._OnGetWorkshopItemsWithMetadataError, (/** @type {Tag} */ tag) => this._currentTag === tag) + _OnAnyGetWorkshopItemsWithMetadataError = this.wrap(super._OnAnyGetWorkshopItemsWithMetadataError, () => true) + _IsFullScreen = this.wrap(super._IsFullScreen, (state) => { return this._fullscreenState === state }, () => false) @@ -3113,6 +4122,244 @@ function getInstanceJs(parentClass, addonTriggers, C3) { return this._ActivateToStoreResultValue }) + _TriggerScreenshotError = this.exprs(super._TriggerScreenshotError, () => { + return this._TriggerScreenshotErrorValue + }) + _TriggerScreenshotResult = this.exprs(super._TriggerScreenshotResult, () => { + return this._TriggerScreenshotResultValue + }) + + _CheckDLCIsInstalledError = this.exprs(super._CheckDLCIsInstalledError, () => { + return this._CheckDLCIsInstalledErrorValue + }) + _CheckDLCIsInstalledResult = this.exprs(super._CheckDLCIsInstalledResult, () => { + return this._CheckDLCIsInstalledResultValue + }) + + // Workshop expressions + _CreateWorkshopItemError = this.exprs(super._CreateWorkshopItemError, () => { + return this._CreateWorkshopItemErrorValue + }) + _CreateWorkshopItemResult = this.exprs(super._CreateWorkshopItemResult, () => { + return this._CreateWorkshopItemResultValue + }) + _CreateWorkshopItemNeedsAgreement = this.exprs(super._CreateWorkshopItemNeedsAgreement, () => { + return this._CreateWorkshopItemNeedsAgreementValue + }) + + _UpdateWorkshopItemError = this.exprs(super._UpdateWorkshopItemError, () => { + return this._UpdateWorkshopItemErrorValue + }) + _UpdateWorkshopItemResult = this.exprs(super._UpdateWorkshopItemResult, () => { + return this._UpdateWorkshopItemResultValue + }) + _UpdateWorkshopItemNeedsAgreement = this.exprs(super._UpdateWorkshopItemNeedsAgreement, () => { + return this._UpdateWorkshopItemNeedsAgreementValue + }) + + _GetSubscribedItemsWithMetadataError = this.exprs(super._GetSubscribedItemsWithMetadataError, () => { + return this._GetSubscribedItemsWithMetadataErrorValue + }) + _GetSubscribedItemsWithMetadataResult = this.exprs(super._GetSubscribedItemsWithMetadataResult, () => { + return this._GetSubscribedItemsWithMetadataErrorValue === '' ? 1 : 0 + }) + + _DownloadWorkshopItemError = this.exprs(super._DownloadWorkshopItemError, () => { + return this._DownloadWorkshopItemErrorValue + }) + _DownloadWorkshopItemResult = this.exprs(super._DownloadWorkshopItemResult, () => { + return this._DownloadWorkshopItemResultValue + }) + + _DeleteWorkshopItemError = this.exprs(super._DeleteWorkshopItemError, () => { + return this._DeleteWorkshopItemErrorValue + }) + _DeleteWorkshopItemResult = this.exprs(super._DeleteWorkshopItemResult, () => { + return this._DeleteWorkshopItemResultValue + }) + + _SubscribeWorkshopItemError = this.exprs(super._SubscribeWorkshopItemError, () => { + return this._SubscribeWorkshopItemErrorValue + }) + _SubscribeWorkshopItemResult = this.exprs(super._SubscribeWorkshopItemResult, () => { + return this._SubscribeWorkshopItemResultValue + }) + + _UnsubscribeWorkshopItemError = this.exprs(super._UnsubscribeWorkshopItemError, () => { + return this._UnsubscribeWorkshopItemErrorValue + }) + _UnsubscribeWorkshopItemResult = this.exprs(super._UnsubscribeWorkshopItemResult, () => { + return this._UnsubscribeWorkshopItemResultValue + }) + + _GetWorkshopItemStateError = this.exprs(super._GetWorkshopItemStateError, () => { + return this._GetWorkshopItemStateErrorValue + }) + _GetWorkshopItemStateResult = this.exprs(super._GetWorkshopItemStateResult, () => { + return this._GetWorkshopItemStateResultValue + }) + + _GetWorkshopItemInstallInfoError = this.exprs(super._GetWorkshopItemInstallInfoError, () => { + return this._GetWorkshopItemInstallInfoErrorValue + }) + _GetWorkshopItemInstallInfoResult = this.exprs(super._GetWorkshopItemInstallInfoResult, () => { + return JSON.stringify(this._lastInstallInfo ?? {}) + }) + + _GetWorkshopItemDownloadInfoError = this.exprs(super._GetWorkshopItemDownloadInfoError, () => { + return this._GetWorkshopItemDownloadInfoErrorValue + }) + _GetWorkshopItemDownloadInfoResult = this.exprs(super._GetWorkshopItemDownloadInfoResult, () => { + return JSON.stringify(this._lastDownloadInfo ?? {}) + }) + + _GetWorkshopItemError = this.exprs(super._GetWorkshopItemError, () => { + return this._GetWorkshopItemErrorValue + }) + _GetWorkshopItemResult = this.exprs(super._GetWorkshopItemResult, () => { + return this._GetWorkshopItemErrorValue === '' ? 1 : 0 + }) + + _GetWorkshopItemsError = this.exprs(super._GetWorkshopItemsError, () => { + return this._GetWorkshopItemsErrorValue + }) + _GetWorkshopItemsResult = this.exprs(super._GetWorkshopItemsResult, () => { + return this._GetWorkshopItemsErrorValue === '' ? 1 : 0 + }) + + _GetSubscribedWorkshopItemsError = this.exprs(super._GetSubscribedWorkshopItemsError, () => { + return this._GetSubscribedWorkshopItemsErrorValue + }) + _GetSubscribedWorkshopItemsResult = this.exprs(super._GetSubscribedWorkshopItemsResult, () => { + return this._GetSubscribedWorkshopItemsErrorValue === '' ? 1 : 0 + }) + + _GetWorkshopItemWithMetadataError = this.exprs(super._GetWorkshopItemWithMetadataError, () => { + return this._GetWorkshopItemWithMetadataErrorValue + }) + _GetWorkshopItemWithMetadataResult = this.exprs(super._GetWorkshopItemWithMetadataResult, () => { + return this._GetWorkshopItemWithMetadataErrorValue === '' ? 1 : 0 + }) + + _GetWorkshopItemsWithMetadataError = this.exprs(super._GetWorkshopItemsWithMetadataError, () => { + return this._GetWorkshopItemsWithMetadataErrorValue + }) + _GetWorkshopItemsWithMetadataResult = this.exprs(super._GetWorkshopItemsWithMetadataResult, () => { + return this._GetWorkshopItemsWithMetadataErrorValue === '' ? 1 : 0 + }) + + _SubscribedItemsCount = this.exprs(super._SubscribedItemsCount, () => { + return this._subscribedItemIds.length + }) + + _SubscribedItemIdAt = this.exprs(super._SubscribedItemIdAt, (/** @type {number} */ index) => { + if (index < 0 || index >= this._subscribedItemIds.length) return '' + return this._subscribedItemIds[index] + }) + + _WorkshopItemTitle = this.exprs(super._WorkshopItemTitle, (/** @type {string} */ itemId) => { + const item = this._workshopItemsMap.get(itemId) + return item?.title ?? '' + }) + + _WorkshopItemDescription = this.exprs(super._WorkshopItemDescription, (/** @type {string} */ itemId) => { + const item = this._workshopItemsMap.get(itemId) + return item?.description ?? '' + }) + + _WorkshopItemOwnerSteamId64 = this.exprs(super._WorkshopItemOwnerSteamId64, (/** @type {string} */ itemId) => { + const item = this._workshopItemsMap.get(itemId) + return item?.owner?.steamId64?.toString() ?? '' + }) + + _WorkshopItemOwnerAccountId = this.exprs(super._WorkshopItemOwnerAccountId, (/** @type {string} */ itemId) => { + const item = this._workshopItemsMap.get(itemId) + return item?.owner?.accountId ?? 0 + }) + + _WorkshopItemTags = this.exprs(super._WorkshopItemTags, (/** @type {string} */ itemId) => { + const item = this._workshopItemsMap.get(itemId) + return item?.tags?.join(', ') ?? '' + }) + + _WorkshopItemUpvotes = this.exprs(super._WorkshopItemUpvotes, (/** @type {string} */ itemId) => { + const item = this._workshopItemsMap.get(itemId) + return item?.numUpvotes ?? 0 + }) + + _WorkshopItemDownvotes = this.exprs(super._WorkshopItemDownvotes, (/** @type {string} */ itemId) => { + const item = this._workshopItemsMap.get(itemId) + return item?.numDownvotes ?? 0 + }) + + _WorkshopItemPreviewUrl = this.exprs(super._WorkshopItemPreviewUrl, (/** @type {string} */ itemId) => { + const item = this._workshopItemsMap.get(itemId) + return item?.previewUrl ?? '' + }) + + _WorkshopItemUrl = this.exprs(super._WorkshopItemUrl, (/** @type {string} */ itemId) => { + const item = this._workshopItemsMap.get(itemId) + return item?.url ?? '' + }) + + _WorkshopItemTimeCreated = this.exprs(super._WorkshopItemTimeCreated, (/** @type {string} */ itemId) => { + const item = this._workshopItemsMap.get(itemId) + return item?.timeCreated ?? 0 + }) + + _WorkshopItemTimeUpdated = this.exprs(super._WorkshopItemTimeUpdated, (/** @type {string} */ itemId) => { + const item = this._workshopItemsMap.get(itemId) + return item?.timeUpdated ?? 0 + }) + + _WorkshopItemState = this.exprs(super._WorkshopItemState, (/** @type {string} */ itemId) => { + const item = this._workshopItemsMap.get(itemId) + return item?.state ?? 0 + }) + + _WorkshopItemIsInstalled = this.exprs(super._WorkshopItemIsInstalled, (/** @type {string} */ itemId) => { + const item = this._workshopItemsMap.get(itemId) + const state = item?.state + return (state !== undefined && state !== null && (state & 4)) ? 1 : 0 + }) + + _WorkshopItemIsDownloading = this.exprs(super._WorkshopItemIsDownloading, (/** @type {string} */ itemId) => { + const item = this._workshopItemsMap.get(itemId) + const state = item?.state + return (state !== undefined && state !== null && (state & 16)) ? 1 : 0 + }) + + _WorkshopItemNeedsUpdate = this.exprs(super._WorkshopItemNeedsUpdate, (/** @type {string} */ itemId) => { + const item = this._workshopItemsMap.get(itemId) + const state = item?.state + return (state !== undefined && state !== null && (state & 8)) ? 1 : 0 + }) + + _WorkshopItemInstallFolder = this.exprs(super._WorkshopItemInstallFolder, (/** @type {string} */ itemId) => { + const item = this._workshopItemsMap.get(itemId) + return item?.installInfo?.folder ?? '' + }) + + _WorkshopItemSizeOnDisk = this.exprs(super._WorkshopItemSizeOnDisk, (/** @type {string} */ itemId) => { + const item = this._workshopItemsMap.get(itemId) + return Number(item?.installInfo?.sizeOnDisk ?? 0) + }) + + _WorkshopItemTimestamp = this.exprs(super._WorkshopItemTimestamp, (/** @type {string} */ itemId) => { + const item = this._workshopItemsMap.get(itemId) + return item?.installInfo?.timestamp ?? 0 + }) + + _WorkshopItemDownloadCurrent = this.exprs(super._WorkshopItemDownloadCurrent, (/** @type {string} */ itemId) => { + const item = this._workshopItemsMap.get(itemId) + return Number(item?.downloadInfo?.current ?? 0) + }) + + _WorkshopItemDownloadTotal = this.exprs(super._WorkshopItemDownloadTotal, (/** @type {string} */ itemId) => { + const item = this._workshopItemsMap.get(itemId) + return Number(item?.downloadInfo?.total ?? 0) + }) + // _saveToJson() { diff --git a/src/pluginConfig.js b/src/pluginConfig.js index 1c9f770..1aede23 100644 --- a/src/pluginConfig.js +++ b/src/pluginConfig.js @@ -1205,6 +1205,399 @@ const ActivateToStore = ACEGenerator("ActivateToStore", /** @type {const} */ ({ description: "Activates the Steam Overlay to the Steam store page for the provided app", })) +// Steam Screenshots +const TriggerScreenshot = ACEGenerator("TriggerScreenshot", /** @type {const} */ ({ + category: "steam", + highlight: false, + deprecated: false, + params: [], + listName: "Trigger screenshot", + displayText: "Trigger Steam screenshot", + description: "Captures the current screen and saves to Steam screenshot library", +})) + +// Steam DLC +const CheckDLCIsInstalled = ACEGenerator("CheckDLCIsInstalled", /** @type {const} */ ({ + category: "steam", + highlight: false, + deprecated: false, + params: [ + { + id: 'appId', + desc: "The App ID of the DLC to check", + name: "DLC App ID", + type: 'number', + initialValue: "0", + } + ], + listName: "Check DLC is installed", + displayText: "Check DLC [b]{0}[/b] is installed", + description: "Checks if the user owns and has installed a specific DLC", +})) + +// Steam Workshop +const CreateWorkshopItem = ACEGenerator("CreateWorkshopItem", /** @type {const} */ ({ + category: "steam-workshop", + highlight: false, + deprecated: false, + params: [ + { + id: 'appID', + desc: "The Steam App ID for the workshop item", + name: "App ID", + type: 'number', + } + ], + listName: "Create workshop item", + displayText: "Create workshop item for app [b]{0}[/b]", + description: "Creates a new workshop item for the specified Steam App ID and returns its ID", +})) + +const UpdateWorkshopItem = ACEGenerator("UpdateWorkshopItem", /** @type {const} */ ({ + category: "steam-workshop", + highlight: false, + deprecated: false, + params: [ + { + id: 'appID', + desc: "The Steam App ID for the workshop item", + name: "App ID", + type: 'number', + }, + { + id: 'itemId', + desc: "The Workshop Item ID", + name: "Item ID", + type: 'string', + initialValue: '""', + }, + { + id: 'updateTitle', + desc: "Whether to update the title", + name: "Update Title", + type: 'boolean', + initialValue: 'true', + }, + { + id: 'title', + desc: "The title of the workshop item", + name: "Title", + type: 'string', + initialValue: '""', + }, + { + id: 'updateDescription', + desc: "Whether to update the description", + name: "Update Description", + type: 'boolean', + initialValue: 'true', + }, + { + id: 'description', + desc: "The description of the workshop item", + name: "Description", + type: 'string', + initialValue: '""', + }, + { + id: 'updateContent', + desc: "Whether to update the content folder", + name: "Update Content", + type: 'boolean', + initialValue: 'true', + }, + { + id: 'contentFolderPath', + desc: "Absolute path to the folder containing the workshop content", + name: "Content Folder Path", + type: 'string', + initialValue: '""', + }, + { + id: 'changeNote', + desc: "Optional change note describing the content update", + name: "Change Note", + type: 'string', + initialValue: '""', + }, + { + id: 'updatePreview', + desc: "Whether to update the preview image", + name: "Update Preview", + type: 'boolean', + initialValue: 'true', + }, + { + id: 'previewImagePath', + desc: "Absolute path to the preview image file", + name: "Preview Image Path", + type: 'string', + initialValue: '""', + }, + { + id: 'updateTags', + desc: "Whether to update the tags", + name: "Update Tags", + type: 'boolean', + initialValue: 'true', + }, + { + id: 'tags', + desc: "Comma-separated list of tags", + name: "Tags", + type: 'string', + initialValue: '""', + }, + { + id: 'updateVisibility', + desc: "Whether to update the visibility", + name: "Update Visibility", + type: 'boolean', + initialValue: 'true', + }, + { + id: 'visibility', + desc: "Visibility setting (0=Public, 1=FriendsOnly, 2=Private, 3=Unlisted)", + name: "Visibility", + type: 'combo', + items: [ + { "public": "Public" }, + { "friendsOnly": "Friends Only" }, + { "private": "Private" }, + { "unlisted": "Unlisted" }, + ] + } + ], + listName: "Update workshop item", + displayText: "Update workshop item [b]{1}[/b] for app [b]{0}[/b] (title: {2} {3}, description: {4} {5}, content: {6} {7} with change note: {8}, preview: {9} {10}, tags: {11} {12}, visibility: {13} {14})", + description: "Updates content and metadata of a workshop item. Use the update flags to control which fields are updated.", +})) + +const GetSubscribedItemsWithMetadata = ACEGenerator("GetSubscribedItemsWithMetadata", /** @type {const} */ ({ + category: "steam-workshop", + highlight: false, + deprecated: false, + params: [], + listName: "Get subscribed items with metadata", + displayText: "Get subscribed items with metadata", + description: "Gets all subscribed workshop items with their metadata and install info", +})) + +const DownloadWorkshopItem = ACEGenerator("DownloadWorkshopItem", /** @type {const} */ ({ + category: "steam-workshop", + highlight: false, + deprecated: false, + params: [ + { + id: 'itemId', + desc: "The Workshop Item ID", + name: "Item ID", + type: 'string', + initialValue: '""', + }, + { + id: 'highPriority', + desc: "Whether to download with high priority", + name: "High Priority", + type: 'boolean', + initialValue: 'false', + }, + ], + listName: "Download workshop item", + displayText: "Download workshop item [b]{0}[/b] (priority: {1})", + description: "Downloads or updates a workshop item", +})) + +const DeleteWorkshopItem = ACEGenerator("DeleteWorkshopItem", /** @type {const} */ ({ + category: "steam-workshop", + highlight: false, + deprecated: false, + params: [ + { + id: 'itemId', + desc: "The Workshop Item ID", + name: "Item ID", + type: 'string', + initialValue: '""', + }, + ], + listName: "Delete workshop item", + displayText: "Delete workshop item [b]{0}[/b]", + description: "Deletes a workshop item", +})) + +const SubscribeWorkshopItem = ACEGenerator("SubscribeWorkshopItem", /** @type {const} */ ({ + category: "steam-workshop", + highlight: false, + deprecated: false, + params: [ + { + id: 'itemId', + desc: "The Workshop Item ID", + name: "Item ID", + type: 'string', + initialValue: '""', + }, + ], + listName: "Subscribe to workshop item", + displayText: "Subscribe to workshop item [b]{0}[/b]", + description: "Subscribes to a workshop item", +})) + +const UnsubscribeWorkshopItem = ACEGenerator("UnsubscribeWorkshopItem", /** @type {const} */ ({ + category: "steam-workshop", + highlight: false, + deprecated: false, + params: [ + { + id: 'itemId', + desc: "The Workshop Item ID", + name: "Item ID", + type: 'string', + initialValue: '""', + }, + ], + listName: "Unsubscribe from workshop item", + displayText: "Unsubscribe from workshop item [b]{0}[/b]", + description: "Unsubscribes from a workshop item", +})) + +const GetWorkshopItemState = ACEGenerator("GetWorkshopItemState", /** @type {const} */ ({ + category: "steam-workshop", + highlight: false, + deprecated: false, + params: [ + { + id: 'itemId', + desc: "The Workshop Item ID", + name: "Item ID", + type: 'string', + initialValue: '""', + }, + ], + listName: "Get workshop item state", + displayText: "Get state of workshop item [b]{0}[/b]", + description: "Gets the state of a workshop item", +})) + +const GetWorkshopItemInstallInfo = ACEGenerator("GetWorkshopItemInstallInfo", /** @type {const} */ ({ + category: "steam-workshop", + highlight: false, + deprecated: false, + params: [ + { + id: 'itemId', + desc: "The Workshop Item ID", + name: "Item ID", + type: 'string', + initialValue: '""', + }, + ], + listName: "Get workshop item install info", + displayText: "Get install info of workshop item [b]{0}[/b]", + description: "Gets the install info of a workshop item", +})) + +const GetWorkshopItemDownloadInfo = ACEGenerator("GetWorkshopItemDownloadInfo", /** @type {const} */ ({ + category: "steam-workshop", + highlight: false, + deprecated: false, + params: [ + { + id: 'itemId', + desc: "The Workshop Item ID", + name: "Item ID", + type: 'string', + initialValue: '""', + }, + ], + listName: "Get workshop item download info", + displayText: "Get download info of workshop item [b]{0}[/b]", + description: "Gets the download info of a workshop item", +})) + +const GetWorkshopItem = ACEGenerator("GetWorkshopItem", /** @type {const} */ ({ + category: "steam-workshop", + highlight: false, + deprecated: false, + params: [ + { + id: 'itemId', + desc: "The Workshop Item ID", + name: "Item ID", + type: 'string', + initialValue: '""', + }, + ], + listName: "Get workshop item", + displayText: "Get workshop item [b]{0}[/b]", + description: "Gets a workshop item's metadata", +})) + +const GetWorkshopItems = ACEGenerator("GetWorkshopItems", /** @type {const} */ ({ + category: "steam-workshop", + highlight: false, + deprecated: false, + params: [ + { + id: 'itemIds', + desc: "Comma-separated list of Workshop Item IDs", + name: "Item IDs", + type: 'string', + initialValue: '""', + }, + ], + listName: "Get workshop items", + displayText: "Get workshop items [b]{0}[/b]", + description: "Gets multiple workshop items' metadata", +})) + +const GetSubscribedWorkshopItems = ACEGenerator("GetSubscribedWorkshopItems", /** @type {const} */ ({ + category: "steam-workshop", + highlight: false, + deprecated: false, + params: [], + listName: "Get subscribed items", + displayText: "Get subscribed workshop items", + description: "Gets all subscribed workshop item IDs", +})) + +const GetWorkshopItemWithMetadata = ACEGenerator("GetWorkshopItemWithMetadata", /** @type {const} */ ({ + category: "steam-workshop", + highlight: false, + deprecated: false, + params: [ + { + id: 'itemId', + desc: "The Workshop Item ID", + name: "Item ID", + type: 'string', + initialValue: '""', + }, + ], + listName: "Get workshop item with metadata", + displayText: "Get workshop item [b]{0}[/b] with metadata", + description: "Gets a workshop item with its metadata, state, install info, and download info", +})) + +const GetWorkshopItemsWithMetadata = ACEGenerator("GetWorkshopItemsWithMetadata", /** @type {const} */ ({ + category: "steam-workshop", + highlight: false, + deprecated: false, + params: [ + { + id: 'itemIds', + desc: "Comma-separated list of Workshop Item IDs", + name: "Item IDs", + type: 'string', + initialValue: '""', + }, + ], + listName: "Get workshop items with metadata", + displayText: "Get workshop items [b]{0}[/b] with metadata", + description: "Gets multiple workshop items with their metadata, state, install info, and download info", +})) + /** * @satisfies {import('./sdk.js').Config} */ @@ -1333,6 +1726,7 @@ const Config = /** @type {const} */({ 'file-dialogs': "File Dialogs", 'command-line': "Command line", 'steam': "Steam", + 'steam-workshop': "Steam Workshop", 'discord': "Discord" }, Acts: /** @type {const} */ { @@ -1387,6 +1781,23 @@ const Config = /** @type {const} */({ ...LeaderboardDownloadScore.actions, ...ActivateToWebPage.actions, ...ActivateToStore.actions, + ...TriggerScreenshot.actions, + ...CheckDLCIsInstalled.actions, + ...CreateWorkshopItem.actions, + ...UpdateWorkshopItem.actions, + ...GetSubscribedItemsWithMetadata.actions, + ...DownloadWorkshopItem.actions, + ...DeleteWorkshopItem.actions, + ...SubscribeWorkshopItem.actions, + ...UnsubscribeWorkshopItem.actions, + ...GetWorkshopItemState.actions, + ...GetWorkshopItemInstallInfo.actions, + ...GetWorkshopItemDownloadInfo.actions, + ...GetWorkshopItem.actions, + ...GetWorkshopItems.actions, + ...GetSubscribedWorkshopItems.actions, + ...GetWorkshopItemWithMetadata.actions, + ...GetWorkshopItemsWithMetadata.actions, }, Cnds: { ...Initialize.conditions, @@ -1437,6 +1848,23 @@ const Config = /** @type {const} */({ ...LeaderboardDownloadScore.conditions, ...ActivateToWebPage.conditions, ...ActivateToStore.conditions, + ...TriggerScreenshot.conditions, + ...CheckDLCIsInstalled.conditions, + ...CreateWorkshopItem.conditions, + ...UpdateWorkshopItem.conditions, + ...GetSubscribedItemsWithMetadata.conditions, + ...DownloadWorkshopItem.conditions, + ...DeleteWorkshopItem.conditions, + ...SubscribeWorkshopItem.conditions, + ...UnsubscribeWorkshopItem.conditions, + ...GetWorkshopItemState.conditions, + ...GetWorkshopItemInstallInfo.conditions, + ...GetWorkshopItemDownloadInfo.conditions, + ...GetWorkshopItem.conditions, + ...GetWorkshopItems.conditions, + ...GetSubscribedWorkshopItems.conditions, + ...GetWorkshopItemWithMetadata.conditions, + ...GetWorkshopItemsWithMetadata.conditions, IsEngine: { category: "general", forward: "_IsEngine", @@ -1558,6 +1986,369 @@ const Config = /** @type {const} */({ ...LeaderboardDownloadScore.expressions, ...ActivateToWebPage.expressions, ...ActivateToStore.expressions, + ...TriggerScreenshot.expressions, + ...CheckDLCIsInstalled.expressions, + ...CreateWorkshopItem.expressions, + ...UpdateWorkshopItem.expressions, + ...GetSubscribedItemsWithMetadata.expressions, + ...DownloadWorkshopItem.expressions, + ...DeleteWorkshopItem.expressions, + ...SubscribeWorkshopItem.expressions, + ...UnsubscribeWorkshopItem.expressions, + ...GetWorkshopItemState.expressions, + ...GetWorkshopItemInstallInfo.expressions, + ...GetWorkshopItemDownloadInfo.expressions, + ...GetWorkshopItem.expressions, + ...GetWorkshopItems.expressions, + ...GetSubscribedWorkshopItems.expressions, + ...GetWorkshopItemWithMetadata.expressions, + ...GetWorkshopItemsWithMetadata.expressions, + + // Steam Workshop - Additional Expressions + SubscribedItemsCount: { + category: "steam-workshop", + forward: "_SubscribedItemsCount", + highlight: false, + deprecated: false, + returnType: 'number', + description: "Get the number of subscribed workshop items", + }, + SubscribedItemIdAt: { + category: "steam-workshop", + forward: "_SubscribedItemIdAt", + highlight: false, + deprecated: false, + returnType: 'string', + params: [ + { + id: 'index', + desc: "The index of the item (0 to count-1)", + name: "Index", + type: 'number', + } + ], + description: "Get the workshop item ID at the given index", + }, + WorkshopItemTitle: { + category: "steam-workshop", + forward: "_WorkshopItemTitle", + highlight: false, + deprecated: false, + returnType: 'string', + params: [ + { + id: 'itemId', + desc: "The workshop item ID", + name: "Item ID", + type: 'string', + } + ], + description: "Get the title of a workshop item", + }, + WorkshopItemDescription: { + category: "steam-workshop", + forward: "_WorkshopItemDescription", + highlight: false, + deprecated: false, + returnType: 'string', + params: [ + { + id: 'itemId', + desc: "The workshop item ID", + name: "Item ID", + type: 'string', + } + ], + description: "Get the description of a workshop item", + }, + WorkshopItemOwnerSteamId64: { + category: "steam-workshop", + forward: "_WorkshopItemOwnerSteamId64", + highlight: false, + deprecated: false, + returnType: 'string', + params: [ + { + id: 'itemId', + desc: "The workshop item ID", + name: "Item ID", + type: 'string', + } + ], + description: "Get the owner's Steam ID64 of a workshop item", + }, + WorkshopItemOwnerAccountId: { + category: "steam-workshop", + forward: "_WorkshopItemOwnerAccountId", + highlight: false, + deprecated: false, + returnType: 'number', + params: [ + { + id: 'itemId', + desc: "The workshop item ID", + name: "Item ID", + type: 'string', + } + ], + description: "Get the owner's account ID of a workshop item", + }, + WorkshopItemTags: { + category: "steam-workshop", + forward: "_WorkshopItemTags", + highlight: false, + deprecated: false, + returnType: 'string', + params: [ + { + id: 'itemId', + desc: "The workshop item ID", + name: "Item ID", + type: 'string', + } + ], + description: "Get the tags of a workshop item (comma-separated)", + }, + WorkshopItemUpvotes: { + category: "steam-workshop", + forward: "_WorkshopItemUpvotes", + highlight: false, + deprecated: false, + returnType: 'number', + params: [ + { + id: 'itemId', + desc: "The workshop item ID", + name: "Item ID", + type: 'string', + } + ], + description: "Get the number of upvotes for a workshop item", + }, + WorkshopItemDownvotes: { + category: "steam-workshop", + forward: "_WorkshopItemDownvotes", + highlight: false, + deprecated: false, + returnType: 'number', + params: [ + { + id: 'itemId', + desc: "The workshop item ID", + name: "Item ID", + type: 'string', + } + ], + description: "Get the number of downvotes for a workshop item", + }, + WorkshopItemPreviewUrl: { + category: "steam-workshop", + forward: "_WorkshopItemPreviewUrl", + highlight: false, + deprecated: false, + returnType: 'string', + params: [ + { + id: 'itemId', + desc: "The workshop item ID", + name: "Item ID", + type: 'string', + } + ], + description: "Get the preview image URL of a workshop item", + }, + WorkshopItemUrl: { + category: "steam-workshop", + forward: "_WorkshopItemUrl", + highlight: false, + deprecated: false, + returnType: 'string', + params: [ + { + id: 'itemId', + desc: "The workshop item ID", + name: "Item ID", + type: 'string', + } + ], + description: "Get the Steam Workshop URL of a workshop item", + }, + WorkshopItemTimeCreated: { + category: "steam-workshop", + forward: "_WorkshopItemTimeCreated", + highlight: false, + deprecated: false, + returnType: 'number', + params: [ + { + id: 'itemId', + desc: "The workshop item ID", + name: "Item ID", + type: 'string', + } + ], + description: "Get the creation timestamp of a workshop item (Unix epoch)", + }, + WorkshopItemTimeUpdated: { + category: "steam-workshop", + forward: "_WorkshopItemTimeUpdated", + highlight: false, + deprecated: false, + returnType: 'number', + params: [ + { + id: 'itemId', + desc: "The workshop item ID", + name: "Item ID", + type: 'string', + } + ], + description: "Get the last update timestamp of a workshop item (Unix epoch)", + }, + WorkshopItemState: { + category: "steam-workshop", + forward: "_WorkshopItemState", + highlight: false, + deprecated: false, + returnType: 'number', + params: [ + { + id: 'itemId', + desc: "The workshop item ID", + name: "Item ID", + type: 'string', + } + ], + description: "Get the state bitfield of a workshop item", + }, + WorkshopItemIsInstalled: { + category: "steam-workshop", + forward: "_WorkshopItemIsInstalled", + highlight: false, + deprecated: false, + returnType: 'number', + params: [ + { + id: 'itemId', + desc: "The workshop item ID", + name: "Item ID", + type: 'string', + } + ], + description: "Check if a workshop item is installed (returns 0 or 1)", + }, + WorkshopItemIsDownloading: { + category: "steam-workshop", + forward: "_WorkshopItemIsDownloading", + highlight: false, + deprecated: false, + returnType: 'number', + params: [ + { + id: 'itemId', + desc: "The workshop item ID", + name: "Item ID", + type: 'string', + } + ], + description: "Check if a workshop item is downloading (returns 0 or 1)", + }, + WorkshopItemNeedsUpdate: { + category: "steam-workshop", + forward: "_WorkshopItemNeedsUpdate", + highlight: false, + deprecated: false, + returnType: 'number', + params: [ + { + id: 'itemId', + desc: "The workshop item ID", + name: "Item ID", + type: 'string', + } + ], + description: "Check if a workshop item needs an update (returns 0 or 1)", + }, + WorkshopItemInstallFolder: { + category: "steam-workshop", + forward: "_WorkshopItemInstallFolder", + highlight: false, + deprecated: false, + returnType: 'string', + params: [ + { + id: 'itemId', + desc: "The workshop item ID", + name: "Item ID", + type: 'string', + } + ], + description: "Get the installation folder path of a workshop item", + }, + WorkshopItemSizeOnDisk: { + category: "steam-workshop", + forward: "_WorkshopItemSizeOnDisk", + highlight: false, + deprecated: false, + returnType: 'number', + params: [ + { + id: 'itemId', + desc: "The workshop item ID", + name: "Item ID", + type: 'string', + } + ], + description: "Get the size on disk of a workshop item in bytes", + }, + WorkshopItemTimestamp: { + category: "steam-workshop", + forward: "_WorkshopItemTimestamp", + highlight: false, + deprecated: false, + returnType: 'number', + params: [ + { + id: 'itemId', + desc: "The workshop item ID", + name: "Item ID", + type: 'string', + } + ], + description: "Get the install timestamp of a workshop item", + }, + WorkshopItemDownloadCurrent: { + category: "steam-workshop", + forward: "_WorkshopItemDownloadCurrent", + highlight: false, + deprecated: false, + returnType: 'number', + params: [ + { + id: 'itemId', + desc: "The workshop item ID", + name: "Item ID", + type: 'string', + } + ], + description: "Get the current download progress of a workshop item", + }, + WorkshopItemDownloadTotal: { + category: "steam-workshop", + forward: "_WorkshopItemDownloadTotal", + highlight: false, + deprecated: false, + returnType: 'number', + params: [ + { + id: 'itemId', + desc: "The workshop item ID", + name: "Item ID", + type: 'string', + } + ], + description: "Get the total download progress of a workshop item", + }, // command line ArgumentAt: { diff --git a/src/sdk.d.ts b/src/sdk.d.ts index 6995556..c371b4f 100644 --- a/src/sdk.d.ts +++ b/src/sdk.d.ts @@ -29,7 +29,7 @@ type MyExpression = params: PARAMS } -type Categories = 'general' | 'window' | 'filesystem' | 'file-dialogs' | 'command-line' | 'steam' | 'discord' +type Categories = 'general' | 'window' | 'filesystem' | 'file-dialogs' | 'command-line' | 'steam' | 'steam-workshop' | 'discord' type Config = import("c3ide2-types").Plugin; diff --git a/validate.js b/validate.js index c64cb8e..e4e63bc 100644 --- a/validate.js +++ b/validate.js @@ -13,7 +13,7 @@ function validateDisplayText(name, obj, aceType) { if (obj.hasOwnProperty("displayText")) { const paramCount = (obj.params || []).length; // use regex to find the number of {/d} in displayText - const regex = /{\d}/g; + const regex = /{\d+}/g; const matches = obj.displayText.match(regex); const matchCount = matches ? matches.length : 0; // check if the number of {/d} matches the number of params @@ -48,8 +48,8 @@ async function ensureForwardScript(name, obj, aceType) { addLoadPromise: () => {}, }, }; - _postToDOMAsync = () => new Promise(() => {}) - _addDOMMessageHandler = () => {} + _postToDOMAsync = () => new Promise(() => {}); + _addDOMMessageHandler = () => {}; }, undefined, undefined