Beispiel #1
0
        public SourceSplitSettings()
        {
            this.InitializeComponent();

            this.chkAutoSplitEnabled.DataBindings.Add("Checked", this, nameof(this.AutoSplitEnabled), false, DataSourceUpdateMode.OnPropertyChanged);
            this.dmnSplitInterval.DataBindings.Add("Value", this, nameof(this.SplitInterval), false, DataSourceUpdateMode.OnPropertyChanged);
            this.chkShowGameTime.DataBindings.Add("Checked", this, nameof(this.ShowGameTime), false, DataSourceUpdateMode.OnPropertyChanged);
            this.chkAutoStartEndReset.DataBindings.Add("Checked", this, nameof(this.AutoStartEndResetEnabled), false, DataSourceUpdateMode.OnPropertyChanged);

            this.rdoWhitelist.CheckedChanged        += rdoAutoSplitType_CheckedChanged;
            this.rdoInterval.CheckedChanged         += rdoAutoSplitType_CheckedChanged;
            this.chkAutoSplitEnabled.CheckedChanged += UpdateDisabledControls;

            // defaults
            this.lbGameProcesses.Rows.Add("hl2.exe");
            this.lbGameProcesses.Rows.Add("portal2.exe");
            this.lbGameProcesses.Rows.Add("dearesther.exe");
            this.lbGameProcesses.Rows.Add("mm.exe");
            this.lbGameProcesses.Rows.Add("EYE.exe");
            this.SplitInterval            = DEFAULT_SPLITINTERVAL;
            this.AutoSplitType            = DEFAULT_AUTOSPLITYPE;
            this.ShowGameTime             = DEFAULT_SHOWGAMETIME;
            this.AutoSplitEnabled         = DEFAULT_AUTOSPLIT_ENABLED;
            this.AutoStartEndResetEnabled = DEFAULT_AUTOSTARTENDRESET_ENABLED;
            this.GameTimingMethod         = DEFAULT_GAME_TIMING_METHOD;

            this.UpdateDisabledControls(this, EventArgs.Empty);
        }
        public SourceSplitSettings()
        {
            this.InitializeComponent();

            AutoSplitEnabled.Bind(chkAutoSplitEnabled, "Checked"); _settingEntries.Add(AutoSplitEnabled);
            AutoSplitOnGenericMap.Bind(chkSplitGenericMap, "Checked"); _settingEntries.Add(AutoSplitOnGenericMap);
            AutoSplitOnLevelTrans.Bind(chkSplitLevelTrans, "Checked"); _settingEntries.Add(AutoSplitOnLevelTrans);
            AutoSplitOnSpecial.Bind(chkSplitSpecial, "Checked"); _settingEntries.Add(AutoSplitOnSpecial);
            SplitInterval.Bind(dmnSplitInterval, "Value"); _settingEntries.Add(SplitInterval);
            ShowGameTime.Bind(chkShowGameTime, "Checked"); _settingEntries.Add(ShowGameTime);
            ShowAltTime.Bind(chkShowAlt, "Checked"); _settingEntries.Add(ShowAltTime);
            GameTimeDecimalPlaces.Bind(nudDecimalPlaces, "Value"); _settingEntries.Add(GameTimeDecimalPlaces);
            AutoStartEnabled.Bind(chkAutoStart, "Checked"); _settingEntries.Add(AutoStartEnabled);
            AutoStopEnabled.Bind(chkAutoStop, "Checked"); _settingEntries.Add(AutoStopEnabled);
            AutoResetEnabled.Bind(chkAutoReset, "Checked"); _settingEntries.Add(AutoResetEnabled);
            StartMap.Bind(boxStartMap, "Text"); _settingEntries.Add(StartMap);
            ShowTickCount.Bind(chkShowTickCount, "Checked"); _settingEntries.Add(ShowTickCount);
            HoldUntilPause.Bind(chkHoldUntilPause, "Checked"); _settingEntries.Add(HoldUntilPause);
            RTAStartOffset.Bind(chkRTAStartOffset, "Checked"); _settingEntries.Add(RTAStartOffset);
            ServerInitialTicks.Bind(chkServerInitialTicks, "Checked"); _settingEntries.Add(ServerInitialTicks);
            SLPenalty.Bind(nudSLPenalty, "Value"); _settingEntries.Add(SLPenalty);
            SplitInstead.Bind(boxSplitInstead, "Checked"); _settingEntries.Add(SplitInstead);
            ResetMapTransitions.Bind(chkResetMapTransitions, "Checked"); _settingEntries.Add(ResetMapTransitions);

            this.rdoWhitelist.CheckedChanged        += rdoAutoSplitType_CheckedChanged;
            this.rdoInterval.CheckedChanged         += rdoAutoSplitType_CheckedChanged;
            this.chkAutoSplitEnabled.CheckedChanged += UpdateDisabledControls;
            this.chkShowGameTime.CheckedChanged     += UpdateDisabledControls;

            // defaults
            lbGameProcessesSetDefault();
            this.GameTimingMethod = DEFAULT_GAME_TIMING_METHOD;

            this.UpdateDisabledControls(this, EventArgs.Empty);

            // HACKHACK: due to all the data bindings shenanigans, we need to load all the tab pages when opening the settings
            // so just give in...
            this.Load += (e, f) =>
            {
                for (int i = tabCtrlMaster.TabPages.Count - 1; i >= 0; i--)
                {
                    tabCtrlMaster.SelectedIndex = i;
                    Thread.Sleep(1);
                }
            };
        }
Beispiel #3
0
        public void SetSettings(XmlNode settings)
        {
            bool bval;
            int  ival;

            this.AutoSplitEnabled = settings[nameof(this.AutoSplitEnabled)] != null ?
                                    (Boolean.TryParse(settings[nameof(this.AutoSplitEnabled)].InnerText, out bval) ? bval : DEFAULT_AUTOSPLIT_ENABLED)
                : DEFAULT_AUTOSPLIT_ENABLED;

            this.AutoStartEndResetEnabled = settings[nameof(this.AutoStartEndResetEnabled)] != null ?
                                            (Boolean.TryParse(settings[nameof(this.AutoStartEndResetEnabled)].InnerText, out bval) ? bval : DEFAULT_AUTOSTARTENDRESET_ENABLED)
                : DEFAULT_AUTOSTARTENDRESET_ENABLED;

            this.SplitInterval = settings[nameof(this.SplitInterval)] != null ?
                                 (Int32.TryParse(settings[nameof(this.SplitInterval)].InnerText, out ival) ? ival : DEFAULT_SPLITINTERVAL)
                : DEFAULT_SPLITINTERVAL;

            this.ShowGameTime = settings[nameof(this.ShowGameTime)] != null ?
                                (Boolean.TryParse(settings[nameof(this.ShowGameTime)].InnerText, out bval) ? bval : DEFAULT_SHOWGAMETIME)
                : DEFAULT_SHOWGAMETIME;

            GameTimingMethodSetting gtm;

            this.GameTimingMethod = settings[nameof(this.GameTimingMethod)] != null?
                                    Enum.TryParse(settings[nameof(this.GameTimingMethod)].InnerText, out gtm) ? gtm : DEFAULT_GAME_TIMING_METHOD
                                    : DEFAULT_GAME_TIMING_METHOD;

            AutoSplitType splitType;

            this.AutoSplitType = settings[nameof(this.AutoSplitType)] != null ?
                                 (Enum.TryParse(settings[nameof(this.AutoSplitType)].InnerText, out splitType) ? splitType : DEFAULT_AUTOSPLITYPE)
                : AutoSplitType.Interval;
            this.rdoInterval.Checked  = this.AutoSplitType == AutoSplitType.Interval;
            this.rdoWhitelist.Checked = this.AutoSplitType == AutoSplitType.Whitelist;

            this.lbMapWhitelist.Rows.Clear();
            string whitelist = settings[nameof(this.MapWhitelist)]?.InnerText ?? String.Empty;

            foreach (string map in whitelist.Split('|'))
            {
                this.lbMapWhitelist.Rows.Add(map);
            }

            this.lbMapBlacklist.Rows.Clear();
            string blacklist = settings[nameof(this.MapBlacklist)]?.InnerText ?? String.Empty;

            foreach (string map in blacklist.Split('|'))
            {
                this.lbMapBlacklist.Rows.Add(map);
            }

            lock (_lock)
            {
                this.lbGameProcesses.Rows.Clear();
                string gameProcesses = settings[nameof(this.GameProcesses)]?.InnerText ?? String.Empty;
                foreach (string process in gameProcesses.Split('|'))
                {
                    this.lbGameProcesses.Rows.Add(process);
                }
            }
        }