本文整理汇总了C#中System.ConfigNode.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigNode.SetValue方法的具体用法?C# ConfigNode.SetValue怎么用?C# ConfigNode.SetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ConfigNode
的用法示例。
在下文中一共展示了ConfigNode.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnSave
public override void OnSave(ConfigNode node)
{
base.OnSave(node);
if (noseAnimControl != null)
{
noseAnimState = noseAnimControl.animationState.ToString();
bodyAnimState = bodyAnimControl.animationState.ToString();
tailAnimState = tailAnimControl.animationState.ToString();
node.SetValue("noseAnimState", noseAnimState, true);
node.SetValue("bodyAnimState", bodyAnimState, true);
node.SetValue("tailAnimState", tailAnimState, true);
}
}
示例2: onVesselLoaded
//loop through parts on vessel
// loop through modules on part
// for each docking node found
// if no existing docking-port-fix module is found
// add new SSTUDockingPortFix set to index-in-docking-modules of the docking port being fixed
// TODO - check for existing dock-port-fix modules?
private void onVesselLoaded(Vessel v)
{
int len = v.Parts.Count;
int dLen;
Part p;
ModuleDockingNode[] mdns;
ModuleDockingNode mdn;
SSTUDockingPortFix dpf;
ConfigNode dpfNode = new ConfigNode("MODULE");
dpfNode.AddValue("name", nameof(SSTUDockingPortFix));
for (int i = 0; i < len; i++)
{
p = v.Parts[i];
if (p == null) { continue; }
mdns = p.GetComponents<ModuleDockingNode>();
if (mdns == null || mdns.Length == 0) { continue; }
dLen = mdns.Length;
for (int k = 0; k < dLen; k++)
{
mdn = mdns[k];
dpfNode.SetValue("portIndex", k, true);
//dpf = (SSTUDockingPortFix)p.AddModule(dpfNode);
}
}
}
示例3: OnSave
public override void OnSave(ConfigNode node)
{
base.OnSave(node);
ConfigNode efficiencyNode;
if (node.HasValue("reputationIndex"))
node.SetValue("reputationIndex", reputationIndex.ToString());
else
node.AddValue("reputationIndex", reputationIndex.ToString());
if (node.HasValue("drillToolTipShown"))
node.SetValue("drillToolTipShown", drillToolTipShown.ToString());
else
node.AddValue("drillToolTipShown", drillToolTipShown.ToString());
foreach (EfficiencyData data in efficiencyDataMap.Values)
{
efficiencyNode = new ConfigNode(kEfficiencyData);
data.Save(efficiencyNode);
node.AddNode(efficiencyNode);
}
}
示例4: OnSave
public override void OnSave(ConfigNode node)
{
base.OnSave(node);
ConfigNode efficiencyNode;
if (node.HasValue("reputationIndex"))
node.SetValue("reputationIndex", reputationIndex.ToString());
else
node.AddValue("reputationIndex", reputationIndex.ToString());
foreach (EfficiencyData data in efficiencyDataMap.Values)
{
efficiencyNode = new ConfigNode(kEfficiencyData);
data.Save(efficiencyNode);
node.AddNode(efficiencyNode);
}
node.RemoveNodes(kToolTip);
foreach (ConfigNode toolTipNode in toolTips.Values)
node.AddNode(toolTipNode);
}
示例5: DodgeVesselLandedStatus
private void DodgeVesselLandedStatus(ConfigNode vesselNode)
{
if (vesselNode != null)
{
string situation = vesselNode.GetValue("sit");
switch (situation)
{
case "LANDED":
vesselNode.SetValue("landed", "True");
vesselNode.SetValue("splashed", "False");
break;
case "SPLASHED":
vesselNode.SetValue("splashed", "True");
vesselNode.SetValue("landed", "False");
break;
}
}
}
示例6: SaveRippleOptions
void SaveRippleOptions(ConfigNode node)
{
if(rippleDictionary != null)
{
rippleData = string.Empty;
foreach(var wpnName in rippleDictionary.Keys)
{
rippleData += wpnName + "," + rippleDictionary[wpnName].rippleFire.ToString() + "," + rippleDictionary[wpnName].rpm.ToString() + ";";
}
node.SetValue("RippleData", rippleData, true);
}
Debug.Log("Saved ripple data: "+rippleData);
}
示例7: Start
//.........这里部分代码省略.........
CurrentKeySet = Convert.ToInt32(AGExtNode.GetValue("ActiveKeySet"));
//LoadCurrentKeySet();
CurrentKeySetName = AGExtNode.GetValue("KeySetName" + CurrentKeySet);
CurrentVesselActions = new List<AGXAction>();
AGXRoot = null;
GroupsWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("EdGroupsX")), Convert.ToInt32(AGExtNode.GetValue("EdGroupsY")), 250, 530);
SelPartsWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("EdSelPartsX")), Convert.ToInt32(AGExtNode.GetValue("EdSelPartsY")), 365, 270);
KeyCodeWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("EdKeyCodeX")), Convert.ToInt32(AGExtNode.GetValue("EdKeyCodeY")), 410, 730);
KeySetWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("EdKeySetX")), Convert.ToInt32(AGExtNode.GetValue("EdKeySetY")), 185, 335);
CurActsWin = new Rect(Convert.ToInt32(AGExtNode.GetValue("EdCurActsX")), Convert.ToInt32(AGExtNode.GetValue("EdCurActsY")), 345, 140);
LoadCurrentKeyBindings();
if (ToolbarManager.ToolbarAvailable) //check if toolbar available, load if it is
{
AGXBtn = ToolbarManager.Instance.add("AGX", "AGXBtn");
AGXBtn.TexturePath = "Diazo/AGExt/icon_button";
AGXBtn.ToolTip = "Action Groups Extended";
AGXBtn.OnClick += (e) =>
{
//List<UnityEngine.Transform> UIPanelList = new List<UnityEngine.Transform>(); //setup list to find Editor Actions UI transform into a list. Could not figure out how to find just a transform
//UIPanelList.AddRange(FindObjectsOfType<UnityEngine.Transform>().Where(n => n.name == "PanelActionGroups")); //actual find command
if (EditorLogic.fetch.editorScreen == EditorLogic.EditorScreen.Actions)
{
if (AGXShow)
{
//UIPanelList.First().Translate(new Vector3(500f, 0, 0), UIPanelList.First().parent.transform); //hide UI panel
AGXShow = false;
AGExtNode.SetValue("EditShow", "0");
EditorPanels.Instance.panelManager.BringIn(EditorPanels.Instance.actions);
}
else
{
// UIPanelList.First().Translate(new Vector3(-500f, 0, 0), UIPanelList.First().parent.transform); //show UI panel
AGXShow = true;
AGExtNode.SetValue("EditShow", "1");
EditorPanels.Instance.panelManager.Dismiss();
}
AGExtNode.Save(KSPUtil.ApplicationRootPath + "GameData/Diazo/AGExt/AGExt.cfg");
}
else
{
EditorLogic.fetch.SelectPanelActions();
}
};
}
else
{
AGXShow = true; //toolbar not installed, show AGX regardless
}
DetachedPartActions = new List<AGXAction>();
DetachedPartReset = new Timer();
DetachedPartReset.Interval = 500;
DetachedPartReset.Stop();
DetachedPartReset.AutoReset = true;
DetachedPartReset.Elapsed += new ElapsedEventHandler(ResetDetachedParts);
示例8: SaveState
public void SaveState(ConfigNode configNode)
{
if (configNode != null)
{
configNode.SetValue("useStockSkin", m_UseKSPSkin ? "true" : "false");
configNode.SetValue("useOldPresetEditor", m_UseOldPresetsWindow ? "true" : "false");
}
Configuration.Serialize(GetAbsoluteConfigurationPath(), m_Configuration);
}
示例9: SetConfiguration
public virtual void SetConfiguration(string newConfiguration = null, bool resetTechLevels = false)
{
if (newConfiguration == null)
newConfiguration = configuration;
ConfigSaveLoad();
ConfigNode newConfig = configs.Find (c => c.GetValue ("name").Equals (newConfiguration));
if (!UnlockedConfig(newConfig, part))
{
if(newConfig == null)
Debug.Log("*RFMEC* ERROR Can't find configuration " + newConfiguration + ", falling back to first tech-available config.");
foreach(ConfigNode cfg in configs)
if (UnlockedConfig(cfg, part))
{
newConfig = cfg;
newConfiguration = cfg.GetValue("name");
break;
}
}
if (newConfig != null)
{
if (configuration != newConfiguration && resetTechLevels)
techLevel = origTechLevel;
// for asmi
if (useConfigAsTitle)
part.partInfo.title = configuration;
configuration = newConfiguration;
config = new ConfigNode("MODULE");
newConfig.CopyTo(config);
config.name = "MODULE";
#if DEBUG
print ("replacing " + type + " with:");
print (newConfig.ToString ());
#endif
pModule = null;
// get correct module
pModule = GetSpecifiedModule(part, engineID, moduleIndex, type, useWeakType);
if ((object)pModule == null)
{
Debug.Log("*RFMEC* Could not find appropriate module of type " + type + ", with ID=" + engineID + " and index " + moduleIndex);
return;
}
Type mType = pModule.GetType();
config.SetValue("name", mType.Name);
// clear all FloatCurves we need to clear (i.e. if our config has one, or techlevels are enabled)
bool delAtmo = config.HasNode("atmosphereCurve") || techLevel >= 0;
bool delDens = config.HasNode("atmCurve") || techLevel >= 0;
bool delVel = config.HasNode("velCurve") || techLevel >= 0;
foreach (FieldInfo field in mType.GetFields())
{
if (field.FieldType == typeof(FloatCurve) &&
((field.Name.Equals("atmosphereCurve") && delAtmo)
|| (field.Name.Equals("atmCurve") && delDens)
|| (field.Name.Equals("velCurve") && delVel)))
{
field.SetValue(pModule, new FloatCurve());
}
}
// clear propellant gauges
foreach (FieldInfo field in mType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance))
{
if (field.FieldType == typeof(Dictionary<Propellant, VInfoBox>))
{
Dictionary<Propellant, VInfoBox> boxes = (Dictionary<Propellant, VInfoBox>)(field.GetValue(pModule));
if (boxes == null)
continue;
foreach (VInfoBox v in boxes.Values)
{
if (v == null) //just in case...
continue;
try
{
part.stackIcon.RemoveInfo(v);
}
catch (Exception e)
{
Debug.Log("*RFMEC* Trying to remove info box: " + e.Message);
}
}
boxes.Clear();
}
}
if (type.Equals("ModuleRCS") || type.Equals("ModuleRCSFX"))
{
ModuleRCS rcs = (ModuleRCS)pModule;
if (rcs != null)
{
DoConfig(config);
if (config.HasNode("PROPELLANT"))
{
rcs.propellants.Clear();
//.........这里部分代码省略.........
示例10: writeConfig
private void writeConfig(Config config)
{
ConfigNode root = new ConfigNode ();
ConfigNode top = new ConfigNode (WASD_NODENAME);
root.SetNode (WASD_NODENAME, top, true);
top.SetValue ("defaultCamera", config.defaultCamera.ToString (), true);
top.SetValue ("mouseWheelActive", config.mouseWheelActive.ToString (), true);
top.SetValue ("enableExperimentalEditorExtensionsCompatibility", config.enableExperimentalEditorExtensionsCompatibility.ToString (), true);
top.SetValue ("enforceBounds", config.enforceBounds.ToString (), true);
top.SetValue ("sensitivity", config.sensitivity.ToString (), true);
top.SetValue ("acceleration", config.acceleration.ToString (), true);
top.SetValue ("mouseWheelAcceleration", config.mouseWheelAcceleration.ToString (), true);
top.SetValue ("friction", config.friction.ToString (), true);
top.SetValue ("runMultiplier", config.runMultiplier.ToString (), true);
top.SetValue ("sneakMultiplier", config.sneakMultiplier.ToString (), true);
ConfigNode keysNode = new ConfigNode ("KEYS");
top.SetNode ("KEYS", keysNode, true);
keysNode.SetValue ("forward", config.keyForward.ToString (), true);
keysNode.SetValue ("back", config.keyBack.ToString (), true);
keysNode.SetValue ("right", config.keyRight.ToString (), true);
keysNode.SetValue ("left", config.keyLeft.ToString (), true);
keysNode.SetValue ("up", config.keyUp.ToString (), true);
keysNode.SetValue ("down", config.keyDown.ToString (), true);
keysNode.SetValue ("switchMode", config.keySwitchMode.ToString (), true);
keysNode.SetValue ("run", config.keyRun.ToString (), true);
keysNode.SetValue ("sneak", config.keySneak.ToString (), true);
ConfigNode editorsNode = new ConfigNode ("EDITORS");
top.SetNode ("EDITORS", editorsNode, true);
ConfigNode vabNode = new ConfigNode ("VAB");
editorsNode.SetNode ("VAB", vabNode, true);
string s;
s = config.vab.initialPosition.ToString ();
s = s.TrimStart ('(');
s = s.TrimEnd (')');
vabNode.SetValue ("initialPosition", s, true);
vabNode.SetValue ("initialPitch", config.vab.initialPitch.ToString (), true);
vabNode.SetValue ("initialYaw", config.vab.initialYaw.ToString (), true);
ConfigNode vabBoundsNode = new ConfigNode ("BOUNDS");
vabNode.SetNode ("BOUNDS", vabBoundsNode, true);
s = config.vab.bounds.min.ToString ();
s = s.TrimStart ('(');
s = s.TrimEnd (')');
vabBoundsNode.SetValue ("min", s, true);
s = config.vab.bounds.max.ToString ();
s = s.TrimStart ('(');
s = s.TrimEnd (')');
vabBoundsNode.SetValue ("max", s, true);
// need to do bounds
ConfigNode sphNode = new ConfigNode ("SPH");
editorsNode.SetNode ("SPH", sphNode, true);
s = config.sph.initialPosition.ToString ();
s = s.TrimStart ('(');
s = s.TrimEnd (')');
sphNode.SetValue ("initialPosition", s, true);
sphNode.SetValue ("initialPitch", config.sph.initialPitch.ToString (), true);
sphNode.SetValue ("initialYaw", config.sph.initialYaw.ToString (), true);
// need to do bounds
ConfigNode sphBoundsNode = new ConfigNode ("BOUNDS");
sphNode.SetNode ("BOUNDS", sphBoundsNode, true);
s = config.sph.bounds.min.ToString ();
s = s.TrimStart ('(');
s = s.TrimEnd (')');
sphBoundsNode.SetValue ("min", s, true);
s = config.sph.bounds.max.ToString ();
s = s.TrimStart ('(');
s = s.TrimEnd (')');
sphBoundsNode.SetValue ("max", s, true);
root.Save (WASD_CFG_FILE);
WasdEditorCameraBehaviour.setConfig (root);
}
示例11: OnSave
public override void OnSave(ConfigNode node)
{
// Force saved value for enabled to be true.
node.SetValue("isEnabled", "True");
}
示例12: OnSave
public override void OnSave(ConfigNode node)
{
base.OnSave(node);
savedAnimationState = panelState.ToString();
node.SetValue("savedAnimationState", savedAnimationState, true);
}
示例13: SetNodeForEngine
/// <summary>
/// Store fitted engine parameters in the database so they can be accessed later
/// </summary>
/// <param name="engine">Engine to associated this config node with</param>
/// <param name="node">Config node describing engine parameters (both input parameters and fitted parameters)</param>
public static void SetNodeForEngine(ModuleEnginesSolver engine, ConfigNode node)
{
string partName = engine.part.name;
string engineType = engine.GetType().Name;
string engineID = engine.engineID;
Assembly assembly = engine.GetType().Assembly;
node.SetValue("engineID", engineID, true);
node.SetValue("DeclaringAssemblyVersion", EngineDatabase.AssemblyVersion(assembly), true);
node.SetValue("DeclaringAssemblyChecksum", EngineDatabase.AssemblyChecksum(assembly), true);
node.SetValue("SolverEnginesVersion", SolverEnginesVersion, true);
node.SetValue("SolverEnginesAssemblyChecksum", SolverEnginesAssemblyChecksum, true);
ConfigNode partNode = database.GetNode(partName);
int nodeIndex = 0;
if (partNode != null)
{
ConfigNode[] moduleNodes = partNode.GetNodes(engineType);
for (int i = 0; i < moduleNodes.Length; i++ )
{
ConfigNode mNode = moduleNodes[i];
if (mNode.GetValue("engineID") == engineID)
{
nodeIndex = i;
}
}
}
else
{
partNode = new ConfigNode(partName);
database.AddNode(partNode);
nodeIndex = 0;
}
partNode.SetNode(engineType, node, nodeIndex, true);
SaveDatabase();
}
示例14: OnSave
/// <summary>
/// Saves the internal state of the failure module to the persistence file.
/// Put your custom save logic in DI_OnSave()
/// </summary>
public override void OnSave(ConfigNode node)
{
try
{
// Save the internal state
node.SetValue("HasInitted", this.HasInitted.ToString());
node.SetValue("Age", Age.ToString());
node.SetValue("TimeOfLastReset", TimeOfLastReset.ToString());
node.SetValue("TimeOfLastInspection", TimeOfLastInspection.ToString());
node.SetValue("LastFixedUpdate", LastFixedUpdate.ToString());
node.SetValue("CurrentMTBF", CurrentMTBF.ToString());
node.SetValue("LifeTimeSecs", LifeTimeSecs.ToString());
node.SetValue("HasFailed", HasFailed.ToString());
// Run the subclass' custom onsave
this.DI_OnSave(node);
base.OnSave(node);
}
catch (Exception e)
{
this.OnError(e);
}
}
示例15: OnSave
public override void OnSave(ConfigNode config)
{
//Debug.Log("ResourceRecovery ResourceRecoveryData OnSave beginn1 config=" + config);
//Debug.Log("ResourceRecovery ResourceRecoveryData OnSave beginn2 Foo.get_root()=" + SubRootNode.get_root());
string lc = config.GetValue("loadcount");
int lc2 = 0;
Int32.TryParse(lc, out lc2);
lc2 = lc2+1;
config.SetValue("loadcount", lc2.ToString());
config.SetValue("updated", DateTime.Now.ToString());
//Debug.Log("ResourceRecovery ResourceRecoveryData OnSave ScenarioAttributes.get_ScenarioAttribute(version)=" + ScenarioAttributes.get_ScenarioAttribute("version"));
config.SetValue("dll_version", ScenarioAttributes.get_ScenarioAttribute("dll_version"));
config.SetValue("filesystem_version", ScenarioAttributes.get_ScenarioAttribute("filesystem_version"));
config.SetValue("SaveGameKredits", ScenarioAttributes.get_ScenarioAttribute("SaveGameKredits"));
config.AddNode(SubRootNode.get_sub_root());
//Debug.Log("ResourceRecovery ResourceRecoveryData OnSave done config=" + config);
Debug.Log("ResourceRecovery ResourceRecoveryData OnSave done");
}