Example #1
0
 public StatusItemEntry(StatusItemGroup.Entry item, StatusItemCategory category, GameObject status_item_prefab, Transform parent, TextStyleSetting tooltip_style, Color color, TextStyleSetting style, bool skip_fade, Action <StatusItemEntry> onDestroy)
 {
     this.item      = item;
     this.category  = category;
     tooltipStyle   = tooltip_style;
     this.onDestroy = onDestroy;
     this.color     = color;
     this.style     = style;
     widget         = Util.KInstantiateUI(status_item_prefab, parent.gameObject, false);
     text           = widget.GetComponentInChildren <LocText>(true);
     SetTextStyleSetting.ApplyStyle(text, style);
     toolTip = widget.GetComponentInChildren <ToolTip>(true);
     image   = widget.GetComponentInChildren <Image>(true);
     item.SetIcon(image);
     widget.SetActive(true);
     toolTip.OnToolTip = OnToolTip;
     button            = widget.GetComponentInChildren <KButton>();
     if (item.item.statusItemClickCallback != null)
     {
         button.onClick += OnClick;
     }
     else
     {
         button.enabled = false;
     }
     fadeStage = (skip_fade ? FadeStage.WAIT : FadeStage.IN);
     SimAndRenderScheduler.instance.Add(this, false);
     Refresh();
     SetColor(1f);
 }
        /// <summary>
        /// Updates an individual resource entry with the critters found.
        /// </summary>
        /// <param name="entry">The entry to update.</param>
        /// <param name="quantity">The quantity of this critter which is present.</param>
        private static void UpdateEntry(ResourceEntry entry, CritterTotals quantity)
        {
            var trEntry = Traverse.Create(entry);
            // Update the tool tip text
            var tooltip = trEntry.GetField <ToolTip>("tooltip");

            if (tooltip != null)
            {
                tooltip.OnToolTip = null;
                tooltip.toolTip   = CritterInventoryUtils.FormatTooltip(entry.NameLabel.text,
                                                                        quantity);
            }
            // Determine the color for the labels
            var color = trEntry.GetField <Color>("AvailableColor");

            if (quantity.Available <= 0)
            {
                color = trEntry.GetField <Color>("UnavailableColor");
            }
            LocText qLabel = entry.QuantityLabel, nLabel = entry.NameLabel;

            if (qLabel.color != color)
            {
                qLabel.color = color;
            }
            if (nLabel.color != color)
            {
                nLabel.color = color;
            }
            // Add up overall totals
            qLabel.SetText(quantity.Available.ToString());
        }
    public void SetFailed()
    {
        MultiToggle component = GetComponent <MultiToggle>();

        component.ChangeState(2);
        HierarchyReferences component2 = GetComponent <HierarchyReferences>();

        component2.GetReference <Image>("iconBG").color = color_dark_grey;
        component2.GetReference <Image>("iconBG").SetAlpha(0.5f);
        component2.GetReference <Image>("iconBorder").color = color_grey;
        component2.GetReference <Image>("iconBorder").SetAlpha(0.5f);
        component2.GetReference <Image>("icon").color = color_grey;
        component2.GetReference <Image>("icon").SetAlpha(0.5f);
        LocText[] componentsInChildren = GetComponentsInChildren <LocText>();
        foreach (LocText locText in componentsInChildren)
        {
            LocText locText2 = locText;
            Color   color    = locText.color;
            float   r        = color.r;
            Color   color2   = locText.color;
            float   g        = color2.g;
            Color   color3   = locText.color;
            locText2.color = new Color(r, g, color3.b, 0.25f);
        }
        ConfigureToolTip(GetComponent <ToolTip>(), COLONY_ACHIEVEMENTS.FAILED_THIS_COLONY);
    }
Example #4
0
 public void RefreshToggleContents()
 {
     foreach (KeyValuePair <Tag, KToggle> elementToggle in ElementToggles)
     {
         KToggle    value                = elementToggle.Value;
         Tag        elem                 = elementToggle.Key;
         GameObject gameObject           = value.gameObject;
         LocText[]  componentsInChildren = gameObject.GetComponentsInChildren <LocText>();
         LocText    locText              = componentsInChildren[0];
         LocText    locText2             = componentsInChildren[1];
         Image      image                = gameObject.GetComponentsInChildren <Image>()[1];
         locText2.text = Util.FormatWholeNumber(WorldInventory.Instance.GetAmount(elem));
         locText.text  = Util.FormatWholeNumber(activeMass);
         GameObject gameObject2 = Assets.TryGetPrefab(elementToggle.Key);
         if ((Object)gameObject2 != (Object)null)
         {
             KBatchedAnimController component = gameObject2.GetComponent <KBatchedAnimController>();
             image.sprite = Def.GetUISpriteFromMultiObjectAnim(component.AnimFiles[0], "ui", false, string.Empty);
         }
         gameObject.SetActive(WorldInventory.Instance.IsDiscovered(elem) || DebugHandler.InstantBuildMode || Game.Instance.SandboxModeActive);
         SetToggleBGImage(elementToggle.Value, elementToggle.Key);
         value.soundPlayer.AcceptClickCondition = (() => IsEnoughMass(elem));
         value.ClearOnClick();
         if (IsEnoughMass(elem))
         {
             value.onClick += delegate
             {
                 OnSelectMaterial(elem, activeRecipe, false);
             };
         }
     }
     SortElementToggles();
     UpdateMaterialTooltips();
     UpdateHeader();
 }
            public static void Postfix(ManagementMenu.ScreenData screenData, ManagementMenu __instance)
            {
                KIconToggleMenu.ToggleInfo researchInfo = Traverse.Create(__instance).Field("researchInfo").GetValue <KIconToggleMenu.ToggleInfo>();
                ManagementMenu.ScreenData  activeScreen = Traverse.Create(__instance).Field("activeScreen").GetValue <ManagementMenu.ScreenData>();

                if (screenData.toggleInfo == researchInfo && activeScreen == screenData)
                {
                    RequirementFunctions.CountResourcesInReservoirs();
                    ResearchScreen researchScreen             = (ResearchScreen)ManagementMenu.Instance.researchScreen;
                    Dictionary <Tech, ResearchEntry> entryMap = Traverse.Create(researchScreen).Field("entryMap").GetValue <Dictionary <Tech, ResearchEntry> >();
                    foreach (Tech tech in entryMap.Keys)
                    {
                        if (!tech.IsComplete())
                        {
                            LocText researchName = Traverse.Create(entryMap[tech]).Field("researchName").GetValue <LocText>();
                            if (!TechRequirements.Instance.HasTechReq(tech.Id))
                            {
                                continue;
                            }
                            researchName.GetComponent <ToolTip>().toolTip = CreateTechTooltipText(tech);
                        }
                    }
                }

                /*else if (screenData.toggleInfo == researchInfo && activeScreen != screenData)
                 *  Debug.Log("ResearchRequirements: Research closed");
                 * else
                 *  Debug.Log("ResearchRequirements: Other screen toogled");*/
            }
Example #6
0
 private void UpdateHeader()
 {
     if (activeIngredient != null)
     {
         int num = 0;
         foreach (KeyValuePair <Tag, KToggle> elementToggle in ElementToggles)
         {
             KToggle value = elementToggle.Value;
             if (value.gameObject.activeSelf)
             {
                 num++;
             }
         }
         LocText componentInChildren = Headerbar.GetComponentInChildren <LocText>();
         if (num == 0)
         {
             componentInChildren.text = string.Format(UI.PRODUCTINFO_MISSINGRESOURCES_TITLE, activeIngredient.tag.ProperName(), GameUtil.GetFormattedMass(activeIngredient.amount, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}"));
             string text = string.Format(UI.PRODUCTINFO_MISSINGRESOURCES_DESC, activeIngredient.tag.ProperName());
             NoMaterialDiscovered.text = text;
             NoMaterialDiscovered.gameObject.SetActive(true);
             NoMaterialDiscovered.color = Constants.NEGATIVE_COLOR;
             BadBG.SetActive(true);
             Scrollbar.SetActive(false);
             LayoutContainer.SetActive(false);
         }
         else
         {
             componentInChildren.text = string.Format(UI.PRODUCTINFO_SELECTMATERIAL, activeIngredient.tag.ProperName());
             NoMaterialDiscovered.gameObject.SetActive(false);
             BadBG.SetActive(false);
             LayoutContainer.SetActive(true);
             UpdateScrollBar();
         }
     }
 }
        private static void Postfix(MainMenu __instance, KButton ___buttonPrefab, GameObject ___buttonParent)
        {
            KButton kButton = Util.KInstantiateUI <KButton>(___buttonPrefab.gameObject, ___buttonParent, force_active: true);

            kButton.onClick += () => {
                ConfirmDialogScreen confirmDialogScreen = (ConfirmDialogScreen)KScreenManager.Instance.StartScreen(ScreenPrefabs.Instance.ConfirmDialogScreen.gameObject, Global.Instance.globalCanvas);
                var text = new StringBuilder();
                text.AppendLine("Duplicants rescued:");
                var state = EndpointState.Load();
                foreach (var item in from x in state.times_rescued orderby - x.Value, x.Key select x)
                {
                    if (item.Value == 1)
                    {
                        text.AppendLine(item.Key);
                    }
                    else
                    {
                        text.AppendLine(item.Key + " x" + item.Value);
                    }
                }
                confirmDialogScreen.PopupConfirmDialog(text.ToString(), null, null, null, null, "Endpoint Population");
            };
            LocText loctext = kButton.GetComponentInChildren <LocText>();

            loctext.text     = "ENDPOINT";
            loctext.fontSize = 14.0f;
        }
 internal ProcessConditionRow(GameObject go, bool header)
 {
     // Will never be equal to a valid status
     lastStatus = (ProcessCondition.Status)(-1);
     root       = go;
     root.TryGetComponent(out freeze);
     root.TryGetComponent(out thaw);
     root.TryGetComponent(out tooltip);
     if (root.TryGetComponent(out HierarchyReferences hr))
     {
         text = hr.GetReference <LocText>("Label");
         if (header)
         {
             box   = null;
             check = dash = null;
         }
         else
         {
             box   = hr.GetReference <Image>("Box");
             check = hr.GetReference <Image>("Check").gameObject;
             dash  = hr.GetReference <Image>("Dash").gameObject;
             dash.SetActive(false);
         }
     }
     else
     {
         box   = null;
         text  = null;
         check = dash = null;
     }
     freeze.enabled = false;
     thaw.enabled   = true;
 }
Example #9
0
    private GameObject NewCategoryHeader(KeyValuePair <string, CodexEntry> entryKVP, Dictionary <string, GameObject> categories)
    {
        if (entryKVP.Value.category == string.Empty)
        {
            entryKVP.Value.category = "Root";
        }
        GameObject categoryHeader  = Util.KInstantiateUI(prefabCategoryHeader, navigatorContent.gameObject, true);
        GameObject categoryContent = categoryHeader.GetComponent <HierarchyReferences>().GetReference("Content").gameObject;

        categories.Add(entryKVP.Value.category, categoryContent);
        LocText reference = categoryHeader.GetComponent <HierarchyReferences>().GetReference <LocText>("Label");

        if (CodexCache.entries.ContainsKey(entryKVP.Value.category))
        {
            reference.text = CodexCache.entries[entryKVP.Value.category].name;
        }
        else
        {
            reference.text = Strings.Get("STRINGS.UI.CODEX.CATEGORYNAMES." + entryKVP.Value.category.ToUpper());
        }
        categoryHeaders.Add(categoryHeader);
        categoryContent.SetActive(false);
        MultiToggle reference2 = categoryHeader.GetComponent <HierarchyReferences>().GetReference <MultiToggle>("ExpandToggle");

        reference2.onClick = delegate
        {
            ToggleCategoryOpen(categoryHeader, !categoryContent.activeSelf);
        };
        return(categoryHeader);
    }
Example #10
0
 private void Initialize(List <Event> events)
 {
     foreach (Event @event in events)
     {
         Event current = @event;
         HierarchyReferences hierarchyReferences = Util.KInstantiateUI <HierarchyReferences>(entryPrefab, entryParent.gameObject, true);
         LocText             reference           = hierarchyReferences.GetReference <LocText>("Title");
         LocText             reference2          = hierarchyReferences.GetReference <LocText>("Description");
         KButton             reference3          = hierarchyReferences.GetReference <KButton>("Details");
         Event.GetUIStrings(current.event_type, out string title, out string title_tooltip);
         reference.text = title;
         reference.GetComponent <ToolTip>().toolTip = title_tooltip;
         reference2.text = current.mod.title;
         ToolTip component = reference2.GetComponent <ToolTip>();
         if ((Object)component != (Object)null)
         {
             component.toolTip = current.mod.ToString();
         }
         reference3.isInteractable = false;
         Mod mod = Global.Instance.modManager.FindMod(current.mod);
         if (mod != null)
         {
             if ((Object)component != (Object)null && !string.IsNullOrEmpty(mod.description))
             {
                 component.toolTip = mod.description;
             }
             if (mod.on_managed != null)
             {
                 reference3.onClick       += mod.on_managed;
                 reference3.isInteractable = true;
             }
         }
     }
 }
Example #11
0
        public static void Postfix(Transform ___entryParent)
        {
            string currentPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            for (int i = 0; i < Global.Instance.modManager.mods.Count; ++i)
            {
                KMod.Mod mod = Global.Instance.modManager.mods[i];
                if ((mod.loaded_content & KMod.Content.DLL) == KMod.Content.DLL)
                {
                    if (string.Equals(Path.GetFullPath(mod.label.install_path), currentPath))
                    {
                        string modTitle = mod.label.title;
                        for (int j = 0; j < ___entryParent.childCount; ++j)
                        {
                            Transform           modSpecificTransform = ___entryParent.GetChild(j);
                            HierarchyReferences hierarchyReferences  = modSpecificTransform.GetComponent <HierarchyReferences>();
                            LocText             titleReference       = hierarchyReferences.GetReference <LocText>("Title");

                            if (titleReference != null && titleReference.text == modTitle)
                            {
                                Version version = Assembly.GetExecutingAssembly().GetName().Version;
                                titleReference.text = $"<align=left>{titleReference.text}\n" +
                                                      $"<size=65%>Last updated {FormatDay(version.Build)} {months[version.Minor-1]} {version.Major} - Revision {version.Revision}";
                                titleReference.autoSizeTextContainer = false;

                                break;
                            }
                        }
                        break;
                    }
                }
            }
        }
Example #12
0
 public static void delBr(ref LocText ___title)
 {
     if (___title.text.Contains("<BR>"))
     {
         ___title.text = ___title.text.Substring(0, ___title.text.IndexOf("<BR>"));
     }
 }
Example #13
0
        public static void Postfix(Transform ___entryParent)
        {
            string currentPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            for (int i = 0; i < Global.Instance.modManager.mods.Count; ++i)
            {
                KMod.Mod mod = Global.Instance.modManager.mods[i];

                if ((mod.loaded_content & KMod.Content.DLL) == KMod.Content.DLL)
                {
                    if (string.Equals(Path.GetFullPath(mod.label.install_path), currentPath))
                    {
                        string modTitle = mod.label.title;

                        for (int j = 0; j < ___entryParent.childCount; ++j)
                        {
                            Transform           modSpecificTransform = ___entryParent.GetChild(j);
                            HierarchyReferences hierarchyReferences  = modSpecificTransform.GetComponent <HierarchyReferences>();
                            LocText             titleReference       = hierarchyReferences.GetReference <LocText>("Title");

                            if (titleReference != null && titleReference.text == modTitle)
                            {
                                titleReference.text = "<align=left>" + titleReference.text + " <line-height=0.000000001>\n<align=right>(" + Assembly.GetExecutingAssembly().GetName().Version + ")";
                                titleReference.autoSizeTextContainer = false;

                                break;
                            }
                        }

                        break;
                    }
                }
            }
        }
Example #14
0
        /// <summary>
        /// Updates an individual resource entry with the critters found.
        /// </summary>
        /// <param name="quantity">The quantity of this critter which is present.</param>
        internal void UpdateEntry(CritterTotals quantity)
        {
            // Update the tool tip text
            var tooltip = entry.GetComponent <ToolTip>();

            if (tooltip != null)
            {
                tooltip.OnToolTip = OnEntryTooltip;
            }
            // Determine the color for the labels (overdrawn is impossible for critters)
            var color = AVAILABLE_COLOR.Get(entry);

            if (quantity.Available <= 0)
            {
                color = UNAVAILABLE_COLOR.Get(entry);
            }
            LocText qLabel = entry.QuantityLabel, nLabel = entry.NameLabel;

            if (qLabel.color != color)
            {
                qLabel.color = color;
            }
            if (nLabel.color != color)
            {
                nLabel.color = color;
            }
            // Add up overall totals
            qLabel.SetText(quantity.Available.ToString());
        }
 public void DrawText(string text, TextStyleSetting style, Color color, bool override_color = true)
 {
     if (skin.drawWidgets)
     {
         BeginSample("DrawText");
         Pool <LocText> .Entry entry = textWidgets.Draw(currentPos);
         LocText widget = entry.widget;
         Color   color2 = Color.white;
         if ((UnityEngine.Object)widget.textStyleSetting != (UnityEngine.Object)style)
         {
             widget.textStyleSetting = style;
             widget.ApplySettings();
         }
         if ((UnityEngine.Object)style != (UnityEngine.Object)null)
         {
             color2 = style.textColor;
         }
         if (override_color)
         {
             color2 = color;
         }
         widget.color = color2;
         if (widget.text != text)
         {
             widget.text = text;
             widget.KForceUpdateDirty();
         }
         currentPos.x += widget.renderedWidth;
         maxShadowX    = Mathf.Max(currentPos.x, maxShadowX);
         minLineHeight = (int)Mathf.Max((float)minLineHeight, widget.renderedHeight);
         EndSample();
     }
 }
        public static void ReadAllAgemo(string cnPath, string jpPath)
        {
            //string cnPath = "./cn-text";
            //string jpPath = "./jp-text";
            string[] cnFiles = Directory.GetFiles(cnPath, "*.txt", SearchOption.AllDirectories);
            Dictionary <string, AgemoText.Data> cnDictionary = new Dictionary <string, AgemoText.Data>();

            LocText tempLoc = new LocText("");

            foreach (var fileName in cnFiles)
            {
                string fName = Path.GetFileName(fileName);
                if (File.Exists(cnPath + "/" + fName) && File.Exists(jpPath + "/" + fName))
                {
                    List <AgemoText.Data> cnData = AgemoText.ReadAgemoText(File.ReadAllLines(cnPath + "/" + fName, Encoding.Unicode));
                    List <AgemoText.Data> jpData = AgemoText.ReadAgemoText(File.ReadAllLines(jpPath + "/" + fName, Encoding.Unicode));
                    cnDictionary = convData(cnData);
                    for (int i = 0; i < jpData.Count; i++)
                    {
                        tempLoc = new LocText(jpData[i].Text);
                        if (cnDictionary.ContainsKey(jpData[i].TAG))
                        {
                            tempLoc.zh_CN = cnDictionary[jpData[i].TAG].Text;
                        }
                        DataMgr.Instance.GameTextDictionary.Add(fName + "__" + jpData[i].TAG, tempLoc);
                    }
                }
            }

            ExcelLoader excel = new ExcelLoader("./DDS3_Translation.xlsx");

            excel.WriteExcel(DataMgr.Instance.GameTextDictionary);
        }
Example #17
0
 private void RebuildUGCButtons()
 {
     if (!((UnityEngine.Object)SteamUGCService.Instance == (UnityEngine.Object)null))
     {
         foreach (Mod mod in Global.Instance.modManager.mods)
         {
             if ((mod.available_content & Content.Translation) != 0 && mod.status == Mod.Status.Installed)
             {
                 GameObject gameObject = Util.KInstantiateUI(languageButtonPrefab, ugcLanguagesContainer, false);
                 gameObject.name = mod.title + "_button";
                 HierarchyReferences component      = gameObject.GetComponent <HierarchyReferences>();
                 PublishedFileId_t   file_id        = new PublishedFileId_t(ulong.Parse(mod.label.id));
                 TMP_FontAsset       fontForLangage = GetFontForLangage(file_id);
                 LocText             reference      = component.GetReference <LocText>("Title");
                 reference.SetText(string.Format(UI.FRONTEND.TRANSLATIONS_SCREEN.UGC_MOD_TITLE_FORMAT, mod.title));
                 reference.font = fontForLangage;
                 Texture2D texture2D = SteamUGCService.Instance.FindMod(file_id)?.previewImage;
                 if ((UnityEngine.Object)texture2D != (UnityEngine.Object)null)
                 {
                     Image reference2 = component.GetReference <Image>("Image");
                     reference2.sprite = Sprite.Create(texture2D, new Rect(Vector2.zero, new Vector2((float)texture2D.width, (float)texture2D.height)), Vector2.one * 0.5f);
                 }
                 KButton component2 = gameObject.GetComponent <KButton>();
                 component2.onClick += delegate
                 {
                     ConfirmLanguageChoiceDialog(string.Empty, file_id);
                 };
                 buttons.Add(gameObject);
             }
         }
     }
 }
Example #18
0
    private void PopulateNoiseLegend(OverlayInfo info)
    {
        if (info.infoUnits != null && info.infoUnits.Count > 0)
        {
            PopulateOverlayInfoUnits(info, false);
        }
        string[] names  = Enum.GetNames(typeof(AudioEventManager.NoiseEffect));
        Array    values = Enum.GetValues(typeof(AudioEventManager.NoiseEffect));

        Color[] dbColours = SimDebugView.dbColours;
        for (int i = 0; i < names.Length; i++)
        {
            GameObject freeUnitObject = GetFreeUnitObject();
            Image      component      = freeUnitObject.transform.Find("Icon").GetComponent <Image>();
            component.gameObject.SetActive(true);
            component.sprite  = Assets.instance.LegendColourBox;
            component.color   = ((i != 0) ? Color.Lerp(dbColours[i * 2], dbColours[Mathf.Min(dbColours.Length - 1, i * 2 + 1)], 0.5f) : new Color(1f, 1f, 1f, 0.7f));
            component.enabled = true;
            component.type    = Image.Type.Simple;
            string  str  = names[i].ToUpper();
            int     num  = (int)values.GetValue(i);
            int     num2 = (int)values.GetValue(i);
            LocText componentInChildren = freeUnitObject.GetComponentInChildren <LocText>();
            componentInChildren.text    = Strings.Get("STRINGS.UI.OVERLAYS.NOISE_POLLUTION.NAMES." + str) + " " + string.Format(UI.OVERLAYS.NOISE_POLLUTION.RANGE, num);
            componentInChildren.color   = Color.white;
            componentInChildren.enabled = true;
            ToolTip component2 = freeUnitObject.GetComponent <ToolTip>();
            component2.enabled = true;
            component2.toolTip = string.Format(Strings.Get("STRINGS.UI.OVERLAYS.NOISE_POLLUTION.TOOLTIPS." + str), num, num2);
            freeUnitObject.SetActive(true);
            freeUnitObject.transform.SetParent(activeUnitsParent.transform);
        }
    }
Example #19
0
 private void RebuildPreinstalledButtons()
 {
     foreach (string preinstalledLanguage in Localization.PreinstalledLanguages)
     {
         if (!(preinstalledLanguage != Localization.DEFAULT_LANGUAGE_CODE) || File.Exists(Localization.GetPreinstalledLocalizationFilePath(preinstalledLanguage)))
         {
             GameObject gameObject = Util.KInstantiateUI(languageButtonPrefab, preinstalledLanguagesContainer, false);
             gameObject.name = preinstalledLanguage + "_button";
             HierarchyReferences component = gameObject.GetComponent <HierarchyReferences>();
             LocText             reference = component.GetReference <LocText>("Title");
             reference.text    = Localization.GetPreinstalledLocalizationTitle(preinstalledLanguage);
             reference.enabled = false;
             reference.enabled = true;
             Texture2D preinstalledLocalizationImage = Localization.GetPreinstalledLocalizationImage(preinstalledLanguage);
             if ((UnityEngine.Object)preinstalledLocalizationImage != (UnityEngine.Object)null)
             {
                 Image reference2 = component.GetReference <Image>("Image");
                 reference2.sprite = Sprite.Create(preinstalledLocalizationImage, new Rect(Vector2.zero, new Vector2((float)preinstalledLocalizationImage.width, (float)preinstalledLocalizationImage.height)), Vector2.one * 0.5f);
             }
             KButton component2 = gameObject.GetComponent <KButton>();
             component2.onClick += delegate
             {
                 ConfirmLanguageChoiceDialog((!(preinstalledLanguage != Localization.DEFAULT_LANGUAGE_CODE)) ? string.Empty : preinstalledLanguage, PublishedFileId_t.Invalid);
             };
             buttons.Add(gameObject);
         }
     }
 }
 public void ConfigureLabel(LocText label, Dictionary <CodexTextStyle, TextStyleSetting> textStyles)
 {
     label.gameObject.SetActive(true);
     label.AllowLinks       = (style == CodexTextStyle.Body);
     label.textStyleSetting = textStyles[style];
     label.text             = text;
     label.ApplySettings();
 }
        public LogicSettingUIInfo(LocText prefab, LogicLabelSetting logicSettingDispComp)
        {
            logicSettingDisplay = logicSettingDispComp;
            cachedLocText       = prefab;

            prefab.transform.position = logicSettingDisplay.position + LabelPrefab.offset;
            var rectTransform = prefab.GetComponent <RectTransform>();

            rectTransform.sizeDelta = logicSettingDisplay.sizeDelta * rectTransform.InverseLocalScale();
            prefab.gameObject.SetActive(true);
        }
    private KButton MakeButton(ButtonInfo info)
    {
        KButton kButton = Util.KInstantiateUI <KButton>(buttonPrefab.gameObject, buttonParent, true);

        kButton.onClick += info.action;
        LocText componentInChildren = kButton.GetComponentInChildren <LocText>();

        componentInChildren.text     = info.text;
        componentInChildren.fontSize = (float)info.fontSize;
        return(kButton);
    }
Example #23
0
        public static KButton MakeKButton(ButtonInfo info, GameObject buttonPrefab, GameObject parent, int index = 0)
        {
            KButton kbutton = Util.KInstantiateUI <KButton>(buttonPrefab, parent, true);

            kbutton.onClick += info.action;
            kbutton.transform.SetSiblingIndex(index);
            LocText componentInChildren = kbutton.GetComponentInChildren <LocText>();

            componentInChildren.text     = info.text;
            componentInChildren.fontSize = info.fontSize;
            return(kbutton);
        }
Example #24
0
    public override GameObject GetHeaderWidget(GameObject parent)
    {
        GameObject headerWidget        = base.GetHeaderWidget(parent);
        LocText    componentInChildren = headerWidget.GetComponentInChildren <LocText>();

        if ((UnityEngine.Object)componentInChildren != (UnityEngine.Object)null)
        {
            headerWidget.GetComponentInChildren <LocText>().text = get_header_label(headerWidget);
        }
        headerWidget.GetComponentInChildren <MultiToggle>().gameObject.SetActive(false);
        return(headerWidget);
    }
Example #25
0
    private void RebuildUGCButtons()
    {
        ListPool <SteamUGCService.Mod, ScenariosMenu> .PooledList pooledList = ListPool <SteamUGCService.Mod, ScenariosMenu> .Allocate();

        bool flag = pooledList.Count > 0;

        noScenariosText.gameObject.SetActive(!flag);
        contentRoot.gameObject.SetActive(flag);
        bool flag2 = true;

        if (pooledList.Count != 0)
        {
            for (int i = 0; i < pooledList.Count; i++)
            {
                GameObject gameObject = Util.KInstantiateUI(ugcButtonPrefab, ugcContainer, false);
                gameObject.name = pooledList[i].title + "_button";
                gameObject.gameObject.SetActive(true);
                HierarchyReferences component      = gameObject.GetComponent <HierarchyReferences>();
                TMP_FontAsset       fontForLangage = LanguageOptionsScreen.GetFontForLangage(pooledList[i].fileId);
                LocText             reference      = component.GetReference <LocText>("Title");
                reference.SetText(pooledList[i].title);
                reference.font = fontForLangage;
                Texture2D previewImage = pooledList[i].previewImage;
                if ((UnityEngine.Object)previewImage != (UnityEngine.Object)null)
                {
                    Image reference2 = component.GetReference <Image>("Image");
                    reference2.sprite = Sprite.Create(previewImage, new Rect(Vector2.zero, new Vector2((float)previewImage.width, (float)previewImage.height)), Vector2.one * 0.5f);
                }
                KButton           component2 = gameObject.GetComponent <KButton>();
                int               index      = i;
                PublishedFileId_t item       = pooledList[index].fileId;
                component2.onClick += delegate
                {
                    ShowDetails(item);
                };
                component2.onDoubleClick += delegate
                {
                    LoadScenario(item);
                };
                buttons.Add(gameObject);
                if (item == activeItem)
                {
                    flag2 = false;
                }
            }
        }
        if (flag2)
        {
            HideDetails();
        }
        pooledList.Recycle();
    }
Example #26
0
            public static void RefreshPatch(MeterScreen __instance)
            {
                if (__instance.RationsText.text.Contains("|"))
                {
                    string text = __instance.RationsText.text.Split(new char[] { '|' })[0];
                    __instance.RationsText.text = text.Trim() + " | " + STclockMod.FormatAsClock(STclockMod.GetClock());
                    return;
                }
                LocText rationsText = __instance.RationsText;

                rationsText.text = rationsText.text + " | " + STclockMod.FormatAsClock(STclockMod.GetClock());
                return;
            }
    public void PopupConfirmDialog(string text, System.Action on_confirm, System.Action on_cancel, string configurable_text = null, System.Action on_configurable_clicked = null, string title_text = null, string confirm_text = null, string cancel_text = null, Sprite image_sprite = null, bool activateBlackBackground = true)
    {
        while ((UnityEngine.Object)base.transform.parent.GetComponent <Canvas>() == (UnityEngine.Object)null && (UnityEngine.Object)base.transform.parent.parent != (UnityEngine.Object)null)
        {
            base.transform.SetParent(base.transform.parent.parent);
        }
        base.transform.SetAsLastSibling();
        fadeBG.SetActive(activateBlackBackground);
        confirmAction      = on_confirm;
        cancelAction       = on_cancel;
        configurableAction = on_configurable_clicked;
        int num = 0;

        if (confirmAction != null)
        {
            num++;
        }
        if (cancelAction != null)
        {
            num++;
        }
        if (configurableAction != null)
        {
            num++;
        }
        confirmButton.GetComponentInChildren <LocText>().text = ((confirm_text != null) ? confirm_text : UI.CONFIRMDIALOG.OK.text);
        cancelButton.GetComponentInChildren <LocText>().text  = ((cancel_text != null) ? cancel_text : UI.CONFIRMDIALOG.CANCEL.text);
        confirmButton.GetComponent <KButton>().onClick       += OnSelect_OK;
        cancelButton.GetComponent <KButton>().onClick        += OnSelect_CANCEL;
        configurableButton.GetComponent <KButton>().onClick  += OnSelect_third;
        cancelButton.SetActive(on_cancel != null);
        if ((UnityEngine.Object)configurableButton != (UnityEngine.Object)null)
        {
            configurableButton.SetActive(configurableAction != null);
            if (configurable_text != null)
            {
                LocText componentInChildren = configurableButton.GetComponentInChildren <LocText>();
                componentInChildren.text = configurable_text;
            }
        }
        if ((UnityEngine.Object)image_sprite != (UnityEngine.Object)null)
        {
            image.sprite = image_sprite;
            image.gameObject.SetActive(true);
        }
        if (title_text != null)
        {
            titleText.text = title_text;
        }
        popupMessage.text = text;
    }
Example #28
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();
        }
    }
    private void on_load_qualityoflife_expectations(IAssignableIdentity minion, GameObject widget_go)
    {
        TableRow widgetRow           = GetWidgetRow(widget_go);
        LocText  componentInChildren = widget_go.GetComponentInChildren <LocText>(true);

        if (minion != null)
        {
            componentInChildren.text = (GetWidgetColumn(widget_go) as LabelTableColumn).get_value_action(minion, widget_go);
        }
        else
        {
            componentInChildren.text = ((!widgetRow.isDefault) ? UI.VITALSSCREEN.QUALITYOFLIFE_EXPECTATIONS.ToString() : string.Empty);
        }
    }
 private void Initialize()
 {
     if ((Object)unitLabel == (Object)null)
     {
         unitLabel = currentKJLabel.gameObject.GetComponentInChildrenOnly <LocText>();
     }
     if (sizeMap == null || sizeMap.Count == 0)
     {
         sizeMap = new Dictionary <float, float>();
         sizeMap.Add(20000f, 10f);
         sizeMap.Add(40000f, 25f);
         sizeMap.Add(60000f, 40f);
     }
 }