Files
TeslaSuite/Console/TeslaConsole.RedPlanet/RPConfig.cs
T
CydandClaude Opus 4.8 548550b312 Initial commit: TeslaSuite monorepo (TeslaConsole + TeslaLauncher)
Co-locate the two cockpit-pod projects into a single repository:

- Console/  : TeslaConsole, the net48 WinForms operator console (decompiled
              reconstruction) plus its differential + catalog test suite.
- Launcher/ : TeslaLauncher, the net6 pod-side Service + Agent rewrite.

Adds a combined TeslaSuite.sln, root README documenting the shared wire
contract (and its current duplication, the main follow-up), and a root
.gitignore. Histories were not preserved per request; this is a fresh start
from the current working state of both projects.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 14:43:28 -05:00

121 lines
2.9 KiB
C#

using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using System.Xml;
namespace TeslaConsole.RedPlanet;
public static class RPConfig
{
private static readonly DeathRaceScenario mRace;
private static readonly FootballScenario mFootball;
private static readonly Dictionary<string, RPMap> mMaps;
private static readonly Dictionary<string, RPVehicle> mVehicles;
private static readonly Dictionary<string, string> mTimesOfDay;
private static readonly Dictionary<string, string> mWeather;
public static DeathRaceScenario DeathRace => mRace;
public static FootballScenario Football => mFootball;
public static Dictionary<string, RPMap> Maps => mMaps;
public static Dictionary<string, RPVehicle> Vehicles => mVehicles;
public static Dictionary<string, string> TimesOfDay => mTimesOfDay;
public static Dictionary<string, string> Weather => mWeather;
static RPConfig()
{
mRace = null;
mFootball = null;
mMaps = new Dictionary<string, RPMap>();
mVehicles = new Dictionary<string, RPVehicle>();
mTimesOfDay = new Dictionary<string, string>();
mWeather = new Dictionary<string, string>();
XmlNode scenarioNode = null;
XmlNode scenarioNode2 = null;
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "RedPlanet\\RPConfig.xml"));
foreach (XmlNode childNode in xmlDocument.DocumentElement.ChildNodes)
{
switch (childNode.Name)
{
case "race":
scenarioNode = childNode;
break;
case "football":
scenarioNode2 = childNode;
break;
case "map":
{
RPMap rPMap = new RPMap(childNode);
mMaps.Add(rPMap.Key, rPMap);
break;
}
case "vehicle":
{
RPVehicle rPVehicle = new RPVehicle(childNode);
mVehicles.Add(rPVehicle.Key, rPVehicle);
break;
}
case "time":
AddKeyNameNode(childNode, mTimesOfDay);
break;
case "weather":
AddKeyNameNode(childNode, mWeather);
break;
}
}
mRace = new DeathRaceScenario(scenarioNode);
mFootball = new FootballScenario(scenarioNode2);
}
internal static void AddKeyNameNode(XmlNode node, Dictionary<string, string> list)
{
list.Add(node.Attributes["key"].InnerText, node.Attributes["name"].InnerText);
}
public static string MapNameOrKey(string mapKey)
{
if (!mMaps.ContainsKey(mapKey))
{
return mapKey;
}
return mMaps[mapKey].Name;
}
public static string VehicleNameOrKey(string vehicleKey)
{
if (!mVehicles.ContainsKey(vehicleKey))
{
return vehicleKey;
}
return mVehicles[vehicleKey].Name;
}
public static string TimeOfDayNameOrKey(string timeOfDayKey)
{
if (!mTimesOfDay.ContainsKey(timeOfDayKey))
{
return timeOfDayKey;
}
return mTimesOfDay[timeOfDayKey];
}
public static string WeatherNameOrKey(string weatherKey)
{
if (!mWeather.ContainsKey(weatherKey))
{
return weatherKey;
}
return mWeather[weatherKey];
}
}