Exemplo n.º 1
0
        private void CheckOptions(ArgumentParser parser)
        {
            if (parser.HasErrors)
            {
                runShutdown = false;
                exitApp     = true;
                Current.Shutdown(1);
            }
            else if (parser.Driverinstall)
            {
                CreateBaseThread();
                WelcomeDialog dialog = new WelcomeDialog(true);
                dialog.ShowDialog();
                runShutdown = false;
                exitApp     = true;
                Current.Shutdown();
            }
            else if (parser.ReenableDevice)
            {
                DS4Devices.ReEnableDevice(parser.DeviceInstanceId);
                runShutdown = false;
                exitApp     = true;
                Current.Shutdown();
            }
            else if (parser.Runtask)
            {
                StartupMethods.LaunchOldTask();
                runShutdown = false;
                exitApp     = true;
                Current.Shutdown();
            }
            else if (parser.Command)
            {
                IntPtr hWndDS4WindowsForm = FindWindow(ReadIPCClassNameMMF(), "DS4Windows");
                if (hWndDS4WindowsForm != IntPtr.Zero)
                {
                    COPYDATASTRUCT cds;
                    cds.lpData = IntPtr.Zero;

                    try
                    {
                        cds.dwData = IntPtr.Zero;
                        cds.cbData = parser.CommandArgs.Length;
                        cds.lpData = Marshal.StringToHGlobalAnsi(parser.CommandArgs);
                        SendMessage(hWndDS4WindowsForm, DS4Forms.MainWindow.WM_COPYDATA, IntPtr.Zero, ref cds);
                    }
                    finally
                    {
                        if (cds.lpData != IntPtr.Zero)
                        {
                            Marshal.FreeHGlobal(cds.lpData);
                        }
                    }
                }

                runShutdown = false;
                exitApp     = true;
                Current.Shutdown();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes the Properties.Settings .NET applications settings.
        /// Used for all settings that we want to persist, even if the user decides to delete the
        /// json settings file or starts AML from different folders.
        /// </summary>
        private static void InitAppSettings()
        {
            var appSettings    = Properties.Settings.Default;
            var currentVersion = GetCurrentVersion().ToString(3);

            // Upgrade settings from previous version if required
            if (appSettings.IsSettingsUpgradeRequired)
            {
                Log.Info($"Upgrading ApplicationSettings from version '{appSettings.Version}' to '{currentVersion}'.");
                appSettings.Upgrade();
                appSettings.IsSettingsUpgradeRequired = false;

                // Show Welcome Dialog and ask user to opt-in for Sentry error reporting
                WelcomeDialog dlg = new WelcomeDialog();
                dlg.ShowDialog();

                appSettings.IsSentryEnabled = dlg.UseSentry;
            }

            // Initialize GUID (used for error reporting)
            if (string.IsNullOrEmpty(appSettings.Guid))
            {
                appSettings.Guid = Guid.NewGuid().ToString();
            }

            // Version information can be used to perform version specific migrations if required.
            if (appSettings.Version != currentVersion)
            {
                // IF required at some point
                appSettings.Version = currentVersion;
            }

            appSettings.Save();
        }
Exemplo n.º 3
0
        private void tsmiAbout_Click(object sender, System.EventArgs e)
        {
            var aForm = new WelcomeDialog(false)
            {
                StartPosition = FormStartPosition.CenterParent
            };

            aForm.ShowDialog(this);
        }
Exemplo n.º 4
0
        private void aboutXrmToolBoxToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            var aForm   = new WelcomeDialog(version, false)
            {
                StartPosition = FormStartPosition.CenterParent
            };

            aForm.ShowDialog(this);
        }
Exemplo n.º 5
0
        private void ShowWelcome()
        {
            WelcomeDialog dlg = new WelcomeDialog();

            dlg.Owner = MainWindow.Window;
            dlg.HorizontalAlignment  = System.Windows.HorizontalAlignment.Center;
            dlg.VerticalAlignment    = System.Windows.VerticalAlignment.Center;
            dlg.ShowWelcomeOnStartup = ViewModel.ShowWelcomeOnStartup;
            dlg.ShowDialog();
            ViewModel.ShowWelcomeOnStartup = dlg.ShowWelcomeOnStartup;
        }
Exemplo n.º 6
0
 private Task LaunchWelcomeDialog()
 {
     return(new Task(() => this.Invoke(new Action(() =>
     {
         var version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
         var blackScreen = new WelcomeDialog(version)
         {
             StartPosition = FormStartPosition.CenterScreen
         };
         blackScreen.ShowDialog(this);
     }))));
 }
Exemplo n.º 7
0
        /// <summary>
        /// Initializes GlobalSettings class.
        /// Used for all settings that we want to persist, even if the user decides to delete the
        /// json settings file or starts AML from different folders.
        /// </summary>
        private static void InitAppSettings()
        {
            var appSettings    = GlobalSettings.Instance;
            var currentVersion = GetCurrentVersion();

            if (appSettings.MaxVersion < currentVersion)
            {
                Log.Info($"AML was upgraded from '{appSettings.MaxVersion}' to '{currentVersion}'.");

                // Show Welcome Dialog and ask user to opt-in for Sentry error reporting.
                WelcomeDialog dlg = new WelcomeDialog();
                dlg.ShowDialog();
                appSettings.IsSentryEnabled = dlg.UseSentry;

                appSettings.MaxVersion = currentVersion;
            }

            appSettings.Save();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Initializes GlobalSettings class.
        /// Used for all settings that we want to persist, even if the user decides to delete the
        /// json settings file or starts AML from different folders.
        /// </summary>
        private static void InitAppSettings()
        {
            var appSettings    = GlobalSettings.Instance;
            var currentVersion = new Version(GitVersionInfo.MajorMinorPatch);

            if (appSettings.MaxVersion < currentVersion)
            {
                appSettings.MaxVersion = currentVersion;
            }

            // AML will either be used for XCOM2 or Chimera Squad
            // Create Steam application id file if it does not exist (depending on game choice of the user)
            if (!File.Exists(Workshop.APPID_FILENAME))
            {
                // Show Welcome Dialog and ask user to opt-in for Sentry error reporting.
                WelcomeDialog dlg = new WelcomeDialog();
                dlg.ShowDialog();
                appSettings.IsSentryEnabled = dlg.UseSentry;

                try
                {
                    using (var file = File.CreateText(Workshop.APPID_FILENAME))
                    {
                        file.WriteLine((uint)dlg.Game);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"Unable to create {Workshop.APPID_FILENAME}. {Environment.NewLine} {ex.Message} ");
                    return;
                }
            }

            // Use Steam Application id file to determine which game this AML installation is used for.
            string appIdStr;

            try
            {
                appIdStr = File.ReadAllText(Workshop.APPID_FILENAME);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Unable to access {Workshop.APPID_FILENAME}. {Environment.NewLine} {ex.Message} ");
                return;
            }

            if (uint.TryParse(appIdStr, out uint appId))
            {
                switch ((GameId)appId)
                {
                case GameId.X2:
                    XEnv = new Xcom2Env();
                    break;

                case GameId.ChimeraSquad:
                    XEnv = new XComChimeraSquadEnv();
                    break;

                default:
                    MessageBox.Show($"The {Workshop.APPID_FILENAME} file contains an unexpected application id: {appId}.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }


            appSettings.Save();
        }
		void window_Loaded(object sender, RoutedEventArgs e)
		{
			var project = MainMenu.AddContainer("Project");
			project.AddAction("New", NewMission);
			project.AddAction("Open", LoadMission);
			project.AddAction("Save", QuickSave);
			project.AddAction("Save As", SaveMission);

            var welcomeScreen = new WelcomeDialog { ShowInTaskbar = true, Owner = this };
            welcomeScreen.ShowDialog();
            if (Mission == null)
            {
                MessageBox.Show("A mission needs to be selected");
                Environment.Exit(0);
            }

            var mission = MainMenu.AddContainer("Mission");
            mission.AddAction("Create Mutator", () => BuildMission());
            mission.AddAction("Create Invisible Mutator", () => BuildMission(true));
            mission.AddAction("Test Mission", TestMission);
            mission.AddAction("Export Localization File", ExportLocalizationFile);
            mission.AddAction("Publish", ShowMissionManagement);
            mission.AddAction("Settings", ShowMissionSettings);

            var newMenu = MainMenu.AddContainer("New");
            newMenu.AddAction("New Trigger", CreateNewTrigger);
            newMenu.AddAction("New Trigger (Repeating)", CreateNewRepeatingTrigger);
            newMenu.AddAction("New Region", CreateNewRegion);
            newMenu.AddAction("Copy Trigger", () => Mission.CopyTrigger(CurrentTrigger));
            newMenu.Items.Add(GetNewConditionMenu(delegate
            {
                if (logicGrid.SelectedItem is Trigger) return CurrentTrigger;
                if (logicGrid.SelectedItem is ActionsFolder) return CurrentActionsFolder.Trigger;
                if (logicGrid.SelectedItem is ConditionsFolder) return CurrentConditionsFolder.Trigger;
                if (logicGrid.SelectedItem is TriggerLogic) return Mission.FindLogicOwner(CurrentLogic);
                return null;
            }));
            newMenu.Items.Add(GetNewActionMenu(() => CurrentTrigger));

            var editMenu = MainMenu.AddContainer("Edit");
            editMenu.AddAction("Rename", RenameCurrentItem);
            editMenu.AddAction("Delete", DeleteCurrentItem);
            editMenu.AddAction("Move Up", () => MoveCurrentItem(MoveDirection.Up));
            editMenu.AddAction("Move Up 5 Spaces", () => MoveCurrentItem(MoveDirection.Up, 5));
            editMenu.AddAction("Move To Top", () => MoveCurrentItem(MoveDirection.Up, true));
            editMenu.AddAction("Move Down", () => MoveCurrentItem(MoveDirection.Down));
            editMenu.AddAction("Move Down 5 Spaces", () => MoveCurrentItem(MoveDirection.Down, 5));
            editMenu.AddAction("Move To Bottom", () => MoveCurrentItem(MoveDirection.Down, true));
            editMenu.AddAction("Expand All Triggers", ExpandAllTriggers);
            editMenu.AddAction("Collapse All Triggers", CollapseAllTriggers);

			var menu = new ContextMenu();
			menu.AddAction("New Trigger", CreateNewTrigger);
			menu.AddAction("New Trigger (Repeating)", CreateNewRepeatingTrigger);
			menu.AddAction("New Region", CreateNewRegion);
			logicGrid.ContextMenu = menu;

            Assembly assembly = Assembly.GetExecutingAssembly();
            FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
            string version = fileVersionInfo.FileVersion;
            var aboutString = String.Format("Mission Editor {0}\n\nby Quantum and KingRaptor\n\nFor help with the program, visit {1}", version, GlobalConst.BaseSiteUrl + "/Wiki/MissionEditorStartPage");
            var help = MainMenu.AddContainer("Help");
            help.AddAction("About", () => MessageBox.Show(aboutString, "About Mission Editor", MessageBoxButton.OK, MessageBoxImage.Information));

            autosaveTimer.Start();
		}