本文整理汇总了C#中ConfigNode.AddNode方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigNode.AddNode方法的具体用法?C# ConfigNode.AddNode怎么用?C# ConfigNode.AddNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigNode
的用法示例。
在下文中一共展示了ConfigNode.AddNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RealChuteSettings
/// <summary>
/// Loads the RealChute_Settings config to memory
/// </summary>
public RealChuteSettings()
{
ConfigNode node = new ConfigNode(), settings = new ConfigNode("REALCHUTE_SETTINGS");
Debug.Log("[RealChute]: Loading settings file.");
if (!System.IO.File.Exists(RCUtils.settingsURL))
{
Debug.LogWarning("[RealChute]: RealChute_Settings.cfg is missing component. Creating new version.");
settings.AddValue("autoArm", autoArm);
settings.AddValue("jokeActivated", jokeActivated);
node.AddNode(settings);
node.Save(RCUtils.settingsURL);
}
else
{
node = ConfigNode.Load(RCUtils.settingsURL);
node.TryGetNode("REALCHUTE_SETTINGS", ref settings);
bool missing = false;
if (!settings.TryGetValue("autoArm", ref _autoArm)) { missing = true; }
if (!settings.TryGetValue("jokeActivated", ref _jokeActivated)) { missing = true; }
if (missing)
{
Debug.LogWarning("[RealChute]: RealChute_Settings.cfg is missing component. Fixing settings file.");
settings.ClearValues();
settings.AddValue("autoArm", autoArm);
settings.AddValue("jokeActivated", jokeActivated);
node.ClearData();
node.AddNode(settings);
node.Save(RCUtils.settingsURL);
}
}
}
示例2: RealChuteSettings
/// <summary>
/// Loads the RealChute_Settings config to memory
/// </summary>
public RealChuteSettings()
{
ConfigNode node = new ConfigNode(), settings = new ConfigNode("REALCHUTE_SETTINGS");
Debug.Log("[RealChute]: Loading settings file.");
if (!File.Exists(RCUtils.settingsURL))
{
Debug.LogWarning("[RealChute]: RealChute_Settings.cfg is missing. Creating new.");
settings.AddValue("autoArm", autoArm);
settings.AddValue("jokeActivated", jokeActivated);
settings.AddValue("hideIcon", hideIcon);
node.AddNode(settings);
node.Save(RCUtils.settingsURL);
}
else
{
node = ConfigNode.Load(RCUtils.settingsURL);
if (!node.TryGetNode("REALCHUTE_SETTINGS", ref settings)) { goto missing; }
if (!settings.TryGetValue("autoArm", ref _autoArm)) { goto missing; }
if (!settings.TryGetValue("jokeActivated", ref _jokeActivated)) { goto missing; }
if (settings.TryGetValue("hideIcon", ref _hideIcon)) { goto missing; }
return;
missing:
{
Debug.LogWarning("[RealChute]: RealChute_Settings.cfg is missing component. Fixing settings file.");
settings.ClearValues();
settings.AddValue("autoArm", autoArm);
settings.AddValue("jokeActivated", jokeActivated);
settings.AddValue("hideIcon", hideIcon);
node.ClearData();
node.AddNode(settings);
node.Save(RCUtils.settingsURL);
}
}
}
示例3: Save
public void Save(ConfigNode node)
{
ConfigNode pNode = new ConfigNode("WING_PROPERTY");
pNode.AddValue(nameof(ID), ID);
pNode.AddValue(nameof(value), value);
node.AddNode(pNode);
}
示例4: Save
public void Save(ConfigNode node)
{
ConfigNode newNode = new ConfigNode("Resource");
newNode.AddValue("name", resource.name);
newNode.AddValue("ratio", ratio);
node.AddNode(newNode);
}
示例5: Save
public void Save(ConfigNode node)
{
if (node.HasNode("KOLONIZATION"))
{
SettingsNode = node.GetNode("KOLONIZATION");
}
else
{
SettingsNode = node.AddNode("KOLONIZATION");
}
foreach (KolonizationEntry r in _LogInfo)
{
var rNode = new ConfigNode("KOLONY_ENTRY");
rNode.AddValue("BodyIndex", r.BodyIndex);
rNode.AddValue("VesselId", r.VesselId);
rNode.AddValue("LastUpdate", r.LastUpdate);
rNode.AddValue("KolonyDate", r.KolonyDate);
rNode.AddValue("GeologyResearch", r.GeologyResearch);
rNode.AddValue("BotanyResearch", r.BotanyResearch);
rNode.AddValue("KolonizationResearch", r.KolonizationResearch);
rNode.AddValue("Science", r.Science);
rNode.AddValue("Rep", r.Rep);
rNode.AddValue("Funds", r.Funds);
SettingsNode.AddNode(rNode);
}
//Reset cache
KolonizationManager.Instance.ResetCache();
}
示例6: RealChuteSettings
/// <summary>
/// Loads the RealChute_Settings config to memory
/// </summary>
public RealChuteSettings()
{
ConfigNode node = new ConfigNode(), settings = new ConfigNode("REALCHUTE_SETTINGS");
Debug.Log("[RealChute]: Loading settings file.");
if (!File.Exists(RCUtils.settingsURL))
{
Debug.LogError("[RealChute]: RealChute_Settings.cfg is missing. Creating new.");
settings.AddValue("autoArm", this._autoArm);
settings.AddValue("jokeActivated", this._jokeActivated);
settings.AddValue("guiResizeUpdates", this._guiResizeUpdates);
settings.AddValue("mustBeEngineer", this._mustBeEngineer);
settings.AddValue("engineerLevel", this._engineerLevel);
node.AddNode(settings);
node.Save(RCUtils.settingsURL);
}
else
{
node = ConfigNode.Load(RCUtils.settingsURL);
bool mustSave = false;
if (!node.TryGetNode("REALCHUTE_SETTINGS", ref settings)) { SaveSettings(); return; }
if (!settings.TryGetValue("autoArm", ref this._autoArm)) { mustSave = true; return; }
if (!settings.TryGetValue("jokeActivated", ref this._jokeActivated)) { mustSave = true; return; }
if (!settings.TryGetValue("guiResizeUpdates", ref this._guiResizeUpdates)) { mustSave = true; return; }
if (!settings.TryGetValue("mustBeEngineer", ref this._mustBeEngineer)) { mustSave = true; return; }
if (!settings.TryGetValue("engineerLevel", ref this._engineerLevel)) { mustSave = true; return; }
this._presets = settings.GetNodes("PRESET");
if (mustSave) { SaveSettings(); }
}
}
示例7: Save
public void Save(ConfigNode node)
{
ConfigNode newNode = new ConfigNode("FuelSet");
foreach (KeyValuePair<string, WingTankResource> kvp in resources)
{
kvp.Value.Save(newNode);
}
node.AddNode(newNode);
}
示例8: Save
internal void Save(ConfigNode node)
{
ConfigNode settingsNode;
if (node.HasNode(configNodeName))
{
settingsNode = node.GetNode(configNodeName);
settingsNode.ClearData();
}
else
{
settingsNode = node.AddNode(configNodeName);
}
settingsNode.AddValue("fixtimecounts", false);
}
示例9: Save
public bool Save(ConfigNode node)
{
var save = false;
foreach (var metric in Metrics)
{
var metricNode = new ConfigNode($"%METRIC[{metric.Name.Name}]");
if (metric.Save(metricNode))
{
node.AddNode(metricNode);
save = true;
}
}
return save;
}
示例10: OnSave
// Save the Deformation
public override void OnSave(ConfigNode node)
{
// Loop through all bodies with a PQS
foreach (CelestialBody body in PSystemManager.Instance.localBodies.Where(b => b.pqsController != null))
{
// Get the Deformation controller
PQSMod_TerrainDeformation pqsDeformation = body.pqsController.GetComponentInChildren<PQSMod_TerrainDeformation>();
// Add a node for the body
ConfigNode bodyNode = node.AddNode(body.transform.name);
// Build the Deformations
foreach (Deformation deformation in pqsDeformation.deformations)
{
ConfigNode deformationNode = bodyNode.AddNode("Deformation");
deformationNode.AddValue("position", Utility.FormatVector3D(deformation.position));
deformationNode.AddValue("depth", deformation.depth);
deformationNode.AddValue("width", deformation.width);
}
}
}
示例11: Save
public void Save(ConfigNode node)
{
if (node.HasNode("PLANETARY_LOGISTICS"))
{
SettingsNode = node.GetNode("PLANETARY_LOGISTICS");
}
else
{
SettingsNode = node.AddNode("PLANETARY_LOGISTICS");
}
foreach (PlanetaryLogisticsEntry r in _LogInfo)
{
var rNode = new ConfigNode("LOGISTICS_ENTRY");
rNode.AddValue("BodyIndex", r.BodyIndex);
rNode.AddValue("ResourceName", r.ResourceName);
rNode.AddValue("StoredQuantity", r.StoredQuantity);
SettingsNode.AddNode(rNode);
}
//Reset cache
PlanetaryLogisticsManager.Instance.ResetCache();
}
示例12: SaveConfig
/// <summary>Saves the settings to the configuration file.</summary>
internal static void SaveConfig()
{
// KFGlobals.cfg
System.IO.File.Delete(configFileName);
// Sync debug state with debug options.
if (!isDebugEnabled && debugIsWaterColliderVisible)
{
debugIsWaterColliderVisible = false;
}
var configFile = new ConfigNode();
configFile.AddNode("KFGlobals");
ConfigNode configNode = configFile.GetNode("KFGlobals");
configNode.SetValue("isDustEnabled", string.Format("{0}", isDustEnabled), true);
configNode.SetValue("isDustCameraEnabled", string.Format("{0}", isDustCameraEnabled), true);
configNode.SetValue("isMarkerEnabled", string.Format("{0}", isMarkerEnabled), true);
configNode.SetValue("isRepLightEnabled", string.Format("{0}", isRepLightEnabled), true);
configNode.SetValue("dustAmount", string.Format("{0}", Mathf.Clamp(Extensions.RoundToNearestValue(dustAmount, 0.25f), 0f, 3f)), true);
configNode.SetValue("suspensionIncrement", string.Format("{0}", Mathf.Clamp(Extensions.RoundToNearestValue(suspensionIncrement, 5f), 5f, 20f)), true);
configNode.SetValue("isDebugEnabled", string.Format("{0}", isDebugEnabled), true);
configNode.SetValue("debugIsWaterColliderVisible", string.Format("{0}", debugIsWaterColliderVisible), true);
configNode.SetValue("writeToLogFile", writeToLogFile.ToString(), true);
configNode.SetValue("logFile", logFile, true);
configFile.Save(configFileName);
KFLog.Log("Global Settings Saved.");
LogConfigValues();
}
示例13: Save
public ConfigNode Save(ConfigNode config)
{
ConfigNode node = config.AddNode(ConfigNodeName);
node.AddValue("vesselName", vesselName);
node.AddValue("vesselType", vesselType.ToString());
node.AddValue("vesselSituation", vesselSituation.ToString());
node.AddValue("vesselIsPreLaunch", vesselIsPreLaunch);
node.AddValue("numCrew", numCrew);
node.AddValue("numFrozenCrew", numFrozenCrew);
node.AddValue("numOccupiedParts", numOccupiedParts);
node.AddValue("lastUpdate", lastUpdate);
node.AddValue("lastFood", lastFood);
node.AddValue("lastWater", lastWater);
node.AddValue("lastOxygen", lastOxygen);
node.AddValue("lastElectricity", lastElectricity);
node.AddValue("remainingFood", remainingFood);
node.AddValue("remainingWater", remainingWater);
node.AddValue("remainingOxygen", remainingOxygen);
node.AddValue("remainingElectricity", remainingElectricity);
node.AddValue("remainingCO2", remainingCO2);
node.AddValue("remainingWaste", remainingWaste);
node.AddValue("remainingWasteWater", remainingWasteWater);
node.AddValue("maxFood", maxFood);
node.AddValue("maxWater", maxWater);
node.AddValue("maxOxygen", maxOxygen);
node.AddValue("maxElectricity", maxElectricity);
node.AddValue("estimatedElectricityConsumptionRate", estimatedElectricityConsumptionRate);
node.AddValue("hibernating", hibernating);
node.AddValue("recoveryvessel", recoveryvessel);
return node;
}
示例14: SaveSelectedDefault
public static void SaveSelectedDefault(ConfigNode config, string path)
{
config.AddNode(GetSelectedDefault().CreateConfigNode(true));
config.Save(path);
}
示例15: SaveSettings
/// <summary>
/// Saves the RealChute_Settings config into GameData
/// </summary>
public static void SaveSettings()
{
ConfigNode settings = new ConfigNode("REALCHUTE_SETTINGS"), node = new ConfigNode();
settings.AddValue("autoArm", fetch.autoArm);
settings.AddValue("jokeActivated", fetch.jokeActivated);
if (PresetsLibrary.instance.presets.Count > 0)
{
PresetsLibrary.instance.presets.ForEach(p => settings.AddNode(p.Save()));
}
node.AddNode(settings);
node.Save(RCUtils.settingsURL);
}