public void SetUp(LabelOptionItem selectedData, ushort buildingID) { _linkedEvent = selectedData.linkedEvent; if (_linkedEvent != null && buildingID != 0 && _ticketSlider != null) { List <CityEventXmlIncentive> incentives = _linkedEvent.GetIncentives(); title = _linkedEvent.GetReadableName(); _ticketSlider.maxValue = _linkedEvent.GetCapacity(); _ticketSlider.minValue = Mathf.Min(_linkedEvent.GetCapacity(), 100); _ticketSlider.value = _ticketSlider.minValue; _incentiveList.rowsData.Clear(); foreach (CityEventXmlIncentive incentive in incentives) { IncentiveOptionItem optionItem = new IncentiveOptionItem() { cost = incentive._cost, description = incentive._description, negativeEffect = incentive._negativeEffect, positiveEffect = incentive._positiveEffect, returnCost = incentive._returnCost, title = incentive._name, ticketCount = _ticketSlider.value }; optionItem.OnOptionItemChanged += OptionItem_OnOptionItemChanged; _incentiveList.rowsData.Add(optionItem); } try { _incentiveList.DisplayAt(0); _incentiveList.selectedIndex = 0; _incentiveList.Show(); } catch { LoggingWrapper.LogError("IncentiveList DisplayAt hit an error. Probably too few items in the list."); } _incentiveList.Refresh(); CalculateTotal(); TranslateInfoString(); PerformLayout(); LoggingWrapper.Log("Event capacity is " + _linkedEvent.GetCapacity().ToString() + "."); LoggingWrapper.Log("Successfully set up the UserEventCreationWindow."); } else { LoggingWrapper.LogError("Linked event was invalid, or the building was 0!"); } relativePosition = Vector3.zero; }
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!"); } }
public void Display(object data, bool isRowOdd) { if (data != null) { LabelOptionItem option = data as LabelOptionItem; if (option != null && option.readableLabel != null && option.readableLabel != "" && background != null) { itemLabel.name = option.readableLabel; itemLabel.text = option.readableLabel; itemLabel.autoSize = false; itemLabel.autoHeight = false; itemLabel.width = width; itemLabel.height = 20; itemLabel.textAlignment = UIHorizontalAlignment.Left; itemLabel.verticalAlignment = UIVerticalAlignment.Middle; if (isRowOdd) { background.backgroundSprite = "UnlockingItemBackground"; background.color = new Color32(0, 0, 0, 128); } else { background.backgroundSprite = null; } } } }
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); } } } }