private string ShowEditReadmeWindow(string readmePath)
        {
            var editRedmeWin = new ReadmeWindow(readmePath);

            editRedmeWin.ShowDialog();
            ShowReadme(readmePath);
            return(editRedmeWin.ReadmeText);
        }
Exemple #2
0
        public override void OnGUI()
        {
            base.OnGUI();

            mRootLayout.OnGUI();

            GUILayout.BeginVertical("box");

            mFrameworkInfoLayout.OnGUI();

            mToolbarIndex = GUILayout.Toolbar(mToolbarIndex, ToolbarNames);

            // 这里开始具体的内容
            GUILayout.BeginHorizontal("box");
            GUILayout.Label("Package", GUILayout.Width(150));
            GUILayout.Label("Server", GUILayout.Width(80));
            GUILayout.Label("Local", GUILayout.Width(80));
            GUILayout.Label("Access Right", GUILayout.Width(80));
            GUILayout.Label("Doc", new GUIStyle {
                alignment = TextAnchor.MiddleCenter, fixedWidth = 40f
            });
            GUILayout.Label("Action", new GUIStyle {
                alignment = TextAnchor.MiddleCenter, fixedWidth = 100f
            });
            GUILayout.Label("Release Note", new GUIStyle {
                alignment = TextAnchor.MiddleCenter, fixedWidth = 100f
            });
            GUILayout.EndHorizontal();

            GUILayout.BeginVertical("box");

            mScrollPos = GUILayout.BeginScrollView(mScrollPos, false, true, GUILayout.Height(240));

            foreach (var packageData in SelectedPackageType)
            {
                GUILayout.Space(2);
                GUILayout.BeginHorizontal();
                GUILayout.Label(packageData.Name, GUILayout.Width(150));
                GUILayout.Label(packageData.Version, GUILayout.Width(80));
                var installedPackage = InstalledPackageVersions.FindVersionByName(packageData.Name);
                GUILayout.Label(installedPackage != null ? installedPackage.Version : " ", GUILayout.Width(80));
                GUILayout.Label(packageData.AccessRight.ToString(), GUILayout.Width(80));

                if (packageData.DocUrl.IsNotNullAndEmpty())
                {
                    if (GUILayout.Button("Doc", GUILayout.Width(40)))
                    {
                        Application.OpenURL(packageData.DocUrl);
                    }
                }
                else
                {
                    GUILayout.Space(40);
                }

                if (installedPackage == null)
                {
                    if (GUILayout.Button("Import", GUILayout.Width(90)))
                    {
                        EditorActionKit.ExecuteNode(new InstallPackage(packageData));

                        PackageApplication.Container.Resolve <PackageKitWindow>().Close();
                    }
                }
                else if (installedPackage != null && packageData.VersionNumber > installedPackage.VersionNumber)
                {
                    if (GUILayout.Button("Update", GUILayout.Width(90)))
                    {
                        var path = Application.dataPath.Replace("Assets", packageData.InstallPath);

                        if (Directory.Exists(path))
                        {
                            Directory.Delete(path, true);
                        }

                        EditorActionKit.ExecuteNode(new InstallPackage(packageData));

                        PackageApplication.Container.Resolve <PackageKitWindow>().Close();
                    }
                }
                else if (installedPackage.IsNotNull() && packageData.VersionNumber == installedPackage.VersionNumber)
                {
                    if (GUILayout.Button("Reimport", GUILayout.Width(90)))
                    {
                        var path = Application.dataPath.Replace("Assets", packageData.InstallPath);

                        if (Directory.Exists(path))
                        {
                            Directory.Delete(path, true);
                        }

                        EditorActionKit.ExecuteNode(new InstallPackage(packageData));
                        PackageApplication.Container.Resolve <PackageKitWindow>().Close();
                    }
                }
                else if (installedPackage != null)
                {
                    // maybe support upload?
                    GUILayout.Space(94);
                }

                if (GUILayout.Button("Release Notes", GUILayout.Width(100)))
                {
                    ReadmeWindow.Init(packageData.readme, packageData.PackageVersions.First());
                }

                GUILayout.EndHorizontal();
            }

            GUILayout.EndScrollView();

            GUILayout.Space(2);

            GUILayout.EndVertical();

            GUILayout.EndVertical();


            GUILayout.Space(50);
        }
Exemple #3
0
        protected override void OnRefresh()
        {
            Clear();

            new EGO.Framework.SpaceView(2).AddTo(this);

            new EGO.Framework.LabelView(mPackageData.Name)
            .FontBold()
            .Width(150)
            .AddTo(this);

            new EGO.Framework.LabelView(mPackageData.Version)
            .TextMiddleCenter()
            .Width(80)
            .AddTo(this);

            var installedPackage = InstalledPackageVersions.FindVersionByName(mPackageData.Name);

            new EGO.Framework.LabelView(installedPackage != null ? installedPackage.Version : " ")
            .TextMiddleCenter()
            .Width(80)
            .AddTo(this);

            new EGO.Framework.LabelView(mPackageData.AccessRight.ToString())
            .TextMiddleCenter()
            .Width(80)
            .AddTo(this);

            if (mPackageData.DocUrl.IsNotNullAndEmpty())
            {
                new ButtonView(LocaleText.Doc, () => { }).AddTo(this);
            }
            else
            {
                new EGO.Framework.SpaceView(40).AddTo(this);
            }


            if (installedPackage == null)
            {
                new ButtonView(LocaleText.Import, () =>
                {
                    EditorActionKit.ExecuteNode(new InstallPackage(mPackageData));

                    PackageApplication.Container.Resolve <PackageKitWindow>().Close();
                })
                .Width(90)
                .AddTo(this);
            }

            else if (installedPackage != null && mPackageData.VersionNumber > installedPackage.VersionNumber)
            {
                new ButtonView(LocaleText.Update, () =>
                {
                    var path = Application.dataPath.Replace("Assets", mPackageData.InstallPath);

                    path.DeleteDirIfExists();

                    EditorActionKit.ExecuteNode(new InstallPackage(mPackageData));

                    PackageApplication.Container.Resolve <PackageKitWindow>().Close();
                })
                .Width(90)
                .AddTo(this);
            }
            else if (installedPackage.IsNotNull() &&
                     mPackageData.VersionNumber == installedPackage.VersionNumber)
            {
                new ButtonView(LocaleText.Reimport, () =>
                {
                    var path = Application.dataPath.Replace("Assets", mPackageData.InstallPath);

                    path.DeleteDirIfExists();

                    EditorActionKit.ExecuteNode(new InstallPackage(mPackageData));
                    PackageApplication.Container.Resolve <PackageKitWindow>().Close();
                })
                .Width(90)
                .AddTo(this);
            }
            else if (installedPackage != null)
            {
                new EGO.Framework.SpaceView(94).AddTo(this);
            }

            new ButtonView(LocaleText.ReleaseNotes,
                           () => { ReadmeWindow.Init(mPackageData.readme, mPackageData.PackageVersions.First()); }).Width(100)
            .AddTo(this);
        }