Skip to content

Commit 383603d

Browse files
skymenArmaldio
andauthored
Added Activate Overlay + AppID expression + is initialized (#1)
* Added Steam overlay actions and AppID expression * Add IsInitialized condition to expose _isInitialized boolean state Co-authored-by: Quentin Goinaud <[email protected]>
1 parent c9c4755 commit 383603d

File tree

3 files changed

+259
-1
lines changed

3 files changed

+259
-1
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ A plugin that integrate with Pipelab <br>
55
Author: Armaldio <br>
66
Website: https://github.com/CynToolkit/construct-plugin <br>
77
Addon Url: https://github.com/CynToolkit/construct-plugin <br>
8-
Download Latest Version : [Version: 2.2.0](https://github.com/CynToolkit/construct-plugin/releases/latest) <br>
8+
Download Latest Version : [Version: 2.3.0](https://github.com/CynToolkit/construct-plugin/releases/latest) <br>
99
<sub>Made using [c3ide2-framework](https://github.com/ConstructFund/c3ide2-framework) </sub><br>
1010

1111
## Table of Contents
@@ -145,6 +145,10 @@ When Download type is Around the user, the offsets are the amount of entries aro
145145
| Download scores | Download scores from a leaderboard
146146
When Download type is Regular, offset are absolute.
147147
When Download type is Around the user, the offsets are the amount of entries around the user to fetch. | Leaderboard *(string)* <br>Download type *(combo)* <br>Start *(number)* <br>End *(number)* <br>Output *(object)* <br> |
148+
| Activate Steam overlay to web page (synchronous) | Activates Steam Overlay web browser directly to the specified URL (synchronous) | URL *(string)* <br>Mode *(combo)* <br>Tag *(string)* <br> |
149+
| Activate Steam overlay to web page | Activates Steam Overlay web browser directly to the specified URL | URL *(string)* <br>Mode *(combo)* <br> |
150+
| Activate Steam overlay to store (synchronous) | Activates the Steam Overlay to the Steam store page for the provided app (synchronous) | App ID *(number)* <br>Flag *(combo)* <br>Tag *(string)* <br> |
151+
| Activate Steam overlay to store | Activates the Steam Overlay to the Steam store page for the provided app | App ID *(number)* <br>Flag *(combo)* <br> |
148152

149153

150154
---
@@ -335,7 +339,16 @@ When Download type is Around the user, the offsets are the amount of entries aro
335339
| On any "LeaderboardDownloadScore" success | Trigger when any of the "LeaderboardDownloadScore" are executed with success. | |
336340
| On "LeaderboardDownloadScore" error | Trigger when the "LeaderboardDownloadScore" failed to execute. | Tag *(string)* <br> |
337341
| On any "LeaderboardDownloadScore" error | Trigger when any of the "LeaderboardDownloadScore" failed to execute. | |
342+
| On "ActivateToWebPage" success | Trigger when the "ActivateToWebPage" is executed with success. | Tag *(string)* <br> |
343+
| On any "ActivateToWebPage" success | Trigger when any of the "ActivateToWebPage" are executed with success. | |
344+
| On "ActivateToWebPage" error | Trigger when the "ActivateToWebPage" failed to execute. | Tag *(string)* <br> |
345+
| On any "ActivateToWebPage" error | Trigger when any of the "ActivateToWebPage" failed to execute. | |
346+
| On "ActivateToStore" success | Trigger when the "ActivateToStore" is executed with success. | Tag *(string)* <br> |
347+
| On any "ActivateToStore" success | Trigger when any of the "ActivateToStore" are executed with success. | |
348+
| On "ActivateToStore" error | Trigger when the "ActivateToStore" failed to execute. | Tag *(string)* <br> |
349+
| On any "ActivateToStore" error | Trigger when any of the "ActivateToStore" failed to execute. | |
338350
| Is engine | Return true if the engine running the app is the one selected | Engine *(combo)* <br> |
351+
| Is initialized | Returns true if the Pipelab integration has been initialized | |
339352
| Is full screen | Returns true if the window is in full screen mode. | State *(combo)* <br> |
340353
| Last checked path exists | Returns true if the last checked path exists. | |
341354

@@ -436,6 +449,10 @@ When Download type is Around the user, the offsets are the amount of entries aro
436449
| LeaderboardUploadScoreWithMetadataResult | The result of the "LeaderboardUploadScoreWithMetadata last call" | string | |
437450
| LeaderboardDownloadScoreError | The error of the "LeaderboardDownloadScore last call" | string | |
438451
| LeaderboardDownloadScoreResult | The result of the "LeaderboardDownloadScore last call" | string | |
452+
| ActivateToWebPageError | The error of the "ActivateToWebPage last call" | string | |
453+
| ActivateToWebPageResult | The result of the "ActivateToWebPage last call" | string | |
454+
| ActivateToStoreError | The error of the "ActivateToStore last call" | string | |
455+
| ActivateToStoreResult | The result of the "ActivateToStore last call" | string | |
439456
| ArgumentAt | Get the argument at the given index. | string | Index *(number)* <br> |
440457
| ArgumentCount | Get the number of arguments. | number | |
441458
| AppFolderURL | Return the URL of the folder of the current app. | string | |
@@ -480,6 +497,7 @@ When Download type is Around the user, the offsets are the amount of entries aro
480497
| SteamLevel | Get the Steam level. | number | |
481498
| SteamIpCountry | Get the Steam IP country. | string | |
482499
| SteamIsRunningOnSteamDeck | Return true if the app is running on a Steam Deck. | number | |
500+
| SteamAppId | Get the currently used Steam App ID. | number | |
483501

484502
## Paths
485503
**ProjectFilesFolder**: Direct path to your games's content

src/instance.js

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,17 @@ const defaultSteamId = {
223223
steamId64: '',
224224
}
225225

226+
// Simple path utility for POSIX-style path operations
227+
const posixPath = {
228+
dirname: (path) => {
229+
const lastSlash = path.lastIndexOf('/');
230+
return lastSlash === -1 ? '.' : path.substring(0, lastSlash);
231+
},
232+
join: (dirname, filename) => {
233+
return dirname.endsWith('/') ? dirname + filename : dirname + '/' + filename;
234+
}
235+
};
236+
226237
let DOM_COMPONENT_ID = ''
227238
//<-- DOM_COMPONENT_ID -->
228239

@@ -355,11 +366,24 @@ function getInstanceJs(parentClass, addonTriggers, C3) {
355366
/** @type {string} */
356367
_arch = ''
357368

369+
/** @type {number} */
370+
_steam_AppId = -1
371+
358372
/** @type {string} */
359373
_ListFilesErrorValue = ''
360374
/** @type {import("@pipelab/core").FileFolder[]} */
361375
_ListFilesResultValue = []
362376

377+
/** @type {string} */
378+
_ActivateToWebPageErrorValue = ''
379+
/** @type {boolean} */
380+
_ActivateToWebPageResultValue = false
381+
382+
/** @type {string} */
383+
_ActivateToStoreErrorValue = ''
384+
/** @type {boolean} */
385+
_ActivateToStoreResultValue = false
386+
363387
/**
364388
* Description
365389
* @param {ISDKInstanceBase_} inst
@@ -681,6 +705,20 @@ function getInstanceJs(parentClass, addonTriggers, C3) {
681705
this._arch = response?.body.arch ?? "";
682706
})
683707

708+
promises.push(async () => {
709+
/** @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw<'utils', 'getAppId'>, 'input'>} */
710+
const order = {
711+
url: '/steam/raw',
712+
body: {
713+
namespace: 'utils',
714+
method: 'getAppId',
715+
args: [],
716+
},
717+
};
718+
const response = await this.ws?.sendAndWaitForResponse(order);
719+
this._steam_AppId = response?.body.data ?? -1;
720+
})
721+
684722
const results = await Promise.allSettled(promises.map(x => x()))
685723

686724
// -----------------------------------------------------------------------
@@ -2136,6 +2174,94 @@ function getInstanceJs(parentClass, addonTriggers, C3) {
21362174
_DiscordSetActivitySync = this._DiscordSetActivityBase
21372175
_DiscordSetActivity = this._DiscordSetActivityBase
21382176

2177+
_ActivateToWebPageBase = this.wrap(super._ActivateToWebPage, async (
2178+
/** @type {string} */ url,
2179+
/** @type {number} */ mode,
2180+
/** @type {Tag} */ tag
2181+
) => {
2182+
try {
2183+
// Map Construct3 combo values to Steam constants
2184+
// 0 = "default", 1 = "modal"
2185+
const steamMode = mode === 1 ? 1 : 0; // k_EActivateGameOverlayToWebPageMode_Modal : k_EActivateGameOverlayToWebPageMode_Default
2186+
2187+
/** @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw<'overlay', 'activateToWebPage'>, 'input'>} */
2188+
const order = {
2189+
url: '/steam/raw',
2190+
body: {
2191+
namespace: 'overlay',
2192+
method: 'activateToWebPage',
2193+
args: [url, steamMode],
2194+
},
2195+
};
2196+
const answer = await this.ws?.sendAndWaitForResponse(order);
2197+
if (answer?.body.success === false) {
2198+
throw new Error('Failed')
2199+
}
2200+
this._ActivateToWebPageResultValue = answer?.body.success
2201+
this._ActivateToWebPageErrorValue = ''
2202+
2203+
await this.trigger(tag, [
2204+
C3.Plugins.pipelabv2.Cnds.OnActivateToWebPageSuccess,
2205+
C3.Plugins.pipelabv2.Cnds.OnAnyActivateToWebPageSuccess
2206+
])
2207+
} catch (e) {
2208+
if (e instanceof Error) {
2209+
this._ActivateToWebPageErrorValue = e.message
2210+
this._ActivateToWebPageResultValue = false
2211+
await this.trigger(tag, [
2212+
C3.Plugins.pipelabv2.Cnds.OnActivateToWebPageError,
2213+
C3.Plugins.pipelabv2.Cnds.OnAnyActivateToWebPageError
2214+
])
2215+
}
2216+
}
2217+
}, this.unsupportedEngine)
2218+
_ActivateToWebPage = this._ActivateToWebPageBase
2219+
_ActivateToWebPageSync = this._ActivateToWebPageBase
2220+
2221+
_ActivateToStoreBase = this.wrap(super._ActivateToStore, async (
2222+
/** @type {number} */ appId,
2223+
/** @type {number} */ flag,
2224+
/** @type {Tag} */ tag
2225+
) => {
2226+
try {
2227+
// Map Construct3 combo values to Steam constants
2228+
// 0 = "none", 1 = "addToCartAndShow"
2229+
const steamFlag = flag === 1 ? 2 : 0; // k_EOverlayToStoreFlag_AddToCartAndShow : k_EOverlayToStoreFlag_None
2230+
2231+
/** @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').SteamRaw<'overlay', 'activateToStore'>, 'input'>} */
2232+
const order = {
2233+
url: '/steam/raw',
2234+
body: {
2235+
namespace: 'overlay',
2236+
method: 'activateToStore',
2237+
args: [appId, steamFlag],
2238+
},
2239+
};
2240+
const answer = await this.ws?.sendAndWaitForResponse(order);
2241+
if (answer?.body.success === false) {
2242+
throw new Error('Failed')
2243+
}
2244+
this._ActivateToStoreResultValue = answer?.body.success
2245+
this._ActivateToStoreErrorValue = ''
2246+
2247+
await this.trigger(tag, [
2248+
C3.Plugins.pipelabv2.Cnds.OnActivateToStoreSuccess,
2249+
C3.Plugins.pipelabv2.Cnds.OnAnyActivateToStoreSuccess
2250+
])
2251+
} catch (e) {
2252+
if (e instanceof Error) {
2253+
this._ActivateToStoreErrorValue = e.message
2254+
this._ActivateToStoreResultValue = false
2255+
await this.trigger(tag, [
2256+
C3.Plugins.pipelabv2.Cnds.OnActivateToStoreError,
2257+
C3.Plugins.pipelabv2.Cnds.OnAnyActivateToStoreError
2258+
])
2259+
}
2260+
}
2261+
}, this.unsupportedEngine)
2262+
_ActivateToStore = this._ActivateToStoreBase
2263+
_ActivateToStoreSync = this._ActivateToStoreBase
2264+
21392265
// #region Cnds
21402266
_OnInitializeSuccess = this.wrap(super._OnInitializeSuccess, (/** @type {Tag} */ tag) => {
21412267
return this._currentTag === tag;
@@ -2500,13 +2626,27 @@ function getInstanceJs(parentClass, addonTriggers, C3) {
25002626
return true
25012627
})
25022628

2629+
_OnActivateToWebPageSuccess = this.wrap(super._OnActivateToWebPageSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag)
2630+
_OnAnyActivateToWebPageSuccess = this.wrap(super._OnAnyActivateToWebPageSuccess, () => true)
2631+
_OnActivateToWebPageError = this.wrap(super._OnActivateToWebPageError, (/** @type {Tag} */ tag) => this._currentTag === tag)
2632+
_OnAnyActivateToWebPageError = this.wrap(super._OnAnyActivateToWebPageError, () => true)
2633+
2634+
_OnActivateToStoreSuccess = this.wrap(super._OnActivateToStoreSuccess, (/** @type {Tag} */ tag) => this._currentTag === tag)
2635+
_OnAnyActivateToStoreSuccess = this.wrap(super._OnAnyActivateToStoreSuccess, () => true)
2636+
_OnActivateToStoreError = this.wrap(super._OnActivateToStoreError, (/** @type {Tag} */ tag) => this._currentTag === tag)
2637+
_OnAnyActivateToStoreError = this.wrap(super._OnAnyActivateToStoreError, () => true)
2638+
25032639
_IsFullScreen = this.wrap(super._IsFullScreen, (state) => {
25042640
return this._fullscreenState === state
25052641
}, () => false)
25062642

25072643
_LastCheckedPathExists = this.wrap(super._LastCheckedPathExists, (state) => {
25082644
return this._CheckIfPathExistErrorValue === ''
25092645
}, () => false)
2646+
2647+
_IsInitialized = this.wrap(super._IsInitialized, () => {
2648+
return this._isInitialized
2649+
}, () => false)
25102650
// #endregion
25112651

25122652
// #region Exps
@@ -2674,6 +2814,9 @@ function getInstanceJs(parentClass, addonTriggers, C3) {
26742814
_SteamIsRunningOnSteamDeck = this.exprs(super._SteamIsRunningOnSteamDeck, () => {
26752815
return this._steam_IsRunningOnSteamDeck ? 1 : 0
26762816
})
2817+
_SteamAppId = this.exprs(super._SteamAppId, () => {
2818+
return this._steam_AppId
2819+
})
26772820

26782821
_InitializeError = this.exprs(super._InitializeError, () => {
26792822
return this._InitializeErrorValue
@@ -2956,6 +3099,20 @@ function getInstanceJs(parentClass, addonTriggers, C3) {
29563099
return this._DiscordSetActivityResultValue
29573100
})
29583101

3102+
_ActivateToWebPageError = this.exprs(super._ActivateToWebPageError, () => {
3103+
return this._ActivateToWebPageErrorValue
3104+
})
3105+
_ActivateToWebPageResult = this.exprs(super._ActivateToWebPageResult, () => {
3106+
return this._ActivateToWebPageResultValue
3107+
})
3108+
3109+
_ActivateToStoreError = this.exprs(super._ActivateToStoreError, () => {
3110+
return this._ActivateToStoreErrorValue
3111+
})
3112+
_ActivateToStoreResult = this.exprs(super._ActivateToStoreResult, () => {
3113+
return this._ActivateToStoreResultValue
3114+
})
3115+
29593116
//
29603117

29613118
_saveToJson() {

src/pluginConfig.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,62 @@ const DiscordSetActivity = ACEGenerator("DiscordSetActivity", /** @type {const}
11491149
description: "Set the discord activity (aka Rich presence).",
11501150
}))
11511151

1152+
const ActivateToWebPage = ACEGenerator("ActivateToWebPage", /** @type {const} */ ({
1153+
category: "steam",
1154+
highlight: false,
1155+
deprecated: false,
1156+
params: [
1157+
{
1158+
id: 'url',
1159+
desc: "The webpage to open. A fully qualified address with the protocol is required (e.g. 'http://www.steampowered.com')",
1160+
name: "URL",
1161+
type: 'string',
1162+
initialValue: "\"\"",
1163+
},
1164+
{
1165+
id: 'mode',
1166+
desc: "Mode for the web page.",
1167+
name: "Mode",
1168+
type: 'combo',
1169+
items: [
1170+
{ "default": "Default" },
1171+
{ "modal": "Modal" },
1172+
]
1173+
}
1174+
],
1175+
listName: "Activate Steam overlay to web page",
1176+
displayText: "Activate Steam overlay to web page [b]{0}[/b] (mode: {1})",
1177+
description: "Activates Steam Overlay web browser directly to the specified URL",
1178+
}))
1179+
1180+
const ActivateToStore = ACEGenerator("ActivateToStore", /** @type {const} */ ({
1181+
category: "steam",
1182+
highlight: false,
1183+
deprecated: false,
1184+
params: [
1185+
{
1186+
id: 'appId',
1187+
desc: "The app ID to show the store page of",
1188+
name: "App ID",
1189+
type: 'number',
1190+
initialValue: "0",
1191+
},
1192+
{
1193+
id: 'flag',
1194+
desc: "Flags to modify the behavior when the page opens",
1195+
name: "Flag",
1196+
type: 'combo',
1197+
items: [
1198+
{ "none": "None" },
1199+
{ "addToCartAndShow": "Add to cart and show" },
1200+
]
1201+
}
1202+
],
1203+
listName: "Activate Steam overlay to store",
1204+
displayText: "Activate Steam overlay to store for app [b]{0}[/b] (flag: {1})",
1205+
description: "Activates the Steam Overlay to the Steam store page for the provided app",
1206+
}))
1207+
11521208
/**
11531209
* @satisfies {import('./sdk.js').Config<import('./sdk.js').Categories>}
11541210
*/
@@ -1329,6 +1385,8 @@ const Config = /** @type {const} */({
13291385
...LeaderboardUploadScore.actions,
13301386
...LeaderboardUploadScoreWithMetadata.actions,
13311387
...LeaderboardDownloadScore.actions,
1388+
...ActivateToWebPage.actions,
1389+
...ActivateToStore.actions,
13321390
},
13331391
Cnds: {
13341392
...Initialize.conditions,
@@ -1377,6 +1435,8 @@ const Config = /** @type {const} */({
13771435
...LeaderboardUploadScore.conditions,
13781436
...LeaderboardUploadScoreWithMetadata.conditions,
13791437
...LeaderboardDownloadScore.conditions,
1438+
...ActivateToWebPage.conditions,
1439+
...ActivateToStore.conditions,
13801440
IsEngine: {
13811441
category: "general",
13821442
forward: "_IsEngine",
@@ -1399,6 +1459,19 @@ const Config = /** @type {const} */({
13991459
listName: "Is engine",
14001460
},
14011461

1462+
IsInitialized: {
1463+
category: "general",
1464+
forward: "_IsInitialized",
1465+
highlight: false,
1466+
deprecated: false,
1467+
description: "Returns true if the Pipelab integration has been initialized",
1468+
displayText: "Is initialized",
1469+
listName: "Is initialized",
1470+
isInvertible: true,
1471+
isTrigger: false,
1472+
params: []
1473+
},
1474+
14021475
IsFullScreen: {
14031476
category: "window",
14041477
forward: "_IsFullScreen",
@@ -1483,6 +1556,8 @@ const Config = /** @type {const} */({
14831556
...LeaderboardUploadScore.expressions,
14841557
...LeaderboardUploadScoreWithMetadata.expressions,
14851558
...LeaderboardDownloadScore.expressions,
1559+
...ActivateToWebPage.expressions,
1560+
...ActivateToStore.expressions,
14861561

14871562
// command line
14881563
ArgumentAt: {
@@ -1881,6 +1956,14 @@ const Config = /** @type {const} */({
18811956
returnType: 'number',
18821957
description: "Return true if the app is running on a Steam Deck.",
18831958
},
1959+
SteamAppId: {
1960+
category: "steam",
1961+
forward: "_SteamAppId",
1962+
highlight: false,
1963+
deprecated: false,
1964+
returnType: 'number',
1965+
description: "Get the currently used Steam App ID.",
1966+
},
18841967
},
18851968
});
18861969

0 commit comments

Comments
 (0)