void OnGameSettingsApplied() { Main.Log.Info("GameEvent.OnGameSettingsApplied"); if (HighLogic.CurrentGame.Parameters.CustomParams <RM_3>().resetCommon) { Scenario_Module.ResetDefaultRMD(); HighLogic.CurrentGame.Parameters.CustomParams <RM_3>().resetCommon = false; ScreenMessages.PostScreenMessage("Common Resource Monitors have been reset to the default settings", 15); } }
void LoadDefaults() { Log.Info("LoadDefaults, file: " + dataFile + " exists: " + File.Exists(dataFile).ToString()); if (!File.Exists(dataFile)) { return; } initialDefaultRMD = new List <ResourceMonitorDef>(); ConfigNode defaults = ConfigNode.Load(dataFile); ConfigNode r = defaults.GetNode(DEF_NODENAME); if (r.HasNode(DEF_DEFAULT_NODENAME)) { ConfigNode resAlertnode = r.GetNode(DEF_DEFAULT_NODENAME); var resNodes = resAlertnode.GetNodes(RESNODE); foreach (var resNode in resNodes) { ResourceMonitorDef defaultResource = new ResourceMonitorDef(); resNode.TryGetValue(VAL_RESNAME, ref defaultResource.resname); if (!defaultResource.SetResource(defaultResource.resname)) { Log.Error("defaultResource.resname (" + defaultResource.resname + ") not set correctly"); } resNode.TryGetValue(VAL_MONITOR, ref defaultResource.monitorByPercentage); resNode.TryGetValue(VAL_PERCENT, ref defaultResource.percentage); resNode.TryGetValue(VAL_AMT, ref defaultResource.minAmt); resNode.TryGetValue(VAL_ALARM, ref defaultResource.alarm); resNode.TryGetValue(VAL_ENABLED, ref defaultResource.Enabled); initialDefaultRMD.Add(defaultResource); Log.Info("Default resource loaded: " + defaultResource.resname); } } Scenario_Module.ResetDefaultRMD(); if (r.HasNode(DEF_COMMON_NODENAME)) { ConfigNode common = r.GetNode(DEF_COMMON_NODENAME); string[] resourceNodes = common.GetValues("resource"); if (resourceNodes.Length > 0) { commonResources = resourceNodes; foreach (var rrr in commonResources) { Log.Info("CommonResource loaded: " + rrr); } } } }