Example #1
0
        public void Show(VehicleOptions options)
        {
            m_initialized = false;

            m_options = options;

            if (m_color0 == null)
            {
                return;
            }

            m_color0.relativePosition = new Vector3(35, 135);
            m_color1.relativePosition = new Vector3(35, 160);
            m_color2.relativePosition = new Vector3(182, 135);
            m_color3.relativePosition = new Vector3(182, 160);

            if (!AdvancedVehicleOptions.SpeedUnitOption)
            {
                m_maxSpeed.text = Mathf.RoundToInt(options.maxSpeed * maxSpeedToKmhConversionFactor).ToString();
                kmhLabel.text   = Translations.Translate("AVO_MOD_OP01");
            }
            else
            {
                m_maxSpeed.text = Mathf.RoundToInt((options.maxSpeed / mphFactor) * maxSpeedToKmhConversionFactor).ToString();
                kmhLabel.text   = Translations.Translate("AVO_MOD_OP02");
            }

            m_acceleration.text        = options.acceleration.ToString();
            m_braking.text             = options.braking.ToString();
            m_turning.text             = options.turning.ToString();
            m_springs.text             = options.springs.ToString();
            m_dampers.text             = options.dampers.ToString();
            m_leanMultiplier.text      = options.leanMultiplier.ToString();
            m_nodMultiplier.text       = options.nodMultiplier.ToString();
            m_useColors.isChecked      = options.useColorVariations;
            m_color0.selectedColor     = options.color0;
            m_color1.selectedColor     = options.color1;
            m_color2.selectedColor     = options.color2;
            m_color3.selectedColor     = options.color3;
            m_color0_hex.text          = options.color0.ToString();
            m_color1_hex.text          = options.color1.ToString();
            m_color2_hex.text          = options.color2.ToString();
            m_color3_hex.text          = options.color3.ToString();
            m_isLargeVehicle.isChecked = options.isLargeVehicle;

            m_enabled.isChecked = options.enabled;
            m_enabled.Show();
            m_enabled.isVisible = !options.isTrailer;

            m_addBackEngine.isChecked = options.addBackEngine;
            m_addBackEngine.isVisible = options.isTrain;
            m_maxSpeed.isInteractive  = true;

            m_lineoverview.Hide();
            m_isLargeVehicle.Hide();
            m_useColorsLabel.Hide();

            m_capacity.parent.isVisible = true;
            m_capacity.isInteractive    = true;
            m_capacity.text             = options.capacity.ToString();
            m_capacity.isVisible        = options.hasCapacity;
            capacityLabel.isVisible     = options.hasCapacity;
            bustrailerLabel.isVisible   = false;

            m_specialcapacity.text               = options.specialcapacity.ToString();
            m_specialcapacity.isVisible          = options.hasSpecialCapacity;
            specialcapacityLabel.isVisible       = options.hasSpecialCapacity;
            m_userguidespecialcapacity.isVisible = options.hasSpecialCapacity;

            m_capacity.color          = OldColorTextField;
            m_capacity.textColor      = OldColorText;
            m_capacity.tooltip        = OldCapacityTooltip;
            m_specialcapacity.tooltip = OldSpecialCapacityTooltip;
            m_maxSpeed.color          = OldColorTextField;
            m_maxSpeed.textColor      = OldColorText;
            m_maxSpeed.tooltip        = OldMaxSpeedTooltip;

            //Only display Cargo Capacity or Passenger Capacity - not any other values
            if (options.isNonPaxCargo == true && options.hasCapacity == true && AdvancedVehicleOptions.ShowMoreVehicleOptions == true)
            {
                m_capacity.parent.isVisible = true;
            }
            else
            if (options.isNonPaxCargo == true && options.hasCapacity == true && AdvancedVehicleOptions.ShowMoreVehicleOptions == false)
            {
                m_capacity.parent.isVisible = false;
            }

            //Compatibility Patch for Vehicle Color Expander - hide all controls, if mod is active. Not relating to PublicTransport only, but all vehicles
            if (VCXCompatibilityPatch.IsVCXActive())
            {
                m_useColors.enabled = false;
                m_color0.Hide();
                m_color0_hex.Hide();
                m_color1.Hide();
                m_color1_hex.Hide();
                m_color2.Hide();
                m_color2_hex.Hide();
                m_color3.Hide();
                m_color3_hex.Hide();
                m_useColorsLabel.Show();
            }

            // Compatibility Patch for IPT, TLM and Cities Skylines Vehicle Spawning, Vehicle values. Instead of Spawn Allowed buttons for the Vehicles the Line Overview Window will be shown.
            if (options.isPublicTransportGame == true)
            {
                m_enabled.Hide();
                m_lineoverview.Show();
                m_userguidespawn.Show();
                LineOverviewType = options.ReturnLineOverviewType;
            }
            else
            {
                if (options.ValidateIsBusTrailer)
                {
                    m_enabled.Hide();
                    bustrailerLabel.isVisible = true;
                }
                else
                {
                    m_enabled.Show();
                    bustrailerLabel.isVisible = false;
                }
                m_lineoverview.Hide();
                m_userguidespawn.Hide();
            }

            if (AdvancedVehicleOptions.OverrideCompatibilityWarnings == true && options.isPublicTransport == true && !options.isNotPublicTransportMod == true)
            {
                if (IPTCompatibilityPatch.IsIPTActive() == true)
                {
                    m_maxSpeed.color            = new Color32(240, 130, 130, 255);
                    m_capacity.color            = new Color32(240, 130, 130, 255);
                    m_specialcapacity.color     = new Color32(240, 130, 130, 255);
                    m_maxSpeed.textColor        = new Color32(255, 230, 130, 255);
                    m_capacity.textColor        = new Color32(255, 230, 130, 255);
                    m_specialcapacity.textColor = new Color32(255, 230, 130, 255);
                    m_maxSpeed.tooltip          = m_maxSpeed.tooltip + Translations.Translate("AVO_MOD_OP03");
                    m_capacity.tooltip          = m_capacity.tooltip + Translations.Translate("AVO_MOD_OP03");
                    m_specialcapacity.tooltip   = m_specialcapacity.tooltip + Translations.Translate("AVO_MOD_OP03");
                }
                if (TLMCompatibilityPatch.IsTLMActive() == true)
                {
                    m_capacity.color     = new Color32(240, 130, 130, 255);
                    m_capacity.textColor = new Color32(255, 230, 130, 255);
                    m_capacity.tooltip   = m_capacity.tooltip + Translations.Translate("AVO_MOD_OP04");
                }
            }

            if (NoBigTruckCompatibilityPatch.IsNBTActive() == true && AdvancedVehicleOptions.ControlTruckDelivery == true && options.isDelivery == true && options.hasTrailer == true)
            {
                m_isLargeVehicle.Show();

                Logging.Message("Vehicle " + options.localizedName + " is flagged as Large Vehicle.");
            }

            // Compatibility Patch section ends


            // Flight Stand Info introduced in Airports DLC

            if ((options.prefab.m_vehicleType == VehicleInfo.VehicleType.Plane && options.prefab.m_class.m_level != ItemClass.Level.Level5))
            {
                if (options.prefab.m_class.m_level == ItemClass.Level.Level1)
                {
                    m_planesize.text = Translations.Translate("AVO_MOD_OP43") + " " + Translations.Translate("AVO_MOD_OP45");
                }
                if (options.prefab.m_class.m_level == ItemClass.Level.Level2)
                {
                    m_planesize.text = Translations.Translate("AVO_MOD_OP43") + " " + Translations.Translate("AVO_MOD_OP46");
                }
                if (options.prefab.m_class.m_level == ItemClass.Level.Level3)
                {
                    m_planesize.text = Translations.Translate("AVO_MOD_OP43") + " " + Translations.Translate("AVO_MOD_OP44");;
                }
                if (options.prefab.m_class.m_level == ItemClass.Level.Level4)
                {
                    m_planesize.text = Translations.Translate("AVO_MOD_OP43") + " " + Translations.Translate("AVO_MOD_OP47");;
                }
                m_planesize.isVisible = true;
            }
            else
            {
                m_planesize.isVisible = false;
            }

            string name = options.localizedName;

            if (name.Length > 40)
            {
                name = name.Substring(0, 38) + "...";
            }
            m_removeLabel.text = Translations.Translate("AVO_MOD_OP05") + name;

            (parent as UIMainPanel).ChangePreviewColor(m_color0.selectedColor);

            capacityLabel.text        = options.CapacityString;
            specialcapacityLabel.text = options.SpecialCapacityString;

            m_initialized = true;
        }
        public void Show(VehicleOptions options)
        {
            m_initialized = false;

            m_options = options;

            if (m_color0 == null)
            {
                return;
            }

            m_color0.relativePosition = new Vector3(35, 135);
            m_color1.relativePosition = new Vector3(35, 160);
            m_color2.relativePosition = new Vector3(182, 135);
            m_color3.relativePosition = new Vector3(182, 160);

            if (!AdvancedVehicleOptionsUID.SpeedUnitOption)
            {
                m_maxSpeed.text = Mathf.RoundToInt(options.maxSpeed * maxSpeedToKmhConversionFactor).ToString();
                kmhLabel.text   = "km/h";
            }
            else
            {
                m_maxSpeed.text = Mathf.RoundToInt((options.maxSpeed / mphFactor) * maxSpeedToKmhConversionFactor).ToString();
                kmhLabel.text   = "mph";
            }

            m_acceleration.text        = options.acceleration.ToString();//m_capacity
            m_braking.text             = options.braking.ToString();
            m_turning.text             = options.turning.ToString();
            m_springs.text             = options.springs.ToString();
            m_dampers.text             = options.dampers.ToString();
            m_leanMultiplier.text      = options.leanMultiplier.ToString();
            m_nodMultiplier.text       = options.nodMultiplier.ToString();
            m_useColors.isChecked      = options.useColorVariations;
            m_color0.selectedColor     = options.color0;
            m_color1.selectedColor     = options.color1;
            m_color2.selectedColor     = options.color2;
            m_color3.selectedColor     = options.color3;
            m_color0_hex.text          = options.color0.ToString();
            m_color1_hex.text          = options.color1.ToString();
            m_color2_hex.text          = options.color2.ToString();
            m_color3_hex.text          = options.color3.ToString();
            m_isLargeVehicle.isChecked = options.isLargeVehicle;

            m_enabled.isChecked = options.enabled;
            m_enabled.Show();
            m_enabled.isVisible = !options.isTrailer;

            m_addBackEngine.isChecked = options.addBackEngine;
            m_addBackEngine.isVisible = options.isTrain;
            m_maxSpeed.isInteractive  = true;

            m_lineoverview.Hide();
            m_isLargeVehicle.Hide();
            m_useColorsLabel.Hide();

            m_capacity.parent.isVisible = true;
            m_capacity.isInteractive    = true;
            m_capacity.text             = options.capacity.ToString();
            m_capacity.isVisible        = options.hasCapacity;
            capacityLabel.isVisible     = options.hasCapacity;
            bustrailerLabel.isVisible   = false;

            m_specialcapacity.text               = options.specialcapacity.ToString();
            m_specialcapacity.isVisible          = options.hasSpecialCapacity;
            specialcapacityLabel.isVisible       = options.hasSpecialCapacity;
            m_userguidespecialcapacity.isVisible = options.hasSpecialCapacity;

            m_capacity.color          = OldColorTextField;
            m_capacity.textColor      = OldColorText;
            m_capacity.tooltip        = OldCapacityTooltip;
            m_specialcapacity.tooltip = OldSpecialCapacityTooltip;
            m_maxSpeed.color          = OldColorTextField;
            m_maxSpeed.textColor      = OldColorText;
            m_maxSpeed.tooltip        = OldMaxSpeedTooltip;

            //DebugUtils.Log("GameBalanceOptionsptions " + AdvancedVehicleOptionsUID.GameBalanceOptions);
            //DebugUtils.Log("NonPaxCargo - Do Not Show Capacity " + options.isNonPaxCargo);
            //DebugUtils.Log("Capacity - Do Not Show Capacity " + options.hasCapacity);

            //Only display Cargo Capacity or Passenger Capacity - not any other values
            if (options.isNonPaxCargo == true && options.hasCapacity == true && AdvancedVehicleOptionsUID.GameBalanceOptions == true)
            {
                m_capacity.parent.isVisible = true;
            }
            else
            if (options.isNonPaxCargo == true && options.hasCapacity == true && AdvancedVehicleOptionsUID.GameBalanceOptions == false)
            {
                m_capacity.parent.isVisible = false;
            }

            //Compatibility Patch for Vehicle Color Expander - hide all controls, if mod is active. Not relating to PublicTransport only, but all vehicles
            if (VCXCompatibilityPatch.IsVCXActive())
            {
                m_useColors.enabled = false;
                m_color0.Hide();
                m_color0_hex.Hide();
                m_color1.Hide();
                m_color1_hex.Hide();
                m_color2.Hide();
                m_color2_hex.Hide();
                m_color3.Hide();
                m_color3_hex.Hide();
                m_useColorsLabel.Show();
            }

            //DebugUtils.Log("IsIPTActive " + IPTCompatibilityPatch.IsIPTActive());
            //DebugUtils.Log("OverrideIPT " + AdvancedVehicleOptionsUID.OverrideIPT);
            //DebugUtils.Log("IsPublicTransport " + options.isPublicTransport);

            // Compatibility Patch for IPT, TLM and Cities Skylines Vehicle Spawning, Vehicle values. For Spawning Vehicles the Line Overview Window will be shown.

            if ((options.isPublicTransportGame == true) && AdvancedVehicleOptionsUID.SpawnControl == true)
            {
                m_enabled.Hide();
                m_lineoverview.Show();
                m_userguidespawn.Show();
                LineOverviewType = options.ReturnLineOverviewType;
            }
            else
            {
                if (options.ValidateIsBusTrailer)
                {
                    m_enabled.Hide();
                    bustrailerLabel.isVisible = true;
                }
                else
                {
                    m_enabled.Show();
                    bustrailerLabel.isVisible = false;
                }
                m_lineoverview.Hide();
                m_userguidespawn.Hide();
            }

            if (AdvancedVehicleOptionsUID.OverrideCompatibilityWarnings == true && options.isPublicTransport == true && !options.isNotPublicTransportMod == true)
            {
                if (IPTCompatibilityPatch.IsIPTActive() == true)
                {
                    m_maxSpeed.color            = new Color32(240, 130, 130, 255);
                    m_capacity.color            = new Color32(240, 130, 130, 255);
                    m_specialcapacity.color     = new Color32(240, 130, 130, 255);
                    m_maxSpeed.textColor        = new Color32(255, 230, 130, 255);
                    m_capacity.textColor        = new Color32(255, 230, 130, 255);
                    m_specialcapacity.textColor = new Color32(255, 230, 130, 255);
                    m_maxSpeed.tooltip          = m_maxSpeed.tooltip + "\n\nWarning: Improved Public Transport is active\nand may override this setting.";
                    m_capacity.tooltip          = m_capacity.tooltip + "\n\nWarning: Improved Public Transport is active\nand may override this setting.";
                    m_specialcapacity.tooltip   = m_specialcapacity.tooltip + "\n\nWarning: Improved Public Transport is active\nand may override this setting.";
                }
                if (TLMCompatibilityPatch.IsTLMActive() == true)
                {
                    m_capacity.color     = new Color32(240, 130, 130, 255);
                    m_capacity.textColor = new Color32(255, 230, 130, 255);
                    m_capacity.tooltip   = m_capacity.tooltip + "\n\nWarning: Transport Lines Manager is active\nand may override this setting.";
                }
            }

            if (NoBigTruckCompatibilityPatch.IsNBTActive() == true && AdvancedVehicleOptionsUID.ControlTruckDelivery == true && options.isDelivery == true && options.hasTrailer == true)
            {
                m_isLargeVehicle.Show();
                //DebugUtils.Log("AVO IsLargeVehicle");
            }

            // Compatibility Patch section ends

            string name = options.localizedName;

            if (name.Length > 40)
            {
                name = name.Substring(0, 38) + "...";
            }
            m_removeLabel.text = "Actions for: " + name;

            (parent as UIMainPanel).ChangePreviewColor(m_color0.selectedColor);

            capacityLabel.text        = options.CapacityString;
            specialcapacityLabel.text = options.SpecialCapacityString;

            m_initialized = true;
        }