Ejemplo n.º 1
0
        public override void Start()
        {
            base.Start();

            if (Parent == null)
            {
                ModDebug.Error(String.Format("Parent not set in {0}", this.GetType().Name));
                return;
            }

            width            = Parent.width;
            relativePosition = Vector3.zero;
            isVisible        = true;
            canFocus         = true;
            isInteractive    = true;;

            _drag.width            = width - 50;
            _drag.height           = height;
            _drag.relativePosition = Vector3.zero;
            _drag.target           = Parent;

            _icon.spriteName       = IconSprite;
            _icon.relativePosition = new Vector3(5, 10);

            _title.relativePosition = new Vector3(50, 13);
            _title.text             = TitleText;

            _close.relativePosition = new Vector3(width - 35, 2);
            _close.normalBgSprite   = "buttonclose";
            _close.hoveredBgSprite  = "buttonclosehover";
            _close.pressedBgSprite  = "buttonclosepressed";
            _close.eventClick      += (component, param) => Parent.Hide();
        }
Ejemplo n.º 2
0
        private void HookIntoNativeUI()
        {
            _busPanel   = UIUtil.FindUIComponent("BusPanel");
            _metroPanel = UIUtil.FindUIComponent("MetroPanel");
            _trainPanel = UIUtil.FindUIComponent("TrainPanel");

            _busBg   = UIUtil.FindUIComponent("BusBackground");
            _metroBg = UIUtil.FindUIComponent("MetroBackground");
            _trainBg = UIUtil.FindUIComponent("TrainBackground");

            if (_busPanel == null || _busBg == null)
            {
                ModDebug.Error("Failed to locate BusPanel - could not hook into native UI.");
                return;
            }

            if (_metroPanel == null || _metroBg == null)
            {
                ModDebug.Error("Failed to locate MetroPanel - could not hook into native UI.");
                return;
            }

            if (_trainPanel == null || _trainBg == null)
            {
                ModDebug.Error("Failed to locate TrainPanel - could not hook into native UI.");
                return;
            }

            // extended bus hook
            _busPanel.eventClick      += BusPanelOnEventClick;
            _busPanel.eventMouseHover += BusPanelOnEventMouseHover;
            _busPanel.eventMouseLeave += BusPanelOnEventMouseLeave;

            // extended metro hook
            _metroPanel.eventClick      += MetroPanelOnEventClick;
            _metroPanel.eventMouseHover += MetroPanelOnEventMouseHover;
            _metroPanel.eventMouseLeave += MetroPanelOnEventMouseLeave;

            // extended train hook
            _trainPanel.eventClick      += TrainPanelOnEventClick;
            _trainPanel.eventMouseHover += TrainPanelOnEventMouseHover;
            _trainPanel.eventMouseLeave += TrainPanelOnEventMouseLeave;

            // hide all extended panels, when the transport info view gets closed
            _busPanel.parent.eventVisibilityChanged += InfoPanelOnEventVisibilityChanged;
        }
Ejemplo n.º 3
0
        private void HookIntoNativeUI()
        {
            _busPanel   = UIUtil.FindUIComponent("BusPanel");
            _metroPanel = UIUtil.FindUIComponent("MetroPanel");
            _trainPanel = UIUtil.FindUIComponent("TrainPanel");

            _busBg   = UIUtil.FindUIComponent("BusBackground");
            _metroBg = UIUtil.FindUIComponent("MetroBackground");
            _trainBg = UIUtil.FindUIComponent("TrainBackground");

            if (_busPanel == null || _busBg == null)
            {
                ModDebug.Error("Failed to locate BusPanel - could not hook into native UI.");
                return;
            }

            if (_metroPanel == null || _metroBg == null)
            {
                ModDebug.Error("Failed to locate MetroPanel - could not hook into native UI.");
                return;
            }

            if (_trainPanel == null || _trainBg == null)
            {
                ModDebug.Error("Failed to locate TrainPanel - could not hook into native UI.");
                return;
            }

            // extended bus hook
            _busPanel.eventClick += (component, param) =>
            {
                _extendedMetroPanel.isVisible      = false;
                _extendedTrainPanel.isVisible      = false;
                _extendedBusPanel.isVisible        = !_extendedBusPanel.isVisible;
                _extendedBusPanel.relativePosition = new Vector3(396, 58);
            };
            _busPanel.eventMouseHover += (component, param) => _busBg.color = new Color32(84, 182, 231, 255);
            _busPanel.eventMouseLeave += (component, param) => _busBg.color = new Color32(44, 142, 191, 255);

            // extended metro hook
            _metroPanel.eventClick += (component, param) =>
            {
                _extendedBusPanel.isVisible          = false;
                _extendedTrainPanel.isVisible        = false;
                _extendedMetroPanel.isVisible        = !_extendedMetroPanel.isVisible;
                _extendedMetroPanel.relativePosition = new Vector3(396, 58);
            };
            _metroPanel.eventMouseHover += (component, param) => _metroBg.color = new Color32(40, 224, 40, 255);
            _metroPanel.eventMouseLeave += (component, param) => _metroBg.color = new Color32(0, 184, 0, 255);

            // extended train hook
            _trainPanel.eventClick += (component, param) =>
            {
                _extendedBusPanel.isVisible          = false;
                _extendedMetroPanel.isVisible        = false;
                _extendedTrainPanel.isVisible        = !_extendedTrainPanel.isVisible;
                _extendedTrainPanel.relativePosition = new Vector3(396, 58);
            };
            _trainPanel.eventMouseHover += (component, param) => _trainBg.color = new Color32(255, 126, 40, 255);
            _trainPanel.eventMouseLeave += (component, param) => _trainBg.color = new Color32(219, 86, 0, 255);

            // hide all extended panels, when the transport info view gets closed
            _busPanel.parent.eventVisibilityChanged += (component, visibility) =>
            {
                if (!visibility)
                {
                    _extendedBusPanel.isVisible   = false;
                    _extendedMetroPanel.isVisible = false;
                    _extendedTrainPanel.isVisible = false;
                }
            };
        }