Пример #1
0
 private void InitializeItems(List <InputListItem> items, string[] paths)
 {
     items.Clear();
     foreach (string path in paths)
     {
         InputListItem item = new InputListItem()
         {
             AssetType = ReproProjectAssetType.Wildcard, AssetPath = path, AssetObject = null
         };
         items.Add(item);
     }
 }
Пример #2
0
    private void CopyItemsFromSettings(List <InputListItem> targetItems, ReproProjectSettings.InputItem[] settingsItems)
    {
        if (settingsItems == null)
        {
            return;
        }

        targetItems.Clear();
        for (int i = 0; i < settingsItems.Length; i++)
        {
            ReproProjectSettings.InputItem sourceItem = settingsItems[i];
            InputListItem item = new InputListItem()
            {
                AssetType = sourceItem.AssetType, AssetPath = sourceItem.AssetPath, AssetObject = null
            };
            if (item.AssetType != ReproProjectAssetType.Wildcard && !string.IsNullOrEmpty(item.AssetPath))
            {
                item.AssetObject = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(item.AssetPath);
            }
            targetItems.Add(item);
        }
    }
Пример #3
0
        public static List <InputListItem> GetContentsColumns(SiteInfo siteInfo, ChannelInfo channelInfo, bool includeAll)
        {
            var items = new List <InputListItem>();

            var attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(channelInfo.Additional.ContentAttributesOfDisplay);
            var pluginIds           = PluginContentManager.GetContentPluginIds(channelInfo);
            var pluginColumns       = PluginContentManager.GetContentColumns(pluginIds);

            var styleInfoList = ContentUtility.GetAllTableStyleInfoList(TableStyleManager.GetContentStyleInfoList(siteInfo, channelInfo));

            styleInfoList.Insert(0, new TableStyleInfo
            {
                AttributeName = ContentAttribute.Sequence,
                DisplayName   = "序号"
            });

            foreach (var styleInfo in styleInfoList)
            {
                if (styleInfo.InputType == InputType.TextEditor)
                {
                    continue;
                }

                var listitem = new InputListItem
                {
                    Text  = styleInfo.DisplayName,
                    Value = styleInfo.AttributeName
                };
                if (styleInfo.AttributeName == ContentAttribute.Title)
                {
                    listitem.Selected = true;
                }
                else
                {
                    if (attributesOfDisplay.Contains(styleInfo.AttributeName))
                    {
                        listitem.Selected = true;
                    }
                }

                if (includeAll || listitem.Selected)
                {
                    items.Add(listitem);
                }
            }

            if (pluginColumns != null)
            {
                foreach (var pluginId in pluginColumns.Keys)
                {
                    var contentColumns = pluginColumns[pluginId];
                    if (contentColumns == null || contentColumns.Count == 0)
                    {
                        continue;
                    }

                    foreach (var columnName in contentColumns.Keys)
                    {
                        var attributeName = $"{pluginId}:{columnName}";
                        var listitem      = new InputListItem
                        {
                            Text  = $"{columnName}({pluginId})",
                            Value = attributeName
                        };

                        if (attributesOfDisplay.Contains(attributeName))
                        {
                            listitem.Selected = true;
                        }

                        if (includeAll || listitem.Selected)
                        {
                            items.Add(listitem);
                        }
                    }
                }
            }

            return(items);
        }
Пример #4
0
    private void OnGUIInputList(List <InputListItem> items)
    {
        for (int i = 0; i < items.Count; i++)
        {
            InputListItem item = items[i];
            EditorGUILayout.BeginHorizontal();

            // Toggle between text and object selection
            ReproProjectAssetType assetType = (ReproProjectAssetType)EditorGUILayout.Popup((int)item.AssetType, m_AssetTypesPopup, GUILayout.Width(80));
            if (assetType != item.AssetType)
            {
                item.AssetObject = (assetType == ReproProjectAssetType.Wildcard) ? null : AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(item.AssetPath);
                item.AssetType   = assetType;
            }

            if (assetType == ReproProjectAssetType.Wildcard)
            {
                // Text field
                item.AssetPath = EditorGUILayout.TextField(item.AssetPath);

                // File browser button
                if (GUILayout.Button("...", GUILayout.Width(40)))
                {
                    string dir       = "Assets";
                    string parentDir = string.IsNullOrEmpty(item.AssetPath) ? "" : Path.GetDirectoryName(item.AssetPath);
                    if (Directory.Exists(item.AssetPath))
                    {
                        dir = item.AssetPath;
                    }
                    else if (Directory.Exists(parentDir))
                    {
                        dir = parentDir;
                    }
                    string newAsset = EditorUtility.OpenFilePanel("Add File", dir, "");
                    if (!string.IsNullOrEmpty(newAsset))
                    {
                        newAsset       = newAsset.Replace(m_CurrentProjectPath, "").TrimStart(new char[] { '/', '\\' });
                        item.AssetPath = newAsset;
                        GUI.FocusControl("");
                    }
                }
            }
            else
            {
                // Object selection field
                UnityEngine.Object obj = EditorGUILayout.ObjectField(item.AssetObject, m_AssetBrowserTypes[(int)item.AssetType], allowSceneObjects: false);
                if (obj != item.AssetObject)
                {
                    item.AssetObject = obj;
                    item.AssetPath   = obj != null?AssetDatabase.GetAssetPath(obj) : "";
                }
            }

            // save item data back into list
            items[i] = item;

            // Remove entry button
            if (GUILayout.Button("-", GUILayout.Width(40)))
            {
                // remove this item from the list
                items.RemoveAt(i);
                i--;
            }
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("", GUILayout.Width(10));
        if (GUILayout.Button("+"))
        {
            items.Add(new InputListItem()
            {
                AssetType = ReproProjectAssetType.Scene, AssetPath = "", AssetObject = null
            });
        }
        EditorGUILayout.EndHorizontal();
    }
Пример #5
0
        public IHttpActionResult GetAttributes()
        {
            try
            {
                var request   = Context.AuthenticatedRequest;
                var siteId    = request.GetQueryInt("siteId");
                var channelId = request.GetQueryInt("channelId");
                var ruleId    = request.GetQueryInt("ruleId");

                if (!request.IsAdminLoggin ||
                    !request.AdminPermissions.HasSitePermissions(siteId, Utils.PluginId))
                {
                    return(Unauthorized());
                }

                var attributes         = new List <InputListItem>();
                var contentAttributes  = Context.ContentApi.GetInputStyles(siteId, channelId);
                var selectedAttributes = new List <string>();

                if (ruleId > 0)
                {
                    var ruleInfo = Main.GatherRuleRepository.GetGatherRuleInfo(ruleId);
                    selectedAttributes = TranslateUtils.StringCollectionToStringList(ruleInfo.ContentAttributes);
                }

                foreach (var attribute in contentAttributes)
                {
                    if (StringUtils.EqualsIgnoreCase(attribute.AttributeName, ContentAttribute.Title) ||
                        StringUtils.EqualsIgnoreCase(attribute.AttributeName, ContentAttribute.Content) ||
                        StringUtils.EqualsIgnoreCase(attribute.AttributeName, ContentAttribute.Id) ||
                        StringUtils.EqualsIgnoreCase(attribute.AttributeName, ContentAttribute.LastEditDate) ||
                        StringUtils.EqualsIgnoreCase(attribute.AttributeName, ContentAttribute.AddUserName) ||
                        StringUtils.EqualsIgnoreCase(attribute.AttributeName, ContentAttribute.LastEditUserName) ||
                        StringUtils.EqualsIgnoreCase(attribute.AttributeName, ContentAttribute.AdminId) ||
                        StringUtils.EqualsIgnoreCase(attribute.AttributeName, ContentAttribute.UserId) ||
                        StringUtils.EqualsIgnoreCase(attribute.AttributeName, ContentAttribute.SourceId) ||
                        StringUtils.EqualsIgnoreCase(attribute.AttributeName, ContentAttribute.HitsByDay) ||
                        StringUtils.EqualsIgnoreCase(attribute.AttributeName, ContentAttribute.HitsByWeek) ||
                        StringUtils.EqualsIgnoreCase(attribute.AttributeName, ContentAttribute.HitsByMonth) ||
                        StringUtils.EqualsIgnoreCase(attribute.AttributeName, ContentAttribute.LastHitsDate) ||
                        StringUtils.EqualsIgnoreCase(attribute.AttributeName, "CheckUserName") ||
                        StringUtils.EqualsIgnoreCase(attribute.AttributeName, "CheckDate") ||
                        StringUtils.EqualsIgnoreCase(attribute.AttributeName, "CheckReasons"))
                    {
                        continue;
                    }

                    var listItem = new InputListItem
                    {
                        Value = attribute.AttributeName,
                        Text  = attribute.DisplayName
                    };
                    if (StringUtils.ContainsIgnoreCase(selectedAttributes, attribute.AttributeName))
                    {
                        listItem.Selected = true;
                    }
                    attributes.Add(listItem);
                }

                return(Ok(new
                {
                    Value = attributes
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }