Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion p2ce/campaign.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,20 @@ declare namespace CampaignAPI {
function IsCampaignActive(): boolean;
function FindCampaign(campaign: string): CampaignPair|null;

function GetCampaignMeta(name: string|null): Map<string, string>;
function GetCampaignMeta(name: string|null): Map<string, string>|null;

function SetActiveCampaign(name: string|null): boolean;
function StartCampaign(campaign: string, chapter: string, map: number): boolean;
function ContinueCampaign(campaign: string): boolean;

function GetCampaignUnlockProgress(campaign: string): number;

function CampaignHasSaveData(campaign: string|null): boolean;
function MoveToNextMap(): void;
}

interface GlobalEventNameMap {
PanoramaComponent_Campaign_OnActiveCampaignChanged: (campaign: string|null) => void;
PanoramaComponent_Campaign_OnRefreshList: () => void;
PanoramaComponent_Campaign_OnCampaignEvaluationRequested: (campaign: string) => void;
}
31 changes: 31 additions & 0 deletions p2ce/caption.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* @packageDocumentation
* Captioning Interface
*/

interface Caption {
bLowPriority: boolean;
bSFX: boolean;
flNoRepeat: number;
flDelay: number;
flLifetimeOverride: number;
text: string;
options: Map<string, string>;
}

declare enum CloseCaptioningExpiryMethod {
STACK = 0,
INDIVIDUAL = 1
}

interface GlobalEventNameMap {
DisplayCaption: (token: string, caption: Caption, lifetime: number, emitTime: number) => void;
BadCaption: (token: string, lifetime: number, emitTime: number) => void;
EndCaption: (token: string) => void;
}

declare namespace ClosedCaptionsAPI {
function SetMaxCaptionEntries(num: number): void;
function GetAvailableLanguages(): Array<string>;
function SetCaptioningExpiryMethod(method: CloseCaptioningExpiryMethod): void;
}
75 changes: 26 additions & 49 deletions p2ce/workshop.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,14 @@
* ```
*/

/** @group enum */
declare enum DownloadState {
UninstallPending = 0,
Uninstalling = 1,
Uninstalled = 2,

InstallPending = 3,
Installing = 4,
Installed = 5,
}
declare type AddonIndex_t = int32;
declare type PublishedFileId_t = bigint;

/** @group enum */
declare enum AddonRating {
None = 0,
ThumbsDown = 1,
ThumbsUp = 2,
ThumbsUp = 1,
ThumbsDown = 2,
}

/** Describes a workshop item. */
Expand All @@ -34,13 +26,12 @@ interface AddonMeta {
index: number;
title: string;
description: string;
workshopid: number;
workshopid: PublishedFileId_t;
local: boolean;

authors: string[];
tags: string[];

dependencies: {[uuid: string]: { required: boolean }};
votescore: number;
flagged: boolean;
upvotes: number;
Expand All @@ -53,21 +44,14 @@ interface AddonMeta {

// The standard workshop thumbnail. Exists on all addons.
thumb: string;

// These only exist when the addon is a campaign.
cover?: string;
logo?: string;
}

/** A chapter of an addon. */
interface AddonChapterMeta {
map: string;
title: string;
description: string;

unlocked: boolean;
thumb: string;
background: string;
interface SteamUGCDetails_t {
m_nPublishedFileId: PublishedFileId_t;
m_rgchTitle: string;
m_rgchDescription: string;
m_rgchPreviewUrl: string;
m_ulSteamIDOwner: uint64_num;
}

/** [API not finalized] The workshop content API. Exclusive to P2:CE! */
Expand All @@ -76,48 +60,41 @@ declare namespace WorkshopAPI {
function GetAddonCount(): number;

/** Returns the metadata for the addon at the specified index. */
function GetAddonMeta(index: uint32): AddonMeta;
function GetAddonMeta(index: AddonIndex_t): AddonMeta;

/** Sets the subscription state of the addon at the specified index */
function SetAddonSubscribed(index: uint32, subscribed: boolean): void;
function SetAddonSubscribed(index: AddonIndex_t, subscribed: boolean): void;

/** Returns the subscription state of the addon at the specified index. */
function GetAddonSubscribed(index: uint32): boolean;
function GetAddonSubscribed(index: AddonIndex_t): boolean;

/** Sets the enable state of the addon at the specified index */
function SetAddonEnabled(index: uint32, enabled: boolean): void;
function SetAddonEnabled(index: AddonIndex_t, enabled: boolean): void;

/** Returns the enable state of the addon at the specified index. */
function GetAddonEnabled(index: uint32): boolean;
function GetAddonEnabled(index: AddonIndex_t): boolean;

/** Gets the user rating for the given addon. If installed locally, returns AddonRating.None */
function GetAddonUserRating(index: uint32): AddonRating;
function GetAddonUserRating(index: AddonIndex_t): AddonRating;

/** Sets the user rating for the given addon */
function SetAddonUserRating(index: uint32, rating: AddonRating): void;
function SetAddonUserRating(index: AddonIndex_t, rating: AddonRating): void;

/** Enables or disables a set of addons in one fell swoop. Use this if you're planning to enable/disable multiple at once */
function SetAddonListEnabled(addons: Record<int32, boolean>): void;
function SetAddonListEnabled(addons: Record<AddonIndex_t, boolean>): void;

/** Returns the content path of an addon at the specified index. */
function GetAddonNamedPath(index: number): string;
function GetAddonNamedPath(index: AddonIndex_t): string;

/** Launched the game from Hammer or using the -workshop_tools launch option */
function IsWorkshopToolsMode(): string;

/****** Below here are @TODO items!! *******/

/** Returns the index of the addon that owns the specified map, or null if the map is not owned by an addon. */
function GetAddonByMap(mapname: string): number|null;

/** Returns the metadata of the maps for the addon at the specified index. */
function GetAddonChapters(index: uint32): AddonChapterMeta[];
function IsWorkshopToolsMode(): boolean;

/** Returns the download state of the addon at the specified index. */
function GetAddonState(index: uint32): DownloadState;
function GetAddonDependencies(index: AddonIndex_t): Array<AddonIndex_t> | null;
function GetAddonDependenciesMissing(index: AddonIndex_t): Array<PublishedFileId_t> | null;
function CreateQueryUGCDetailsRequest(callback: (success: boolean, data: Array<SteamUGCDetails_t> | null) => void, workshopIds: Array<PublishedFileId_t>): boolean;
function GetActiveMountList(): Array<AddonIndex_t>;
}

interface GlobalEventNameMap {
/** Fires when the installation state of an addon is updated. */
'WorkshopAddonStateUpdated': (index: uint32, state: DownloadState) => void,
'PanoramaComponent_Workshop_OnAddonInstalled': (index: AddonIndex_t) => void,
}
2 changes: 1 addition & 1 deletion shared/events.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ interface GlobalEventNameMap {
'MapLoaded': (mapName: string, isBackgroundMap: boolean) => void,
'MapUnloaded': () => void,
'Cancelled': (sourceID: string, source: PanelEventSource) => void,
'PopulateLoadingScreen': (mapName: string) => void,
'PopulateLoadingScreen': (mapName: string, mapGroup: string) => void,
'ApplyVideoSettings': () => void,
'VideoSettingsInit': () => void,
'VideoSettingsResetDefault': () => void,
Expand Down
6 changes: 6 additions & 0 deletions shared/panels.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,12 @@ declare interface Label extends AbstractPanel<'Label'> {
SetLocalizationString(text: string): void;

SetProceduralTextThatIPromiseIsLocalizedAndEscaped(text: string, allowDialogVariables: boolean): void;

/**
* Approximates the height this label would have
* if the passed in text was set, given a pre-determined width.
*/
GetHeightForText(width: number, text: string): number;
}

declare interface Movie extends AbstractPanel<'Movie'> {
Expand Down