Skip to content
63 changes: 63 additions & 0 deletions p2ce/campaign.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* @packageDocumentation
* P2:CE Campaign API.
*/

interface ChapterMap {
name: string;

meta: Map<string, string>;
}

interface ChapterInfo {
id: string;
title: string;
maps: ChapterMap[];

meta: Map<string, string>;
}

interface CampaignInfo {
id: string;
title: string;
chapters: ChapterInfo[];

meta: Map<string, string>;
}

// Holds multiple campaigns
interface CampaignBucket {
id: string;
addon_id: number; // Workshop Addon ID or -1 if not present
campaigns: CampaignInfo[];

meta: Map<string, string>;
}

interface CampaignPair
{
bucket: CampaignBucket;
campaign: CampaignInfo;
}

/** [API not finalized] The Campaign API. Exclusive to P2:CE! */
declare namespace CampaignAPI {
function ReloadCampaigns();

function GetAllCampaignBuckets(): CampaignBucket[];
function GetActiveCampaign(): CampaignPair|null;
function IsCampaignActive(): boolean;
function FindCampaign(campaign: string): CampaignPair|null;

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

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;
}

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

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

interface GlobalEventNameMap {
BadCaptionRequest: (token: string, lifetime: number) => void;
DisplayCaptionRequest: (token: string, caption: Caption, lifetime: number) => void;
DisplayRawCaptionRequest: (text: string, lifetime: number) => void;
CaptionTick: (time: number) => void;
}
3 changes: 3 additions & 0 deletions p2ce/workshop.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ declare namespace WorkshopAPI {
/** 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;

/** Returns the content path of an addon at the specified index. */
function GetAddonNamedPath(index: number): 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. */
Expand Down
6 changes: 6 additions & 0 deletions shared/panels.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,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