public Editor(Configuration configuration) { m_LauncherButton = new LauncherButton(); m_ToolbarButton = new ToolbarButton(); m_Position = new Rect(0.5f * Screen.width - 200.0f, 0.5f * Screen.height - 250.0f, 400.0f, 450.0f); m_NextButtonTexture = GameDatabase.Instance.GetTexture("KSEA/Historian/Historian_Button_Next", false); m_PreviousButtonTexture = GameDatabase.Instance.GetTexture("KSEA/Historian/Historian_Button_Previous", false); m_EnableLauncherButton = configuration.EnableLauncherButton; m_EnableToolberButton = configuration.EnableToolbarButton; if (m_EnableLauncherButton) { m_LauncherButton.OnTrue += Button_OnTrue; m_LauncherButton.OnFalse += Button_OnFalse; m_LauncherButton.Register(); } if (m_EnableToolberButton) { m_ToolbarButton.OnTrue += Button_OnTrue; m_ToolbarButton.OnFalse += Button_OnFalse; m_ToolbarButton.OnAlternateClick += Button_OnAlternateClick; m_ToolbarButton.Register(); } }
public static Configuration Load(string file) { try { var node = ConfigNode.Load(file).GetNode("KSEA_HISTORIAN_CONFIGURATION"); var configuration = new Configuration(); var version = node.GetVersion("Version", new Version()); configuration.m_Layout = node.GetString("Layout", "Default"); configuration.m_EnableLauncherButton = node.GetBoolean("EnableLauncherButton", true); configuration.m_EnableToolbarButton = node.GetBoolean("EnableToolbarButton", true); configuration.m_CustomText = node.GetString("CustomText", ""); configuration.m_PersistentCustomText = node.GetBoolean("PersistentCustomText", false); configuration.m_PersistentConfigurationWindow = node.GetBoolean("PersistentConfigurationWindow", true); if (version != CurrentVersion) { configuration.Save(file); } return configuration; } catch { Historian.Print("Failed to load configuration file '{0}'. Attempting recovery ...", file); if (File.Exists(file)) { File.Delete(file); } var configuration = new Configuration(); configuration.m_Layout = "Default"; configuration.m_EnableLauncherButton = true; configuration.m_EnableToolbarButton = true; configuration.m_CustomText = ""; configuration.m_PersistentCustomText = false; configuration.m_PersistentConfigurationWindow = true; configuration.Save(file); return configuration; } }