Ejemplo n.º 1
0
        DragList.ItemDescriptor CreateListItem(PackageInfo info)
        {
            string caption;

            if (_view.ViewState == PmViewStates.ReleasesAndPackages)
            {
                var releaseInfo = info.InstallInfo.ReleaseInfo;
                if (!string.IsNullOrEmpty(releaseInfo.Name))
                {
                    caption = "{0} ({1}{2})".Fmt(
                        info.Name,
                        ImguiUtil.WrapWithColor(releaseInfo.Name, _pmSettings.View.Theme.DraggableItemAlreadyAddedColor),
                        string.IsNullOrEmpty(releaseInfo.Version) ? "" : ImguiUtil.WrapWithColor(" v" + releaseInfo.Version, _pmSettings.View.Theme.VersionColor));
                }
                else
                {
                    caption = info.Name;
                }
            }
            else
            {
                // this isn't always the case since it can be rendered when interpolating
                //Assert.IsEqual(_model.ViewState, PmViewStates.PackagesAndProject);

                if (_model.IsPackageAddedToProject(info.Name))
                {
                    caption = ImguiUtil.WrapWithColor(
                        info.Name, _pmSettings.View.Theme.DraggableItemAlreadyAddedColor);
                }
                else
                {
                    caption = info.Name;
                }
            }

            return new DragList.ItemDescriptor()
            {
                Caption = caption,
                Model = info
            };
        }
Ejemplo n.º 2
0
        object GetPackageSortField(PackageInfo info)
        {
            switch ((PackagesSortMethod)_view.GetList(DragListTypes.Package).SortMethod)
            {
                case PackagesSortMethod.Name:
                {
                    return info.Name;
                }
                case PackagesSortMethod.InstallDate:
                {
                    return info.InstallInfo.InstallDateTicks;
                }
                case PackagesSortMethod.ReleasePublishDate:
                {
                    return info.InstallInfo.ReleaseInfo.AssetStoreInfo.PublishDateTicks;
                }
            }

            Assert.Throw();
            return null;
        }
Ejemplo n.º 3
0
        IEnumerator RenamePackageAsync(PackageInfo info)
        {
            var newPackageName = _view.PromptForInput("Enter package name:", info.Name);

            yield return newPackageName;

            if (newPackageName.Current == null)
            {
                // User Cancelled
                yield break;
            }

            if (newPackageName.Current == info.Name)
            {
                yield break;
            }

            var fullPath = PrjPathVars.Expand(info.FullPath);

            Assert.That(Directory.Exists(fullPath), "Expected path to exist: {0}", fullPath);

            var dirInfo = new DirectoryInfo(fullPath);
            Assert.That(dirInfo.Name == info.Name);

            var newPath = Path.Combine(dirInfo.Parent.FullName, newPackageName.Current);

            Assert.That(!Directory.Exists(newPath), "Package with name '{0}' already exists.  Rename aborted.", newPackageName.Current);

            dirInfo.MoveTo(newPath);

            yield return _packageHandler.RefreshPackagesAsync();

            _view.ClearSelected();
            _view.GetList(DragListTypes.Package).Values
                .Where(x => ((PackageInfo)x.Model).Name == newPackageName.Current).Single().IsSelected = true;
        }
Ejemplo n.º 4
0
        IEnumerator OpenMoreInfoPopup(PackageInfo info)
        {
            bool isDone = false;

            var skin = _pmSettings.ReleaseMoreInfoDialog;
            Vector2 scrollPos = Vector2.zero;

            var popupId = _view.AddPopup(delegate(Rect fullRect)
            {
                var popupRect = ImguiUtil.CenterRectInRect(fullRect, skin.PopupSize);

                _view.DrawPopupCommon(fullRect, popupRect);

                var contentRect = ImguiUtil.CreateContentRectWithPadding(
                    popupRect, skin.PanelPadding);

                var scrollViewRect = new Rect(
                    contentRect.xMin, contentRect.yMin, contentRect.width, contentRect.height - skin.MarginBottom - skin.OkButtonHeight - skin.OkButtonTopPadding);

                GUILayout.BeginArea(scrollViewRect);
                {
                    scrollPos = GUILayout.BeginScrollView(scrollPos, false, true, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, skin.ScrollViewStyle, GUILayout.ExpandHeight(true));
                    {
                        GUILayout.Space(skin.ListPaddingTop);
                        GUILayout.Label("Package Info", skin.HeadingStyle);
                        GUILayout.Space(skin.HeadingBottomPadding);

                        PmViewHandlerCommon.DrawMoreInfoRow(skin, "Name", info.Name);
                        GUILayout.Space(skin.RowSpacing);
                        PmViewHandlerCommon.DrawMoreInfoRow(skin, "Path", info.FullPath);
                        GUILayout.Space(skin.RowSpacing);
                        PmViewHandlerCommon.DrawMoreInfoRow(skin, "Creation Date", !string.IsNullOrEmpty(info.InstallInfo.InstallDate) ? info.InstallInfo.InstallDate : PmViewHandlerCommon.NotAvailableLabel);

                        GUILayout.Space(skin.ListPaddingTop);
                        GUILayout.Space(skin.ListPaddingTop);
                        GUILayout.Label("Release Info", skin.HeadingStyle);
                        GUILayout.Space(skin.HeadingBottomPadding);

                        if (string.IsNullOrEmpty(info.InstallInfo.ReleaseInfo.Id))
                        {
                            GUI.color = skin.ValueStyle.normal.textColor;
                            GUILayout.Label("No release is associated with this package", skin.HeadingStyle);
                            GUI.color = Color.white;
                        }
                        else
                        {
                            PmViewHandlerCommon.AddReleaseInfoMoreInfoRows(info.InstallInfo.ReleaseInfo, skin);
                        }

                        GUILayout.Space(skin.RowSpacing);
                    }
                    GUI.EndScrollView();
                }
                GUILayout.EndArea();

                var okButtonRect = new Rect(
                    contentRect.xMin + 0.5f * contentRect.width - 0.5f * skin.OkButtonWidth,
                    contentRect.yMax - skin.MarginBottom - skin.OkButtonHeight,
                    skin.OkButtonWidth,
                    skin.OkButtonHeight);

                if (GUI.Button(okButtonRect, "Ok") || Event.current.keyCode == KeyCode.Escape)
                {
                    isDone = true;
                }
            });

            while (!isDone)
            {
                yield return null;
            }

            _view.RemovePopup(popupId);
        }
Ejemplo n.º 5
0
 bool HasPackageYaml(PackageInfo info)
 {
     var fullPath = PrjPathVars.Expand(info.FullPath);
     var configPath = Path.Combine(fullPath, ProjenyEditorUtil.PackageConfigFileName);
     return File.Exists(configPath);
 }
Ejemplo n.º 6
0
 bool HasPackageYaml(PackageInfo info)
 {
     var configPath = Path.Combine(info.Path, ProjenyEditorUtil.PackageConfigFileName);
     return File.Exists(configPath);
 }