Exemplo n.º 1
0
        protected override void Init()
        {
            Settings          = DedimaniaUISettings.ReadFromFile(PluginSettingsFilePath);
            UpdateListTimer   = new TimedVolatileExecutionQueue <DedimaniaRanking[]>(TimeSpan.FromSeconds(Settings.UpdateInterval));
            UpdateRecordTimer = new TimedVolatileExecutionQueue <object>(TimeSpan.FromSeconds(Settings.UpdateInterval));

            HostPlugin.RankChanged     += HostPlugin_RankChanged;
            HostPlugin.RankingsChanged += HostPlugin_RankingsChanged;
            Context.RPCClient.Callbacks.PlayerConnect += Callbacks_PlayerConnect;
            Context.RPCClient.Callbacks.EndRace       += Callbacks_EndRace;
        }
Exemplo n.º 2
0
        public static DedimaniaUISettings ReadFromFile(string xmlConfigurationFile)
        {
            string settingsDirectory = Path.GetDirectoryName(xmlConfigurationFile);

            DedimaniaUISettings result         = new DedimaniaUISettings();
            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.ShowRecordUI             = ReadConfigBool(configDocument.Root, "ShowDEDUI", SHOW_RECORD_UI, xmlConfigurationFile);
            result.ShowRecordListUI         = ReadConfigBool(configDocument.Root, "ShowDEDListUI", SHOW_RECORD_LIST_UI, xmlConfigurationFile);
            result.HideRecordListUIOnFinish = ReadConfigBool(configDocument.Root, "HideDEDListUIOnFinish", HIDE_RECORD_LIST_UI_ON_FINISH, xmlConfigurationFile);
            result.NoticeDelayInSeconds     = ReadConfigUInt(configDocument.Root, "NoticeDelayInSeconds", NOTICE_DELAY_IN_SECONDS, xmlConfigurationFile);
            result.NewRankMessage           = ReadConfigString(configDocument.Root, "NewDedimaniaRankMessage", NEW_RANK_MESSAGE, xmlConfigurationFile);
            result.ImprovedRankMessage      = ReadConfigString(configDocument.Root, "ImprovedDedimaniaRankMessage", IMPROVED_RANK_MESSAGE, xmlConfigurationFile);
            result.StripNickFormatting      = ReadConfigBool(configDocument.Root, "StripNickFormatting", STRIP_NICK_FORMATTING, xmlConfigurationFile);
            result.StaticModeStartLimit     = ReadConfigUInt(configDocument.Root, "StaticModeStartLimit", STATIC_MODE_START_LIMIT, xmlConfigurationFile);
            result.UpdateInterval           = ReadConfigUInt(configDocument.Root, "UpdateInterval", UPDATE_INTERVAL, xmlConfigurationFile);

            string dediPanelActiveTemplateFile = Path.Combine(settingsDirectory, "DediPanelTemplate.xml");

            result.DediPanelTemplateActive = File.Exists(dediPanelActiveTemplateFile) ? File.ReadAllText(dediPanelActiveTemplateFile) : UITemplates.LowerRightDediRecordPanel;

            result.RecordListPlayerToContainerMarginY = RECORDLIST_PLAYER_TO_CONTAINER_MARGIN_Y;
            result.RecordListPlayerStartMargin        = RECORDLIST_PLAYER_START_MARGIN;
            result.RecordListPlayerEndMargin          = RECORDLIST_PLAYER_END_MARGIN;
            result.RecordListPlayerRecordHeight       = RECORDLIST_PLAYER_RECORD_HEIGHT;
            result.RecordListTop3Gap = RECORDLIST_TOP3_GAP;

            result.RecordListMainTemplate            = UITemplates.RecordListMainTemplate;
            result.RecordListTop3RecordTemplate      = UITemplates.RecordListTop3RecordTemplate;
            result.RecordListRecordTemplate          = UITemplates.RecordListRecordTemplate;
            result.RecordListRecordHighlightTemplate = UITemplates.RecordListRecordHighlightTemplate;

            string recordListTemplateFile = Path.Combine(settingsDirectory, "DedimaniaRecordListTemplate.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);
        }