示例#1
0
        public static LiveRankingsSettings ReadFromFile(string xmlConfigurationFile)
        {
            string settingsDirectory            = Path.GetDirectoryName(xmlConfigurationFile);
            LiveRankingsSettings result         = new LiveRankingsSettings();
            XDocument            configDocument = XDocument.Load(xmlConfigurationFile);

            if (configDocument.Root == null)
            {
                throw new ConfigurationErrorsException("Could not find root node in file: " + xmlConfigurationFile);
            }

            result.MaxRecordsToShow     = ReadConfigUInt(configDocument.Root, "MaxRecordsToShow", MAX_RECORDS_TO_SHOW, xmlConfigurationFile);
            result.UpdateInterval       = ReadConfigUInt(configDocument.Root, "UpdateIntervalInSeconds", UPDATE_INTERVAL_IN_SECONDS, xmlConfigurationFile);
            result.StripNickFormatting  = ReadConfigBool(configDocument.Root, "StripNickFormatting", STRIP_NICK_FORMATTING, xmlConfigurationFile);
            result.StaticModeStartLimit = ReadConfigUInt(configDocument.Root, "StaticModeStartLimit", STATIC_MODE_START_LIMIT, xmlConfigurationFile);

            result.RankingPlayerToContainerMarginY = RANKING_PLAYER_TO_CONTAINER_MARGIN_Y;
            result.RankingPlayerStartMargin        = RANKING_PLAYER_START_MARGIN;
            result.RankingPlayerEndMargin          = RANKING_PLAYER_END_MARGIN;
            result.RankingPlayerRecordHeight       = RANKING_PLAYER_RECORD_HEIGHT;
            result.RankingTop3Gap = RANKING_TOP3_GAP;

            result.RankingListTemplate       = UITemplates.RankingListTemplate;
            result.RankingTop3RecordTemplate = UITemplates.RankingTop3RecordTemplate;
            result.RankingTemplate           = UITemplates.RankingTemplate;
            result.RankingHighlightTemplate  = UITemplates.RankingHighlightTemplate;

            string recordListTemplateFile = Path.Combine(settingsDirectory, "LiveRankingListTemplate.xml");

            if (File.Exists(recordListTemplateFile))
            {
                XDocument listTemplateDocument = XDocument.Load(recordListTemplateFile);

                if (listTemplateDocument.Root == null)
                {
                    throw new ConfigurationErrorsException("Could not find root node in file: " + listTemplateDocument);
                }

                result.RankingPlayerStartMargin        = ReadConfigDouble(listTemplateDocument.Root, "PlayerStartMargin", result.RankingPlayerStartMargin, recordListTemplateFile);
                result.RankingTop3Gap                  = ReadConfigDouble(listTemplateDocument.Root, "Top3Gap", result.RankingTop3Gap, recordListTemplateFile);
                result.RankingPlayerRecordHeight       = ReadConfigDouble(listTemplateDocument.Root, "PlayerRecordHeight", result.RankingPlayerRecordHeight, recordListTemplateFile);
                result.RankingPlayerEndMargin          = ReadConfigDouble(listTemplateDocument.Root, "PlayerEndMargin", result.RankingPlayerEndMargin, recordListTemplateFile);
                result.RankingPlayerToContainerMarginY = ReadConfigDouble(listTemplateDocument.Root, "PlayerToContainerMarginY", result.RankingPlayerToContainerMarginY, recordListTemplateFile);

                XElement templatesElement = listTemplateDocument.Root.Element("Templates");

                if (templatesElement != null)
                {
                    result.RankingListTemplate       = ReadConfigString(templatesElement, "MainTemplate", result.RankingListTemplate, recordListTemplateFile);
                    result.RankingTop3RecordTemplate = ReadConfigString(templatesElement, "Top3RecordTemplate", result.RankingTop3RecordTemplate, recordListTemplateFile);
                    result.RankingTemplate           = ReadConfigString(templatesElement, "RecordTemplate", result.RankingTemplate, recordListTemplateFile);
                    result.RankingHighlightTemplate  = ReadConfigString(templatesElement, "RecordHighlightTemplate", result.RankingHighlightTemplate, recordListTemplateFile);
                }
            }

            return(result);
        }
示例#2
0
        protected override void Init()
        {
            PodiumStage  = false;
            Settings     = LiveRankingsSettings.ReadFromFile(PluginSettingsFilePath);
            LastRankings = new PlayerRank[] {};
            UpdateUI(this);
            UpdateTimer = new TimedVolatileExecutionQueue <LiveRankingPlugin>(TimeSpan.FromSeconds(Settings.UpdateInterval));

            Context.RPCClient.Callbacks.PlayerConnect += Callbacks_PlayerConnect;
            Context.RPCClient.Callbacks.BeginRace     += Callbacks_BeginRace;
            Context.RPCClient.Callbacks.EndRace       += Callbacks_EndRace;
            Context.RPCClient.Callbacks.PlayerFinish  += Callbacks_PlayerFinish;
        }