Initial commit

This commit is contained in:
Ubuntu
2026-06-19 00:00:16 -04:00
commit 73701ff86e
7100 changed files with 1952988 additions and 0 deletions
+106
View File
@@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.IO;
using Server;
using Server.Items;
using Server.Engines.UOStore;
namespace Server.Engines.UOStore
{
public static class UltimaStoreJsonLoader
{
private const string JsonPath = "Data/UltimaStore.json";
public static void Load()
{
string fullPath = Path.Combine(Core.BaseDirectory, JsonPath);
if (!File.Exists(fullPath))
{
Console.WriteLine("UltimaStoreJsonLoader: JSON file not found: " + fullPath);
return;
}
string json = File.ReadAllText(fullPath);
var data = MiniJson.Parse(json) as Dictionary<string, object>;
if (data == null)
{
Console.WriteLine("UltimaStoreJsonLoader: Failed to parse JSON.");
return;
}
UltimaStore.Entries.Clear();
foreach (var kvp in data)
{
if (!Enum.TryParse(kvp.Key, out StoreCategory cat))
{
Console.WriteLine("UltimaStoreJsonLoader: Unknown category " + kvp.Key);
continue;
}
var list = kvp.Value as List<object>;
if (list == null)
continue;
foreach (var entryObj in list)
{
var entry = entryObj as Dictionary<string, object>;
if (entry == null)
continue;
LoadEntry(entry, cat);
}
}
Console.WriteLine("UltimaStoreJsonLoader: JSON store loaded.");
}
public static void WriteJson(string json)
{
string fullPath = Path.Combine(Core.BaseDirectory, JsonPath);
File.WriteAllText(fullPath, json);
}
private static void LoadEntry(Dictionary<string, object> e, StoreCategory cat)
{
string full = e["Type"] as string;
string typeName = full.Contains(".")
? full.Substring(full.LastIndexOf('.') + 1)
: full;
Type itemType = ScriptCompiler.FindTypeByName(typeName);
if (itemType == null)
{
Console.WriteLine("UltimaStoreJsonLoader: Type not found: " + typeName);
return;
}
var nameList = e["NameLines"] as List<object>;
TextDefinition[] names = new TextDefinition[nameList.Count];
for (int i = 0; i < nameList.Count; i++)
names[i] = new TextDefinition(nameList[i].ToString());
int tooltip = Convert.ToInt32(e["Tooltip"]);
string tooltipText = e["TooltipText"] as string;
int itemID = Convert.ToInt32(e["ItemID"]);
int gumpID = Convert.ToInt32(e["GumpID"]);
int hue = Convert.ToInt32(e["Hue"]);
int price = Convert.ToInt32(e["Price"]);
if (!string.IsNullOrEmpty(tooltipText))
{
UltimaStore.Register(itemType, names, tooltipText, itemID, gumpID, hue, price, cat);
}
else
{
UltimaStore.Register(itemType, names, tooltip, itemID, gumpID, hue, price, cat);
}
}
}
}