public static void Prefix(InfoMode mode, SubInfoMode subMode)
        {
            if (!RoadSelectionPanels.Root)
            {
                return;
            }

            if (RoadSelectionPanels.Root.RoadWorldInfoPanelExt != null)
            {
                RoadSelectionPanels.Root.RoadWorldInfoPanelExt.isVisible =
                    mode == InfoMode.None ||
                    RoadSelectionUtil.IsNetAdjustMode(mode, (int)subMode);
            }
            if (RoadSelectionUtil.IsNetAdjustMode(mode, (int)subMode))
            {
                // UI to be handled by Default tool
                ModUI.Instance.CloseMainMenu();

                SimulationManager.instance.m_ThreadingWrapper.QueueMainThread(() => {
                    DefaultTool.OpenWorldInfoPanel(
                        Singleton <InstanceManager> .instance.GetSelectedInstance(),
                        Input.mousePosition);
                });
            }
            else
            {
                SimulationManager.instance.m_ThreadingWrapper.QueueMainThread(RoadSelectionPanels.RoadWorldInfoPanel.Hide);
            }
        }
Exemplo n.º 2
0
        private void OnMouseDown(UIComponent component, UIMouseEventParameter p)
        {
            VehicleListBoxRow vehicleListBoxRow = component as VehicleListBoxRow;
            bool zoomIn = Input.GetKey(KeyCode.LeftShift) | Input.GetKey(KeyCode.RightShift);

            if ((int)vehicleListBoxRow.VehicleID != 0 && p.buttons == UIMouseButton.Right)
            {
                InstanceID id = new InstanceID();
                id.Vehicle = vehicleListBoxRow.VehicleID;
                ToolsModifierControl.cameraController.SetTarget(id, ToolsModifierControl.cameraController.transform.position, zoomIn);
                DefaultTool.OpenWorldInfoPanel(id, ToolsModifierControl.cameraController.transform.position);
            }
            else
            {
                if (p.buttons != UIMouseButton.Left)
                {
                    return;
                }
                // ISSUE: reference to a compiler-generated field
                if (this.eventRowShiftClick != null && zoomIn)
                {
                    this.PlayClickSound(p.source);
                    // ISSUE: reference to a compiler-generated field
                    this.eventRowShiftClick(component, p);
                    if (vehicleListBoxRow.IsSelected)
                    {
                        return;
                    }
                }
                vehicleListBoxRow.IsSelected = !vehicleListBoxRow.IsSelected;
                this.OnSelectedItemsChanged();
            }
        }
        public void GoToInstance(InstanceID id, Vector3 pos, bool openInfoPanel = false)
        {
            pos.y = Camera.main.transform.position.y;

            ToolsModifierControl.cameraController.SetTarget(id, pos, true);
            Singleton <SimulationManager> .instance.m_ThreadingWrapper.QueueMainThread(() => {
                DefaultTool.OpenWorldInfoPanel(id, pos);
            });
        }
Exemplo n.º 4
0
        /// <summary>
        /// Handles "lookAt" message from client.
        /// </summary>
        /// <param name="msg">Message.</param>
        protected void HandleLookAt(ClientMessage msg)
        {
            Vector3    pos;
            InstanceID id  = default(InstanceID);
            var        cam = ToolsModifierControl.cameraController;

            cam.ClearTarget();
            if (msg.HasKey("building"))
            {
                id.Building = (ushort)msg.GetInt("building");
                pos         = BuildingManager.instance.m_buildings.m_buffer[id.Building].m_position;
            }
            else if (msg.HasKey("vehicle"))
            {
                id.Vehicle = (ushort)msg.GetInt("vehicle");
                pos        = VehicleManager.instance.m_vehicles.m_buffer[id.Vehicle].GetLastFramePosition();
            }
            else if (msg.HasKey("parkedVehicle"))
            {
                id.ParkedVehicle = (ushort)msg.GetInt("parkedVehicle");
                pos = VehicleManager.instance.m_parkedVehicles.m_buffer[id.ParkedVehicle].m_position;
            }
            else if (msg.HasKey("segment"))
            {
                id.NetSegment = (ushort)msg.GetInt("segment");
                pos           = NetManager.instance.m_segments.m_buffer[id.NetSegment].m_bounds.center;
            }
            else if (msg.HasKey("node"))
            {
                id.NetNode = (ushort)msg.GetInt("node");
                pos        = NetManager.instance.m_nodes.m_buffer[id.NetNode].m_position;
            }
            else if (msg.HasKey("citizenInstance"))
            {
                id.CitizenInstance = (ushort)msg.GetInt("citizenInstance");
                pos = CitizenManager.instance.m_instances.m_buffer[id.CitizenInstance].GetLastFramePosition();
            }
            else if (msg.HasKey("position"))
            {
                cam.m_targetPosition = msg.GetVector3("position");
                return;
            }
            else
            {
                throw new ArgumentException("No target specified");
            }
            bool zoom      = !msg.HasKey("zoom") || msg.GetBool("zoom");
            bool openPanel = !msg.HasKey("openInfoPanel") || msg.GetBool("openInfoPanel");

            cam.SetTarget(id, pos, zoom);
            if (openPanel)
            {
                SimulationManager.instance.m_ThreadingWrapper.QueueMainThread(() => {
                    DefaultTool.OpenWorldInfoPanel(id, pos);
                });
            }
        }
Exemplo n.º 5
0
        private void OnFishFarmMarkerClicked(UIComponent component, UIMouseEventParameter eventParam)
        {
            component.Unfocus();
            if ((int)_fishFarmDropDown.SelectedItem == 0)
            {
                return;
            }
            InstanceID id = new InstanceID();

            id.Building = _fishFarmDropDown.SelectedItem;
            ToolsModifierControl.cameraController.SetTarget(id, ToolsModifierControl.cameraController.transform.position, Input.GetKey(KeyCode.LeftShift) | Input.GetKey(KeyCode.RightShift));
            DefaultTool.OpenWorldInfoPanel(id, ToolsModifierControl.cameraController.transform.position);
        }
        private void SelectSub(UIComponent component, UIMouseEventParameter param)
        {
            if (_idList == null)
            {
                return;
            }
            var buildingId = _idList[selectedIndex];
            var building   = BuildingManager.instance.m_buildings.m_buffer[buildingId];

            if (building.Info != null)
            {
                var localeField = typeof(LocaleManager).GetField("m_Locale", BindingFlags.NonPublic | BindingFlags.Instance);
                var locale      = (Locale)localeField.GetValue(SingletonLite <LocaleManager> .instance);
                var key         = new Locale.Key {
                    m_Identifier = "BUILDING_TITLE", m_Key = building.Info.name
                };
                if (!locale.Exists(key))
                {
                    locale.AddLocalizedString(key, building.Info.name);
                }
                key = new Locale.Key {
                    m_Identifier = "BUILDING_DESC", m_Key = building.Info.name
                };
                if (!locale.Exists(key))
                {
                    locale.AddLocalizedString(key, string.Empty);
                }
                key = new Locale.Key {
                    m_Identifier = "BUILDING_SHORT_DESC", m_Key = building.Info.name
                };
                if (!locale.Exists(key))
                {
                    locale.AddLocalizedString(key, string.Empty);
                }
            }
            var button = GameObject.Find("RelocateAction").GetComponent <UIButton>();

            if (selectedIndex == 0)
            {
                button.Show();
            }
            else
            {
                button.Hide();
            }
            DefaultTool.OpenWorldInfoPanel(new InstanceID {
                Building = buildingId
            }, new Vector2(0, 0));
        }