/// <summary>
        /// Adds a Ploppable RICO button to a building info panel to directly access that building's RICO settings.
        /// The button will be added to the right of the panel with a small margin from the panel edge, at the relative Y position specified.
        /// </summary>
        /// <param name="infoPanel">Infopanel to apply the button to</param>
        private static void AddInfoPanelButton(BuildingWorldInfoPanel infoPanel)
        {
            UIButton panelButton = infoPanel.component.AddUIComponent <UIButton>();

            // Basic button setup.
            panelButton.size             = new Vector2(34, 34);
            panelButton.normalBgSprite   = "ToolbarIconGroup6Normal";
            panelButton.normalFgSprite   = "IconPolicyBigBusiness";
            panelButton.focusedBgSprite  = "ToolbarIconGroup6Focused";
            panelButton.hoveredBgSprite  = "ToolbarIconGroup6Hovered";
            panelButton.pressedBgSprite  = "ToolbarIconGroup6Pressed";
            panelButton.disabledBgSprite = "ToolbarIconGroup6Disabled";
            panelButton.name             = "PloppableButton";
            panelButton.tooltip          = Translations.Translate("PRR_SET_RICO");

            // Find ProblemsPanel relative position to position button.
            // We'll use 40f as a default relative Y in case something doesn't work.
            UIComponent problemsPanel;
            float       relativeY = 40f;

            // Player info panels have wrappers, zoned ones don't.
            UIComponent wrapper = infoPanel.Find("Wrapper");

            if (wrapper == null)
            {
                problemsPanel = infoPanel.Find("ProblemsPanel");
            }
            else
            {
                problemsPanel = wrapper.Find("ProblemsPanel");
            }

            try
            {
                // Position button vertically in the middle of the problems panel.  If wrapper panel exists, we need to add its offset as well.
                relativeY = (wrapper == null ? 0 : wrapper.relativePosition.y) + problemsPanel.relativePosition.y + ((problemsPanel.height - 34) / 2);
            }
            catch
            {
                // Don't really care; just use default relative Y.
                Logging.Message("couldn't find ProblemsPanel relative position");
            }

            // Set position.
            panelButton.AlignTo(infoPanel.component, UIAlignAnchor.TopRight);
            panelButton.relativePosition += new Vector3(-5f, relativeY, 0f);

            // Event handler.
            panelButton.eventClick += (control, clickEvent) =>
            {
                // Select current building in the building details panel and show.
                Open(InstanceManager.GetPrefabInfo(WorldInfoPanel.GetCurrentInstanceID()) as BuildingInfo);

                // Manually unfocus control, otherwise it can stay focused until next UI event (looks untidy).
                control.Unfocus();
            };
        }
Esempio n. 2
0
        public static void OnSetTarget(BuildingWorldInfoPanel thisPanel)
        {
            FieldInfo m_TimeInfo = typeof(BuildingWorldInfoPanel).GetField("m_Time", BindingFlags.NonPublic | BindingFlags.Instance);
            float?    m_Time     = m_TimeInfo.GetValue(thisPanel) as float?;

            if (m_Time != null)
            {
                m_NameField = thisPanel.Find <UITextField>("BuildingName");

                if (m_NameField != null)
                {
                    if (originalNameWidth == -1)
                    {
                        originalNameWidth = m_NameField.width;
                    }

                    m_NameField.text = GetName(thisPanel);
                    m_Time           = 0.0f;

                    CityServiceWorldInfoPanel servicePanel = thisPanel as CityServiceWorldInfoPanel;

                    if (servicePanel != null)
                    {
                        LoggingWrapper.Log("Adding event UI to service panel.");
                        AddEventUI(servicePanel);

                        if (!translationSetUp)
                        {
                            translationSetUp = true;

                            CimTools.CimToolsHandler.CimToolBase.Translation.OnLanguageChanged += delegate(string languageIdentifier)
                            {
                                UIButton createEventButton = null;

                                try { createEventButton = servicePanel.Find <UIButton>("CreateEventButton"); } catch { }

                                if (createEventButton != null)
                                {
                                    createEventButton.tooltip = CimTools.CimToolsHandler.CimToolBase.Translation.GetTranslation("Event_CreateUserEvent");
                                    createEventButton.RefreshTooltip();
                                }
                            };
                        }
                    }
                }
                else
                {
                    Debug.LogError("Couldn't set the m_NameField parameter of the BuildingWorldInfoPanel");
                }
            }
            else
            {
                Debug.LogError("Couldn't set the m_Time parameter of the BuildingWorldInfoPanel");
            }
        }
        public static void Postfix(BuildingWorldInfoPanel __instance, ref string __result)
        {
            InstanceID instanceID = InstanceHelper.GetInstanceID(__instance);

            var building = BuildingManager.instance.m_buildings.m_buffer[instanceID.Building].Info;

            if (CustomizeItExtendedTool.instance.CustomBuildingNames.TryGetValue(building.name,
                                                                                 out NameProperties customName) && customName.DefaultName &&
                !customName.Unaffected.Contains(instanceID.Building))
            {
                __result = customName.CustomName;
            }
        }
        public static void Postfix(BuildingWorldInfoPanel __instance, string text)
        {
            InstanceID instanceID = InstanceHelper.GetInstanceID(__instance);

            var building = BuildingManager.instance.m_buildings.m_buffer[instanceID.Building].Info;


            if (!CustomizeItExtendedTool.instance.CustomBuildingNames.TryGetValue(building.name, out var nameProps))
            {
                return;
            }

            if (!nameProps.Unaffected.Contains(instanceID.Building))
            {
                nameProps.Unaffected.Add(instanceID.Building);
            }

            if (!CustomizeItExtendedMod.Settings.SavePerCity)
            {
                CustomizeItExtendedMod.Settings.Save();
            }
        }
Esempio n. 5
0
        private void Init()
        {
            _buildingWorldInfoPanel = GameObject.Find("(Library) BuildingWorldInfoPanel").GetComponent <BuildingWorldInfoPanel>();
            UIComponent fishExtractorPanel = _buildingWorldInfoPanel.Find("FishFarmPanel");

            _fishAmount   = BuildingExtension.GetPrivate <UILabel>((object)_buildingWorldInfoPanel, "m_incomingResources");
            _mainSubPanel = fishExtractorPanel.parent;
            UIPanel uiPanel = _mainSubPanel.AddUIComponent <UIPanel>();

            uiPanel.name   = "IshmContainer";
            uiPanel.width  = 301f;
            uiPanel.height = 166f;
            uiPanel.autoLayoutDirection = LayoutDirection.Vertical;
            uiPanel.autoLayoutStart     = LayoutStart.TopLeft;
            uiPanel.autoLayoutPadding   = new RectOffset(0, 0, 0, 5);
            uiPanel.autoLayout          = true;
            uiPanel.relativePosition    = new Vector3(10f, 224.0f);
            _ishmContainer = uiPanel;
            CreateDropDownPanel();
            BuildingExtension.OnFishFarmAdded   += OnFishFarmChanged;
            BuildingExtension.OnFishFarmRemoved += OnFishFarmChanged;
            _initialized = true;
        }
        /// <summary>
        /// Adds an ABLC button to a building info panel to open the ABLC panel for that building.
        /// The button will be added to the right of the panel with a small margin from the panel edge, at the relative Y position specified.
        /// </summary>
        internal static void AddInfoPanelButton()
        {
            BuildingWorldInfoPanel infoPanel = UIView.library.Get <ZonedBuildingWorldInfoPanel>(typeof(ZonedBuildingWorldInfoPanel).Name);

            panelButton = infoPanel.component.AddUIComponent <UIButton>();

            // Basic button setup.
            panelButton.atlas            = Textures.ABLCButtonSprites;
            panelButton.size             = new Vector2(36, 36);
            panelButton.normalFgSprite   = "normal";
            panelButton.focusedFgSprite  = "hovered";
            panelButton.hoveredFgSprite  = "hovered";
            panelButton.pressedFgSprite  = "pressed";
            panelButton.disabledFgSprite = "disabled";
            panelButton.name             = "ABLCbutton";
            panelButton.tooltip          = Translations.Translate("ABLC_NAME");

            // Find ProblemsPanel relative position to position button.
            // We'll use 40f as a default relative Y in case something doesn't work.
            UIComponent problemsPanel;
            float       relativeY = 40f;

            // Player info panels have wrappers, zoned ones don't.
            UIComponent wrapper = infoPanel.Find("Wrapper");

            if (wrapper == null)
            {
                problemsPanel = infoPanel.Find("ProblemsPanel");
            }
            else
            {
                problemsPanel = wrapper.Find("ProblemsPanel");
            }

            try
            {
                // Position button vertically in the middle of the problems panel.  If wrapper panel exists, we need to add its offset as well.
                relativeY = (wrapper == null ? 0 : wrapper.relativePosition.y) + problemsPanel.relativePosition.y + ((problemsPanel.height - 36) / 2);
            }
            catch
            {
                // Don't really care; just use default relative Y.
                Logging.Message("couldn't find ProblemsPanel relative position");
            }

            // Set position.
            panelButton.AlignTo(infoPanel.component, UIAlignAnchor.TopRight);
            panelButton.relativePosition += new Vector3(-62f, relativeY, 0f);

            // Event handler.
            panelButton.eventClick += (control, clickEvent) =>
            {
                // Toggle panel visibility.
                if (uiGameObject == null)
                {
                    Create();
                }
                else
                {
                    Close();
                }

                // Manually unfocus control, otherwise it can stay focused until next UI event (looks untidy).
                control.Unfocus();
            };
        }
Esempio n. 7
0
 public static void UpdateBindings(BuildingWorldInfoPanel thisPanel)
 {
     Debug.LogWarning("UpdateBindings is not overridden!");
 }
Esempio n. 8
0
 public static string GetName(BuildingWorldInfoPanel thisPanel)
 {
     Debug.LogWarning("GetName is not overridden!");
     return("");
 }