Exemple #1
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");
            }
        }
Exemple #2
0
        public override void Start()
        {
            base.Start();

            backgroundSprite = "MenuPanel2";
            opacity          = 0.8f;
            isVisible        = true;
            canFocus         = true;
            isInteractive    = true;

            UIPanel stats = baseBuildingWindow.Find <UIPanel>("LayoutPanel");
            UILabel info  = stats.Find <UILabel>("Info");

            label.color     = info.color;
            label.textColor = info.textColor;
            label.textScale = info.textScale;
            label.position  = new Vector3(50, 50);
            label.size      = new Vector2(baseBuildingWindow.component.width - 20, 84);
            label.font      = info.font;
            height          = 104;
            width           = baseBuildingWindow.component.width;
        }
Exemple #3
0
        public static void AddEventUI(CityServiceWorldInfoPanel cityServicePanel)
        {
            UIMultiStateButton      locationButton      = null;
            UIButton                createEventButton   = null;
            UIFastList              eventSelection      = null;
            UserEventCreationWindow eventCreationWindow = null;

            try { locationButton = cityServicePanel.Find <UIMultiStateButton>("LocationMarker"); } catch { }
            try { createEventButton = cityServicePanel.Find <UIButton>("CreateEventButton"); } catch { }
            try { eventSelection = cityServicePanel.Find <UIFastList>("EventSelectionList"); } catch { }
            try { eventCreationWindow = cityServicePanel.Find <UserEventCreationWindow>("EventCreator"); } catch { }

            FieldInfo  m_InstanceIDInfo = typeof(CityServiceWorldInfoPanel).GetField("m_InstanceID", BindingFlags.NonPublic | BindingFlags.Instance);
            InstanceID?m_InstanceID     = m_InstanceIDInfo.GetValue(cityServicePanel) as InstanceID?;

            lastInstanceID = m_InstanceID;

            BuildCreationWindow(cityServicePanel.component);

            if (eventSelection != null)
            {
                eventSelection.Hide();
            }

            if (eventCreationWindow != null)
            {
                eventCreationWindow.Hide();
            }

            if (createEventButton == null && locationButton != null)
            {
                createEventButton                  = cityServicePanel.component.AddUIComponent <UIButton>();
                createEventButton.name             = "CreateEventButton";
                createEventButton.atlas            = CimTools.CimToolsHandler.CimToolBase.SpriteUtilities.GetAtlas("Ingame");
                createEventButton.normalFgSprite   = "InfoIconLevel";
                createEventButton.disabledFgSprite = "InfoIconLevelDisabled";
                createEventButton.focusedFgSprite  = "InfoIconLevelFocused";
                createEventButton.hoveredFgSprite  = "InfoIconLevelHovered";
                createEventButton.pressedFgSprite  = "InfoIconLevelPressed";
                createEventButton.width            = locationButton.width;
                createEventButton.height           = locationButton.height;
                createEventButton.position         = locationButton.position - new Vector3(createEventButton.width - 5f, 0);
                createEventButton.eventClicked    += CreateEventButton_eventClicked;

                BuildDropdownList(createEventButton);
            }

            if (m_InstanceID != null)
            {
                BuildingManager _buildingManager = Singleton <BuildingManager> .instance;
                Building        _currentBuilding = _buildingManager.m_buildings.m_buffer[lastInstanceID.Value.Building];

                if (CityEventBuildings.instance.BuildingHasUserEvents(ref _currentBuilding))
                {
                    createEventButton.Show();
                    createEventButton.Enable();
                    m_NameField.width = originalNameWidth - 45f;
                }
                else
                {
                    if (CityEventBuildings.instance.BuildingHasEvents(ref _currentBuilding))
                    {
                        createEventButton.Show();
                        createEventButton.Disable();
                        m_NameField.width = originalNameWidth - 45f;
                    }
                    else
                    {
                        createEventButton.Hide();
                        m_NameField.width = originalNameWidth;
                    }
                }
            }
        }