コード例 #1
0
        public override string GetLocalizedTooltip()
        {
            string text = LocaleFormatter.FormatGeneric("AIINFO_WATER_CONSUMPTION", new object[]
            {
                this.GetWaterConsumption() * 16
            }) + Environment.NewLine + LocaleFormatter.FormatGeneric("AIINFO_ELECTRICITY_CONSUMPTION", new object[]
            {
                this.GetElectricityConsumption() * 16
            });

            if (this.m_waterConsumption > 0)
            {
                return(TooltipHelper.Append(base.GetLocalizedTooltip(), TooltipHelper.Format(new string[]
                {
                    LocaleFormatter.Info1,
                    text,
                    LocaleFormatter.Info2,
                    LocaleFormatter.FormatGeneric("AIINFO_WATER_INTAKE", new object[]
                    {
                        this.m_waterConsumption * 16 * m_consumption_multiplier
                    })
                })));
            }
            return(TooltipHelper.Append(base.GetLocalizedTooltip(), TooltipHelper.Format(new string[]
            {
                LocaleFormatter.Info1,
                text,
                LocaleFormatter.Info2,
                LocaleFormatter.FormatGeneric("AIINFO_WATER_OUTLET", new object[]
                {
                    this.m_waterConsumption * 16 * m_consumption_multiplier
                })
            })));
        }
コード例 #2
0
 public override string GetLocalizedTooltip()
 {
     return(TooltipHelper.Append(base.GetLocalizedTooltip(), TooltipHelper.Format(new string[]
     {
         LocaleFormatter.Info2,
         LocaleFormatter.FormatGeneric("AIINFO_WATER_OUTLET", new object[]
         {
             0
         })
     })));
 }
コード例 #3
0
 public bool showVersionInfoPopup(bool force = false)
 {
     if (needShowPopup || force)
     {
         try
         {
             UIComponent uIComponent = UIView.library.ShowModal("ExceptionPanel");
             if (uIComponent != null)
             {
                 Cursor.lockState = CursorLockMode.None;
                 Cursor.visible   = true;
                 BindPropertyByKey component = uIComponent.GetComponent <BindPropertyByKey>();
                 if (component != null)
                 {
                     string title = "Transport Lines Manager v" + version;
                     string notes = ResourceLoader.loadResourceString("UI.VersionNotes.txt");
                     string text  = "Transport Lines Manager was updated! Release notes:\r\n\r\n" + notes;
                     string img   = "IconMessage";
                     component.SetProperties(TooltipHelper.Format(new string[]
                     {
                         "title",
                         title,
                         "message",
                         text,
                         "img",
                         img
                     }));
                     needShowPopup            = false;
                     currentSaveVersion.value = fullVersion;
                     return(true);
                 }
                 return(false);
             }
             else
             {
                 if (TLMSingleton.instance != null && TLMSingleton.debugMode)
                 {
                     TLMUtils.doLog("PANEL NOT FOUND!!!!");
                 }
                 return(false);
             }
         }
         catch (Exception e)
         {
             if (TLMSingleton.instance != null && TLMSingleton.debugMode)
             {
                 TLMUtils.doLog("showVersionInfoPopup ERROR {0} {1}", e.GetType(), e.Message);
             }
         }
     }
     return(false);
 }
コード例 #4
0
        public static string GetLocalizedTooltip(Asset asset, PrefabInfo prefab, string title)
        {
            MilestoneInfo unlockMilestone = prefab.GetUnlockMilestone();

            string text = TooltipHelper.Format(new string[]
            {
                LocaleFormatter.Title,
                title,
                LocaleFormatter.Sprite,
                (!string.IsNullOrEmpty(prefab.m_InfoTooltipThumbnail)) ? prefab.m_InfoTooltipThumbnail : prefab.name,
                LocaleFormatter.Text,
                (asset.findIt2Description + Asset.GetLocalizedDescription(prefab)),
                LocaleFormatter.Locked,
                (!ToolsModifierControl.IsUnlocked(unlockMilestone)).ToString()
            });

            ToolsModifierControl.GetUnlockingInfo(unlockMilestone, out string unlockDesc, out string currentValue, out string targetValue, out string progress, out string locked);

            string addTooltip = TooltipHelper.Format(new string[]
            {
                LocaleFormatter.LockedInfo,
                locked,
                LocaleFormatter.UnlockDesc,
                unlockDesc,
                LocaleFormatter.UnlockPopulationProgressText,
                progress,
                LocaleFormatter.UnlockPopulationTarget,
                targetValue,
                LocaleFormatter.UnlockPopulationCurrent,
                currentValue
            });

            text = TooltipHelper.Append(text, addTooltip);
            PrefabAI aI = prefab.GetAI();

            if (aI != null)
            {
                text = TooltipHelper.Append(text, aI.GetLocalizedTooltip());
            }

            if (prefab is PropInfo || prefab is TreeInfo)
            {
                text = TooltipHelper.Append(text, TooltipHelper.Format(new string[]
                {
                    LocaleFormatter.Cost,
                    LocaleFormatter.FormatCost(prefab.GetConstructionCost(), false)
                }));
            }

            return(text);
        }
        private void SpawnEntry(string name, bool enabled, MilestoneInfo info)
        {
            var landscapingInfo = (LandscapingPanel.LandscapingInfo)
                                  typeof(LandscapingPanel).GetProperty("landscapingInfo", BindingFlags.NonPublic | BindingFlags.Instance)
                                  .GetValue(this, null);

            landscapingInfo.m_DirtPrice = Singleton <TerrainManager> .instance.m_properties.m_dirtPrice;
            float  cost = (float)((double)landscapingInfo.m_DirtPrice * 65536.0 / 262144.0 * 512.0 / 100.0);
            string str  = TooltipHelper.Format(LocaleFormatter.Title, Locale.Get("LANDSCAPING_TITLE", name), LocaleFormatter.Sprite, name, LocaleFormatter.Text, Locale.Get("LANDSCAPING_DESC", name), LocaleFormatter.Locked, (!enabled).ToString(), LocaleFormatter.Cost, LocaleFormatter.FormatCubicCost(cost));

            if (Singleton <UnlockManager> .exists)
            {
                string unlockDesc;
                string currentValue;
                string targetValue;
                string progress;
                string locked;
                ToolsModifierControl.GetUnlockingInfo(info, out unlockDesc, out currentValue, out targetValue, out progress, out locked);
                string addTooltip = TooltipHelper.Format(LocaleFormatter.LockedInfo, locked, LocaleFormatter.UnlockDesc, unlockDesc, LocaleFormatter.UnlockPopulationProgressText, progress, LocaleFormatter.UnlockPopulationTarget, targetValue, LocaleFormatter.UnlockPopulationCurrent, currentValue);
                str = TooltipHelper.Append(str, addTooltip);
            }
            //begin mod
            string         buttonName;
            UITextureAtlas buttonAtlas;
            UIComponent    tooltipBox;

            if (name == "Ditch")
            {
                buttonName  = "TerrainDitch";
                buttonAtlas = Util.CreateAtlasFromEmbeddedResources(Assembly.GetExecutingAssembly(), "NaturalResourcesBrush.resources", new List <string> {
                    "TerrainDitch"
                });
                tooltipBox = GeneratedPanel.landscapingTooltipBox;
            }
            else if (name == "Sand")
            {
                buttonName  = "ResourceSand";
                tooltipBox  = GeneratedPanel.tooltipBox;
                buttonAtlas = UIView.GetAView().defaultAtlas;
            }
            else
            {
                buttonName  = "Landscaping" + name;
                buttonAtlas = null;
                tooltipBox  = GeneratedPanel.landscapingTooltipBox;
            }
            var button = (UIButton)this.SpawnEntry(name, str, buttonName, (UITextureAtlas)buttonAtlas, tooltipBox, enabled);

            button.objectUserData = (object)landscapingInfo;
            //end mod
        }
コード例 #6
0
        private void SpawnPolicyEntry(UIComponent container, string name, string unlockText, bool isEnabled)
        {
            UIPanel uiPanel;
            var     objectIndex = (int)_objectIndexField.GetValue(this);

            if (container.childCount > objectIndex)
            {
                uiPanel = container.components[objectIndex] as UIPanel;
            }
            else
            {
                GameObject asGameObject = UITemplateManager.GetAsGameObject(kPolicyTemplate);
                asGameObject.name = name;
                uiPanel           = container.AttachUIComponent(asGameObject) as UIPanel;
            }
            uiPanel.FitTo(uiPanel.parent, LayoutDirection.Horizontal);
            uiPanel.stringUserData = name;
            uiPanel.objectUserData = (object)this;
            uiPanel.isEnabled      = isEnabled;
            UIButton uiButton = uiPanel.Find <UIButton>("PolicyButton");

            uiButton.text = ColossalFramework.Globalization.Locale.Get("POLICIES", name);
            string str = "IconPolicy" + name;

            uiButton.pivot = this.m_DockingPosition != PoliciesPanel.DockingPosition.Left ? UIPivotPoint.TopLeft : UIPivotPoint.TopRight;
            if (isEnabled)
            {
                uiButton.tooltipBox = (UIComponent)_policiesTooltipPropertyInfo.GetValue(this, null);
                uiButton.tooltip    = TooltipHelper.Format("title", ColossalFramework.Globalization.Locale.Get("POLICIES", name), "text", ColossalFramework.Globalization.Locale.Get("POLICIES_DETAIL", name));
            }
            else
            {
                uiButton.tooltipBox = (UIComponent)_defaultTooltipPropertyInfo.GetValue(this, null);
                uiButton.tooltip    = ColossalFramework.Globalization.Locale.Get("POLICIES", name) + " - " + unlockText;
            }
            //begin mod
            uiButton.eventTooltipEnter += (sender, p) =>
            {
                DistrictManager.instance.HighlightPolicy = (DistrictPolicies.Policies)Enum.Parse(typeof(DistrictPolicies.Policies), name);
            };
            uiButton.eventTooltipLeave += (sender, p) =>
            {
                DistrictManager.instance.HighlightPolicy = DistrictPolicies.Policies.None;
            };
            //end mod
            uiButton.normalFgSprite   = str;
            uiButton.disabledFgSprite = str + "Disabled";
            _objectIndexField.SetValue(this, objectIndex + 1);
        }
コード例 #7
0
 public override string GetLocalizedTooltip()
 {
     return(TooltipHelper.Format(new string[]
     {
         LocaleFormatter.Cost,
         LocaleFormatter.FormatCost(this.GetConstructionCost(), true),
         LocaleFormatter.Upkeep,
         LocaleFormatter.FormatUpkeep(this.GetMaintenanceCost(), true),
         LocaleFormatter.Speed,
         LocaleFormatter.FormatGeneric("AIINFO_SPEED", new object[]
         {
             15f
         })
     }));
 }
コード例 #8
0
ファイル: BasicIUserMod.cs プロジェクト: klyte45/SuburbStyler
        public bool showVersionInfoPopup(bool force = false)
        {
            if (needShowPopup || force)
            {
                try
                {
                    UIComponent uIComponent = UIView.library.ShowModal("ExceptionPanel");
                    if (uIComponent != null)
                    {
                        Cursor.lockState = CursorLockMode.None;
                        Cursor.visible   = true;
                        BindPropertyByKey component = uIComponent.GetComponent <BindPropertyByKey>();
                        if (component != null)
                        {
                            string title = $"{SimpleName.Replace("&", "and")} v{version}";
                            string notes = Singleton <R> .instance.loadResourceString("UI.VersionNotes.txt");

                            string text = $"{SimpleName.Replace("&", "and")} was updated! Release notes:\r\n\r\n" + notes;
                            string img  = "IconMessage";
                            component.SetProperties(TooltipHelper.Format(new string[]
                            {
                                "title",
                                title,
                                "message",
                                text,
                                "img",
                                img
                            }));
                            needShowPopup            = false;
                            currentSaveVersion.value = fullVersion;
                            return(true);
                        }
                        return(false);
                    }
                    else
                    {
                        doLog("PANEL NOT FOUND!!!!");
                        return(false);
                    }
                }
                catch (Exception e)
                {
                    doErrorLog("showVersionInfoPopup ERROR {0} {1}", e.GetType(), e.Message);
                }
            }
            return(false);
        }
コード例 #9
0
 public static void DisplayMessage(string str1, string str2, string str3)
 {
     try
     {
         var uiComponent = UIView.library.ShowModal("ExceptionPanel");
         if ((UnityEngine.Object)uiComponent != (UnityEngine.Object)null)
         {
             Cursor.lockState = CursorLockMode.None;
             Cursor.visible   = true;
             var component = uiComponent.GetComponent <BindPropertyByKey>();
             if (component != null)
             {
                 component.SetProperties(TooltipHelper.Format("title", str1, "message", str2, "img", str3));
             }
         }
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }