feat: Add metro transit, gadgets, shop, social apps, and traffic models checkpoint
This commit is contained in:
1 parent
caa42b84ed
commit
74e2963a12
79 files changed
+527962
-496
No files matched your search
@@ -0,0 +1,49 @@
|
||||
using System.Text.Json;
|
||||
using Ananta.Server.Configuration;
|
||||
|
||||
namespace Ananta.Server.ClientData.Client4229938;
|
||||
|
||||
/// <summary>
|
||||
/// Chinese → English name mapping for the debug panel spawn lists. The tables are generated
|
||||
/// by VaultTool/build_translation.py (word segmentation + single-char fallback) over the
|
||||
/// AgentConfig / UrbanDiversityPOIActionConfig name columns; unknown names fall back to the
|
||||
/// original string.
|
||||
/// </summary>
|
||||
internal static class NameTranslator
|
||||
{
|
||||
private static readonly Lazy<Dictionary<string, string>> Agents = new(() => Load("agent_names_en.json"));
|
||||
private static readonly Lazy<Dictionary<string, string>> PoiActions = new(() => Load("poi_actions_en.json"));
|
||||
|
||||
public static string Agent(string? name)
|
||||
=> Translate(Agents.Value, name);
|
||||
|
||||
public static string PoiAction(string? name)
|
||||
=> Translate(PoiActions.Value, name);
|
||||
|
||||
private static string Translate(Dictionary<string, string> table, string? name)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
return name ?? string.Empty;
|
||||
return table.TryGetValue(name, out var en) && !string.IsNullOrWhiteSpace(en) ? en : name;
|
||||
}
|
||||
|
||||
private static Dictionary<string, string> Load(string file)
|
||||
{
|
||||
try
|
||||
{
|
||||
var root = PrivateServerConfigStore.ResolveProjectPath(PrivateServerConfigStore.Current.Paths.ClientConfigs);
|
||||
var path = Path.Combine(root, file);
|
||||
if (!File.Exists(path))
|
||||
return [];
|
||||
using var doc = JsonDocument.Parse(File.ReadAllText(path));
|
||||
var dict = new Dictionary<string, string>();
|
||||
foreach (var p in doc.RootElement.EnumerateObject())
|
||||
dict[p.Name] = p.Value.GetString() ?? string.Empty;
|
||||
return dict;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user