private static JSONConverters jsonconvcache; //cache it public string ToShortString(string additionalremoves = null, JSONConverters jc = null) { if (jc == null) { if (jsonconvcache == null) { jsonconvcache = StandardConverters(); } jc = jsonconvcache; } JSONPrettyPrint jpp = new JSONPrettyPrint(jc, DefaultRemoveItems() + ((additionalremoves != null) ? (";" + additionalremoves) : ""), "_Localised", EventTypeStr); return(jpp.PrettyPrint(EventDataString, 80)); }
public static JSONConverters StandardConverters() { JSONConverters jc = new JSONConverters(); { // unique field names across multiple entries. First up so later ones can override if required jc.AddScale("MassEM", 1.0, "0.0000'em'", "Mass"); jc.AddScale("MassMT", 1.0, "0.0'mt'", "Mass"); jc.AddScale("SurfacePressure", 1.0, "0.0'p'"); jc.AddScale("Radius", 1.0 / 1000, "0.0'km'"); jc.AddScale("InnerRad", 1.0 / 1000, "0.0'km'", "Inner Radius"); jc.AddScale("OuterRad", 1.0 / 1000, "0.0'km'", "Outer Radius"); jc.AddScale("SemiMajorAxis", 1.0 / 1000, "0.0'km'", "Semi Major Axis"); jc.AddScale("OrbitalPeriod;RotationPeriod", 1.0 / 86400, "0.0' days orbit'", ""); jc.AddScale("SurfaceGravity", 1.0 / 9.8, "0.0'g'"); jc.AddScale("SurfaceTemperature", 1.0, "0.0'K'"); jc.AddScale("Scooped", 1.0, "'Scooped '0.0't'", "", "FuelScoop"); jc.AddScale("Total", 1.0, "'Fuel Level '0.0't'", "", "FuelScoop"); jc.AddScale("FuelUsed", 1.0, "'Fuel Used '0.0't'", ""); jc.AddScale("FuelLevel", 1.0, "'Fuel Level Left '0.0't'", ""); jc.AddScale("Amount", 1.0, "'Fuel Bought '0.0't'", "", "RefuelAll"); jc.AddScale("BoostValue", 1.0, "0.0' boost'", "", "JetConeBoost"); jc.AddScale("StarPos", 1.0, "0.0", ""); // any entry StarPos loses it name (inside arrays). StarPos as an array name gets printed sep. jc.AddBool("TidalLock", "Not Tidally Locked", "Tidally Locked", ""); // remove name jc.AddBool("Landable", "Not Landable", "Landable", ""); // remove name jc.AddBool("ShieldsUp", "Shields Down", "Shields Up Captain", ""); // remove name jc.AddState("TerraformState", "Not Terrraformable", ""); // remove name jc.AddState("Atmosphere", "No Atmosphere", ""); jc.AddState("Volcanism", "No Volcanism", ""); jc.AddPrePostfix("StationType", "; Type", ""); jc.AddPrePostfix("StationName", "; Station", ""); jc.AddPrePostfix("DestinationSystem", "; Destination Star System", ""); jc.AddPrePostfix("DestinationStation", "; Destination Station", ""); jc.AddPrePostfix("StarSystem;System", "; Star System", ""); jc.AddPrePostfix("Allegiance", "; Allegiance", ""); jc.AddPrePostfix("Security", "; Security", ""); jc.AddPrePostfix("Faction", "; Faction", ""); jc.AddPrePostfix("Government", "Government Type ", ""); jc.AddPrePostfix("Economy", "Economy Type ", ""); jc.AddBool("Docked", "Not Docked", "Docked", ""); // remove name jc.AddBool("PlayerControlled", "NPC Controlled", "Player Controlled", ""); // remove name jc.AddPrePostfix("Body", "At ", ""); jc.AddPrePostfix("To", "To ", "", "VehicleSwitch"); jc.AddPrePostfix("Name", "", "", "CrewAssign"); jc.AddPrePostfix("Role", "; role", "", "CrewAssign"); jc.AddPrePostfix("Cost;ShipPrice;BaseValue", "; credits", ""); jc.AddPrePostfix("Bonus", "; credits bonus", ""); jc.AddPrePostfix("Amount", "; credits", "", "PayLegacyFines"); jc.AddPrePostfix("BuyPrice", "Bought for ; credits", ""); jc.AddPrePostfix("SellPrice", "Sold for ; credits", ""); jc.AddPrePostfix("TotalCost", "Total cost ; credits", ""); jc.AddPrePostfix("LandingPad", "On pad ", ""); jc.AddPrePostfix("BuyItem", "; bought", ""); jc.AddPrePostfix("SellItem", "; sold", ""); jc.AddPrePostfix("Credits", "; credits", "", "LoadGame"); jc.AddPrePostfix("Ship;ShipType", "Ship ;", ""); jc.AddPrePostfix("StoreOldShip", "; stored", ""); jc.AddScale("Health", 100.0, "'Health' 0.0'%'", ""); jc.AddSpecial("Latitude", JSONConverters.Types.TLat, ""); jc.AddSpecial("Longitude", JSONConverters.Types.TLong, ""); jc.AddPrePostfix("Reward", "; credits", ""); } { //missions jc.AddPrePostfix("Name", "", "", "MissionAccepted;MissionAbandoned;MissionCompleted;MissionFailed"); } { // transfers string transfer = JL(new[] { JournalTypeEnum.ShipyardTransfer }); jc.AddScale("Distance", 1.0 / 299792458.0 / 365 / 24 / 60 / 60, "'Distance' 0.0'ly'", "", transfer); jc.AddPrePostfix("TransferPrice", "; credits", "", transfer); } { // misc jc.AddPrePostfix("Name", "; settlement", "", "ApproachSettlement"); jc.AddPrePostfix("Item", ";", "", "Repair"); } { // scans string scan = JL(new[] { JournalTypeEnum.Scan }); jc.AddPrePostfix("BodyName", "Scan ", "", scan); jc.AddScale("DistanceFromArrivalLS", 1.0, "0.0' ls from arrival point'", "", scan); jc.AddPrePostfix("StarType", "; type star", "", scan); jc.AddScale("StellarMass", 1.0, "0.0' stellar masses'", "", scan); jc.AddScale("Radius", 1.0 / 1000.0, "0.0' km radius'", "", scan); jc.AddScale("AbsoluteMagnitude", 1.0, "0.0' absolute magnitude'", "", scan); jc.AddScale("OrbitalPeriod", 1.0 / 86400, "0.0' days orbit'", "", scan); jc.AddScale("RotationPeriod", 1.0 / 86400, "0.0' days rotation'", "", scan); jc.AddPrePostfix("PlanetClass", "; planet class", "", scan); } { // engineering string engineer = JL(new[] { JournalTypeEnum.EngineerProgress, JournalTypeEnum.EngineerApply, JournalTypeEnum.EngineerCraft }); jc.AddPrePostfix("Engineer", "From ", "", engineer); jc.AddPrePostfix("Progress", "", "", engineer); } { // bounties } { string rank = JL(new[] { JournalTypeEnum.Rank }); jc.AddIndex("Combat", "; combat;0;Harmless;Mostly Harmless;Novice;Competent;Expert;Master;Dangerous;Deadly;Elite", "", rank); jc.AddIndex("Trade", "; trader;0;Penniless;Mostly Penniless;Peddler;Dealer;Merchant;Broker;Entrepreneur;Tycoon;Elite", "", rank); jc.AddIndex("Explore", "; explorer;0;Aimless;Mostly Aimless;Scout;Surveyor;Trailblazer;Pathfinder;Ranger;Pioneer;Elite", "", rank); jc.AddIndex("Empire", "; Empire;0;None;Outsider;Serf;Master;Squire;Knight;Lord;Baron;Viscount;Count;Earl;Marquis;Duke;Prince;King", "", rank); jc.AddIndex("Federation", "; Federation;0;None;Recruit;Cadet;Midshipman;Petty Officer;Chief Pretty Officer;Warren Officer;Ensign;Lieutenant;Lieutenant Commander;Post Commander;Post Captain;Rear Admiral;Vice Admiral;Admiral", "", rank); } { // places where commodities occur string commodities = JL(new[] { JournalTypeEnum.MarketBuy, JournalTypeEnum.MarketSell, JournalTypeEnum.MiningRefined }); jc.AddSpecial("Type", JSONConverters.Types.TMaterialCommodity, ";", "", commodities); jc.AddPrePostfix("Count", ";", "", commodities); } { string materials = JL(new[] { JournalTypeEnum.MaterialCollected, JournalTypeEnum.MaterialDiscarded, JournalTypeEnum.MaterialDiscovered }); jc.AddSpecial("Name", JSONConverters.Types.TMaterialCommodity, ";", "", materials); jc.AddPrePostfix("Category", ";", "", materials); jc.AddPrePostfix("Count", "; items", "", materials); } return(jc); }