From 24bfcb2e3c7ac176ac366b81c9a579181ebc9c83 Mon Sep 17 00:00:00 2001 From: Citrinate Date: Sat, 11 Jan 2025 22:18:13 -0500 Subject: [PATCH] Add additional file contents APIs --- CS2Interface/GameData/GameDataDicationary.cs | 2 +- CS2Interface/GameData/GameDataText.cs | 7 ++- .../IPC/Api/CS2InterfaceController.cs | 36 ++++++++++++++ .../IPC/Documentation/Data/CsgoEnglishTxt.md | 42 +++++++++++++++++ .../IPC/Documentation/Data/ItemsGameCdnTxt.md | 42 +++++++++++++++++ .../IPC/Documentation/Data/SteamInf.md | 47 +++++++++++++++++++ .../Documentation/Items/GetCrateContents.md | 2 +- .../IPC/Documentation/Items/InspectItem.md | 2 +- .../IPC/Documentation/Items/Inventory.md | 2 +- README.md | 5 +- 10 files changed, 178 insertions(+), 9 deletions(-) create mode 100644 CS2Interface/IPC/Documentation/Data/CsgoEnglishTxt.md create mode 100644 CS2Interface/IPC/Documentation/Data/ItemsGameCdnTxt.md create mode 100644 CS2Interface/IPC/Documentation/Data/SteamInf.md diff --git a/CS2Interface/GameData/GameDataDicationary.cs b/CS2Interface/GameData/GameDataDicationary.cs index 9cc4dee..513a0c8 100644 --- a/CS2Interface/GameData/GameDataDicationary.cs +++ b/CS2Interface/GameData/GameDataDicationary.cs @@ -6,7 +6,7 @@ namespace CS2Interface { internal class GameDataDictionary : GameDataResource { - private Dictionary? Data; + internal Dictionary? Data {get; private set;} internal GameDataDictionary(string url) : base(url) {} diff --git a/CS2Interface/GameData/GameDataText.cs b/CS2Interface/GameData/GameDataText.cs index 191868d..2f9b576 100644 --- a/CS2Interface/GameData/GameDataText.cs +++ b/CS2Interface/GameData/GameDataText.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -9,7 +8,7 @@ namespace CS2Interface { internal class GameDataText : GameDataResource { - private List? Data; + internal KeyValue? Data {get; private set;} internal GameDataText(string url) : base(url) {} @@ -21,7 +20,7 @@ internal override async Task Update() { return false; } - Data = data.Children.Where(x => x.Name == "Tokens").SelectMany(x => x.Children).ToList(); + Data = data["Tokens"]; Updated = true; return true; @@ -33,7 +32,7 @@ internal string? this[string? key] { return null; } - return Data.Where(x => x.Name?.ToUpper().Trim() == key.ToUpper().Trim()).FirstOrDefault()?.Value; + return Data.Children.Where(x => x.Name?.ToUpper().Trim() == key.ToUpper().Trim()).FirstOrDefault()?.Value; } } diff --git a/CS2Interface/IPC/Api/CS2InterfaceController.cs b/CS2Interface/IPC/Api/CS2InterfaceController.cs index dc802d0..3f5b87c 100644 --- a/CS2Interface/IPC/Api/CS2InterfaceController.cs +++ b/CS2Interface/IPC/Api/CS2InterfaceController.cs @@ -360,6 +360,42 @@ public async Task> ItemsGame() { return Ok(new GenericResponse(true, new GameDataKV(GameData.ItemsGame.Data))); } + [HttpGet("items_game_cdn.txt")] + [EndpointSummary("Get the contents of items_game_cdn.txt")] + [ProducesResponseType(typeof(GenericResponse>>), (int) HttpStatusCode.OK)] + [ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] + public async Task> ItemsGameCDN() { + if (!await GameData.IsLoaded(update: false).ConfigureAwait(false) || GameData.ItemsGameCdn.Data == null) { + return BadRequest(new GenericResponse(false, Strings.GameDataLoadingFailed)); + } + + return Ok(new GenericResponse>>(true, new GameData>(GameData.ItemsGameCdn.Data))); + } + + [HttpGet("csgo_english.txt")] + [EndpointSummary("Get the contents of csgo_english.txt")] + [ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] + [ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] + public async Task> CSGOEnglish() { + if (!await GameData.IsLoaded(update: false).ConfigureAwait(false) || GameData.CsgoEnglish.Data == null) { + return BadRequest(new GenericResponse(false, Strings.GameDataLoadingFailed)); + } + + return Ok(new GenericResponse(true, new GameDataKV(GameData.CsgoEnglish.Data))); + } + + [HttpGet("steam.inf")] + [EndpointSummary("Get the contents of steam.inf")] + [ProducesResponseType(typeof(GenericResponse>>), (int) HttpStatusCode.OK)] + [ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] + public async Task> SteamINF() { + if (!await GameData.IsLoaded(update: false).ConfigureAwait(false) || GameData.GameVersion.Data == null) { + return BadRequest(new GenericResponse(false, Strings.GameDataLoadingFailed)); + } + + return Ok(new GenericResponse>>(true, new GameData>(GameData.GameVersion.Data))); + } + private async Task> HandleClientException(Bot bot, ClientException e) { bot.ArchiLogger.LogGenericError(e.Message); if (e.Type == EClientExceptionType.Timeout) { diff --git a/CS2Interface/IPC/Documentation/Data/CsgoEnglishTxt.md b/CS2Interface/IPC/Documentation/Data/CsgoEnglishTxt.md new file mode 100644 index 0000000..04386a7 --- /dev/null +++ b/CS2Interface/IPC/Documentation/Data/CsgoEnglishTxt.md @@ -0,0 +1,42 @@ +# GET /Api/CS2Interface/csgo_english.txt + +## Description + +Get the contents of the CS2 game file: [`resource/csgo_english.txt`](https://raw.githubusercontent.com/SteamDatabase/GameTracking-CS2/master/game/csgo/pak01_dir/resource/csgo_english.txt) + +## Path Parameters + +None + +## Query Parameters + +None + +## Response Result + +Property | Type | Description +--- | --- | --- +`ClientVersion` | `uint` | The version of CS2 that this data comes from +`Data` | `object` | The contents of `resource/csgo_english.txt` + +## Example Response + +``` +http://127.0.0.1:1242/Api/CS2Interface/csgo_english.txt +``` + +```javascript +{ + "Message": "OK", + "Success": true, + "Result": { + "ClientVersion": 2000468, + "Data": { + "GameUI_MainMenuMovieScene": "Main Menu Background Scenery", + "GameUI_MainMenuMovieScene_Vanity": "Change Background Scenery", + "GameUI_MainMenuMovieScene_Tooltip": "This setting allows you to customize the main menu background scenery which sets the mood for visual experience of your entire game.", + //... + } + } +} +``` diff --git a/CS2Interface/IPC/Documentation/Data/ItemsGameCdnTxt.md b/CS2Interface/IPC/Documentation/Data/ItemsGameCdnTxt.md new file mode 100644 index 0000000..e0dd366 --- /dev/null +++ b/CS2Interface/IPC/Documentation/Data/ItemsGameCdnTxt.md @@ -0,0 +1,42 @@ +# GET /Api/CS2Interface/items_game_cdn.txt + +## Description + +Get the contents of the CS2 game file: [`scripts/items/items_game_cdn.txt`](https://raw.githubusercontent.com/SteamDatabase/GameTracking-CS2/master/game/csgo/pak01_dir/scripts/items/items_game_cdn.txt) + +## Path Parameters + +None + +## Query Parameters + +None + +## Response Result + +Property | Type | Description +--- | --- | --- +`ClientVersion` | `uint` | The version of CS2 that this data comes from +`Data` | `object` | The contents of `scripts/items/items_game_cdn.txt` + +## Example Response + +``` +http://127.0.0.1:1242/Api/CS2Interface/items_game_cdn.txt +``` + +```javascript +{ + "Message": "OK", + "Success": true, + "Result": { + "ClientVersion": 2000468, + "Data": { + "leather_handwraps_handwrap_camo_grey": "http://media.steampowered.com/apps/730/icons/econ/default_generated/leather_handwraps_handwrap_camo_grey_light_large.04557b1a8d68bccdd60b18521346091328756ded.png", + "leather_handwraps_handwrap_fabric_houndstooth_orange": "http://media.steampowered.com/apps/730/icons/econ/default_generated/leather_handwraps_handwrap_fabric_houndstooth_orange_light_large.08248935a70031a18cb246f3e3ac2bc0d8d66339.png", + "leather_handwraps_handwrap_fabric_orange_camo": "http://media.steampowered.com/apps/730/icons/econ/default_generated/leather_handwraps_handwrap_fabric_orange_camo_light_large.f8453c60f74a846bd3c05310de4f004cd95a1aa2.png", + //... + } + } +} +``` diff --git a/CS2Interface/IPC/Documentation/Data/SteamInf.md b/CS2Interface/IPC/Documentation/Data/SteamInf.md new file mode 100644 index 0000000..5854f0a --- /dev/null +++ b/CS2Interface/IPC/Documentation/Data/SteamInf.md @@ -0,0 +1,47 @@ +# GET /Api/CS2Interface/steam.inf + +## Description + +Get the contents of the CS2 game file: [`game/csgo/steam.inf`](https://raw.githubusercontent.com/SteamDatabase/GameTracking-CS2/master/game/csgo/steam.inf) + +## Path Parameters + +None + +## Query Parameters + +None + +## Response Result + +Property | Type | Description +--- | --- | --- +`ClientVersion` | `uint` | The version of CS2 that this data comes from +`Data` | `object` | The contents of `game/csgo/steam.inf` + +## Example Response + +``` +http://127.0.0.1:1242/Api/CS2Interface/steam.inf +``` + +```json +{ + "Message": "OK", + "Success": true, + "Result": { + "ClientVersion": 2000468, + "Data": { + "ClientVersion": "2000468", + "ServerVersion": "2000468", + "PatchVersion": "1.40.5.9", + "ProductName": "cs2", + "appID": "730", + "ServerAppID": "2347773", + "SourceRevision": "9449802", + "VersionDate": "Jan 09 2025", + "VersionTime": "16:42:11" + } + } +} +``` diff --git a/CS2Interface/IPC/Documentation/Items/GetCrateContents.md b/CS2Interface/IPC/Documentation/Items/GetCrateContents.md index edfbbd9..1a60f4b 100644 --- a/CS2Interface/IPC/Documentation/Items/GetCrateContents.md +++ b/CS2Interface/IPC/Documentation/Items/GetCrateContents.md @@ -38,7 +38,7 @@ Property | Type | Description `item_name` | `string` | The item's name `tool_name` | `string` | What type of tool this is (usually the same as `type_name`, except for Sealed Graffiti) `tint_name` | `string` | The item's tint -`weapon_image_url` | `string` | An image of the item (if one exists in [items_game_cdn.txt](/CS2Interface/IPC/Documentation/Data/ItemsGameTxt.md)) +`weapon_image_url` | `string` | An image of the item (if one exists in [items_game_cdn.txt](/CS2Interface/IPC/Documentation/Data/ItemsGameCdnTxt.md)) `weapon_name` | `string` | The weapon this applies to `wear_name` | `string` | The name for the float range this item falls into `wear` | `float` | The item's float value diff --git a/CS2Interface/IPC/Documentation/Items/InspectItem.md b/CS2Interface/IPC/Documentation/Items/InspectItem.md index d076575..1bb9478 100644 --- a/CS2Interface/IPC/Documentation/Items/InspectItem.md +++ b/CS2Interface/IPC/Documentation/Items/InspectItem.md @@ -39,7 +39,7 @@ Property | Type | Description `item_name` | `string` | The item's name `tool_name` | `string` | What type of tool this is (usually the same as `type_name`, except for Sealed Graffiti) `tint_name` | `string` | The item's tint -`weapon_image_url` | `string` | An image of the item (if one exists in [items_game_cdn.txt](/CS2Interface/IPC/Documentation/Data/ItemsGameTxt.md)) +`weapon_image_url` | `string` | An image of the item (if one exists in [items_game_cdn.txt](/CS2Interface/IPC/Documentation/Data/ItemsGameCdnTxt.md)) `weapon_name` | `string` | The weapon this applies to `wear_name` | `string` | The name for the float range this item falls into `wear` | `float` | The item's float value diff --git a/CS2Interface/IPC/Documentation/Items/Inventory.md b/CS2Interface/IPC/Documentation/Items/Inventory.md index be0fde5..bc662f8 100644 --- a/CS2Interface/IPC/Documentation/Items/Inventory.md +++ b/CS2Interface/IPC/Documentation/Items/Inventory.md @@ -36,7 +36,7 @@ Property | Type | Description `item_name` | `string` | The item's name `tool_name` | `string` | What type of tool this is (usually the same as `type_name`, except for Sealed Graffiti) `tint_name` | `string` | The item's tint -`weapon_image_url` | `string` | An image of the item (if one exists in [items_game_cdn.txt](/CS2Interface/IPC/Documentation/Data/ItemsGameTxt.md)) +`weapon_image_url` | `string` | An image of the item (if one exists in [items_game_cdn.txt](/CS2Interface/IPC/Documentation/Data/ItemsGameCdnTxt.md)) `weapon_name` | `string` | The weapon this applies to `wear_name` | `string` | The name for the float range this item falls into `wear` | `float` | The item's float value diff --git a/README.md b/README.md index b4b069e..508669f 100644 --- a/README.md +++ b/README.md @@ -85,4 +85,7 @@ API | Method | Parameters | Description API | Method | Parameters | Description --- | --- | --- | --- [`/Api/CS2Interface/Recipes`](/CS2Interface/IPC/Documentation/Data/Recipes.md)|`GET`|`showDefs`|Get a list of crafting recipes -[`/Api/CS2Interface/items_game.txt`](/CS2Interface/IPC/Documentation/Data/ItemsGameTxt.md)|`GET`| |Get the contents of items_game.txt +[`/Api/CS2Interface/items_game.txt`](/CS2Interface/IPC/Documentation/Data/ItemsGameTxt.md)|`GET`| |Get the contents of `items_game.txt` +[`/Api/CS2Interface/items_game_cdn.txt`](/CS2Interface/IPC/Documentation/Data/ItemsGameCdnTxt.md)|`GET`| |Get the contents of `items_game_cdn.txt` +[`/Api/CS2Interface/csgo_english.txt`](/CS2Interface/IPC/Documentation/Data/CsgoEnglishTxt.md)|`GET`| |Get the contents of `csgo_english.txt` +[`/Api/CS2Interface/steam.inf`](/CS2Interface/IPC/Documentation/Data/SteamInf.md)|`GET`| |Get the contents of `steam.inf`