Compacted JSON loader to a single file.

Started populating a skin list.
This commit is contained in:
Matthew Neumann 2025-03-07 16:36:20 -08:00
parent 211821d673
commit fe9b0b2c2a
6 changed files with 236 additions and 45 deletions

View File

@ -13,6 +13,7 @@
<ItemGroup>
<None Remove="beltitems.json" />
<None Remove="skins.json" />
<None Remove="weaponmoditems.json" />
<None Remove="wearitems.json" />
</ItemGroup>
@ -24,6 +25,9 @@
<Content Include="beltitems.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="skins.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="weaponmoditems.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

View File

@ -15,12 +15,17 @@ namespace Better_NCP_Editor
private bool fileModified = false;
private ToolTips toolTips = new ToolTips();
// In your Form1 class:
private ToolTip customToolTip = new ToolTip();
private TreeNode lastHoveredNode = null;
// Lists for item dropdowns
private List<String> _wearItems;
private List<String> _beltItems;
private List<String> _weaponModItems;
private Dictionary<String, Dictionary<String,UInt64>> _itemShortnameToSkinName;
// All items dictionary.
private Dictionary<String, String> _allItems;
public Form1()
@ -64,6 +69,7 @@ namespace Better_NCP_Editor
_allItems = LoadItemDatabase("allitems.json");
_beltItems = LoadItemList("beltitems.json");
_weaponModItems = LoadItemList("weaponmoditems.json");
_itemShortnameToSkinName = LoadSkinDict("skins.json");
}
@ -95,6 +101,19 @@ namespace Better_NCP_Editor
}
}
private Dictionary<String,Dictionary<String, UInt64>> LoadSkinDict(String filepath)
{
try
{
return JsonDictionaryLoader.LoadSkinDict(filepath);
}
catch (Exception ex)
{
Console.WriteLine("Error loading JSON file: " + ex.Message);
return null;
}
}
private void EntityTreeView_MouseMove(object sender, MouseEventArgs e)
{
int xOffset = 15;

View File

@ -1,22 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace Better_NCP_Editor
{
public static class JsonDictionaryLoader
{
public static Dictionary<string, string> Load(string filePath)
{
if (!File.Exists(filePath))
throw new FileNotFoundException("The specified JSON file was not found.", filePath);
string json = File.ReadAllText(filePath);
Dictionary<string, string> dictionary = JsonSerializer.Deserialize<Dictionary<string, string>>(json);
return dictionary;
}
}
}

View File

@ -1,22 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace Better_NCP_Editor
{
public static class JsonListLoader
{
public static List<string> Load(string filePath)
{
if (!File.Exists(filePath))
throw new FileNotFoundException("The specified JSON file was not found.", filePath);
string json = File.ReadAllText(filePath);
List<string> list = JsonSerializer.Deserialize<List<string>>(json);
return list;
}
}
}

View File

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace Better_NCP_Editor
{
public static class JsonDictionaryLoader
{
public static Dictionary<string, string> Load(string filePath)
{
if (!File.Exists(filePath))
throw new FileNotFoundException("The specified JSON file was not found.", filePath);
string json = File.ReadAllText(filePath);
Dictionary<string, string> dictionary = JsonSerializer.Deserialize<Dictionary<string, string>>(json);
return dictionary;
}
public static Dictionary<String,Dictionary<String,UInt64>> LoadSkinDict(string filePath)
{
if (!File.Exists(filePath))
throw new FileNotFoundException("The specified JSON file was not found.", filePath);
string json = File.ReadAllText(filePath);
Dictionary<String, Dictionary<String, UInt64>> dictionary = JsonSerializer.Deserialize<Dictionary<String, Dictionary<String, UInt64>>>(json);
return dictionary;
}
}
public static class JsonListLoader
{
public static List<string> Load(string filePath)
{
if (!File.Exists(filePath))
throw new FileNotFoundException("The specified JSON file was not found.", filePath);
string json = File.ReadAllText(filePath);
List<string> list = JsonSerializer.Deserialize<List<string>>(json);
return list;
}
}
}

View File

@ -0,0 +1,166 @@
{
"rifle.ak": {
"Agony Yellow": 849047662,
"Aircraft Parts AK47": 887494035,
"AK Royale": 1359893925,
"AK-47 From Hell": 1202410378,
"AK-47 Victoria": 1372945520,
"Alien Red": 859845460,
"Anubis Ak47": 1259716979,
"Apocalyptic Knight AK": 1826520371,
"Azul AK47": 1750654242,
"Basebreaker AR": 2249370680,
"Battle Scarred AK47": 809212871,
"Battle-Scarred AKS47": 809190373,
"Beast of Industry": 1435827815,
"Betty Lou AK47": 1112904406,
"Blackout AR": 2128372674,
"Brass Lion": 1385673487,
"BullDozer AK47": 1679665505,
"Candy Hunter AR": 2245084157,
"Capitan's AR": 2041629387,
"Cardboard AR": 2101560738,
"Cartagena AK47": 924020531,
"Caution AK47": 1349512142,
"Chained Spirits AR": 2248879512,
"Checkpoint AK47": 937864743,
"Chivalry AK47": 1196676446,
"Claw AK47": 875130056,
"Cobalt Security AR": 1915393587,
"Cobra": 1174389582,
"Cold Hunter AK": 1583542371,
"Conquerer AK47": 1102750231,
"Crimson King": 840477492,
"Crypt of Death AK47": 1306351416,
"Dark Flames": 885146172,
"Dead Pirate Rifle": 1137915903,
"Death in Spades AK47": 1245563496,
"Demonic AK47": 1349324364,
"Desert Hawk AK47": 1929819581,
"Diesel AK47": 1092674304,
"Digital Camo AK47": 615766181,
"Doodle AK47": 2017002938,
"Doombringer AK47": 920472848,
"Dreamland AR": 2075372682,
"Dynasty AK47": 1804885723,
"Epidemic AK47": 928950425,
"Etherya AK47": 1448221547,
"Evil Snowman AR": 2319710097,
"Farseer AK47": 939180121,
"Fate Destroyer": 940035827,
"Frost Wolf": 903882218,
"Gearlord AK47": 1476966011,
"Gingerbread AK": 1588206436,
"Glorious AK": 1167207039,
"Glory AK47": 889710179,
"Gold Rush AK": 1362212220,
"Golden Drake AK47": 1265322092,
"Green Dragon AK47": 1364985829,
"Heartbreaker AR": 1993279809,
"Hell's Dogs": 1599157678,
"Huntsman AK47": 1575397458,
"Jack O Lantern - AK47": 1886272847,
"Jaws AK47": 925720043,
"King of the Jungle AK47": 1272989639,
"Last Phoenix": 1434027951,
"Lonewolf AK47 - Blue": 908297014,
"Mandrill": 1213092632,
"Marrakesh": 1428980348,
"Memories AR": 1983066869,
"Midnight Dream": 1457951707,
"Military Camo AK47": 618543834,
"Monument Memories AR": 2085083014,
"Mystic AK47": 1338305091,
"Neanderthal AR": 2179386526,
"Night Howler AK47": 1118706219,
"Nightmare AK47": 1539318940,
"No Mercy AK47": 1760078043,
"Panther AK47": 1161844853,
"Phantom AK": 1522034435,
"Piranha AK47": 1120500163,
"Playmaker AK47": 1685375084,
"Polymer AK47": 1549426268,
"Porcelain AR": 2304993742,
"Poseidon - AK47": 1907342157,
"PulsAR": 2172715245,
"Punkish AK47": 1870705926,
"Rabble Rouser AK47": 911726740,
"Rainbow AR": 2012334520,
"Rainbow Pony AR": 2059352465,
"Raptor AR": 2108685486,
"Rebellion Assault Rifle": 1252554814,
"Retro Car Parts AK47": 895307805,
"Retrowave AR": 2268418002,
"REX": 1352844155,
"Royal AK47": 1746886322,
"Rumble AK47": 1288866247,
"Rustpunk AK47": 654502185,
"Sandstorm AK47": 934891737,
"Santa Muerte": 1175238674,
"Scarecrow AK47": 1539409946,
"Scorpion AK47": 1372566409,
"Scrapper AK47": 1277707212,
"Smolder": 1396630285,
"Soul Taker AK47": 1076214414,
"Sticker Pack AK47": 1882821847,
"Sunken Treasure AK": 1850236015,
"Sweet Poison AR": 2109182691,
"Talon AK47": 1230963555,
"T-Bone AK47": 1539007965,
"Tempered AK47": 566540646,
"The Beast AK47": 1088459232,
"The Beast Of The East": 1129886223,
"The Reptile": 1124932043,
"Toxic": 1467269924,
"Training AR": 2006878490,
"Troll Daddy AK": 1659781652,
"Trophy Pirate AK47": 1402320927,
"Trust In Rust 3 AR": 2323019876,
"Underworld AR": 2242791041,
"Urban Ice AK47": 1324932956,
"War Machine AK47": 1140366289,
"Wild Spirit AR": 2240088463,
"Wyrm Rifle": 1159593268,
"xQc Assault Rifle": 2352506845,
"X-RAY AK47": 1309470544
},
"mask.bandana": {
"Beast Bandana": 820870847,
"Black Bandana": 10061,
"Blue Bandana": 10060,
"Burlap Bandit Bandana": 1438048628,
"Checkered Bandana": 10067,
"Creepy Bandana": 2093051075,
"Creepy Clown Bandana": 533328361,
"Desert Camo Bandana": 10066,
"Easter Bandit": 2051174405,
"Egg Thief": 1710737837,
"Forest Camo Bandana": 10063,
"Green Bandana": 10059,
"Jawboy": 903595865,
"Red Skull Bandana": 10065,
"Road Raider Bandana": 1323640876,
"Salvaged Hazmat Bandana": 1685873480,
"Santa Bandana": 1185794212,
"Skull Bandana": 10064,
"Snow Camo Bandana": 10062,
"Wizard Bandana": 521069222
},
"hat.cap": {
"Blue Cap": 10029,
"Charitable Rust 2018 Cap": 1565217605,
"Forest Camo Cap": 10027,
"Friendly Cap": 10055,
"Friendly Cap": 494030776,
"Green Cap": 10030,
"Grey Cap": 10026,
"Jockey Cap": 1760269295,
"Oxums Employee Cap": 1137628492,
"Red Cap": 10028,
"Rescue Cap": 10045,
"Rescue Cap": 495026469,
"Taxi Cap": 2276035673,
"Toothy Hat": 890772638,
"Top Cap": 893188334
}
}