diff --git a/p2ce/campaign.d.ts b/p2ce/campaign.d.ts new file mode 100644 index 0000000..98cbbb2 --- /dev/null +++ b/p2ce/campaign.d.ts @@ -0,0 +1,63 @@ +/** + * @packageDocumentation + * P2:CE Campaign API. + */ + +interface ChapterMap { + name: string; + + meta: Map; +} + +interface ChapterInfo { + id: string; + title: string; + maps: ChapterMap[]; + + meta: Map; +} + +interface CampaignInfo { + id: string; + title: string; + chapters: ChapterInfo[]; + + meta: Map; +} + +// Holds multiple campaigns +interface CampaignBucket { + id: string; + addon_id: number; // Workshop Addon ID or -1 if not present + campaigns: CampaignInfo[]; + + meta: Map; +} + +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; + + 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; +} diff --git a/p2ce/caption.d.ts b/p2ce/caption.d.ts new file mode 100644 index 0000000..281d2bf --- /dev/null +++ b/p2ce/caption.d.ts @@ -0,0 +1,21 @@ +/** + * @packageDocumentation + * Captioning Interface + */ + +interface Caption { + bLowPriority: boolean; + bSFX: boolean; + nNoRepeat: number; + nDelay: number; + flLifetimeOverride: number; + text: string; + options: Map; +} + +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; +} diff --git a/p2ce/workshop.d.ts b/p2ce/workshop.d.ts index c011f60..e80c5bd 100644 --- a/p2ce/workshop.d.ts +++ b/p2ce/workshop.d.ts @@ -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): 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. */ diff --git a/shared/panels.d.ts b/shared/panels.d.ts index dbff07c..f760da1 100644 --- a/shared/panels.d.ts +++ b/shared/panels.d.ts @@ -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'> {