예제 #1
0
        private static void UpdateEventSelection(UIComponent component)
        {
            UIFastList list = component as UIFastList;

            if (list != null)
            {
                LabelOptionItem selectedOption = list.selectedItem as LabelOptionItem;

                if (selectedOption != null && eventCreationWindow != null)
                {
                    eventCreationWindow.Show();
                    eventCreationWindow.SetUp(selectedOption, lastInstanceID.Value.Building);
                    eventCreationWindow.relativePosition = list.relativePosition + new Vector3(-(list.width / 2f), list.height);

                    LoggingWrapper.Log("Selected " + list.selectedIndex);
                }
                else
                {
                    LoggingWrapper.LogError("Couldn't find the option that has been selected for an event!");
                }
            }
            else
            {
                LoggingWrapper.LogError("Couldn't find the list that the selection was made on!");
            }
        }
예제 #2
0
        /// <summary>
        /// Use this to create the UIFastList.
        /// Do NOT use AddUIComponent.
        /// I had to do that way because MonoBehaviors classes cannot be generic
        /// </summary>
        /// <typeparam name="T">The type of the row UI component</typeparam>
        /// <param name="parent"></param>
        /// <returns></returns>
        public static UIFastList Create <T>(UIComponent parent)
            where T : UIPanel, IUIFastListRow
        {
            UIFastList list = parent.AddUIComponent <UIFastList>();

            list.m_rowType = typeof(T);
            return(list);
        }
예제 #3
0
        private void Initialise()
        {
            if (_helper == null)
            {
                width         = 400;
                height        = 500;
                isInteractive = true;
                enabled       = true;

                _helper           = new UIHelper(this);
                _titleBar         = AddUIComponent <UITitleBar>();
                _informationLabel = AddUIComponent <UILabel>();
                _totalPanel       = AddUIComponent <UIPanel>();
                _totalAmountLabel = _totalPanel.AddUIComponent <UILabel>();
                _totalIncomeLabel = _totalPanel.AddUIComponent <UILabel>();
                _costLabel        = _totalPanel.AddUIComponent <UILabel>();
                _incomeLabel      = _totalPanel.AddUIComponent <UILabel>();
                _incentiveList    = UIFastList.Create <UIFastListIncentives>(this);

                _titleBar.Initialise(CimTools.CimToolsHandler.CimToolBase);

                _ticketSlider = _helper.AddSlider("Tickets", 100, 9000, 10, 500, delegate(float value)
                {
                    if (_incentiveList != null)
                    {
                        FastList <object> optionItems = _incentiveList.rowsData;

                        foreach (IncentiveOptionItem optionItemObject in optionItems)
                        {
                            optionItemObject.ticketCount = value;
                            optionItemObject.UpdateTicketSize();
                        }
                    }
                }) as UISlider;

                _startDaySlider = _helper.AddSlider("Days", 0, 7, 1, 0, delegate(float value)
                {
                    CalculateTotal();
                }) as UISlider;

                TimeOfDaySlider startTimeSliderOptions = new TimeOfDaySlider()
                {
                    uniqueName = "Time", value = 12f
                };
                _startTimeSlider = startTimeSliderOptions.Create(_helper) as UISlider;
                _startTimeSlider.eventValueChanged += delegate(UIComponent component, float value)
                {
                    CalculateTotal();
                };

                _createButton = _helper.AddButton("Create", new OnButtonClicked(CreateEvent)) as UIButton;

                CimTools.CimToolsHandler.CimToolBase.Translation.OnLanguageChanged += Translation_OnLanguageChanged;
            }
        }
예제 #4
0
        private static void CreateEventButton_eventClicked(UIComponent component, UIMouseEventParameter eventParam)
        {
            UIFastList eventSelection = component.parent.Find <UIFastList>("EventSelectionList");
            ushort     buildingID     = lastInstanceID.Value.Building;

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

                if ((_currentBuilding.m_flags & Building.Flags.Active) != Building.Flags.None)
                {
                    List <CityEvent> userEvents = CityEventBuildings.instance.GetUserEventsForBuilding(ref _currentBuilding);

                    BuildDropdownList(component);

                    if (eventSelection.isVisible)
                    {
                        eventSelection.Hide();
                    }
                    else
                    {
                        eventSelection.selectedIndex = -1;
                        eventSelection.Show();
                        eventSelection.rowsData.Clear();

                        foreach (CityEvent userEvent in userEvents)
                        {
                            XmlEvent xmlUserEvent = userEvent as XmlEvent;

                            if (xmlUserEvent != null)
                            {
                                xmlUserEvent.SetUp(ref buildingID);
                                LabelOptionItem eventToInsert = new LabelOptionItem()
                                {
                                    linkedEvent = xmlUserEvent, readableLabel = xmlUserEvent.GetReadableName()
                                };
                                eventSelection.rowsData.Add(eventToInsert);

                                LoggingWrapper.Log(xmlUserEvent.GetReadableName());
                            }
                        }

                        eventSelection.DisplayAt(0);
                    }
                }
            }
        }
예제 #5
0
        private static void BuildDropdownList(UIComponent component)
        {
            UIFastList eventSelection = component.parent.Find <UIFastList>("EventSelectionList");

            if (eventSelection == null)
            {
                eventSelection                            = UIFastList.Create <UIFastListLabel>(component.parent);
                eventSelection.name                       = "EventSelectionList";
                eventSelection.backgroundSprite           = "UnlockingPanel";
                eventSelection.size                       = new Vector2(120, 60);
                eventSelection.canSelect                  = true;
                eventSelection.relativePosition           = component.relativePosition + new Vector3(0, component.height);
                eventSelection.rowHeight                  = 20f;
                eventSelection.selectedIndex              = -1;
                eventSelection.eventClicked              += EventSelection_eventClicked;
                eventSelection.eventSelectedIndexChanged += EventSelection_eventSelectedIndexChanged;
                eventSelection.Hide();
            }
        }
예제 #6
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;
                    }
                }
            }
        }