Ejemplo n.º 1
0
        private void SetupUIBindings()
        {
            Debug.Log("Setting up UI...");

            cargoPanel = (CargoUIPanel)UIView.GetAView().AddUIComponent(typeof(CargoUIPanel));

            var servicePanel = UIHelper.GetPanel("(Library) CityServiceWorldInfoPanel");
            var statsPanel   = servicePanel?.Find <UIPanel>("StatsPanel");

            statsLabel = statsPanel?.Find <UILabel>("Info");
            if (servicePanel == null)
            {
                Debug.LogError("CityServiceWorldInfoPanel not found");
            }
            if (statsPanel == null)
            {
                Debug.LogError("Service stats panel not found");
            }
            if (statsLabel == null)
            {
                Debug.LogError("Service stats label not found");
            }
            else
            {
                Debug.Log("Service stats label found!");

                showDelegate = (sender, e) =>
                {
                    if (mod.data.TryGetEntry(WorldInfoPanel.GetCurrentInstanceID().Building, out _))
                    {
                        cargoPanel.Show();
                    }
                };

                statsLabel.eventClicked += showDelegate;
            }

            var vehicleMainPanel = UIHelper.GetPanel("(Library) CityServiceVehicleWorldInfoPanel");
            var vehiclePanel     = vehicleMainPanel.Find <UIPanel>("Panel");

            if (vehiclePanel != null)
            {
                vehiclePanel.autoLayout            = false;
                vehicleCargoChart                  = vehiclePanel.AddUIComponent <UICargoChart>();
                vehicleCargoChart.size             = new Vector2(60, 60);
                vehicleCargoChart.relativePosition = new Vector3(330, 0);
                vehicleCargoChart.SetValues(CargoParcel.ResourceTypes.Select(f => 1f / CargoParcel.ResourceTypes.Length).ToArray());
            }
            else
            {
                Debug.LogError("CityServiceVehicleWorldInfoPanel not found!");
            }
        }