public void OnSettingsUI(UIHelperBase helper) { // Load the configuration ElektrixModsConfiguration config = Configuration <ElektrixModsConfiguration> .Load(); UIHelperBase globalSettings = helper.AddGroup("Global Settings"); globalSettings.AddButton("Reset Button Location to (500, 500)", () => { config.PanelX = 500; config.PanelY = 500; if (NetPickerTool.instance != null) { UIView.Find("ElektrixMB").absolutePosition = new Vector2(config.PanelX, config.PanelY); } Configuration <ElektrixModsConfiguration> .Save(); }); globalSettings.AddSpace(10); globalSettings.AddSlider("Panel X", 0, Screen.currentResolution.width, 1.0f, config.PanelX, (nv) => { config.PanelX = (int)nv; if (NetPickerTool.instance != null) { UIView.Find("ElektrixMB").absolutePosition = new Vector2(config.PanelX, config.PanelY); } Configuration <ElektrixModsConfiguration> .Save(); }); globalSettings.AddSlider("Panel Y", 0, Screen.currentResolution.height, 1.0f, config.PanelY, (nv) => { config.PanelY = (int)nv; if (NetPickerTool.instance != null) { UIView.Find("ElektrixMB").absolutePosition = new Vector2(config.PanelX, config.PanelY); } Configuration <ElektrixModsConfiguration> .Save(); }); globalSettings.AddSpace(10); globalSettings.AddCheckbox("Close Window after tool finishes", config.CloseWindow, (value) => { config.CloseWindow = value; Configuration <ElektrixModsConfiguration> .Save(); }); UIHelperBase internalSettings = helper.AddGroup("Mod Settings"); internalSettings.AddCheckbox("Open UI to Road Location (additionally disables hidden roads)", config.NP_OpenUI, (check) => { config.NP_OpenUI = check; Configuration <ElektrixModsConfiguration> .Save(); }); }
protected override void OnToolUpdate() { base.OnToolUpdate(); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastInput input = new RaycastInput(ray, Camera.main.farClipPlane); input.m_ignoreSegmentFlags = NetSegment.Flags.None; input.m_ignoreNodeFlags = NetNode.Flags.All; input.m_ignoreParkFlags = DistrictPark.Flags.All; input.m_ignorePropFlags = PropInstance.Flags.All; input.m_ignoreTreeFlags = TreeInstance.Flags.All; input.m_ignoreCitizenFlags = CitizenInstance.Flags.All; input.m_ignoreVehicleFlags = Vehicle.Flags.Created; input.m_ignoreBuildingFlags = Building.Flags.All; input.m_ignoreDisasterFlags = DisasterData.Flags.All; input.m_ignoreTransportFlags = TransportLine.Flags.All; input.m_ignoreParkedVehicleFlags = VehicleParked.Flags.All; input.m_ignoreTerrain = true; RayCast(input, out RaycastOutput output); m_hover = output.m_netSegment; if (Input.GetKeyDown(KeyCode.Escape)) { enabled = false; ToolsModifierControl.SetTool <DefaultTool>(); } if (m_hover != 0) { m_netInfo = GetSegment(m_hover).Info; if (Input.GetMouseButtonUp(0)) { instance.enabled = false; if (Singleton <UnlockManager> .instance.Unlocked(m_netInfo.m_UnlockMilestone)) { // you know when you make a bugfix just to mess with people? well this is that bugfix. enjoy. UIView.Find("E2A").Unfocus(); UIView.Find("TSCloseButton").SimulateClick(); enabled = false; m_netTool = ToolsModifierControl.SetTool <NetTool>(); m_netInfo = FindDefaultElevation(m_netInfo); // If we don't load UI, stuff happens, whatever. List <UIComponent> reveal = null; ElektrixModsConfiguration config = Configuration <ElektrixModsConfiguration> .Load(); if (config.NP_OpenUI) { reveal = FindRoadInPanel(m_netInfo.name); } m_netTool.Prefab = m_netInfo; if (reveal != null) { UIView.Find("TSCloseButton").SimulateClick(); Db.l("[Net Picker] Attempting to open panel " + reveal[1].parent.parent.parent.parent.name.Replace("Panel", "")); UIButton rb = UIView.Find("MainToolstrip").Find <UIButton>(reveal[1].parent.parent.parent.parent.name.Replace("Panel", "")); rb.SimulateClick(); reveal[0].SimulateClick(); reveal[1].SimulateClick(); if (!UIView.Find("TSCloseButton").isVisible) { Db.l("Failed"); } } else if (config.NP_OpenUI) { ThrowError("This net type is hidden and won't work properly if used by non-advanced users. In order to use this net, disable 'open ui' in Net Picker settings. If this net *isn't* actually hidden, please tweet your net type (and what menu it can be found in) to @cosigncosine. Thanks!"); ToolsModifierControl.SetTool <DefaultTool>(); UIView.Find("ElectricityPanel").Hide(); } m_fakeNetTool = true; //Debug.LogError(NetworkSkins.modPath); ushort segmentId = m_hover; NetInfo prefab = m_netInfo; try { Type segmentDataManagerType = Type.GetType("NetworkSkins.Data.SegmentDataManager, NetworkSkins"); object segmentDataManager = segmentDataManagerType.GetField("Instance").GetValue(null); object[] SegmentToSegmentDataMap = (object[])segmentDataManagerType.GetField("SegmentToSegmentDataMap").GetValue(segmentDataManager); var segmentData = SegmentToSegmentDataMap[segmentId]; segmentDataManagerType.GetMethod("SetActiveOptions").Invoke(segmentDataManager, new object[] { prefab, segmentData }); } catch (Exception e) { Debug.Log("Network skins isn't installed."); } if (config.CloseWindow) { UIView.Find("ElektrixModsPanel").Hide(); } } else { ThrowError("This net type isn't unlocked yet! Wait until this unlock/milestone: " + m_netInfo.m_UnlockMilestone.m_name); } } } else { m_netInfo = default(NetInfo); } }