コード例 #1
0
        public ActionResult StarterKitForm(string starterKitId)
        {
            Mandate.ParameterNotNull(starterKitId, "starterKitName");

            //var publicPackage = _requestContext.PackageContext.PublicPackageManager.SourceRepository.FindPackage(starterKitId);

            //var fileName = _requestContext.PackageContext.PublicPackageManager.PathResolver.GetPackageFileName(publicPackage);
            //var filePath = Path.Combine(_requestContext.PackageContext.LocalPackageManager.SourceRepository.Source, fileName);
            //if (!global::System.IO.File.Exists(filePath))
            //{
            //    using (var file = global::System.IO.File.Create(filePath))
            //    {
            //        publicPackage.GetStream().CopyTo(file);
            //        file.Close();
            //    }
            //}

            var localPackage = _requestContext.PackageContext.LocalPackageManager.SourceRepository.FindPackage(starterKitId);

            _requestContext.PackageContext.LocalPackageManager.InstallPackage(localPackage, false);

            var installation = new PackageInstallation(_requestContext, HttpContext, localPackage);

            installation.CopyPackageFiles();
            installation.ImportData();

            SuccessfulOnRedirectAttribute.EnsureRouteData(this, "id", localPackage.Id);

            return(RedirectToAction("PostStarterKitInstall", new { id = localPackage.Id }));
        }
コード例 #2
0
 public static void InstallCinemachine()
 {
     if (!PackageInstallation.IsInstalled(WelcomeWindow.CinemachinePackageID))
     {
         PackageInstallation.Install(WelcomeWindow.CinemachinePackageVersionID);
     }
 }
コード例 #3
0
 public static void InstallTextMeshPro()
 {
     if (!PackageInstallation.IsInstalled(WelcomeWindow.TextMeshProPackageID))
     {
         PackageInstallation.Install(WelcomeWindow.TextMeshProPackageVersionID);
     }
 }
コード例 #4
0
 public static void InstallPostProcessing()
 {
     if (!PackageInstallation.IsInstalled(WelcomeWindow.PostProcessingPackageID))
     {
         PackageInstallation.Install(WelcomeWindow.PostProcessingPackageVersionID);
     }
 }
コード例 #5
0
 public static void InstallTilemapEditor()
 {
     if (!PackageInstallation.IsInstalled(WelcomeWindow.TilemapEditorPackageID))
     {
         PackageInstallation.Install(WelcomeWindow.TilemapEditorPackageVersionID);
     }
 }
コード例 #6
0
    public static void InstallDependencies()
    {
        bool installHappened = false;

        if (!PackageInstallation.IsInstalled(WelcomeWindow.TilemapEditorPackageID))
        {
            InstallTilemapEditor();
            installHappened = true;
        }
        if (!PackageInstallation.IsInstalled(WelcomeWindow.PostProcessingPackageID))
        {
            InstallPostProcessing();
            installHappened = true;
        }
        if (!PackageInstallation.IsInstalled(WelcomeWindow.CinemachinePackageID))
        {
            InstallCinemachine();
            installHappened = true;
        }
        if (installHappened)
        {
            AssetDatabase.Refresh();
            ReloadCurrentScene();
        }
    }
コード例 #7
0
        public void Test()
        {
            // Arrange
            const string pagePath = "Test.umb";

            var packageExtraction = new Mock <IPackageExtraction>();

            string test;

            packageExtraction.Setup(a => a.ReadTextFileFromArchive(pagePath, Constants.Packaging.PackageXmlFileName, out test)).Returns(Xml);

            var fileService      = new Mock <IFileService>();
            var macroService     = new Mock <IMacroService>();
            var packagingService = new Mock <IPackagingService>();

            var sut = new PackageInstallation(packagingService.Object, macroService.Object, fileService.Object, packageExtraction.Object);

            // Act
            InstallationSummary installationSummary = sut.InstallPackage(pagePath, -1);

            // Assert
            Assert.IsNotNull(installationSummary);
            //Assert.Inconclusive("Lots of more tests can be written");
        }
コード例 #8
0
        public ActionResult AddLocalPackage(HttpPostedFileBase file)
        {
            if (file == null)
            {
                ModelState.AddModelError("PackageFileValidation", "No file selected. Please select a package file to upload.");
                return(LocalRepository());
            }

            if (!Path.GetExtension(file.FileName).EndsWith("nupkg"))
            {
                ModelState.AddModelError("PackageFileValidation", "The file uploaded is not a valid package file, only Nuget packages are supported");
                return(LocalRepository());
            }

            IPackage package;

            try
            {
                package = new ZipPackage(file.InputStream);
            }
            catch (Exception ex)
            {
                LogHelper.Error <PackagingEditorController>("Package could not be unziped.", ex);

                ModelState.AddModelError("PackageFileValidation", "The Nuget package file uploaded could not be read");
                return(LocalRepository());
            }

            try
            {
                var fileName = Path.Combine(BackOfficeRequestContext.PackageContext.LocalPackageManager.SourceRepository.Source, file.FileName);
                file.SaveAs(fileName);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("PackageFileValidation", "The package file could not be saved. " + ex.Message);
                return(LocalRepository());
            }

            if (!string.IsNullOrWhiteSpace(Request.Form["autoinstall"]))
            {
                BackOfficeRequestContext.PackageContext.LocalPackageManager.InstallPackage(package, false);

                var logger       = new PackageLogger(BackOfficeRequestContext, HttpContext, package);
                var installation = new PackageInstallation(BackOfficeRequestContext, HttpContext, package);

                //Copy files from package folder to destination and log results
                var fileResults = installation.CopyPackageFiles();
                foreach (var info in fileResults)
                {
                    logger.Log(info.IsCopiable, info.Message());
                }
                //Import data and log results
                var dataResults = installation.ImportData();
                foreach (var attributeType in dataResults.AttributeTypes)
                {
                    logger.Log(attributeType.IsImportable, string.Format("AttributeType {0}", attributeType.ObjectId.Value.ToString()));
                }
                foreach (var schema in dataResults.Schemas)
                {
                    logger.Log(schema.IsImportable, string.Format("Schema {0}", schema.ObjectId.Value.ToString()));
                }
                foreach (var schemaRelation in dataResults.SchemaRelations)
                {
                    logger.Log(schemaRelation.IsImportable, string.Format("Schema Relation {0}", schemaRelation.ObjectId.Value.ToString()));
                }
                foreach (var entity in dataResults.Entities)
                {
                    logger.Log(entity.IsImportable, string.Format("Entity {0}", entity.ObjectId.Value.ToString()));
                }
                foreach (var entityRelation in dataResults.EntityRelations)
                {
                    logger.Log(entityRelation.IsImportable, string.Format("Entity Relation {0}", entityRelation.ObjectId.Value.ToString()));
                }
                foreach (var language in dataResults.Languages)
                {
                    logger.Log(language.IsImportable, string.Format("Language {0}", language.ObjectId.Value.ToString()));
                }

                //Notifications.Add(new NotificationMessage(package.Title + " has been installed", "Package installed", NotificationType.Success));
                //SuccessfulOnRedirectAttribute.EnsureRouteData(this, "id", package.Id);

                return(RedirectToAction("RecycleApplication", new { id = package.Id, state = PackageInstallationState.Installing }));
            }

            Notifications.Add(new NotificationMessage(package.Title + " added to local repository", "Package added", NotificationType.Success));
            SuccessfulOnRedirectAttribute.EnsureRouteData(this, "id", package.Id);

            return(RedirectToAction("LocalRepository"));
        }
コード例 #9
0
        public ActionResult ManagePackage()
        {
            var toInstallVal = ValueProvider.GetValue("install") == null
                ? new object[] { }
                : ValueProvider.GetValue("install").AttemptedValue.Split('-');
            var toInstall = toInstallVal.Length > 0 ? toInstallVal[0] : null;

            var toUninstallVal = ValueProvider.GetValue("uninstall") == null
                ? new object[] { }
                : ValueProvider.GetValue("uninstall").AttemptedValue.Split('-');
            var toUninstall = toUninstallVal.Length > 0 ? toUninstallVal[0] : null;

            var toRemoveVal = ValueProvider.GetValue("remove") == null
                ? new object[] { }
                : ValueProvider.GetValue("remove").AttemptedValue.Split('-');
            var toRemove = toRemoveVal.Length > 0 ? toRemoveVal[0] : null;

            if (toInstall != null)
            {
                //get the package from the source
                var package = BackOfficeRequestContext.PackageContext.LocalPackageManager.SourceRepository.FindPackage(toInstall.ToString());
                var version = Version.Parse(toInstallVal[1].ToString());
                BackOfficeRequestContext.PackageContext.LocalPackageManager.InstallPackage(package.Id, version, false);

                var logger       = new PackageLogger(BackOfficeRequestContext, HttpContext, package);
                var installation = new PackageInstallation(BackOfficeRequestContext, HttpContext, package);

                //Copy files from package folder to destination and log results
                var fileResults = installation.CopyPackageFiles();
                foreach (var info in fileResults)
                {
                    logger.Log(info.IsCopiable, info.Message());
                }
                //Import data and log results
                var dataResults = installation.ImportData();
                foreach (var attributeType in dataResults.AttributeTypes)
                {
                    logger.Log(attributeType.IsImportable, string.Format("AttributeType {0}", attributeType.ObjectId.Value.ToString()));
                }
                foreach (var schema in dataResults.Schemas)
                {
                    logger.Log(schema.IsImportable, string.Format("Schema {0}", schema.ObjectId.Value.ToString()));
                }
                foreach (var schemaRelation in dataResults.SchemaRelations)
                {
                    logger.Log(schemaRelation.IsImportable, string.Format("Schema Relation {0}", schemaRelation.ObjectId.Value.ToString()));
                }
                foreach (var entity in dataResults.Entities)
                {
                    logger.Log(entity.IsImportable, string.Format("Entity {0}", entity.ObjectId.Value.ToString()));
                }
                foreach (var entityRelation in dataResults.EntityRelations)
                {
                    logger.Log(entityRelation.IsImportable, string.Format("Entity Relation {0}", entityRelation.ObjectId.Value.ToString()));
                }
                foreach (var language in dataResults.Languages)
                {
                    logger.Log(language.IsImportable, string.Format("Language {0}", language.ObjectId.Value.ToString()));
                }

                //Notifications.Add(new NotificationMessage(package.Title + " has been installed", "Package installed", NotificationType.Success));
                SuccessfulOnRedirectAttribute.EnsureRouteData(this, "id", package.Id);

                logger.Persist();

                return(RedirectToAction("RecycleApplication", new { id = package.Id, state = PackageInstallationState.Installing }));
            }

            if (toUninstall != null)
            {
                //get the package from the installed location
                var nugetPackage      = BackOfficeRequestContext.PackageContext.LocalPackageManager.LocalRepository.FindPackage(toUninstall.ToString());
                var packageFolderName = BackOfficeRequestContext.PackageContext.LocalPathResolver.GetPackageDirectory(nugetPackage);

                //execute some tasks
                var taskExeContext = _packageInstallUtility.GetTaskExecutionContext(nugetPackage, packageFolderName, PackageInstallationState.Uninstalling, this);
                _packageInstallUtility.RunPrePackageUninstallActions(taskExeContext, packageFolderName);

                BackOfficeRequestContext.PackageContext.LocalPackageManager.UninstallPackage(nugetPackage, false, false);

                //Notifications.Add(new NotificationMessage(nugetPackage.Title + " has been uninstalled", "Package uninstalled", NotificationType.Success));
                SuccessfulOnRedirectAttribute.EnsureRouteData(this, "id", nugetPackage.Id);

                return(RedirectToAction("RecycleApplication", new { id = nugetPackage.Id, state = PackageInstallationState.Uninstalling }));
            }

            if (toRemove != null)
            {
                var package     = BackOfficeRequestContext.PackageContext.LocalPackageManager.SourceRepository.FindPackage(toRemove.ToString());
                var packageFile = BackOfficeRequestContext.PackageContext.LocalPathResolver.GetPackageFileName(package);


                //delete the package folder... this will check if the file exists by just the package name or also with the version
                if (BackOfficeRequestContext.PackageContext.LocalPackageManager.FileSystem.FileExists(packageFile))
                {
                    BackOfficeRequestContext.PackageContext.LocalPackageManager.FileSystem.DeleteFile(
                        Path.Combine(BackOfficeRequestContext.PackageContext.LocalPackageManager.SourceRepository.Source, packageFile));
                }
                else
                {
                    var fileNameWithVersion = packageFile.Substring(0, packageFile.IndexOf(".nupkg")) + "." + package.Version + ".nupkg";
                    BackOfficeRequestContext.PackageContext.LocalPackageManager.FileSystem.DeleteFile(
                        Path.Combine(BackOfficeRequestContext.PackageContext.LocalPackageManager.SourceRepository.Source, fileNameWithVersion));
                }

                Notifications.Add(new NotificationMessage(package.Title + " has been removed from the local repository", "Package removed", NotificationType.Success));
                SuccessfulOnRedirectAttribute.EnsureRouteData(this, "id", package.Id);

                return(RedirectToAction("LocalRepository"));
            }


            return(HttpNotFound());
        }
コード例 #10
0
    private void OnGUI()
    {
        if (EditorApplication.isCompiling)
        {
            this.ShowNotification(new GUIContent("Compiling Scripts", EditorGUIUtility.IconContent("BuildSettings.Editor").image));
        }
        else
        {
            this.RemoveNotification();
        }
        Texture2D welcomeImage     = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/UltimateGridsEngine/Common/Editor/WelcomeWindow/welcome-banner-v2.png", typeof(Texture2D));
        Rect      welcomeImageRect = new Rect(0, 0, 488, 325);

        UnityEngine.GUI.DrawTexture(welcomeImageRect, welcomeImage);
        GUILayout.Space(345);

        GUILayout.BeginArea(new Rect(EditorGUILayout.GetControlRect().x + 10, 345, WelcomeWindowWidth - 20, WelcomeWindowHeight));
        EditorGUILayout.LabelField("Welcome to the Ultimate Grids Engine - Version 2.1!\n"
                                   , LargeTextStyle);
        EditorGUILayout.Space();
        if (!PackageInstallation.IsInstalled(TilemapEditorPackageID) ||
            !PackageInstallation.IsInstalled(PostProcessingPackageID))
        {
            EditorGUILayout.LabelField("IMPORTANT : DEPENDENCIES", LargeTextStyle);
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("The engine relies on a few <b>Unity packages</b> to run, and if you see this some of them are missing.\n"
                                       + "Click the <b>install buttons</b> below to complete installation.\n"
                                       + "You can learn more about this in the readme file.\n"
                                       + "Once all dependencies are installed, restart Unity and you're good to go!"
                                       , RegularTextStyle);
            EditorGUILayout.Space();
            if (!PackageInstallation.IsInstalled(TilemapEditorPackageID))
            {
                EditorGUILayout.LabelField("Tilemap Editor is <b>not installed</b>", RegularTextStyle);
                if (GUILayout.Button(new GUIContent("  Install Tilemap Editor", EditorGUIUtility.IconContent("BuildSettings.Standalone.Small").image), GUILayout.MaxWidth(185f)))
                {
                    PackageInstallation.Install(TilemapEditorPackageVersionID);
                }
            }
            EditorGUILayout.Space();
            if (!PackageInstallation.IsInstalled(PostProcessingPackageID))
            {
                EditorGUILayout.LabelField("Post Processing is <b>not installed</b>", RegularTextStyle);
                if (GUILayout.Button(new GUIContent("  Install Post Processing", EditorGUIUtility.IconContent("BuildSettings.Standalone.Small").image), GUILayout.MaxWidth(185f)))
                {
                    PackageInstallation.Install(PostProcessingPackageVersionID);
                }
            }
            EditorGUILayout.Space();
            if (!PackageInstallation.IsInstalled(CinemachinePackageID))
            {
                EditorGUILayout.LabelField("Cinemachine is <b>not installed</b>", RegularTextStyle);
                if (GUILayout.Button(new GUIContent("  Install Cinemachine", EditorGUIUtility.IconContent("BuildSettings.Standalone.Small").image), GUILayout.MaxWidth(185f)))
                {
                    PackageInstallation.Install(CinemachinePackageVersionID);
                }
            }
            EditorGUILayout.Space();
            if (!PackageInstallation.IsInstalled(TextMeshProPackageID))
            {
                EditorGUILayout.LabelField("Textmesh Pro is <b>not installed</b>", RegularTextStyle);
                if (GUILayout.Button(new GUIContent("  Install Textmesh Pro", EditorGUIUtility.IconContent("BuildSettings.Standalone.Small").image), GUILayout.MaxWidth(185f)))
                {
                    PackageInstallation.Install(TextMeshProPackageVersionID);
                }
            }
            EditorGUILayout.Space();
            EditorGUILayout.Space();
        }
        EditorGUILayout.LabelField("GETTING STARTED", LargeTextStyle);
        EditorGUILayout.LabelField("You can start by having a look at the documentation and joining the discord server. \nHave fun with your project and rate the asset!", RegularTextStyle);
        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button(new GUIContent(" Open Documentation", EditorGUIUtility.IconContent("_Help").image), GUILayout.MaxWidth(185f), GUILayout.MaxHeight(20f)))
        {
            Application.OpenURL(DOCUMENTATION_URL);
        }
        if (GUILayout.Button(new GUIContent(" Join Discord       ", EditorGUIUtility.IconContent("d_console.infoicon.sml").image), GUILayout.MaxWidth(185f), GUILayout.MaxHeight(20f)))
        {
            Application.OpenURL(DOCUMENTATION_URL);
        }
        EditorGUILayout.EndHorizontal();
        GUILayout.EndArea();

        Rect areaRect = new Rect(0, WelcomeWindowHeight - 20, WelcomeWindowWidth, WelcomeWindowHeight - 20);

        GUILayout.BeginArea(areaRect);
        EditorGUILayout.LabelField("Copyright © 2020 GaboDevelops", FooterTextStyle);
        GUILayout.EndArea();
    }