本文整理汇总了C#中ConfigNode.Save方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigNode.Save方法的具体用法?C# ConfigNode.Save怎么用?C# ConfigNode.Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigNode
的用法示例。
在下文中一共展示了ConfigNode.Save方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: HandleSettings
public void HandleSettings()
{
if (!File.Exists<KineTechAnimationModuleLoader>(SETTINGS_FILE_NAME))
{
ConfigNode node = new ConfigNode();
node.AddValue("DumpDocumentationOnStartup", false);
node.Save(IOUtils.GetFilePathFor(typeof(KineTechAnimationModuleLoader), SETTINGS_FILE_NAME));
}
if (File.Exists<KineTechAnimationModuleLoader>(SETTINGS_FILE_NAME))
{
ConfigNode node = ConfigNode.Load(
IOUtils.GetFilePathFor(typeof(KineTechAnimationModuleLoader), SETTINGS_FILE_NAME));
if(node == null)
return;
//Dump Documentation
if(node.HasValue("DumpDocumentationOnStartup"))
{
bool working = false;
if(bool.TryParse(node.GetValue("DumpDocumentationOnStartup"), out working))
{
GameObject dumperObject = new GameObject("Kine-Tech Animation - ConfigDocumentationGenerator");
dumperObject.AddComponent<KConfigDocumentationGenerator>();
GameObject.DontDestroyOnLoad(dumperObject);
}
}
}
}
示例4: 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(); }
}
}
示例5: SaveSelectedDefault
public static void SaveSelectedDefault(ConfigNode config, string path)
{
config.AddNode(GetSelectedDefault().CreateConfigNode(true));
config.Save(path);
}
示例6: 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);
}
示例7: SaveDatabase
/// <summary>
/// Saves the engine database to file
/// </summary>
public static void SaveDatabase()
{
#if DEBUG
Debug.Log("[SolverEngines] Saving engine database");
#endif
string dirName = System.IO.Path.GetDirectoryName(configPath);
if (!System.IO.Directory.Exists(dirName))
System.IO.Directory.CreateDirectory(dirName);
ConfigNode saveNode = new ConfigNode();
saveNode.AddNode(database);
saveNode.Save(configPath);
}
示例8: 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();
}
示例9: Save
private void Save()
{
string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)
+ "/SmokeScreen.cfg";
MonoBehaviour.print("SmokeScreenConfig saving config");
ConfigNode topNode = new ConfigNode("SmokeScreen");
ConfigNode node = new ConfigNode("SmokeScreen");
ConfigNode.CreateConfigFromObject(this, node);
topNode.AddNode(node);
topNode.Save(path);
}
示例10: 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);
settings.AddValue("guiResizeUpdates", fetch._guiResizeUpdates);
settings.AddValue("mustBeEngineer", fetch._mustBeEngineer);
settings.AddValue("engineerLevel", fetch._engineerLevel);
if (PresetsLibrary.instance.presets.Count > 0)
{
foreach (Preset preset in PresetsLibrary.instance.presets.Values)
{
settings.AddNode(preset.Save());
}
}
node.AddNode(settings);
node.Save(RCUtils.settingsURL);
Debug.Log("[RealChute]: Saved settings file.");
}