private async Task ArgumentHandler(string[] args)
        {
            Arguments = string.Join(" ", args);
            while (args.Length > 0)
            {
                switch (args[0])
                {
                case "--install":
                    if (args.Length < 2 || string.IsNullOrEmpty(args[1]))
                    {
                        Utils.SendNotify(string.Format((string)Current.FindResource("App:InvalidArgument"), "--install"));
                    }
                    else
                    {
                        await OneClickInstaller.InstallAsset(args[1]);
                    }

                    if (CloseWindowOnFinish)
                    {
                        await Task.Delay(5 * 1000);

                        Current.Shutdown();
                    }

                    Update = false;
                    GUI    = false;
                    args   = Shift(args, 2);
                    break;

                case "--no-update":
                    Update = false;
                    args   = Shift(args);
                    break;

                case "--language":
                    if (args.Length < 2 || string.IsNullOrEmpty(args[1]))
                    {
                        Utils.SendNotify(string.Format((string)Current.FindResource("App:InvalidArgument"), "--language"));
                    }
                    else
                    {
                        Languages.LoadLanguage(args[1]);
                    }

                    args = Shift(args, 2);
                    break;

                case "--register":
                    if (args.Length < 2 || string.IsNullOrEmpty(args[1]))
                    {
                        Utils.SendNotify(string.Format((string)Current.FindResource("App:InvalidArgument"), "--register"));
                    }
                    else
                    {
                        OneClickInstaller.Register(args[1], true);
                    }

                    Update = false;
                    GUI    = false;
                    args   = Shift(args, 2);
                    break;

                case "--unregister":
                    if (args.Length < 2 || string.IsNullOrEmpty(args[1]))
                    {
                        Utils.SendNotify(string.Format((string)Current.FindResource("App:InvalidArgument"), "--unregister"));
                    }
                    else
                    {
                        OneClickInstaller.Unregister(args[1], true);
                    }

                    Update = false;
                    GUI    = false;
                    args   = Shift(args, 2);
                    break;

                case "--runforever":
                    while (true)
                    {
                    }

                default:
                    Utils.SendNotify((string)Current.FindResource("App:UnrecognizedArgument"));
                    args = Shift(args);
                    break;
                }
            }
        }
Beispiel #2
0
        public MainWindow()
        {
            InitializeComponent();
            Instance = this;

            const int ContentWidth  = 1280;
            const int ContentHeight = 720;

            double ChromeWidth  = SystemParameters.WindowNonClientFrameThickness.Left + SystemParameters.WindowNonClientFrameThickness.Right;
            double ChromeHeight = SystemParameters.WindowNonClientFrameThickness.Top + SystemParameters.WindowNonClientFrameThickness.Bottom;
            double ResizeBorder = SystemParameters.ResizeFrameVerticalBorderWidth;

            Width  = ChromeWidth + ContentWidth + 2 * ResizeBorder;
            Height = ChromeHeight + ContentHeight + 2 * ResizeBorder;

            VersionText.Text = App.Version;

            if (Utils.IsVoid())
            {
                Main.Content = Invalid.Instance;
                MainWindow.Instance.ModsButton.IsEnabled      = false;
                MainWindow.Instance.OptionsButton.IsEnabled   = false;
                MainWindow.Instance.IntroButton.IsEnabled     = false;
                MainWindow.Instance.AboutButton.IsEnabled     = false;
                MainWindow.Instance.GameVersionsBox.IsEnabled = false;
                return;
            }

            Themes.LoadThemes();
            Themes.FirstLoad(Properties.Settings.Default.SelectedTheme);

            Languages.LoadLanguages();

            Task.Run(() => LoadVersionsAsync());

            if (!Properties.Settings.Default.Agreed || string.IsNullOrEmpty(Properties.Settings.Default.LastTab))
            {
                Main.Content = Intro.Instance;
            }
            else
            {
                switch (Properties.Settings.Default.LastTab)
                {
                case "Intro":
                    Main.Content = Intro.Instance;
                    break;

                case "Mods":
                    _ = ShowModsPage();
                    break;

                case "About":
                    Main.Content = About.Instance;
                    break;

                case "Options":
                    Main.Content = Options.Instance;
                    Themes.LoadThemes();
                    break;

                default:
                    Main.Content = Intro.Instance;
                    break;
                }
            }
        }