public static void RemoveReadoutConfig(ReadoutModule readout) { try { SettingHandler handler = SettingHandler.Load("ReadoutsConfig.xml", new Type[] { typeof(ReadoutModuleConfigNode) }); var r = handler.Get <ReadoutModuleConfigNode>(readout.Name, null); if (r == null) { return; } handler.Items.Remove(handler.Items.Find(i => i.Name == readout.Name)); handler.Save("ReadoutsConfig.xml"); } catch (Exception ex) { MyLogger.Exception(ex); } }
public static void SaveReadoutConfig(ReadoutModule readout) { try { SettingHandler handler = SettingHandler.Load("ReadoutsConfig.xml", new Type[] { typeof(ReadoutModuleConfigNode) }); var r = handler.Get <ReadoutModuleConfigNode>(readout.Name, null); if (r == null) { r = new ReadoutModuleConfigNode(); } r.Name = readout.Name; r.Color = readout.ValueStyle.normal.textColor; handler.Set(r.Name, r); handler.Save("ReadoutsConfig.xml"); } catch (Exception ex) { MyLogger.Exception(ex); } }
private void ShowHelpMessage(ReadoutModule readout) { if (!readout.ShowHelp) { return; } GUILayout.BeginVertical(this.helpBoxStyle); GUILayout.Label(!String.IsNullOrEmpty(readout.HelpString) ? readout.HelpString : "Sorry, no help information has been provided for this readout module.", this.helpTextStyle); GUILayout.EndVertical(); }
/// <summary> /// Initialises all the styles required for this object. /// </summary> private void InitialiseStyles(bool force) { if (NameStyle != null && !force) { return; } ReadoutModule existing = ReadoutLibrary.GetReadout(this.Name); Color c = HighLogic.Skin.label.normal.textColor; if (existing != null) { c = existing.ValueStyle.normal.textColor; } NameStyle = new GUIStyle(HighLogic.Skin.label) { normal = { textColor = Color.white }, margin = new RectOffset(), padding = new RectOffset(5, 0, 0, 0), alignment = TextAnchor.MiddleLeft, fontSize = (int)(11 * GuiDisplaySize.Offset), fontStyle = FontStyle.Bold, fixedHeight = 20.0f * GuiDisplaySize.Offset }; ValueStyle = new GUIStyle(HighLogic.Skin.label) { margin = new RectOffset(), padding = new RectOffset(0, 5, 0, 0), alignment = TextAnchor.MiddleRight, fontSize = (int)(11 * GuiDisplaySize.Offset), fontStyle = FontStyle.Normal, fixedHeight = 20.0f * GuiDisplaySize.Offset, }; MessageStyle = new GUIStyle(HighLogic.Skin.label) { normal = { textColor = Color.white }, margin = new RectOffset(), padding = new RectOffset(), alignment = TextAnchor.MiddleCenter, fontSize = (int)(11 * GuiDisplaySize.Offset), fontStyle = FontStyle.Normal, fixedHeight = 20.0f * GuiDisplaySize.Offset, stretchWidth = true }; FlexiLabelStyle = new GUIStyle(NameStyle) { fixedWidth = 0, stretchWidth = true }; ButtonStyle = new GUIStyle(HighLogic.Skin.button) { normal = { textColor = Color.white }, margin = new RectOffset(0, 0, 1, 1), padding = new RectOffset(), alignment = TextAnchor.MiddleCenter, fontSize = (int)(11 * GuiDisplaySize.Offset), fixedHeight = 18.0f * GuiDisplaySize.Offset }; CompactButtonStyle = new GUIStyle(ButtonStyle) { fontSize = (int)(10 * GuiDisplaySize.Offset), margin = new RectOffset(0, 0, 5, 5), fixedHeight = ButtonStyle.fontSize }; TextFieldStyle = new GUIStyle(HighLogic.Skin.textField) { margin = new RectOffset(0, 0, 1, 1), padding = new RectOffset(5, 5, 0, 0), alignment = TextAnchor.MiddleLeft, fontSize = (int)(11 * GuiDisplaySize.Offset), fixedHeight = 18.0f * GuiDisplaySize.Offset }; this.ValueStyle.normal.textColor = c; }