public LaunchParamsForm(ParamsCollection Params)
        {
            // Create form controls
            InitializeComponent();

            // Set form colors
            this.BackColor      = Color.FromArgb(255, 255, 255);
            groupBox1.BackColor = Color.FromArgb(255, 255, 255);
            groupBox2.BackColor = Color.FromArgb(255, 255, 255);

            // Load a params container
            this.Params = Params;
            foreach (KeyValuePair <string, string> Param in Params.Collection)
            {
                switch (Param.Key.ToLowerInvariant())
                {
                case "fullscreen":
                    WindowedMode.Checked = (Param.Value == "0");
                    break;

                case "szy":
                    HeightText.Text   = Param.Value;
                    CustomRes.Checked = true;
                    break;

                case "szx":
                    WidthText.Text    = Param.Value;
                    CustomRes.Checked = true;
                    break;

                case "restart":
                    Restart.Checked = (Param.Value == "1");
                    break;

                case "disableswiff":
                    DisableSwiff.Checked = (Param.Value == "1");
                    break;

                case "nosound":
                    NoSound.Checked = (Param.Value == "1");
                    break;

                case "lowpriority":
                    LowPriority.Checked = (Param.Value == "1");
                    break;
                }
            }
        }
Пример #2
0
        public MainForm()
        {
            // Create form controls
            InitializeComponent();

            // Set instance
            Instance = this;

            // Make sure the basic configuration settings are setup by the user,
            // and load the BF2 server and installed mods
            if (!SetupManager.Run())
            {
                this.Load += (s, e) => this.Close();
                return;
            }

            // Load Bf2 mods
            LoadModList();

            // Load client settings
            ClientSettings.Load();
            ReloadProviders();
            ReloadServers();

            // Setup theme
            metroStyleManager1.Theme = MetroThemeStyle.Light;
            metroStyleManager1.Style = MetroColorStyle.Blue;

            // Set default texts
            InstallDirTextbox.Text = Program.Config.Bf2InstallDir;

            // Load Redirector
            bool AllSystemsGo = Redirector.Initialize();

            // Select provider if we have redirects detected
            if (Redirector.RedirectsEnabled)
            {
                ServiceProvider Provider;
                if (String.IsNullOrEmpty(Program.Config.LastUsedProvider))
                {
                    Provider = ClientSettings.ServiceProviders
                               .Where(x => x.StatsAddress == Redirector.StatsServerAddress.ToString() &&
                                      x.GamespyAddress == Redirector.GamespyServerAddress.ToString())
                               .FirstOrDefault();
                }
                else
                {
                    Provider = ClientSettings.ServiceProviders
                               .Where(x => x.Name == Program.Config.LastUsedProvider)
                               .FirstOrDefault();
                }

                // Set the last used provider if we have one
                if (Provider != null)
                {
                    ProviderComboBox.SelectedItem = Provider;
                }
            }

            // Set redirect mode
            IcsRadioButton.Checked = false;
            switch (Program.Config.RedirectMode)
            {
            case RedirectMode.HostsIcsFile:
                IcsRadioButton.Checked = true;
                break;

            case RedirectMode.HostsFile:
                HostsRadioButton.Checked = true;
                break;

            case RedirectMode.DnsServer:
                DnsRadioButton.Checked = true;
                break;
            }

            // Set redirect removal
            switch (Program.Config.RedirectRemoveMethod)
            {
            case RedirectRemoveMethod.Never:
                NeverRadioButton.Checked = true;
                break;

            case RedirectRemoveMethod.OnAppClose:
                AppExitsRadioButton.Checked = true;
                break;

            case RedirectRemoveMethod.OnGameClose: break;
            }

            // Auto Login Settings
            CredentialsCheckBox.Checked   = Program.Config.PromptCredentials;
            ProgramUpdateCheckBox.Checked = Program.Config.CheckForUpdates;

            // Load our params
            Params = new ParamsCollection(Program.Config.LaunchParams);
            LaunchParamsTextBox.Text = Params.BuildString(false);

            // Register for events
            BF2Client.PathChanged += LoadModList;
            BF2Client.Started     += BF2Client_Started;
            BF2Client.Exited      += BF2Client_Exited;

            // Focus the mod select first on the Launcher tab!
            MainTabControl.SelectedIndex = 0;

            // Start updater
            if (Program.Config.CheckForUpdates)
            {
                ProgramUpdater.CheckCompleted += ProgramUpdater_CheckCompleted;
                ProgramUpdater.CheckForUpdateAsync();
            }


            // Once the form is shown, asynchronously load the redirect service
            this.Shown += (s, e) =>
            {
                // Focus the mod select combobox
                ModComboBox.Focus();

                // Since we werent registered for Bf2Client events before, do this here
                if (BF2Client.IsRunning)
                {
                    BF2Client_Started();
                }
            };
        }