public override void Start() { base.Start(); isVisible = true; canFocus = true; isInteractive = true; width = 740f; height = 40f; m_name = UIUtils.CreateLabel(this, 300f, height); m_name.textAlignment = UIHorizontalAlignment.Left; m_name.pivot = UIPivotPoint.MiddleLeft; m_name.relativePosition = new Vector3(10f, 0f); statusLabel = UIUtils.CreateLabelForGrid(this, m_name, 190f, height); m_triangles = UIUtils.CreateLabelForGrid(this, statusLabel, 150f, height); m_textureSize = UIUtils.CreateLabelForGrid(this, m_triangles, 90f, height); eventMouseEnter += (component, eventParam) => Background.opacity = Mathf.Lerp(baseBgOpacity, 1, 0.5f); eventMouseLeave += (component, eventParam) => Background.opacity = baseBgOpacity; eventClick += (component, p) => { Background.opacity = Mathf.Lerp(baseBgOpacity, 1, 0.75f); WorldInfoPanel.Show <CityServiceWorldInfoPanel>(m_meshData.position, m_meshData.instanceID); ToolsModifierControl.cameraController.SetTarget(m_meshData.instanceID, m_meshData.position, true); }; }
private void OpenLineLabel(UIComponent component, UIMouseEventParameter eventParam) { if (ushort.TryParse(component.stringUserData, out ushort lineId) && lineId != 0) { Vector3 position = Singleton <NetManager> .instance.m_nodes.m_buffer[Singleton <TransportManager> .instance.m_lines.m_buffer[lineId].m_stops].m_position; InstanceID iid = InstanceID.Empty; iid.TransportLine = lineId; WorldInfoPanel.Show <PublicTransportWorldInfoPanel>(position, iid); eventParam.Use(); } }
private void OnModifyLineClick(UIComponent component, UIMouseEventParameter eventParam) { if (this.m_InstanceID.Type != InstanceType.NetNode || (int)this.m_InstanceID.NetNode == 0) { return; } ushort transportLine = Singleton <NetManager> .instance.m_nodes.m_buffer[(int)this.m_InstanceID.NetNode].m_transportLine; InstanceID instanceID = new InstanceID(); instanceID.TransportLine = transportLine; this.Hide(); WorldInfoPanel.Show <PublicTransportWorldInfoPanel>(this.m_WorldMousePosition, instanceID); }
private void Update() { if (!this._initialized) { return; } if (this.SimulationLineCount > this.KnownLineCount) { Array16 <TransportLine> lines = Singleton <TransportManager> .instance.m_lines; for (ushort lineID = 0; (uint)lineID < lines.m_size; ++lineID) { if (LineWatcher.IsValid(ref lines.m_buffer[(int)lineID]) && this._knownLines.Add(lineID)) { TransportLineMod.SetLineDefaults(lineID); Vector3 position = Singleton <NetManager> .instance.m_nodes.m_buffer[(int)lines.m_buffer[(int)lineID].GetStop(0)].m_position; ushort closestDepot = TransportLineMod.GetClosestDepot(lineID, position); if ((int)closestDepot != 0) { TransportLineMod.SetDepot(lineID, closestDepot); } if (ImprovedPublicTransportMod.Settings.ShowLineInfo) { WorldInfoPanel.Show <PublicTransportWorldInfoPanel>(position, new InstanceID() { TransportLine = lineID }); } } } } else { if (this.SimulationLineCount >= this.KnownLineCount) { return; } Array16 <TransportLine> lines = Singleton <TransportManager> .instance.m_lines; for (ushort index = 0; (uint)index < lines.m_size; ++index) { if (!LineWatcher.IsValid(ref lines.m_buffer[(int)index])) { this._knownLines.Remove(index); } } } }
private void Update() { if (!this._initialized) { return; } if (this.SimulationLineCount > this.KnownLineCount) { Array16 <TransportLine> lines = Singleton <TransportManager> .instance.m_lines; for (ushort lineID = 0; (uint)lineID < lines.m_size; ++lineID) { if (LineWatcher.IsValid(ref lines.m_buffer[(int)lineID]) && this._knownLines.Add(lineID)) { CachedTransportLineData.SetLineDefaults(lineID); DepotUtil.AutoAssignLineDepot(lineID, out var position); if (OptionsWrapper <Settings> .Options.ShowLineInfo && lines.m_buffer[(int)lineID].Info?.m_class?.m_service != ItemClass.Service.Disaster) { WorldInfoPanel.Show <PublicTransportWorldInfoPanel>(position, new InstanceID() { TransportLine = lineID }); } } } } else { if (this.SimulationLineCount >= this.KnownLineCount) { return; } Array16 <TransportLine> lines = Singleton <TransportManager> .instance.m_lines; for (ushort lineID = 0; (uint)lineID < lines.m_size; ++lineID) { if (!LineWatcher.IsValid(ref lines.m_buffer[(int)lineID])) { this._knownLines.Remove(lineID); } } } }
public override void Start() { base.Start(); _checkBox.relativePosition = new Vector3(5, 0); _color.relativePosition = new Vector3(22, 0); _name.relativePosition = new Vector3(43, 0); _stops.relativePosition = new Vector3(170, 0); _passengers.relativePosition = new Vector3(225, 0); _trips.relativePosition = new Vector3(320, 0); _vehicles.relativePosition = new Vector3(401, 0); _name.textColor = new Color32(185, 221, 254, 255); _stops.textColor = new Color32(185, 221, 254, 255); _passengers.textColor = new Color32(185, 221, 254, 255); _trips.textColor = new Color32(185, 221, 254, 255); _vehicles.textColor = new Color32(185, 221, 254, 255); _checkBox.size = new Vector2(12, 12); _checkBox.IsChecked = !IsLineHidden; _color.normalBgSprite = "ColorPickerOutline"; _color.normalFgSprite = "ColorPickerColor"; _color.hoveredBgSprite = "ColorPickerOutlineHovered"; _color.size = new Vector2(15, 15); //_color.triggerButton = _color.AddUIComponent<UIButton>(); /* // Need to attach the ColorPicker somehow, the Button is being setup by ColorField itself (That's what I believe at least) * var panel = UIView.library.Get<PublicTransportWorldInfoPanel>("PublicTransportWorldInfoPanel"); * var fieldInfo = typeof (PublicTransportWorldInfoPanel).GetField("m_ColorField", BindingFlags.NonPublic | BindingFlags.Instance); * var picker = (UIColorField)fieldInfo.GetValue(panel); * _color.colorPicker = Instantiate<UIColorPicker>(picker.colorPicker); */ // event handler _checkBox.eventClick += (component, param) => { _checkBox.IsChecked = !_checkBox.IsChecked; if (!_checkBox.IsChecked) { TransportUtil.HideTransportLine(LineID); } else { TransportUtil.ShowTransportLine(LineID); } }; _name.eventClick += (component, param) => WorldInfoPanel.Show <PublicTransportWorldInfoPanel>(TransportUtil.GetFirstLineStop(LineID), InstanceID); _name.eventMouseHover += (component, param) => { TransportUtil.SelectTransportLine(LineID); _name.textColor = TransportUtil.GetLineColor(LineID); }; _name.eventMouseLeave += (component, param) => { TransportUtil.DeselectTransportLine(LineID); _name.textColor = new Color32(185, 221, 254, 255); }; // scale label texts _name.textScale = 0.8f; _stops.textScale = 0.8f; _passengers.textScale = 0.8f; _trips.textScale = 0.8f; _vehicles.textScale = 0.8f; // zebra stripes background backgroundSprite = "GenericPanelLight"; if (IsOdd) { color = new Color32(150, 150, 150, 255); } else { color = new Color32(130, 130, 130, 255); } // center elements in row UIComponent[] children = GetComponentsInChildren <UIComponent>(); foreach (UIComponent child in children) { if (child == this) { continue; } child.pivot = UIPivotPoint.MiddleLeft; child.transformPosition = new Vector3(child.transformPosition.x, GetBounds().center.y, 0); } }
public static void PrintIntersections(string airport, string harbor, string taxi, string regionalTrainStation, string cableCarStation, UIPanel intersectionsPanel, Dictionary <string, ushort> otherLinesIntersections, Vector3 position, float scale = 1.0f, int maxItemsForSizeSwap = 3) { TransportManager tm = Singleton <TransportManager> .instance; int intersectionCount = otherLinesIntersections.Count; if (!string.IsNullOrEmpty(airport)) { intersectionCount++; } if (!string.IsNullOrEmpty(harbor)) { intersectionCount++; } if (!string.IsNullOrEmpty(taxi)) { intersectionCount++; } if (!string.IsNullOrEmpty(regionalTrainStation)) { intersectionCount++; } if (!string.IsNullOrEmpty(cableCarStation)) { intersectionCount++; } float size = scale * (intersectionCount > maxItemsForSizeSwap ? 20 : 40); float multiplier = scale * (intersectionCount > maxItemsForSizeSwap ? 0.4f : 0.8f); foreach (KeyValuePair <string, ushort> s in otherLinesIntersections.OrderBy(x => x.Key)) { TransportLine intersectLine = tm.m_lines.m_buffer[s.Value]; ItemClass.SubService ss = GetLineNamingParameters(s.Value, out NamingMode prefixo, out Separator separador, out NamingMode sufixo, out NamingMode naoPrefixado, out bool zeros, out bool invertPrefixSuffix, out string bgSprite).SubService; KlyteMonoUtils.CreateUIElement(out UIButtonLineInfo lineCircleIntersect, intersectionsPanel.transform); lineCircleIntersect.autoSize = false; lineCircleIntersect.width = size; lineCircleIntersect.height = size; lineCircleIntersect.color = intersectLine.m_color; lineCircleIntersect.pivot = UIPivotPoint.MiddleLeft; lineCircleIntersect.verticalAlignment = UIVerticalAlignment.Middle; lineCircleIntersect.name = "LineFormat"; lineCircleIntersect.relativePosition = new Vector3(0f, 0f); lineCircleIntersect.normalBgSprite = bgSprite; lineCircleIntersect.hoveredColor = Color.white; lineCircleIntersect.hoveredTextColor = Color.red; lineCircleIntersect.lineID = s.Value; lineCircleIntersect.tooltip = tm.GetLineName(s.Value); lineCircleIntersect.eventClick += (x, y) => { InstanceID iid = InstanceID.Empty; iid.TransportLine = s.Value; WorldInfoPanel.Show <PublicTransportWorldInfoPanel>(position, iid); }; KlyteMonoUtils.CreateUIElement(out UILabel lineNumberIntersect, lineCircleIntersect.transform); lineNumberIntersect.autoSize = false; lineNumberIntersect.autoHeight = false; lineNumberIntersect.width = lineCircleIntersect.width; lineNumberIntersect.pivot = UIPivotPoint.MiddleCenter; lineNumberIntersect.textAlignment = UIHorizontalAlignment.Center; lineNumberIntersect.verticalAlignment = UIVerticalAlignment.Middle; lineNumberIntersect.name = "LineNumber"; lineNumberIntersect.height = size; lineNumberIntersect.relativePosition = new Vector3(-0.5f, 0.5f); lineNumberIntersect.outlineColor = Color.black; lineNumberIntersect.useOutline = true; GetLineActive(ref intersectLine, out bool day, out bool night); bool zeroed; unchecked { zeroed = (tm.m_lines.m_buffer[s.Value].m_flags & (TransportLine.Flags)TLMTransportLineFlags.ZERO_BUDGET_CURRENT) != 0; } if (!day || !night || zeroed) { KlyteMonoUtils.CreateUIElement(out UILabel daytimeIndicator, lineCircleIntersect.transform); daytimeIndicator.autoSize = false; daytimeIndicator.width = size; daytimeIndicator.height = size; daytimeIndicator.color = Color.white; daytimeIndicator.pivot = UIPivotPoint.MiddleLeft; daytimeIndicator.verticalAlignment = UIVerticalAlignment.Middle; daytimeIndicator.name = "LineTime"; daytimeIndicator.relativePosition = new Vector3(0f, 0f); /*TODO: !!!!!! */ daytimeIndicator.backgroundSprite = zeroed ? "NoBudgetIcon" : day ? "DayIcon" : night ? "NightIcon" : "DisabledIcon"; } SetLineNumberCircleOnRef(s.Value, lineNumberIntersect); lineNumberIntersect.textScale *= multiplier; lineNumberIntersect.relativePosition *= multiplier; } if (airport != string.Empty) { AddExtraStationBuildingIntersection(intersectionsPanel, size, "AirplaneIcon", airport); } if (harbor != string.Empty) { AddExtraStationBuildingIntersection(intersectionsPanel, size, "ShipIcon", harbor); } if (taxi != string.Empty) { AddExtraStationBuildingIntersection(intersectionsPanel, size, "TaxiIcon", taxi); } if (regionalTrainStation != string.Empty) { AddExtraStationBuildingIntersection(intersectionsPanel, size, "RegionalTrainIcon", regionalTrainStation); } if (cableCarStation != string.Empty) { AddExtraStationBuildingIntersection(intersectionsPanel, size, "CableCarIcon", cableCarStation); } }
public override void Start() { base.Start(); _checkBox = AddUIComponent <UICustomCheckbox>(); _colorFieldPanel = AddUIComponent <UIPanel>(); _colorFieldPanel.size = new Vector2(17, 17); _colorFieldPanel.relativePosition = new Vector3(22, 0); _color = Instantiate(FindObjectOfType <UIColorField>().gameObject).GetComponent <UIColorField>(); _colorFieldPanel.AttachUIComponent(_color.gameObject); _color.name = "ColorPickerLine" + LineID; _color.size = new Vector2(17, 17); _color.relativePosition = new Vector3(0, 0); _color.pickerPosition = UIColorField.ColorPickerPosition.RightAbove; _color.eventSelectedColorChanged += (component, value) => TransportUtil.SetLineColor(LineID, value); _name = AddUIComponent <UILabel>(); _stops = AddUIComponent <UILabel>(); _passengers = AddUIComponent <UILabel>(); _trips = AddUIComponent <UILabel>(); _vehicles = AddUIComponent <UILabel>(); _dayOnly = AddUIComponent <UICustomCheckbox>(); _nightOnly = AddUIComponent <UICustomCheckbox>(); _deleteButton = AddUIComponent <UIButton>(); _deleteButton.size = new Vector2(17, 17); _deleteButton.tooltip = "Delete line"; _deleteButton.normalFgSprite = "buttonclose"; _deleteButton.pressedFgSprite = "buttonclosepressed"; _deleteButton.hoveredFgSprite = "buttonclosehover"; _deleteButton.isVisible = true; _checkBox.relativePosition = new Vector3(5, 0); _name.relativePosition = new Vector3(43, 0); _stops.relativePosition = new Vector3(170, 0); _passengers.relativePosition = new Vector3(225, 0); _trips.relativePosition = new Vector3(320, 0); _vehicles.relativePosition = new Vector3(401, 0); _dayOnly.relativePosition = new Vector3(455, 0); _nightOnly.relativePosition = new Vector3(490, 0); _deleteButton.relativePosition = new Vector3(515, 0); _name.textColor = new Color32(185, 221, 254, 255); _stops.textColor = new Color32(185, 221, 254, 255); _passengers.textColor = new Color32(185, 221, 254, 255); _trips.textColor = new Color32(185, 221, 254, 255); _vehicles.textColor = new Color32(185, 221, 254, 255); _checkBox.size = new Vector2(12, 12); _dayOnly.size = new Vector2(12, 12); _nightOnly.size = new Vector2(12, 12); //init the day/night checkboxes _dayOnly.IsChecked = TransportUtil.GetDay(LineID); _nightOnly.IsChecked = TransportUtil.GetNight(LineID); // event handler for on/off of the line _checkBox.eventClick += (component, param) => { _checkBox.IsChecked = !_checkBox.IsChecked; if (!_checkBox.IsChecked) { TransportUtil.HideTransportLine(LineID); } else { TransportUtil.ShowTransportLine(LineID); } }; // event handler for on/off of day _dayOnly.eventClick += (component, param) => { _dayOnly.IsChecked = !_dayOnly.IsChecked; TransportUtil.SetDay(LineID, _dayOnly.IsChecked); }; // event handler for on/off of night _nightOnly.eventClick += (component, param) => { _nightOnly.IsChecked = !_nightOnly.IsChecked; TransportUtil.SetNight(LineID, _nightOnly.IsChecked); }; _name.eventClick += (component, param) => WorldInfoPanel.Show <PublicTransportWorldInfoPanel>(TransportUtil.GetFirstLineStop(LineID), InstanceID); _name.eventMouseHover += (component, param) => { TransportUtil.SelectTransportLine(LineID); _name.textColor = TransportUtil.GetLineColor(LineID); }; _name.eventMouseLeave += (component, param) => { TransportUtil.DeselectTransportLine(LineID); _name.textColor = new Color32(185, 221, 254, 255); }; _deleteButton.eventClick += (component, param) => Singleton <TransportManager> .instance.ReleaseLine(LineID); // scale label texts _name.textScale = 0.8f; _stops.textScale = 0.8f; _passengers.textScale = 0.8f; _trips.textScale = 0.8f; _vehicles.textScale = 0.8f; _deleteButton.textScale = 0.8f; // zebra stripes background backgroundSprite = "GenericPanelLight"; if (IsOdd) { color = new Color32(150, 150, 150, 255); } else { color = new Color32(130, 130, 130, 255); } // center elements in row UIComponent[] children = GetComponentsInChildren <UIComponent>(); foreach (UIComponent child in children) { if (child == this) { continue; } child.pivot = UIPivotPoint.MiddleLeft; child.transformPosition = new Vector3(child.transformPosition.x, GetBounds().center.y, 0); } }