Пример #1
0
    private void PopulateGeneratedLegend(OverlayInfo info, bool isRefresh = false)
    {
        if (isRefresh)
        {
            RemoveActiveObjects();
        }
        if (info.infoUnits != null && info.infoUnits.Count > 0)
        {
            PopulateOverlayInfoUnits(info, isRefresh);
        }
        List <LegendEntry> customLegendData = currentMode.GetCustomLegendData();

        if (customLegendData != null)
        {
            activeUnitsParent.SetActive(true);
            foreach (LegendEntry item in customLegendData)
            {
                GameObject freeUnitObject = GetFreeUnitObject();
                Image      component      = freeUnitObject.transform.Find("Icon").GetComponent <Image>();
                component.gameObject.SetActive(true);
                component.sprite  = Assets.instance.LegendColourBox;
                component.color   = item.colour;
                component.enabled = true;
                component.type    = Image.Type.Simple;
                LocText componentInChildren = freeUnitObject.GetComponentInChildren <LocText>();
                componentInChildren.text    = item.name;
                componentInChildren.color   = Color.white;
                componentInChildren.enabled = true;
                ToolTip component2 = freeUnitObject.GetComponent <ToolTip>();
                component2.enabled = true;
                component2.toolTip = item.desc;
                freeUnitObject.SetActive(true);
                freeUnitObject.transform.SetParent(activeUnitsParent.transform);
            }
        }
        else
        {
            activeUnitsParent.SetActive(false);
        }
        if (!isRefresh && currentMode.legendFilters != null)
        {
            GameObject gameObject = Util.KInstantiateUI(toolParameterMenuPrefab, diagramsParent, false);
            activeDiagrams.Add(gameObject);
            diagramsParent.SetActive(true);
            filterMenu = gameObject.GetComponent <ToolParameterMenu>();
            filterMenu.PopulateMenu(currentMode.legendFilters);
            filterMenu.onParametersChanged += OnFiltersChanged;
            OnFiltersChanged();
        }
    }
Пример #2
0
        /// <summary>
        /// Sets up tool options in the tool parameter menu.
        /// </summary>
        /// <param name="menu">The menu to configure.</param>
        /// <param name="options">The available modes.</param>
        /// <returns>A dictionary which is updated in real time to contain the actual state of each mode.</returns>
        public static IDictionary <string, ToolParameterMenu.ToggleState> PopulateMenu(
            ToolParameterMenu menu, ICollection <PToolMode> options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }
            var kOpt = new Dictionary <string, ToolParameterMenu.ToggleState>(options.Count);

            // Add to Klei format, yes it loses the order but it means less of a mess
            foreach (var option in options)
            {
                string key = option.Key;
                Strings.Add("STRINGS.UI.TOOLS.FILTERLAYERS." + key, option.Title);
                kOpt.Add(key, option.State);
            }
            menu.PopulateMenu(kOpt);
            return(kOpt);
        }