Пример #1
0
        protected override void Init()
        {
            LastRankings = new RankEntry[] { };
            Settings     = LocalRecordsUISettings.ReadFromFile(PluginSettingsFilePath);

            if (Settings.MaxRecordsToShow > HostPlugin.Settings.MaxRecordsToReport)
            {
                Settings.MaxRecordsToShow = HostPlugin.Settings.MaxRecordsToReport;
            }

            UpdateListTimer        = new TimedVolatileExecutionQueue <RankEntry[]>(TimeSpan.FromSeconds(Settings.UpdateInterval));
            UpdateLocalRecordTimer = new TimedVolatileExecutionQueue <string>(TimeSpan.FromSeconds(Settings.UpdateInterval));

            //SendPBManiaLinkPageToAll(null);
            HostPlugin.PlayerNewRecord                += HostPlugin_PlayerNewRecord;
            HostPlugin.LocalRecordsDetermined         += HostPlugin_LocalRecordsDetermined;
            HostPlugin.PlayerWins                     += HostPlugin_PlayerWins;
            Context.RPCClient.Callbacks.EndRace       += Callbacks_EndRace;
            Context.RPCClient.Callbacks.PlayerConnect += Callbacks_PlayerConnect;
            Context.RPCClient.Callbacks.PlayerChat    += Callbacks_PlayerChat;
        }
Пример #2
0
        public static LocalRecordsUISettings ReadFromFile(string xmlConfigurationFile)
        {
            string settingsDirectory = Path.GetDirectoryName(xmlConfigurationFile);

            LocalRecordsUISettings result = new LocalRecordsUISettings();
            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.ShowMessages                     = ReadConfigBool(configDocument.Root, "ShowMessages", SHOW_MESSAGES, xmlConfigurationFile);
            result.ShowPBUserInterface              = ReadConfigBool(configDocument.Root, "ShowPBUI", SHOW_PB_RECORD_UI, xmlConfigurationFile);
            result.ShowLocalRecordUserInterface     = ReadConfigBool(configDocument.Root, "ShowLRUI", SHOW_LOCAL_RECORD_UI, xmlConfigurationFile);
            result.ShowLocalRecordListUserInterface = ReadConfigBool(configDocument.Root, "ShowLRListUI", SHOW_LOCAL_RECORD_LIST_UI, xmlConfigurationFile);
            result.HideRecordListUIOnFinish         = ReadConfigBool(configDocument.Root, "HideLRListUIOnFinish", HIDE_RECORD_LIST_UI_ON_FINISH, xmlConfigurationFile);
            result.FirstLocalRankMessage            = ReadConfigString(configDocument.Root, "FirstLocalRankMessage", FIRST_LOCAL_RANK_MESSAGE, xmlConfigurationFile);
            result.NewLocalRankMessage              = ReadConfigString(configDocument.Root, "NewLocalRankMessage", NEW_LOCAL_RANK_MESSAGE, xmlConfigurationFile);
            result.ImprovedLocalRankMessage         = ReadConfigString(configDocument.Root, "ImprovedLocalRankMessage", IMPROVED_LOCAL_RANK_MESSAGE, xmlConfigurationFile);
            result.WinMessage            = ReadConfigString(configDocument.Root, "WinMessage", WIN_MESSAGE, xmlConfigurationFile);
            result.InfoMessage           = ReadConfigString(configDocument.Root, "InfoMessage", INFO_MESSAGE, xmlConfigurationFile);
            result.RankingMessage        = ReadConfigString(configDocument.Root, "RankingMessage", RANKING_MESSAGE, xmlConfigurationFile);
            result.NextRankMessage       = ReadConfigString(configDocument.Root, "NextRankMessage", NEXT_RANK_MESSAGE, xmlConfigurationFile);
            result.NoBetterRankMessage   = ReadConfigString(configDocument.Root, "NoBetterRankMessage", NO_BETTER_RANK_MESSAGE, xmlConfigurationFile);
            result.NoticeDelayInSeconds  = ReadConfigUInt(configDocument.Root, "NoticeDelayInSeconds", NOTICE_DELAY_IN_SECONDS, xmlConfigurationFile);
            result.StripNickFormatting   = ReadConfigBool(configDocument.Root, "StripNickFormatting", STRIP_NICK_FORMATTING, xmlConfigurationFile);
            result.UpdateInterval        = ReadConfigUInt(configDocument.Root, "UpdateInterval", UPDATE_INTERVAL, xmlConfigurationFile);
            result.StaticModeStartLimit  = ReadConfigUInt(configDocument.Root, "StaticModeStartLimit", STATIC_MODE_START_LIMIT, xmlConfigurationFile);
            result.LastSeenMessage       = ReadConfigString(configDocument.Root, "LastSeenMessage", LAST_SEEN_MESSAGE, xmlConfigurationFile);
            result.PlayerOnServerMessage = ReadConfigString(configDocument.Root, "PlayerOnServerMessage", PLAYER_ON_SERVER_MESSAGE, xmlConfigurationFile);

            string pbPanelTemplateFile = Path.Combine(settingsDirectory, "PBPanelTemplate.xml");

            result.PBPanelTemplate = File.Exists(pbPanelTemplateFile) ? File.ReadAllText(pbPanelTemplateFile) : UITemplates.LowerRightPBRecordPanelActive;

            string localRecordPanelTemplateFile = Path.Combine(settingsDirectory, "LocalRecordPanelTemplate.xml");

            result.LocalRecordPanelTemplate = File.Exists(localRecordPanelTemplateFile) ? File.ReadAllText(localRecordPanelTemplateFile) : UITemplates.LowerRightLocalRecordPanelActive;


            string recordListTemplateFile = Path.Combine(settingsDirectory, "LocalRecordsListTemplate.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.RecordListPlayerStartMargin        = ReadConfigDouble(listTemplateDocument.Root, "PlayerStartMargin", result.RecordListPlayerStartMargin, recordListTemplateFile);
                result.RecordListTop3Gap                  = ReadConfigDouble(listTemplateDocument.Root, "Top3Gap", result.RecordListTop3Gap, recordListTemplateFile);
                result.RecordListPlayerRecordHeight       = ReadConfigDouble(listTemplateDocument.Root, "PlayerRecordHeight", result.RecordListPlayerRecordHeight, recordListTemplateFile);
                result.RecordListPlayerEndMargin          = ReadConfigDouble(listTemplateDocument.Root, "PlayerEndMargin", result.RecordListPlayerEndMargin, recordListTemplateFile);
                result.RecordListPlayerToContainerMarginY = ReadConfigDouble(listTemplateDocument.Root, "PlayerToContainerMarginY", result.RecordListPlayerToContainerMarginY, recordListTemplateFile);

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

                if (templatesElement != null)
                {
                    result.RecordListMainTemplate            = ReadConfigString(templatesElement, "MainTemplate", result.RecordListMainTemplate, recordListTemplateFile);
                    result.RecordListTop3RecordTemplate      = ReadConfigString(templatesElement, "Top3RecordTemplate", result.RecordListTop3RecordTemplate, recordListTemplateFile);
                    result.RecordListRecordTemplate          = ReadConfigString(templatesElement, "RecordTemplate", result.RecordListRecordTemplate, recordListTemplateFile);
                    result.RecordListRecordHighlightTemplate = ReadConfigString(templatesElement, "RecordHighlightTemplate", result.RecordListRecordHighlightTemplate, recordListTemplateFile);
                }
            }

            return(result);
        }