protected override void OnExecute()
        {
            if (mPackageVersion.Readme.content.Length < 2)
            {
                PackageKit.Interface
                .GetUtility <IEditorDialogUtility>().ShowErrorMsg("请输入版本修改说明");
                return;
            }

            if (!IsVersionValide(mPackageVersion.Version))
            {
                PackageKit.Interface
                .GetUtility <IEditorDialogUtility>().ShowErrorMsg("请输入正确的版本号 格式:vX.Y.Z");
                return;
            }

            mPackageVersion.DocUrl = "https://lianxiegame.com";

            mPackageVersion.Readme = new ReleaseItem(mPackageVersion.Version, mPackageVersion.Readme.content,
                                                     User.Username.Value,
                                                     DateTime.Now);

            mPackageVersion.Save();

            AssetDatabase.Refresh();

            RenderEndCommandExecutor.PushCommand(() => { PublishPackage(mPackageVersion, false); });
        }
Beispiel #2
0
        public override void OnGUI()
        {
            base.OnGUI();

            RootLayout.DrawGUI();

            RenderEndCommandExecutor.ExecuteCommand();
        }
Beispiel #3
0
        private void OnGUI()
        {
            if (ViewController != null)
            {
                ViewController.View.DrawGUI();
            }

            RenderEndCommandExecutor.ExecuteCommand();
        }
        public override void OnGUI()
        {
            base.OnGUI();

            GUILayout.BeginHorizontal();
            GUILayout.EndHorizontal();

            var r = GUILayoutUtility.GetLastRect();

            mSplitView.OnGUI(new Rect(new Vector2(0, r.yMax),
                                      new Vector2(position.width, position.height - r.height)));

            RenderEndCommandExecutor.ExecuteCommand();
        }
Beispiel #5
0
        protected override void OnExecute()
        {
            var path = Application.dataPath.Replace("Assets", mPackageRepository.installPath);

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

            RenderEndCommandExecutor.PushCommand(() =>
            {
                AssetDatabase.Refresh();

                PackageApplication.Container.Resolve <PackageKitWindow>().Close();

                this.SendCommand(new InstallPackage(mPackageRepository));
            });
        }
Beispiel #6
0
 public static T PushCommand <T>(this T view, System.Action command) where T : IMGUIView
 {
     RenderEndCommandExecutor.PushCommand(command);
     return(view);
 }
Beispiel #7
0
 public void PushCommand(System.Action command)
 {
     RenderEndCommandExecutor.PushCommand(command);
 }
Beispiel #8
0
        public void Init(IQFrameworkContainer container)
        {
            Container = container;
            var localPackageVersionModel = this.GetModel <ILocalPackageVersionModel>();

            // 左侧
            mLeftLayout = EasyIMGUI.Vertical()
                          .AddChild(EasyIMGUI.Area().WithRectGetter(() => mLeftRect)
                                    // 间距 20
                                    .AddChild(EasyIMGUI.Vertical()
                                              .AddChild(EasyIMGUI.Space().Pixel(20)))
                                    // 搜索
                                    .AddChild(EasyIMGUI.Horizontal()
                                              .AddChild(EasyIMGUI.Label().Text("搜索:")
                                                        .FontBold()
                                                        .FontSize(12)
                                                        .Width(40)
                                                        ).AddChild(EasyIMGUI.TextField()
                                                                   .Height(20)
                                                                   .Self(search =>
            {
                search.Content
                .Bind(key => { this.SendCommand(new SearchCommand(key)); })
                .AddToDisposeList(mDisposableList);
            })
                                                                   )
                                              )

                                    // 权限
                                    .AddChild(EasyIMGUI.Toolbar()
                                              .Menus(new List <string>()
            {
                "All", PackageAccessRight.Public.ToString(), PackageAccessRight.Private.ToString()
            })
                                              .Self(self =>
            {
                self.IndexProperty.Bind(value =>
                {
                    PackageManagerState.AccessRightIndex.Value = value;
                    this.SendCommand(new SearchCommand(PackageManagerState.SearchKey.Value));
                }).AddToDisposeList(mDisposableList);
            }))
                                    // 分类
                                    .AddChild(
                                        EasyIMGUI.Horizontal()
                                        .AddChild(PopupView.Create()
                                                  .ToolbarStyle()
                                                  .Self(self =>
            {
                self.IndexProperty.Bind(value =>
                {
                    PackageManagerState.CategoryIndex.Value = value;
                    this.SendCommand(new SearchCommand(PackageManagerState.SearchKey.Value));
                }).AddToDisposeList(mDisposableList);

                mCategoriesSelectorView = self;
            }))
                                        )
                                    // 是否是官方
                                    .AddChild(
                                        EasyIMGUI.Horizontal()
                                        .AddChild(EasyIMGUI.Toggle().IsOn(mIsOfficial)
                                                  .Self(t => t.ValueProperty.Bind(v => mIsOfficial = v)))
                                        .AddChild(EasyIMGUI.Label().Text("官方"))
                                        .AddChild(EasyIMGUI.FlexibleSpace())
                                        )
                                    .AddChild(EasyIMGUI.Scroll()
                                              .AddChild(EasyIMGUI.Custom().OnGUI(() =>
            {
                PackageManagerState.PackageRepositories.Value
                .Where(p => p.isOfficial == mIsOfficial)
                .OrderByDescending(p =>
                {
                    var installedVersion = localPackageVersionModel.GetByName(p.name);

                    if (installedVersion == null)
                    {
                        return(-1);
                    }
                    else if (installedVersion.VersionNumber < p.VersionNumber)
                    {
                        return(2);
                    }
                    else if (installedVersion.VersionNumber == p.VersionNumber)
                    {
                        return(1);
                    }
                    else
                    {
                        return(0);
                    }
                })
                .ThenBy(p => p.name)
                .ForEach(p =>
                {
                    GUILayout.BeginVertical("box");

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label(p.name);
                        GUILayout.FlexibleSpace();
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    {
                        EasyIMGUI.Box().Text(p.latestVersion)
                        .Self(self => self.BackgroundColor = Color.green)
                        .DrawGUI();

                        GUILayout.FlexibleSpace();

                        var installedVersion = localPackageVersionModel.GetByName(p.name);

                        if (installedVersion == null)
                        {
                            if (GUILayout.Button(LocaleText.Import))
                            {
                                RenderEndCommandExecutor.PushCommand(() =>
                                {
                                    this.SendCommand(new ImportPackageCommand(p));
                                });
                            }
                        }
                        else if (installedVersion.VersionNumber < p.VersionNumber)
                        {
                            if (GUILayout.Button(LocaleText.Update))
                            {
                                RenderEndCommandExecutor.PushCommand(() =>
                                {
                                    this.SendCommand(new UpdatePackageCommand(p));
                                });
                            }
                        }
                        else if (installedVersion.VersionNumber == p.VersionNumber)
                        {
                            if (GUILayout.Button(LocaleText.Reimport))
                            {
                                RenderEndCommandExecutor.PushCommand(() =>
                                {
                                    this.SendCommand(new ReimportPackageCommand(p));
                                });
                            }
                        }
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();

                    var rect = GUILayoutUtility.GetLastRect();

                    if (mSelectedPackageRepository == p)
                    {
                        GUI.Box(rect, "", mSelectionRect);
                    }

                    if (rect.Contains(Event.current.mousePosition) &&
                        Event.current.type == EventType.MouseUp)
                    {
                        mSelectedPackageRepository = p;
                        Event.current.Use();
                    }
                });
            }))
                                              )
                                    );

            // var skin = AssetDatabase.LoadAssetAtPath<GUISkin>(
            var skin = AssetDatabase.LoadAssetAtPath <GUISkin>(
                "Assets/QFramework/Framework/Toolkits/Core/Editor/Markdown/Skin/MarkdownSkinQS.guiskin");


            mMarkdownViewer = new MarkdownViewer(skin, string.Empty, "");
            // 右侧
            mRightLayout = EasyIMGUI.Vertical()
                           .AddChild(EasyIMGUI.Area().WithRectGetter(() => mRightRect)
                                     // 间距 20
                                     .AddChild(EasyIMGUI.Vertical()
                                               .AddChild(EasyIMGUI.Space().Pixel(20))
                                               )
                                     // 详细信息
                                     .AddChild(EasyIMGUI.Vertical()
                                               .WithVisibleCondition(() => mSelectedPackageRepository != null)
                                               // 名字
                                               .AddChild(EasyIMGUI.Label()
                                                         .TextGetter(() => mSelectedPackageRepository.name)
                                                         .FontSize(30)
                                                         .FontBold())
                                               .AddChild(EasyIMGUI.Space())
                                               // 服务器版本
                                               .AddChild(EasyIMGUI.Label()
                                                         .TextGetter(() => "服务器版本: " + mSelectedPackageRepository.latestVersion)
                                                         .FontSize(15))
                                               // 本地版本
                                               .AddChild(EasyIMGUI.Label()
                                                         .WithVisibleCondition(() =>
                                                                               localPackageVersionModel.GetByName(mSelectedPackageRepository.name).IsNotNull())
                                                         .TextGetter(() =>
                                                                     "本地版本:" + localPackageVersionModel.GetByName(mSelectedPackageRepository.name).Version)
                                                         .FontSize(15))
                                               // 作者
                                               .AddChild(EasyIMGUI.Label()
                                                         .TextGetter(() => "作者:" + mSelectedPackageRepository.author)
                                                         .FontSize(15))
                                               // 权限
                                               .AddChild(EasyIMGUI.Label()
                                                         .TextGetter(() => "权限:" + mSelectedPackageRepository.accessRight)
                                                         .FontSize(15))
                                               // 主页
                                               .AddChild(
                                                   EasyIMGUI.Horizontal()
                                                   .AddChild(EasyIMGUI.Label()
                                                             .FontSize(15)
                                                             .Text("插件主页:"))
                                                   .AddChild(EasyIMGUI.Button()
                                                             .TextGetter(() => UrlHelper.PackageUrl(mSelectedPackageRepository))
                                                             .FontSize(15)
                                                             .OnClick(() =>
            {
                this.SendCommand(new OpenDetailCommand(mSelectedPackageRepository));
            })
                                                             )
                                                   .AddChild(EasyIMGUI.FlexibleSpace())
                                                   )
                                               // 描述
                                               .AddChild(EasyIMGUI.Label()
                                                         .TextGetter(() => "描述:")
                                                         .FontSize(15)
                                                         )
                                               .AddChild(EasyIMGUI.Space())
                                               // 描述内容
                                               .AddChild(EasyIMGUI.Custom().OnGUI(() =>
            {
                mMarkdownViewer.UpdateText(mSelectedPackageRepository.description);
                var lastRect = GUILayoutUtility.GetLastRect();
                mMarkdownViewer.DrawWithRect(new Rect(lastRect.x, lastRect.y + lastRect.height,
                                                      mRightRect.width - 210, mRightRect.height - lastRect.y - lastRect.height));
                // mMarkdownViewer.Draw();
            }))
                                               )
                                     );

            mPackageKitWindow = EditorWindow.GetWindow <PackageKitWindow>();

            this.SendCommand <PackageManagerInitCommand>();


            PackageManagerState.Categories.Bind(value =>
            {
                mCategoriesSelectorView.Menus(value);
                mPackageKitWindow.Repaint();
            }).AddToDisposeList(mDisposableList);


            // 创建双屏
            mSplitView = mSplitView = new VerticalSplitView
            {
                Split   = 240,
                fistPan = rect =>
                {
                    mLeftRect = rect;
                    mLeftLayout.DrawGUI();
                },
                secondPan = rect =>
                {
                    mRightRect = rect;
                    mRightLayout.DrawGUI();
                }
            };
        }
        public void OnCreateUIPanelClick()
        {
            var controllerNode = ControllerNode <PackageKit> .Allocate();

            var panelName = mPanelNameToCreate;

            if (panelName.IsNotNullAndEmpty())
            {
                var fullScenePath = "Assets/Scenes/TestUIPanels/".CreateDirIfNotExists()
                                    .Append("Test{0}.unity".FillFormat(panelName)).ToString();

                var panelPrefabPath = "Assets/Art/UIPrefab/".CreateDirIfNotExists()
                                      .Append("{0}.prefab".FillFormat(panelName)).ToString();

                if (File.Exists(panelPrefabPath))
                {
                    (SingletonProperty <PackageKit> .Instance as IArchitecture).GetUtility <IEditorDialogUtility>()
                    .ShowErrorMsg("UI 界面已存在:{0}".FillFormat(panelPrefabPath));
                    return;
                }

                if (File.Exists(fullScenePath))
                {
                    (SingletonProperty <PackageKit> .Instance as IArchitecture).GetUtility <IEditorDialogUtility>()
                    .ShowErrorMsg("测试场景已存在:{0}".FillFormat(fullScenePath));
                    return;
                }

                RenderEndCommandExecutor.PushCommand(() =>
                {
                    var currentScene = SceneManager.GetActiveScene();
                    EditorSceneManager.SaveScene(currentScene);

                    var scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);
                    EditorSceneManager.SaveScene(scene, fullScenePath);

                    var uiroot = Resources.Load <GameObject>("UIRoot").Instantiate().Name("UIRoot");

                    var designTransform = uiroot.transform.Find("Design");

                    var gameObj = new GameObject(panelName);
                    gameObj.transform.Parent(designTransform)
                    .LocalScaleIdentity();

                    var rectTransform                = gameObj.AddComponent <RectTransform>();
                    rectTransform.offsetMin          = Vector2.zero;
                    rectTransform.offsetMax          = Vector2.zero;
                    rectTransform.anchoredPosition3D = Vector3.zero;
                    rectTransform.anchorMin          = Vector2.zero;
                    rectTransform.anchorMax          = Vector2.one;

                    var prefab = PrefabUtils.SaveAndConnect(panelPrefabPath, gameObj);

                    EditorSceneManager.SaveScene(scene);

                    // 标记 AssetBundle
                    ResKitAssetsMenu.MarkAB(panelPrefabPath);

                    var tester = new GameObject("Test{0}".FillFormat(panelName));
                    // var uiPanelTester = tester.AddComponent<UIPanelTester>();
                    // uiPanelTester.PanelName = panelName;

                    // 开始生成代码
                    UICodeGenerator.DoCreateCode(new[] { prefab });
                });
            }

            controllerNode.Recycle2Cache();
            controllerNode = null;
        }