Ejemplo n.º 1
0
        private void SetupUIBindings()
        {
#if DEBUG
            Debug.Log("Setting up UI...");
#endif
            cargoPanel = (CargoUIPanel)UIView.GetAView().AddUIComponent(typeof(CargoUIPanel));

            var servicePanel = UIHelper.GetPanel("(Library) CityServiceWorldInfoPanel");
            //var statsPanel = servicePanel?.Find<UIPanel>("DescPanel");
            //statsLabel = statsPanel?.Find<UILabel>("Desc");
            statsLabel = servicePanel?.Find <UILabel>("Desc");
            rightPanel = servicePanel?.Find <UIPanel>("Right");
            if (servicePanel == null)
            {
                Debug.LogError("CityServiceWorldInfoPanel not found");
            }
            //if (statsPanel == null)
            //    Debug.LogError("DescPanel not found");
            //if (statsLabel == null)
            if (rightPanel == null)
            {
                //Debug.LogError("DescPanel.Desc label not found");
                Debug.LogError("ServicePanel.Right panel not found");
            }
            else
            {
                //Debug.Log("Service stats label found!");
#if DEBUG
                Debug.Log("ServicePanel.Right panel found!");
#endif
                showDelegate = (sender, e) =>
                {
                    if (mod.data.TryGetEntry(WorldInfoPanel.GetCurrentInstanceID().Building, out _))
                    {
                        cargoPanel.Show();
                    }
                };

                //statsLabel.eventClicked += showDelegate;
                rightPanel.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!");
            }
        }