2024-02-15 13:42:39 +00:00
/ * *
* The supports action tells galaxy what parts of the API you interact with , and hides / shows certain elements of the player accordingly .
* /
interface SupportsAction {
action : "supports" ;
/** If your game auto-saves or allows the user to make/load game saves from within the UI. */
saving : boolean ;
/** If your game has a complete save manager integrated into it — save deletion, export, import, labels, all save slots, etc. */
save_manager : boolean ;
}
/ * *
2024-02-15 13:43:51 +00:00
* The save_list action sends a retrieval request to Galaxy to get the player ' s cloud save list which contains all the save data the player has . The actual save data then will be retrieved through the save_list response .
2024-02-15 13:42:39 +00:00
* @see { @link SaveListResponse }
* /
interface SaveListAction {
action : "save_list" ;
}
/ * *
* The save action creates a cloud save and then puts it into a certain save slot . If a save is already present in that slot , the old save will be overridden . The save result can be determined through the returning saved response .
* @see { @link SavedResponse }
* /
interface SaveAction {
action : "save" ;
/** The save slot number. Must be an integer between 0 and 10, inclusive. */
slot : number ;
2024-02-15 13:43:51 +00:00
/** The optional label of the save file. It is recommended for this to be a quick summary of the player's current progress (e.g. e1,000 points, Stage 64-25, Arcana level 308). Must be 100 characters in length or fewer. */
2024-02-15 13:42:39 +00:00
label? : string ;
/** The actual save data. Must be 256,000 characters in length or fewer. */
data : string ;
}
/ * *
*
The load action sends a retrieval request to Galaxy to get the cloud save data inside a certain save slot . The actual save data will then be retrieved through the save_content response .
* @see { @link SaveContentResponse }
* /
interface LoadAction {
action : "load" ;
/** The save slot number. Must be an integer between 0 and 10, inclusive. */
slot : number ;
}
/ * *
* The info response is first sent when the page loads , and may be sent multiple times after page load if any of the values inside change .
* /
interface InfoResponse {
type : "info" ;
2024-02-15 13:43:51 +00:00
/** Whether you're talking to Galaxy. This should always be true. */
2024-02-15 13:42:39 +00:00
galaxy : boolean ;
/** The version of the API. Will only increment for every breaking API change. It is not a bad idea to disable your implementation if this does not match. */
api_version : number ;
2024-02-15 13:43:51 +00:00
/** The player's theme preference. Valid values are none, light, and dark. Use this to determine the color scheme of your game on the first startup. */
2024-02-15 13:42:39 +00:00
theme_preference : string ;
/** Whether the player is logged in. Certain features (like cloud saving) require the player to be logged into a Galaxy account in order to work. */
logged_in : boolean ;
}
/ * *
* The save_list response is requested by the save_list action and contains the requested list of save data .
* @see { @link SaveListAction }
* /
interface SaveListResponse {
type : "save_list" ;
/** A list of saves. Each key in the object is the save slot number / save ID. Will be an empty object ({}) when {@link error} is true. */
list : Record < number , {
/** The label describing the save. */
label : string ;
/** The content of the save. */
content : string ;
} > ;
/** Whether the action encountered an error. */
error : boolean ;
/ * *
* Present when error is true , tells the reason why the action encountered an error .
* Valid values are :
* - "no_account" : The player was logged out .
2024-02-15 13:43:51 +00:00
* - "server_error" : The game couldn 't connect to Galaxy' s servers .
2024-02-15 13:42:39 +00:00
* /
message ? : "no_account" | "server_error" ;
}
/ * *
2024-02-15 13:43:51 +00:00
* The save_content response is requested by the load action and contains information about the action ' s load request along with the requested save data .
2024-02-15 13:42:39 +00:00
* @see { @link LoadAction }
* /
interface SaveContentResponse {
type : "save_content" ;
/** Whether the action encountered an error. */
error : boolean ;
/ * *
* Present when error is true , tells the reason why the action encountered an error .
* Valid values are :
* - "no_account" : The player was logged out .
* - "empty_slot" : The save slot is empty .
* - "invalid_slot" : The slot value was invalid .
2024-02-15 13:43:51 +00:00
* - "server_error" : The game couldn 't connect to Galaxy' s servers .
2024-02-15 13:42:39 +00:00
* /
message ? : "no_account" | "empty_slot" | "invalid_slot" | "server_error" ;
/** The save slot number. */
slot : number ;
2024-02-15 13:43:51 +00:00
/** The save's label, or null if error is true. */
2024-02-15 13:42:39 +00:00
label? : string ;
2024-02-15 13:43:51 +00:00
/** The save's actual data, or null if error is true. */
2024-02-15 13:42:39 +00:00
content? : string ;
}
/ * *
2024-02-15 13:43:51 +00:00
* The saved response is requested by the save action and contains information about the action ' s save request .
2024-02-15 13:42:39 +00:00
* @see { @link SaveAction }
* /
interface SavedResponse {
type : "saved" ;
/** Whether the action encountered an error. */
error : boolean ;
/** The save slot number. */
slot : number ;
/ * *
* Present when error is true , tells the reason why the action encountered an error .
* Valid values are :
* - "too_big" : The save data exceeded the 256 , 000 character limit
* - "no_account" : The player was logged out .
* - "invalid_slot" : The slot value was invalid .
2024-02-15 13:43:51 +00:00
* - "server_error" : The game couldn 't connect to Galaxy' s servers .
2024-02-15 13:42:39 +00:00
* /
message ? : "no_account" | "empty_slot" | "invalid_slot" | "server_error" ;
}
type GalaxyResponse = InfoResponse | SaveListResponse | SaveContentResponse | SavedResponse ;