Skip to content

Commit

Permalink
Add additional file contents APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed Jan 12, 2025
1 parent 43620de commit 24bfcb2
Show file tree
Hide file tree
Showing 10 changed files with 178 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CS2Interface/GameData/GameDataDicationary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace CS2Interface {
internal class GameDataDictionary : GameDataResource {
private Dictionary<string, string>? Data;
internal Dictionary<string, string>? Data {get; private set;}

internal GameDataDictionary(string url) : base(url) {}

Expand Down
7 changes: 3 additions & 4 deletions CS2Interface/GameData/GameDataText.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -9,7 +8,7 @@

namespace CS2Interface {
internal class GameDataText : GameDataResource {
private List<KeyValue>? Data;
internal KeyValue? Data {get; private set;}

internal GameDataText(string url) : base(url) {}

Expand All @@ -21,7 +20,7 @@ internal override async Task<bool> Update() {
return false;
}

Data = data.Children.Where(x => x.Name == "Tokens").SelectMany(x => x.Children).ToList();
Data = data["Tokens"];
Updated = true;

return true;
Expand All @@ -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;
}
}

Expand Down
36 changes: 36 additions & 0 deletions CS2Interface/IPC/Api/CS2InterfaceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,42 @@ public async Task<ActionResult<GenericResponse>> ItemsGame() {
return Ok(new GenericResponse<GameDataKV>(true, new GameDataKV(GameData.ItemsGame.Data)));
}

[HttpGet("items_game_cdn.txt")]
[EndpointSummary("Get the contents of items_game_cdn.txt")]
[ProducesResponseType(typeof(GenericResponse<GameData<Dictionary<string, string>>>), (int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> ItemsGameCDN() {
if (!await GameData.IsLoaded(update: false).ConfigureAwait(false) || GameData.ItemsGameCdn.Data == null) {
return BadRequest(new GenericResponse(false, Strings.GameDataLoadingFailed));
}

return Ok(new GenericResponse<GameData<Dictionary<string, string>>>(true, new GameData<Dictionary<string, string>>(GameData.ItemsGameCdn.Data)));
}

[HttpGet("csgo_english.txt")]
[EndpointSummary("Get the contents of csgo_english.txt")]
[ProducesResponseType(typeof(GenericResponse<GameDataKV>), (int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> CSGOEnglish() {
if (!await GameData.IsLoaded(update: false).ConfigureAwait(false) || GameData.CsgoEnglish.Data == null) {
return BadRequest(new GenericResponse(false, Strings.GameDataLoadingFailed));
}

return Ok(new GenericResponse<GameDataKV>(true, new GameDataKV(GameData.CsgoEnglish.Data)));
}

[HttpGet("steam.inf")]
[EndpointSummary("Get the contents of steam.inf")]
[ProducesResponseType(typeof(GenericResponse<GameData<Dictionary<string, string>>>), (int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> SteamINF() {
if (!await GameData.IsLoaded(update: false).ConfigureAwait(false) || GameData.GameVersion.Data == null) {
return BadRequest(new GenericResponse(false, Strings.GameDataLoadingFailed));
}

return Ok(new GenericResponse<GameData<Dictionary<string, string>>>(true, new GameData<Dictionary<string, string>>(GameData.GameVersion.Data)));
}

private async Task<ActionResult<GenericResponse>> HandleClientException(Bot bot, ClientException e) {
bot.ArchiLogger.LogGenericError(e.Message);
if (e.Type == EClientExceptionType.Timeout) {
Expand Down
42 changes: 42 additions & 0 deletions CS2Interface/IPC/Documentation/Data/CsgoEnglishTxt.md
Original file line number Diff line number Diff line change
@@ -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.",
//...
}
}
}
```
42 changes: 42 additions & 0 deletions CS2Interface/IPC/Documentation/Data/ItemsGameCdnTxt.md
Original file line number Diff line number Diff line change
@@ -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",
//...
}
}
}
```
47 changes: 47 additions & 0 deletions CS2Interface/IPC/Documentation/Data/SteamInf.md
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
```
2 changes: 1 addition & 1 deletion CS2Interface/IPC/Documentation/Items/GetCrateContents.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CS2Interface/IPC/Documentation/Items/InspectItem.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CS2Interface/IPC/Documentation/Items/Inventory.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

0 comments on commit 24bfcb2

Please sign in to comment.