/// <summary> /// Look for keypress to open GUI. /// </summary> /// <param name="realTimeDelta"></param> /// <param name="simulationTimeDelta"></param> public override void OnUpdate(float realTimeDelta, float simulationTimeDelta) { // Has hotkey been pressed? if (hotKey != KeyCode.None && Input.GetKey(hotKey)) { // Check modifier keys according to settings. bool altPressed = Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) || Input.GetKey(KeyCode.AltGr); bool ctrlPressed = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl); bool shiftPressed = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift); // Modifiers have to *exactly match* settings, e.g. "alt-E" should not trigger on "ctrl-alt-E". bool altOkay = altPressed == hotAlt; bool ctrlOkay = ctrlPressed == hotCtrl; bool shiftOkay = shiftPressed == hotShift; // Process keystroke. if (altOkay && ctrlOkay && shiftOkay) { // Cancel if key input is already queued for processing. if (_processed) { return; } _processed = true; try { // Is options panel open? If so, we ignore this and don't do anything. if (!OptionsPanel.IsOpen) { BuildingDetailsPanel.Open(); } } catch (Exception e) { Debugging.LogException(e); } } else { // Relevant keys aren't pressed anymore; this keystroke is over, so reset and continue. _processed = false; } } else { // Relevant keys aren't pressed anymore; this keystroke is over, so reset and continue. _processed = false; } }
/// <summary> /// Adds button to access building details from building info panels. /// </summary> internal static void AddInfoPanelButton() { // Get parent panel and apply button. ZonedBuildingWorldInfoPanel infoPanel = UIView.library.Get <ZonedBuildingWorldInfoPanel>(typeof(ZonedBuildingWorldInfoPanel).Name); UIButton panelButton = UIUtils.CreateButton(infoPanel.component, 133); // Basic setup. panelButton.height = 19.5f; panelButton.textScale = 0.65f; panelButton.textVerticalAlignment = UIVerticalAlignment.Bottom; panelButton.relativePosition = new UnityEngine.Vector3(infoPanel.component.width - panelButton.width - 10, 120); panelButton.text = Translations.Translate("RPR_REALPOP"); // Just in case other mods are interfering. panelButton.Enable(); // Event handler. panelButton.eventClick += (control, clickEvent) => { // Select current building in the building details panel and show. BuildingDetailsPanel.Open(InstanceManager.GetPrefabInfo(WorldInfoPanel.GetCurrentInstanceID()) as BuildingInfo); }; }