protected override void Init() { Settings = StaticUIPluginSettings.ReadFromFile(PluginSettingsFilePath); SendContentToAll(); Context.RPCClient.Callbacks.PlayerConnect += Callbacks_PlayerConnect; Context.RPCClient.Callbacks.BeginRace += Callbacks_BeginRace; Context.RPCClient.Callbacks.EndRace += Callbacks_EndRace; }
public static StaticUIPluginSettings ReadFromFile(string xmlConfigurationFile) { string settingsDirectory = Path.GetDirectoryName(xmlConfigurationFile); StaticUIPluginSettings result = new StaticUIPluginSettings(); XDocument configDocument = XDocument.Load(xmlConfigurationFile); if (configDocument.Root == null) { throw new ConfigurationErrorsException("Could not find root node in file: " + xmlConfigurationFile); } result.HidOnFinish = ReadConfigBool(configDocument.Root, "HidOnFinish", HIDE_ON_FINISH, xmlConfigurationFile); result.ManiaLinkPageID = ReadConfigString(configDocument.Root, "ManiaLinkPageID", MANIA_LINK_PAGE_ID, xmlConfigurationFile); string contentFile = Path.Combine(settingsDirectory, "Content.xml"); if (!File.Exists(contentFile)) { throw new FileNotFoundException("Could not find file content to display!", contentFile); } result.ManiaLinkPageContent = File.ReadAllText(contentFile); return(result); }