예제 #1
0
        public GameObject CreateIntegerPropertyFilterPanel(string propertyName, string displayName)
        {
            GameObject newPanel = Instantiate(integerPropertyPanel.gameObject, propertyFiltersContent);

            newPanel.gameObject.SetActive(true);

            SearchPropertyPanel config = newPanel.GetComponent <SearchPropertyPanel>();

            config.nameLabelText.text = !string.IsNullOrEmpty(displayName) ? displayName : propertyName;
            int storedFilter;

            if (Filters.IntMinProperties.TryGetValue(propertyName, out storedFilter))
            {
                config.integerMinInputField.text = storedFilter.ToString();
            }
            config.integerMinInputField.onValueChanged.AddListener(text => SetIntMinPropertyFilter(propertyName, text));

            if (Filters.IntMaxProperties.TryGetValue(propertyName, out storedFilter))
            {
                config.integerMaxInputField.text = storedFilter.ToString();
            }
            config.integerMaxInputField.onValueChanged.AddListener(text => SetIntMaxPropertyFilter(propertyName, text));

            return(newPanel);
        }
예제 #2
0
        public GameObject CreateEnumPropertyFilterPanel(PropertyDef property)
        {
            GameObject newPanel = Instantiate(enumPropertyPanel.gameObject, propertyFiltersContent);

            newPanel.gameObject.SetActive(true);

            SearchPropertyPanel config = newPanel.GetComponent <SearchPropertyPanel>();

            config.nameLabelText.text = !string.IsNullOrEmpty(property.Display) ? property.Display : property.Name;
            int storedFilter;

            Filters.EnumProperties.TryGetValue(property.Name, out storedFilter);

            EnumDef enumDef       = CardGameManager.Current.Enums.First(def => def.Property.Equals(property.Name));
            Vector3 localPosition = config.enumToggle.transform.localPosition;
            float   panelWidth    = 0;

            foreach (KeyValuePair <string, string> enumValue in enumDef.Values)
            {
                int lookupKey;
                if (!enumDef.Lookup.TryGetValue(enumValue.Key, out lookupKey))
                {
                    lookupKey = enumDef.CreateLookup(enumValue.Key);
                }
                Toggle newToggle = Instantiate(config.enumToggle.gameObject, config.enumContent).GetOrAddComponent <Toggle>();
                newToggle.isOn = (storedFilter & lookupKey) != 0;
                newToggle.onValueChanged.AddListener(isOn => SetEnumPropertyFilter(property.Name, lookupKey, isOn));
                newToggle.GetComponentInChildren <Text>().text = enumValue.Value;
                newToggle.transform.localPosition = localPosition;
                float         width          = newToggle.GetComponentInChildren <Text>().preferredWidth + 25;
                RectTransform imageTransform = (RectTransform)newToggle.GetComponentInChildren <Image>().transform;
                imageTransform.sizeDelta = new Vector2(width, imageTransform.sizeDelta.y);
                localPosition.x         += width;
                panelWidth += width;
            }

            if (!string.IsNullOrEmpty(property.Empty))
            {
                int lookupKey;
                if (!enumDef.Lookup.TryGetValue(property.Empty, out lookupKey))
                {
                    lookupKey = enumDef.CreateLookup(property.Empty);
                }
                Toggle newToggle = Instantiate(config.enumToggle.gameObject, config.enumContent).GetOrAddComponent <Toggle>();
                newToggle.isOn = (storedFilter & lookupKey) != 0;
                newToggle.onValueChanged.AddListener(isOn => SetEnumPropertyFilter(property.Name, lookupKey, isOn));
                newToggle.GetComponentInChildren <Text>().text = property.Empty;
                newToggle.transform.localPosition = localPosition;
                float         width          = newToggle.GetComponentInChildren <Text>().preferredWidth + 25;
                RectTransform imageTransform = (RectTransform)newToggle.GetComponentInChildren <Image>().transform;
                imageTransform.sizeDelta = new Vector2(width, imageTransform.sizeDelta.y);
                localPosition.x         += width;
                panelWidth += width;
            }
            config.enumToggle.gameObject.SetActive(false);
            config.enumContent.sizeDelta = new Vector2(panelWidth, config.enumContent.sizeDelta.y);

            return(newPanel);
        }
예제 #3
0
        public GameObject CreateStringPropertyFilterPanel(string propertyName, string displayName)
        {
            GameObject newPanel = Instantiate(stringPropertyPanel.gameObject, propertyFiltersContent);

            newPanel.gameObject.SetActive(true);

            SearchPropertyPanel config = newPanel.GetComponent <SearchPropertyPanel>();

            config.nameLabelText.text = !string.IsNullOrEmpty(displayName) ? displayName : propertyName;
            string storedFilter;

            if (Filters.StringProperties.TryGetValue(propertyName, out storedFilter))
            {
                config.stringInputField.text = storedFilter;
            }
            config.stringPlaceHolderText.text = "Enter " + propertyName + "...";
            config.stringInputField.onValueChanged.AddListener(text => SetStringPropertyFilter(propertyName, text));

            return(newPanel);
        }