コード例 #1
0
ファイル: LauncherForm.cs プロジェクト: l1j-en/launcher
        public LauncherForm()
        {
            var appLocation         = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var associatedLaunchers = Helpers.GetAssociatedLaunchers(appLocation);

            if (!Helpers.LauncherInLineageDirectory(appLocation))
            {
                MessageBox.Show("The launcher must be installed in your Lineage directory!\n\n " +
                                @"Please reinstall if you used the installer, or move this file to your lineage directory.", @"Invalid Directory", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                this.Close();
                return;
            }

            // If no launchers are available, let's assume resurrection
            if (associatedLaunchers.Count == 0)
            {
                associatedLaunchers.Add("Lineage Resurrection");
            }

            if (associatedLaunchers.Count > 1)
            {
                MessageBox.Show("More than one launcher associated with this folder! Using the first one found.");
            }

            var launcherConfig = Helpers.GetLauncherConfig(associatedLaunchers[0], appLocation);

            if (launcherConfig == null)
            {
                MessageBox.Show("There was an error loading the config. Please re-install the launcher.");
                this.Close();
                return;
            }

            this._config = launcherConfig;

            if (this._config == null || this._config.Servers == null || this._config.Servers.Count == 0)
            {
                MessageBox.Show(@"No servers configured, contact your server admin. Closing launcher.", @"No Servers Found", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

                this.Load += (s, e) =>
                {
                    this.Close();
                    Application.Exit();
                };
            }

            this._isWin8OrHigher = Helpers.IsWin8OrHigher(out this._windowsVersion);
            InitializeComponent();
            this.BannerBrowser.Url = this._config.NewsUrl;
        }