Example #1
0
        public async Task <bool> StartDebug(EditorViewModel editor, ProjectViewModel currentProject, LoggerResult logger)
        {
            if (currentProject == null)
            {
                await editor.Session.Dialogs.MessageBox(Tr._p("Message", "An executable project must be set as current project in the session explorer in order to process build."),
                                                        MessageBoxButton.OK, MessageBoxImage.Information);

                return(false);
            }

            try
            {
                var projectWatcher = new ProjectWatcher(currentProject.Session, false);
                await projectWatcher.Initialize();

                var executableOutputPath = Path.GetDirectoryName(projectWatcher.CurrentGameExecutable.OutputFilePath);

                var debuggerProcess = await GetDebuggerProcess(editor);

                var projectCouldFirstCompile = new TaskCompletionSource <bool>();
                Task.Run(() => StartDebugHost(executableOutputPath, projectWatcher, projectCouldFirstCompile, RecompilationDelay, debuggerProcess, logger)).Forget();

                return(await projectCouldFirstCompile.Task);
            }
            catch
            {
                return(false);
            }
        }
        private async void ButtonOk(object sender, RoutedEventArgs e)
        {
            if (!SelectedPlatforms.Any())
            {
                await services.Get <IDialogService>().MessageBox(Tr._p("Message", "You must select at least one platform."), MessageBoxButton.OK, MessageBoxImage.Information);

                return;
            }

            if (AvailablePlatforms.Any(x => x.MarkedToRemove))
            {
                var buttons = DialogHelper.CreateButtons(new[]
                {
                    Tr._p("Button", "Remove"),
                    Tr._p("Button", "Cancel")
                }, 1, 2);
                var msg    = string.Format(Tr._p("Message", "Are you sure you want to remove these {0} platform(s) from the package?"), AvailablePlatforms.Count(x => x.MarkedToRemove));
                var result = await services.Get <IDialogService>().MessageBox(msg, buttons, MessageBoxImage.Question);

                if (result != 1)
                {
                    return;
                }

                Result = Stride.Core.Presentation.Services.DialogResult.Ok;
                Close();
                return;
            }

            Result = Stride.Core.Presentation.Services.DialogResult.Ok;
            Close();
        }
 public ProjectSelectionWindow()
 {
     InitializeComponent();
     Width  = Math.Min(Width, SystemParameters.WorkArea.Width);
     Height = Math.Min(Height, SystemParameters.WorkArea.Height);
     Title  = string.Format(Tr._p("Title", "Project selection - {0}"), EditorPath.EditorTitle);
 }
        protected virtual bool IsValidName(string value, out string error)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            if (value.Length > 240)
            {
                error = Tr._p("Message", "The name is too long.");
                return(false);
            }

            if (value.Contains(UPath.DirectorySeparatorChar) || value.Contains(UPath.DirectorySeparatorCharAlt) || !UPath.IsValid(value))
            {
                error = Tr._p("Message", "The name contains invalid characters.");
                return(false);
            }

            if (string.IsNullOrEmpty(value))
            {
                error = Tr._p("Message", "The name is empty.");
                return(false);
            }

            error = null;

            return(true);
        }
Example #5
0
 static ThemesSettings()
 {
     ThemeName = new SettingsKey <ThemeType>("Themes/ThemeName", EditorSettings.SettingsContainer, ThemeType.ExpressionDark)
     {
         DisplayName = $"{Themes}/{Tr._p("Settings", "Theme Name")}"
     };
 }
Example #6
0
        private async Task Explore()
        {
            try
            {
                var path       = GetSpriteInfo().Source;
                var stringPath = path?.ToString().Replace('/', '\\') ?? "";
                if (!File.Exists(stringPath))
                {
                    await ServiceProvider.Get <IDialogService>().MessageBox(Tr._p("Message", "Couldn't find the file"), MessageBoxButton.OK, MessageBoxImage.Information);

                    return;
                }

                var startInfo = new ProcessStartInfo("explorer.exe", "/select," + stringPath)
                {
                    UseShellExecute = true
                };
                var explorer = new Process {
                    StartInfo = startInfo
                };
                explorer.Start();
            }
            catch (Exception ex)
            {
                var message = string.Format(Tr._p("Message", "There was a problem opening Explorer.{0}"), ex.FormatSummary(true));
                await ServiceProvider.Get <IDialogService>().MessageBox(message, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #7
0
        /// <summary>
        /// Display error message associated to <seealso cref="CredentialError"/>.
        /// </summary>
        private void DisplayError()
        {
            string message;
            var    messageBoxImage = MessageBoxImage.Error;

            switch (lastError)
            {
            case CredentialError.None:
                messageBoxImage = MessageBoxImage.Information;
                message         = Tr._p("Credentials", "Your credentials are correct.");
                break;

            case CredentialError.InvalidHost:
                message = Tr._p("Credentials", "Couldn't reach the specified host.");
                break;

            case CredentialError.InvalidUserOrPassword:
                message = Tr._p("Credentials", "Invalid credentials.");
                break;

            case CredentialError.InvalidPath:
                message = Tr._p("Credentials", "The location you specified doesn't exist.");
                break;

            default:
                message = Tr._p("Credentials", "An unknown error occurred.");
                break;
            }
            Service.MessageBox(message, MessageBoxButton.OK, messageBoxImage);
        }
Example #8
0
        private bool CanUpdateName([CanBeNull] string newName)
        {
            // empty names are not allowed
            if (string.IsNullOrWhiteSpace(newName))
            {
                return(false);
            }

            // folder separator is not allowed
            if (newName.Contains(FolderSeparator))
            {
                return(false);
            }

            // check for name collision
            if (Parent == null)
            {
                throw new InvalidOperationException($"{nameof(Parent)} cannot be null");
            }
            var canRename = Parent.Folders.All(x => x == this || !string.Equals(x.Name, newName, FolderCase));

            if (!canRename)
            {
                ServiceProvider.Get <IDialogService>()
                .BlockingMessageBox(string.Format(Tr._p("Message", "Unable to rename the folder '{0}' to '{1}'. A folder with the same name already exists."), name, newName), MessageBoxButton.OK,
                                    MessageBoxImage.Information);
            }
            return(canRename);
        }
Example #9
0
        private async void ButtonOk(object sender, RoutedEventArgs e)
        {
            if (Orientation == DisplayOrientation.Default)
            {
                await services.Get <IDialogService>().MessageBox(Tr._p("Message", "Select an orientation."), MessageBoxButton.OK, MessageBoxImage.Information);

                return;
            }
            if (!SelectedPlatforms.Any())
            {
                await services.Get <IDialogService>().MessageBox(Tr._p("Message", "Select at least one platform."), MessageBoxButton.OK, MessageBoxImage.Information);

                return;
            }

            string error;

            if (!NamingHelper.IsValidNamespace(Namespace, out error))
            {
                await services.Get <IDialogService>().MessageBox(string.Format(Tr._p("Message", "Type a valid namespace name. Error with {0}"), error), MessageBoxButton.OK, MessageBoxImage.Information);

                return;
            }

            Result = Stride.Core.Presentation.Services.DialogResult.Ok;
            Close();
        }
Example #10
0
        public async Task OpenFile(string filePath, bool tryEdit)
        {
            try
            {
                filePath = filePath.Replace('/', '\\');
                if (!File.Exists(filePath))
                {
                    await ServiceProvider.Get <IDialogService>().MessageBox(Tr._p("Message", "You need to save the file before you can open it."), MessageBoxButton.OK, MessageBoxImage.Information);

                    return;
                }

                var process = new Process {
                    StartInfo = new ProcessStartInfo(filePath)
                    {
                        UseShellExecute = true
                    }
                };
                if (tryEdit)
                {
                    process.StartInfo.Verb = process.StartInfo.Verbs.FirstOrDefault(x => x.ToLowerInvariant() == "edit");
                }
                process.Start();
            }
            catch (Exception ex)
            {
                var message = $"{Tr._p("Message", "An error occurred while opening the file.")}{ex.FormatSummary(true)}";
                await ServiceProvider.Get <IDialogService>().MessageBox(message, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #11
0
        private async Task ResetAllLayouts()
        {
            var assets = assetEditorsManager.OpenedAssets.Select(x => x.Id).ToList();

            if (assets.Count > 0)
            {
                var message = Tr._p("Message", "To reset the layout, Game Studio needs to close and re-open all asset and document editors. You won't lose unsaved changes.");
                var buttons = DialogHelper.CreateButtons(new[] { "Reset layout", "Cancel" }, 1, 2);
                var result  = await Editor.ServiceProvider.Get <IEditorDialogService>().MessageBox(message, buttons);

                if (result != 1)
                {
                    return;
                }
            }

            // Close all editors
            assetEditorsManager.CloseAllEditorWindows(null);

            // Check if user cancelled closing some of the editors.
            if (assetEditorsManager.OpenedAssets.Any())
            {
                return;
            }

            // Safely reset layout
            dockingLayout.ResetAllLayouts();

            // Reopen editors
            await ReopenAssetEditors(assets);
        }
Example #12
0
        private async Task EditImage()
        {
            try
            {
                var path       = GetSpriteInfo().Source;
                var stringPath = path?.ToString().Replace('/', '\\') ?? "";
                if (!File.Exists(stringPath))
                {
                    await ServiceProvider.Get <IDialogService>().MessageBox(Tr._p("Message", "Couldn't find the file"), MessageBoxButton.OK, MessageBoxImage.Information);

                    return;
                }

                var process = new Process {
                    StartInfo = new ProcessStartInfo(stringPath)
                    {
                        UseShellExecute = true
                    }
                };
                process.StartInfo.Verb = process.StartInfo.Verbs.FirstOrDefault(x => x.ToLowerInvariant() == "edit");
                process.Start();
            }
            catch (Exception ex)
            {
                var message = string.Format(Tr._p("Message", "There was a problem while editing the image.{0}"), ex.FormatSummary(true));
                await ServiceProvider.Get <IDialogService>().MessageBox(message, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #13
0
        private static string GetGamepadSourceName(Gamepad gamepad, int index)
        {
            var baseName   = Tr._("Gamepad");
            var deviceName = gamepad.name ?? Tr._p("device name", "Unknown");

            return($"{baseName} '{deviceName}' ({index + 1})");
        }
Example #14
0
 static ScriptEditorSettings()
 {
     // Note: assignment cannot be moved to initializer, because category names need to be assigned first.
     FontSize = new SettingsKey <int>("ScriptEditor/FontSize", Stride.Core.Assets.Editor.Settings.EditorSettings.SettingsContainer, 12)
     {
         DisplayName = $"{ScriptEditor}/{Tr._p("Settings", "Font size")}"
     };
 }
Example #15
0
 static UIEditorSettings()
 {
     // Note: assignments cannot be moved to initializer, because category names need to be assigned first.
     AskBeforeDeletingUIElements = new SettingsKey <bool>("UIEditor/AskBeforeDeletingUIElements", Stride.Core.Assets.Editor.Settings.EditorSettings.SettingsContainer, true)
     {
         DisplayName = $"{UIEditor}/{Tr._p("Settings", "Ask before deleting UI elements")}"
     };
 }
Example #16
0
 public override bool CanDelete(out string error)
 {
     error = "";
     if (!IsEditable)
     {
         error = Tr._p("Message", "This package that contains this folder can't be edited.");
     }
     return(IsEditable);
 }
Example #17
0
        private static async Task <bool> CheckCanOpenSolution(SessionViewModel session)
        {
            if (string.IsNullOrEmpty(session.SolutionPath))
            {
                await session.Dialogs.MessageBox(Tr._p("Message", "The session currently open is not a Visual Studio session."), MessageBoxButton.OK, MessageBoxImage.Information);

                return(false);
            }
            return(true);
        }
Example #18
0
        /// <summary>
        /// Invokes the given template generator safely. The generator will be prepared on the calling thread, and run from
        /// a task. This methods will catch and log all exceptions occurring during the template generation.
        /// </summary>
        /// <param name="generator">The template generator to run.</param>
        /// <param name="parameters">The parameters for the template generator.</param>
        /// <param name="workProgress">The view model used to report progress.</param>
        /// <returns>A task that completes when the template generator has finished to run.</returns>
        internal static async Task <bool> RunTemplateGeneratorSafe <TParameters>(ITemplateGenerator <TParameters> generator, TParameters parameters, WorkProgressViewModel workProgress) where TParameters : TemplateGeneratorParameters
        {
            if (generator == null)
            {
                throw new ArgumentNullException(nameof(generator));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }
            var success = false;

            try
            {
                success = await generator.PrepareForRun(parameters);

                if (!success)
                {
                    // If the preparation failed without error, it means that the user cancelled the operation.
                    if (!parameters.Logger.HasErrors)
                    {
                        parameters.Logger.Info(Tr._p("Log", "Operation cancelled."));
                    }

                    return(false);
                }
            }
            catch (Exception e)
            {
                parameters.Logger.Error(Tr._p("Log", "An exception occurred while generating the template."), e);
            }

            if (parameters.Logger.HasErrors || !success)
            {
                workProgress?.ServiceProvider.Get <IEditorDialogService>().ShowProgressWindow(workProgress, 0);
                return(false);
            }

            workProgress?.ServiceProvider.Get <IEditorDialogService>().ShowProgressWindow(workProgress, 500);

            var result = await Task.Run(() =>
            {
                try
                {
                    return(generator.Run(parameters));
                }
                catch (Exception e)
                {
                    parameters.Logger.Error(Tr._p("Log", "An exception occurred while generating the template."), e);
                    return(false);
                }
            });

            return(result && !parameters.Logger.HasErrors);
        }
Example #19
0
        /// <summary>
        /// Reloads a project when a .csproj files changes on the hard drive.
        /// </summary>
        /// <remarks>
        /// In case of destructive changes (i.e. dirty files that disappeared), user confirmation will be asked to proceed.
        /// </remarks>
        private async Task ReloadProject(SessionViewModel session, Project project)
        {
            var workspace = await Workspace;

            // Get assets and namespace from csproj
            // TODO: Use roslyn list of files? not sure we could have non .cs files easily though
            // However, if we load from file, it might not be in sync with Roslyn state
            string projectNamespace;
            var    projectFiles = Package.FindAssetsInProject(project.FilePath, out projectNamespace);

            // Find associated ProjectViewModel
            var projectViewModel = session.LocalPackages.FirstOrDefault(y => y.Name == project.Name) as ProjectViewModel;

            if (projectViewModel == null)
            {
                return;
            }

            // List current assets
            var projectAssets  = new List <AssetViewModel>();
            var isProjectDirty = GetAssets(projectViewModel.Code, projectAssets);

            // Project is dirty, ask user if he really wants to auto-reload
            if (isProjectDirty)
            {
                var dialogResult = projectViewModel.Session.Dialogs.BlockingMessageBox(
                    string.Format(
                        Tr._p("Message", "Game Studio can't auto-reload the project file {0} because you have local changes such as new or deleted scripts.\r\n\r\nClick OK to keep reloading or Cancel to keep the current version."),
                        Path.GetFileName(project.FilePath)), MessageBoxButton.OKCancel);
                if (dialogResult == MessageBoxResult.Cancel)
                {
                    return;
                }
            }

            // Remove deleted assets (and ask user if he really wants to proceed in case some of them were dirty?)
            bool continueReload = await DeleteRemovedProjectAssets(projectViewModel, projectAssets, project, projectFiles);

            if (!continueReload)
            {
                return;
            }

            // Update Roslyn project
            workspace.AddOrUpdateProject(project);

            // Add new assets
            AddNewProjectAssets(projectViewModel, projectAssets, project, projectFiles);

            // Mark project as non dirty
            // TODO: Does that work properly with Undo/Redo?
            UpdateDirtiness(projectViewModel.Code, false);
        }
Example #20
0
        private async void Validate()
        {
            ClassName = Utilities.BuildValidClassName(ClassNameTextBox.Text, ReservedNames);
            Namespace = Utilities.BuildValidNamespaceName(NamespaceTextBox.Text, ReservedNames);

            if (string.IsNullOrWhiteSpace(ClassName) || string.IsNullOrWhiteSpace(Namespace))
            {
                await services.Get <IDialogService>().MessageBox(Tr._p("Message", "The names you entered are invalid or empty."), MessageBoxButton.OK, MessageBoxImage.Information);

                return;
            }

            Result = Xenko.Core.Presentation.Services.DialogResult.Ok;
            Close();
        }
Example #21
0
        protected override bool IsValidName(string value, out string error)
        {
            if (!base.IsValidName(value, out error))
            {
                return(false);
            }

            if (Session.AllPackages.Any(x => x != this && string.Equals(x.Name, value, StringComparison.InvariantCultureIgnoreCase)))
            {
                error = Tr._p("Message", "A package with the same name already exists in the session.");
                return(false);
            }

            return(true);
        }
Example #22
0
        protected override async Task <bool> PrepareAssetCreation(AssetTemplateGeneratorParameters parameters)
        {
            if (!parameters.Unattended)
            {
                var window = new ScriptNameWindow(parameters.Description.DefaultOutputName, parameters.Namespace);
                await window.ShowModal();

                if (window.Result == DialogResult.Cancel)
                {
                    return(false);
                }

                parameters.Namespace = window.Namespace;
                parameters.Tags.Set(ClassNameKey, window.ClassName);

                var ask = Xenko.Core.Assets.Editor.Settings.EditorSettings.AskBeforeSavingNewScripts.GetValue();
                if (ask)
                {
                    var buttons = DialogHelper.CreateButtons(new[]
                    {
                        Tr._p("Button", "Save"),
                        Tr._p("Button", "Cancel")
                    }, 1, 2);
                    var message        = Tr._p("Message", "You can't use scripts until you save them. Do you want to save now?");
                    var checkedMessage = Xenko.Core.Assets.Editor.Settings.EditorSettings.AlwaysSaveNewScriptsWithoutAsking;
                    var result         = await EditorViewModel.Instance.ServiceProvider.Get <IDialogService>().CheckedMessageBox(message, false, checkedMessage, buttons, MessageBoxImage.Question);

                    if (result.IsChecked == true)
                    {
                        Xenko.Core.Assets.Editor.Settings.EditorSettings.AskBeforeSavingNewScripts.SetValue(false);
                        Xenko.Core.Assets.Editor.Settings.EditorSettings.Save();
                    }
                    parameters.Tags.Set(SaveSessionKey, result.Result == 1);
                }
                else
                {
                    parameters.Tags.Set(SaveSessionKey, true);
                }
            }
            else
            {
                // TODO: Some templates save, some don't (and behavior can even change in Unattended mode)
                // For consistency, should this be moved to a common parameters.Saving?
                parameters.Tags.Set(SaveSessionKey, false);
            }

            return(true);
        }
Example #23
0
        private async void Validate()
        {
            ClassName      = Utilities.BuildValidClassName(ClassNameTextBox.Text, ReservedNames);
            Namespace      = Utilities.BuildValidNamespaceName(NamespaceTextBox.Text, ReservedNames);
            ScriptTemplate = enableTemplateSelect ? TemplateComboBox.SelectedValue as TemplateAssetDescription : defaultScriptTemplate;

            if (string.IsNullOrWhiteSpace(ClassName) || string.IsNullOrWhiteSpace(Namespace))
            {
                await services.Get <IDialogService>().MessageBox(Tr._p("Message", "The names you entered are invalid or empty."), MessageBoxButton.OK, MessageBoxImage.Information);

                return;
            }

            Result = Stride.Core.Presentation.Services.DialogResult.Ok;
            Close();
        }
Example #24
0
        /// <summary>
        ///   Starts a new instance of Visual Studio with the current session.
        /// </summary>
        /// <param name="session">The current session.</param>
        /// <param name="ideInfo">The IDE to launch.</param>
        /// <returns>A <see cref="Task"/> that completes when the IDE is launched.</returns>
        public static async Task <Process> StartVisualStudio(SessionViewModel session, IDEInfo ideInfo)
        {
            if (!await CheckCanOpenSolution(session))
            {
                return(null);
            }

            var startInfo = new ProcessStartInfo();

            if (ideInfo is null)
            {
                var defaultIDEName = EditorSettings.DefaultIDE.GetValue();

                if (!EditorSettings.DefaultIDE.GetAcceptableValues().Contains(defaultIDEName))
                {
                    defaultIDEName = EditorSettings.DefaultIDE.DefaultValue;
                }

                ideInfo = VisualStudioVersions.AvailableVisualStudioInstances
                          .FirstOrDefault(x => x.DisplayName == defaultIDEName) ?? VisualStudioVersions.DefaultIDE;
            }

            // It will be null if either "Default", or if not available anymore (uninstalled?)
            if (ideInfo.DevenvPath != null && File.Exists(ideInfo.DevenvPath))
            {
                startInfo.FileName  = ideInfo.DevenvPath;
                startInfo.Arguments = $"\"{session.SolutionPath}\"";
            }
            else
            {
                startInfo.FileName        = session.SolutionPath.ToWindowsPath();
                startInfo.UseShellExecute = true;
            }

            try
            {
                // Start the IDE
                return(Process.Start(startInfo));
            }
            catch
            {
                await session.Dialogs.MessageBox(Tr._p("Message", "An error occurred while starting Visual Studio."), MessageBoxButton.OK, MessageBoxImage.Information);

                return(null);
            }
        }
Example #25
0
        /// <summary>
        /// // Handle Script asset deletion (from Visual Studio/HDD external changes to Game Studio).
        /// </summary>
        /// <returns>False if user refused to continue (in case deleted assets were dirty).</returns>
        private static async Task <bool> DeleteRemovedProjectAssets(ProjectViewModel projectViewModel, List <AssetViewModel> projectAssets, Project project, List <UFile> projectFiles)
        {
            // List IProjectAsset
            var currentProjectAssets = projectAssets.Where(x => x.AssetItem.Asset is IProjectAsset);

            var assetsToDelete = new List <AssetViewModel>();

            foreach (var asset in currentProjectAssets)
            {
                // Note: if file doesn't exist on HDD anymore (i.e. automatic csproj tracking for *.cs), no need to delete it anymore
                bool isDeleted = !projectFiles.Contains(asset.AssetItem.FullPath);
                if (isDeleted)
                {
                    assetsToDelete.Add(asset);
                }
            }

            var dirtyAssetsToDelete = assetsToDelete.Where(x => x.AssetItem.IsDirty).ToList();

            if (dirtyAssetsToDelete.Count > 0)
            {
                // Check if user is OK with deleting those dirty assets?
                var dialogResult = projectViewModel.Session.Dialogs.BlockingMessageBox(
                    string.Format(
                        Tr._p("Message", "The following source files in the {0} project have been deleted externally, but have unsaved changes in Game Studio. Do you want to delete these files?\r\n\r\n{1}"),
                        Path.GetFileName(project.FilePath), string.Join("\r\n", dirtyAssetsToDelete.Select(x => x.AssetItem.FullPath.ToWindowsPath()))),
                    MessageBoxButton.OKCancel);
                if (dialogResult == MessageBoxResult.Cancel)
                {
                    return(false);
                }
            }

            // delete this asset
            if (assetsToDelete.Count > 0)
            {
                // TODO: this action (it should occur only during assembly releoad) will be undoable (undoing reload restores deleted script)
                if (!await projectViewModel.Session.ActiveAssetView.DeleteContent(assetsToDelete, true))
                {
                    return(false);
                }
            }

            return(true);
        }
Example #26
0
 private async Task OpenWebPage(string url)
 {
     try
     {
         var process = new Process {
             StartInfo = new ProcessStartInfo(url)
             {
                 UseShellExecute = true
             }
         };
         process.Start();
     }
     catch (Exception ex)
     {
         var message = $"{Tr._p("Message", "An error occurred while opening the file.")}{ex.FormatSummary(true)}";
         await ServiceProvider.Get <IDialogService>().MessageBox(message, MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Example #27
0
        /// <inheritdoc />
        protected override async Task Delete()
        {
            var elementsToDelete = GetCommonRoots(SelectedItems);
            var ask = UIEditorSettings.AskBeforeDeletingUIElements.GetValue();

            if (ask)
            {
                var confirmMessage = Tr._p("Message", "Are you sure you want to delete this UI element?");
                if (elementsToDelete.Count > 1)
                {
                    confirmMessage = string.Format(Tr._p("Message", "Are you sure you want to delete these {0} UI elements?"), elementsToDelete.Count);
                }
                var buttons = DialogHelper.CreateButtons(new[] { Tr._p("Button", "Delete"), Tr._p("Button", "Cancel") }, 1, 2);
                var result  = await ServiceProvider.Get <IDialogService>().CheckedMessageBox(confirmMessage, false, DialogHelper.DontAskAgain, buttons, MessageBoxImage.Question);

                if (result.Result != 1)
                {
                    return;
                }
                if (result.IsChecked == true)
                {
                    UIEditorSettings.AskBeforeDeletingUIElements.SetValue(false);
                    UIEditorSettings.Save();
                }
            }

            var hadActiveRoot = elementsToDelete.Any(x => ReferenceEquals(x, ActiveRoot));
            var asset         = elementsToDelete.First().Asset; // all selected items are from the same asset

            using (var transaction = UndoRedoService.CreateTransaction())
            {
                ClearSelection();
                HashSet <Tuple <Guid, Guid> > mapping;
                asset.AssetHierarchyPropertyGraph.DeleteParts(elementsToDelete.Select(x => x.UIElementDesign), out mapping);
                var operation = new DeletedPartsTrackingOperation <UIElementDesign, UIElement>(asset, mapping);
                UndoRedoService.PushOperation(operation);
                UndoRedoService.SetName(transaction, "Delete selected UI elements");
            }
            // Clear active root if it was deleted
            if (hadActiveRoot)
            {
                ActiveRoot = null;
            }
        }
Example #28
0
        protected override bool IsValidName(string value, out string error)
        {
            if (!base.IsValidName(value, out error))
            {
                return(false);
            }

            if (Parent.SubDirectories.Any(x => x != this && string.Equals(x.Name, value, StringComparison.InvariantCultureIgnoreCase)))
            {
                error = Tr._p("Message", "A folder with the same name already exists in the parent folder.");
                return(false);
            }

            if (!IsPathAcceptedByFilesystem(UPath.Combine <UDirectory>(Package.PackagePath.GetFullDirectory(), value), out error))
            {
                return(false);
            }

            return(true);
        }
Example #29
0
 static StrideEditorSettings()
 {
     // Note: assignments cannot be moved to initializer, because category names need to be assigned first.
     StartupSession = new SettingsKey <UFile>("Interface/StartupSession" + StrideGameStudio.EditorVersion, EditorSettings.SettingsContainer, "")
     {
         // Note: the name of this settings is based on the editor version, because we want to force displaying the release notes on a new version.
         DisplayName = $"{EditorSettings.Interface}/{Tr._p("Settings", "Default session to load")}"
     };
     Host = new SettingsKey <string>("Remote/Credentials/Host", EditorSettings.SettingsContainer, "")
     {
         DisplayName = $"{Remote}/{Tr._p("Settings", "Host")}"
     };
     Port = new SettingsKey <int>("Remote/Credentials/Port", EditorSettings.SettingsContainer, 22)
     {
         DisplayName = $"{Remote}/{Tr._p("Settings", "Port")}"
     };
     Username = new SettingsKey <string>("Remote/Credentials/Username", EditorSettings.SettingsContainer, "")
     {
         DisplayName = $"{Remote}/{Tr._p("Settings", "Username")}"
     };
     Password = new SettingsKey <string>("Remote/Credentials/Password", EditorSettings.SettingsContainer, "")
     {
         DisplayName = $"{Remote}/{Tr._p("Settings", "Password")}"
     };
     Location = new SettingsKey <string>("Remote/Location", EditorSettings.SettingsContainer, "Projects")
     {
         DisplayName = $"{Remote}/{Tr._p("Settings", "Location")}"
     };
     AskForCredentials = new SettingsKey <bool>("Remote/Credentials/AskForCredentials", EditorSettings.SettingsContainer, true)
     {
         DisplayName = $"{Remote}/{Tr._p("Settings", "Ask for credentials when deploying game")}"
     };
     Display = new SettingsKey <string>("Remote/Display", EditorSettings.SettingsContainer, ":0.0")
     {
         DisplayName = $"{Remote}/{Tr._p("Settings", "X Display")}"
     };
     UseCoreCLR = new SettingsKey <bool>("Remote/UseCoreCLR", EditorSettings.SettingsContainer, false)
     {
         DisplayName = $"{Remote}/{Tr._p("Settings", "Use CoreCLR")}"
     };
 }
Example #30
0
        public async Task UpdatePackageTemplate(TemplateDescription template)
        {
            var loggerResult = new LoggerResult();

            var workProgress = new WorkProgressViewModel(ServiceProvider, loggerResult)
            {
                Title           = "Updating package...",
                KeepOpen        = KeepOpen.OnWarningsOrErrors,
                IsIndeterminate = true,
                IsCancellable   = false
            };

            workProgress.RegisterProgressStatus(loggerResult, true);

            var parameters = new PackageTemplateGeneratorParameters
            {
                Name            = Package.Meta.Name,
                OutputDirectory = Package.FullPath.GetFullDirectory(),
                Description     = template,
                Package         = Package,
                Logger          = loggerResult,
            };

            var generator = TemplateManager.FindTemplateGenerator(parameters);

            if (generator == null)
            {
                await ServiceProvider.Get <IDialogService>().MessageBox(Tr._p("Message", "Unable to retrieve template generator for the selected template. Aborting."), MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }

            // Errors might occur when generating the template. For the moment we consider them non-fatal and allow to open the project anyway.
            await TemplateGeneratorHelper.RunTemplateGeneratorSafe(generator, parameters, workProgress);

            RefreshProjects();

            await workProgress.NotifyWorkFinished(false, loggerResult.HasErrors);

            Package.IsDirty = true;
        }