From 31dcb70f8b031986f02bdb40780fd26e78937ef4 Mon Sep 17 00:00:00 2001 From: iamsirenstorm <120330118+iamsirenstorm@users.noreply.github.com> Date: Mon, 4 May 2026 21:13:15 -0500 Subject: [PATCH] feat: melt SaveRestoreAPI and GameSavesAPI --- p2ce/events.d.ts | 12 +++++++++--- p2ce/gamesaves.d.ts | 8 +++++++- p2ce/saverestore.d.ts | 38 -------------------------------------- 3 files changed, 16 insertions(+), 42 deletions(-) delete mode 100644 p2ce/saverestore.d.ts diff --git a/p2ce/events.d.ts b/p2ce/events.d.ts index de26bfe..ba020cc 100644 --- a/p2ce/events.d.ts +++ b/p2ce/events.d.ts @@ -3,7 +3,13 @@ */ interface GlobalEventNameMap { - AchievementInfoLoaded: () => void; - AchievementEarned: (player_index: number, achievement_index: number) => void; - GameSaved: (save_name: string, save_type: SaveType) => void, + AchievementInfoLoaded: () => void; + AchievementEarned: (player_index: number, achievement_index: number) => void; + OnSaveMapVersionMismatch: (mapName: string) => void; + OnSaveBegin: (saveName: string) => void; + OnAutoSaveBegin: (saveName: string) => void; + OnAutoSaveDangerousBegin: (saveName: string) => void; + OnSaveBlocked: (saveName: string) => void; + OnSaveFinished: (saveName: string) => void; + OnAutoSaveDangerousMarkedSafe: () => void; } diff --git a/p2ce/gamesaves.d.ts b/p2ce/gamesaves.d.ts index d74de81..8a24a84 100644 --- a/p2ce/gamesaves.d.ts +++ b/p2ce/gamesaves.d.ts @@ -1,4 +1,5 @@ interface GameSave { + name: string; // Name of this save, used to load, delete, or otherwise refer to this save chapter: number; // Chapter this save belongs to under P2:CE's Campaign API comment: string; elapsedSeconds: number; @@ -10,12 +11,17 @@ interface GameSave { isSavedInCloud: boolean; mapGroup: string; // Campaign ID this save belongs to under P2:CE's Campaign API mapName: string; // Map this save was created on - screenshotFileName: string; // Full path from the base game directory to the .sav file + screenshotFileName: string; // Full path from the base game directory to the .tga file + screenshotPath: string; // Panorama path to the screenshot file } declare namespace GameSavesAPI { function GetGameSaves(): Array; + function GetGameSave(name: string): GameSave | null; function CreateSaveGame(): void; + function CreateNamedSave(name: string): void; + function LoadSaveGame(name: string): void; + function DeleteSaveGame(name: string): void; function IsSaveInProgress(): boolean; function IsAutosaveInProgress(): boolean; } diff --git a/p2ce/saverestore.d.ts b/p2ce/saverestore.d.ts deleted file mode 100644 index ae9b030..0000000 --- a/p2ce/saverestore.d.ts +++ /dev/null @@ -1,38 +0,0 @@ - -/** - * Defines the save type, used with 'GameSaved' event in the 'type' parameter - */ -declare const enum SaveType { - Manual = 0, /** User saved with custom filename */ - Autosave, /** Game saved progress automatically */ - Quicksave, /** User saved using the quicksave key */ -} - -interface Save { - name: string; - thumb: string; - time: number; -} - -declare namespace SaveRestoreAPI { - /** Returns an array of save games */ - function GetSaves(): Array; - - /** - * Saves the game - * @param name Name of the save or null to generate one based on the current time - */ - function SaveGame(name: string|null): void; - - /** - * Deletes a save - * @param name Name of the save to delete - */ - function DeleteSave(name: string): void; - - /** - * Loads a save game - * @param name Name of the save. Allowed characters: A-z 0-9 _ - - */ - function LoadSave(name: string): void; -}