private void OnCapacitySubmitted(UIComponent component, string text) { if (this._selectedIndex <= -1 || this._selectedSubService == ItemClass.SubService.PublicTransportTaxi) { return; } PrefabData prefab = GetPrefabs()[this._selectedIndex]; int carCount = prefab.CarCount; int int32 = Utils.ToInt32(text); int num1 = 0; if (int32 > 0) { num1 = Utils.RoundToNearest((float)(int32 / carCount), 5) * carCount; (component as UITextField).text = num1.ToString(); } UITextField uiTextField = this._rightSidePanel.Find <UITextField>("MaintenanceCost"); if (!uiTextField.parent.enabled) { return; } float num2 = (float)num1 / (float)carCount / (float)GameDefault.GetCapacity(prefab.Info.GetService(), prefab.Info.GetSubService(), prefab.Info.GetClassLevel()); uiTextField.text = Mathf.RoundToInt((float)(PrefabData.GetMaintenanceCost(prefab.Info.GetService(), prefab.Info.GetSubService(), prefab.Info.GetClassLevel(), prefab.Info.m_vehicleAI) * 16) * num2).ToString(); }
private void OnApplyButtonClick(UIComponent component, UIMouseEventParameter eventParam) { if (this._selectedIndex <= -1) { return; } UITextField uiTextField1 = this._rightSidePanel.Find <UITextField>("Capacity"); UITextField uiTextField2 = this._rightSidePanel.Find <UITextField>("MaintenanceCost"); UITextField uiTextField4 = this._rightSidePanel.Find <UITextField>("MaxSpeed"); UICheckBox uiCheckBox = this._rightSidePanel.Find <UICheckBox>("EngineOnBothEnds"); PrefabData prefab = GetPrefabs()[this._selectedIndex]; int capacity = Utils.ToInt32(uiTextField1.text) / prefab.CarCount; int int32_1 = Utils.ToInt32(uiTextField2.text); int int32_3 = Utils.ToInt32(uiTextField4.text); bool isChecked = uiCheckBox.isChecked; prefab.SetValues(capacity, int32_1, int32_3, isChecked); this.UpdateBindings(); }
public override void Update() { base.Update(); if (OptionsWrapper <Settings> .Options.HideVehicleEditor != this._hide) { this._hide = OptionsWrapper <Settings> .Options.HideVehicleEditor; this.isVisible = !this._hide; } if (OptionsWrapper <Settings> .Options.VehicleEditorPosition != this._position) { this._position = OptionsWrapper <Settings> .Options.VehicleEditorPosition; if (this.isVisible) { this.UpdatePosition(); } } if (!this._initialized) { this._publicTransportInfoViewPanel = GameObject.Find("(Library) PublicTransportInfoViewPanel").GetComponent <PublicTransportInfoViewPanel>(); if (!((UnityEngine.Object) this._publicTransportInfoViewPanel != (UnityEngine.Object)null)) { return; } this._publicTransportInfoViewPanel.component.eventVisibilityChanged += new PropertyChangedEventHandler <bool>(this.ParentVisibilityChanged); this._publicTransportInfoViewPanel.component.eventPositionChanged += new PropertyChangedEventHandler <Vector2>(this.ParentPositionChanged); this.CreatePanel(); VehicleEditor.Instance = this; this._initialized = true; } else if (this._initialized && this.isVisible && this._firstShow) { this.FirstShowInit(TransportInfo.TransportType.Bus, (VehicleInfo)null); } else { if (!this._initialized || !this.isVisible) { return; } this._rightSidePanel.Find <UILabel>("MaintenanceCostLabel").text = (Utils.ToSingle(this._rightSidePanel.Find <UITextField>("MaintenanceCost").text) * 0.01f).ToString(ColossalFramework.Globalization.Locale.Get("MONEY_FORMAT"), (IFormatProvider)LocaleManager.cultureInfo); this._rightSidePanel.Find <UILabel>("MaxSpeedLabel").text = (Utils.ToInt32(this._rightSidePanel.Find <UITextField>("MaxSpeed").text) * 5).ToString() + " " + OptionsWrapper <Settings> .Options.SpeedString; } }