private void OnBindingMouseDown(UIComponent comp, UIMouseEventParameter p) { if ((SavedValue)this.m_EditingBinding == (SavedValue)null) { p.Use(); this.m_EditingBinding = (SavedInputKey)p.source.objectUserData; UIButton source = p.source as UIButton; source.buttonsMask = UIMouseButton.Left | UIMouseButton.Right | UIMouseButton.Middle | UIMouseButton.Special0 | UIMouseButton.Special1 | UIMouseButton.Special2 | UIMouseButton.Special3; source.text = ColossalFramework.Globalization.Locale.Get("KEYMAPPING_PRESSANYKEY"); p.source.Focus(); UIView.PushModal(p.source); } else { if (this.IsUnbindableMouseButton(p.buttons)) { return; } p.Use(); UIView.PopModal(); this.m_EditingBinding.value = SavedInputKey.Encode(this.ButtonToKeycode(p.buttons), this.IsControlDown(), this.IsShiftDown(), this.IsAltDown()); UIButton source = p.source as UIButton; source.text = this.m_EditingBinding.ToLocalizedString("KEYNAME"); source.buttonsMask = UIMouseButton.Left; this.m_EditingBinding = (SavedInputKey)null; } }
private void OnBindingMouseDown(UIComponent comp, UIMouseEventParameter p) { if (m_EditingBinding == null) { p.Use(); m_EditingBinding = (SavedInputKey)p.source.objectUserData; m_EditingBindingCategory = p.source.stringUserData; var uIButton = p.source as UIButton; uIButton.buttonsMask = UIMouseButton.Left | UIMouseButton.Right | UIMouseButton.Middle | UIMouseButton.Special0 | UIMouseButton.Special1 | UIMouseButton.Special2 | UIMouseButton.Special3; uIButton.text = "Press any key"; p.source.Focus(); UIView.PushModal(p.source); } else if (!IsUnbindableMouseButton(p.buttons)) { p.Use(); UIView.PopModal(); var inputKey = SavedInputKey.Encode(ButtonToKeycode(p.buttons), IsControlDown(), IsShiftDown(), IsAltDown()); m_EditingBinding.value = inputKey; var uIButton2 = p.source as UIButton; uIButton2.text = m_EditingBinding.ToLocalizedString("KEYNAME"); uIButton2.buttonsMask = UIMouseButton.Left; m_EditingBinding = null; m_EditingBindingCategory = string.Empty; } }
private void OnBindingMouseDown(UIComponent component, UIMouseEventParameter evParam) { var editable = (SavedInputKey)evParam.source.objectUserData; var keybindButton = evParam.source as UIButton; // This will only work if the user is not in the process of changing the shortcut if (_currentlyEditingBinding == null) { evParam.Use(); StartKeybindEditMode(editable, keybindButton); } else if (!IsUnbindableMouseButton(evParam.buttons)) { // This will work if the user clicks while the shortcut change is in progress evParam.Use(); var editedBinding = _currentlyEditingBinding; // will be nulled by closing modal UIView.PopModal(); var inputKey = SavedInputKey.Encode(ButtonToKeycode(evParam.buttons), IsControlDown(), IsShiftDown(), IsAltDown()); editedBinding.value = inputKey; keybindButton.buttonsMask = UIMouseButton.Left; keybindButton.text = ToLocalizedString(editedBinding); _currentlyEditingBinding = null; ModService.Instance.FinishKeybindEdit(); } }
private void OnBindingMouseDown(UIComponent comp, UIMouseEventParameter p) { if (this.m_EditingBinding == null) { p.Use(); this.m_EditingBinding = (SavedInputKey)p.source.objectUserData; this.m_EditingBindingCategory = p.source.stringUserData; UIButton uIButton = p.source as UIButton; uIButton.buttonsMask = (UIMouseButton.Left | UIMouseButton.Right | UIMouseButton.Middle | UIMouseButton.Special0 | UIMouseButton.Special1 | UIMouseButton.Special2 | UIMouseButton.Special3); uIButton.text = ModInfo.translation.GetTranslation("NBM_PRESS_KEY"); p.source.Focus(); UIView.PushModal(p.source); } else if (!this.IsUnbindableMouseButton(p.buttons)) { p.Use(); UIView.PopModal(); InputKey inputKey = SavedInputKey.Encode(this.ButtonToKeycode(p.buttons), this.IsControlDown(), this.IsShiftDown(), this.IsAltDown()); this.m_EditingBinding.value = inputKey; UIButton uIButton2 = p.source as UIButton; uIButton2.text = this.m_EditingBinding.ToLocalizedString("KEYNAME"); uIButton2.buttonsMask = UIMouseButton.Left; this.m_EditingBinding = null; this.m_EditingBindingCategory = string.Empty; } }
private void OnBindingMouseDown(UIComponent comp, UIMouseEventParameter p) { if (this.editingBinding == null) { p.Use(); this.editingBinding = (SavedInputKey)p.source.objectUserData; UIButton uibutton = p.source as UIButton; uibutton.buttonsMask = (UIMouseButton.Left | UIMouseButton.Right | UIMouseButton.Middle | UIMouseButton.Special0 | UIMouseButton.Special1 | UIMouseButton.Special2 | UIMouseButton.Special3); uibutton.text = "Press any key"; p.source.Focus(); UIView.PushModal(p.source); return; } if (!this.IsUnbindableMouseButton(p.buttons)) { p.Use(); UIView.PopModal(); InputKey value = SavedInputKey.Encode(this.ButtonToKeycode(p.buttons), this.IsControlDown(), this.IsShiftDown(), this.IsAltDown()); this.editingBinding.value = value; UIButton uibutton2 = p.source as UIButton; uibutton2.text = this.editingBinding.ToLocalizedString("KEYNAME"); uibutton2.buttonsMask = UIMouseButton.Left; this.editingBinding = null; } }
private static void OnBindingMouseDown(UIComponent comp, UIMouseEventParameter p) { if (m_EditingBinding == null) { p.Use(); m_EditingBinding = (Shortcut)p.source.objectUserData; UIButton uIButton = p.source as UIButton; uIButton.buttonsMask = (UIMouseButton.Left | UIMouseButton.Right | UIMouseButton.Middle | UIMouseButton.Special0 | UIMouseButton.Special1 | UIMouseButton.Special2 | UIMouseButton.Special3); uIButton.text = "Press any key"; p.source.Focus(); UIView.PushModal(p.source); } else if (!IsUnbindableMouseButton(p.buttons)) { p.Use(); UIView.PopModal(); InputKey inputKey = SavedInputKey.Encode(ButtonToKeycode(p.buttons), IsControlDown(), IsShiftDown(), IsAltDown()); List <Shortcut> currentAssigned; if (!IsAlreadyBound(m_EditingBinding, inputKey, out currentAssigned)) { if (m_EditingBinding.inputKey != inputKey) { m_EditingBinding.inputKey = inputKey; Shortcut.SaveShorcuts(); } UIButton uIButton = p.source as UIButton; uIButton.text = SavedInputKey.ToLocalizedString("KEYNAME", m_EditingBinding.inputKey); uIButton.buttonsMask = UIMouseButton.Left; m_EditingBinding = null; } else { string arg = (currentAssigned.Count <= 1) ? Locale.Get("KEYMAPPING", currentAssigned[0].name) : Locale.Get("KEYMAPPING_MULTIPLE"); string message = string.Format(Locale.Get("CONFIRM_REBINDKEY", "Message"), SavedInputKey.ToLocalizedString("KEYNAME", inputKey), arg); ConfirmPanel.ShowModal(Locale.Get("CONFIRM_REBINDKEY", "Title"), message, delegate(UIComponent c, int ret) { if (ret == 1) { m_EditingBinding.inputKey = inputKey; for (int i = 0; i < currentAssigned.Count; i++) { currentAssigned[i].inputKey = 0; } Shortcut.SaveShorcuts(); RefreshKeyMapping(); } UIButton uIButton = p.source as UIButton; uIButton.text = SavedInputKey.ToLocalizedString("KEYNAME", m_EditingBinding.inputKey); uIButton.buttonsMask = UIMouseButton.Left; m_EditingBinding = null; }); } } }
protected override void OnMouseWheel(UIMouseEventParameter p) { Log.Debug(GetType().Name + "\n" + Environment.StackTrace); scrollWheelAmount = ScrollStep; value = UISliderExt.Round(value + scrollWheelAmount * p.wheelDelta, scrollWheelAmount); p.Use(); }
protected override void OnMouseWheel(UIMouseEventParameter p) { base.OnMouseWheel(p); if (!p.used) { float prevPos = listPosition; if (m_stepSize > 0 && m_rowHeight > 0) { listPosition = m_pos - p.wheelDelta * m_stepSize / m_rowHeight; } else { listPosition = m_pos - p.wheelDelta; } if (prevPos != listPosition) { p.Use(); } if (selectOnMouseEnter) { OnRowClicked(m_lastMouseEnter, p); } } }
protected override void OnMouseDown(UIMouseEventParameter p) { p.Use(); UIThemeManager.instance.ChangeUpgradeBuilding(m_building); base.OnMouseDown(p); }
private void OnTooltipClicked(UIComponent c, UIMouseEventParameter p) { if (!p.used && p.buttons == UIMouseButton.Right && currentData != null && currentData.asset != null) { if (currentData.asset.author.IsNullOrWhiteSpace() || currentData.asset.steamID == 0 || !currentData.asset.prefab.m_isCustomContent) { return; } PublishedFileId publishedFileId = new PublishedFileId(currentData.asset.steamID); if (publishedFileId != PublishedFileId.invalid) { if (!Settings.useDefaultBrowser) { PlatformService.ActivateGameOverlayToWorkshopItem(publishedFileId); } else { System.Diagnostics.Process.Start("https://steamcommunity.com/sharedfiles/filedetails/?id=" + publishedFileId); } p.Use(); } } }
/// <summary> /// Handles click of "Unsubscribe" or "Delete" button; removes the associated mod and updates UI. /// /// Once all incompatible mods are removed, the dialog will be closed automatically. /// </summary> /// /// <param name="component">A handle to the UI button that was clicked.</param> /// <param name="eventparam">Details of the click event.</param> /// <param name="mod">The <see cref="PluginInfo"/> instance of the mod to remove.</param> private void UnsubscribeClick(UIComponent component, UIMouseEventParameter eventparam, PluginInfo mod) { eventparam.Use(); bool success; // disable button to prevent accidental clicks component.isEnabled = false; Log.Info($"Removing incompatible mod '{mod.name}' from {mod.modPath}"); success = mod.publishedFileID.AsUInt64 == LOCAL_MOD ? DeleteLocalMod(mod) : PlatformService.workshop.Unsubscribe(mod.publishedFileID); if (success) { modListChanged_ = true; IncompatibleMods.Remove(mod); component.parent.Disable(); component.isVisible = false; // automatically close the dialog if no more mods to remove if (IncompatibleMods.Count == 0) { CloseDialog(); } } else { Log.Warning($"Failed to remove mod '{mod.name}'"); component.isEnabled = true; } }
static void HandleMouseDown(UICheckboxDropDown c, UIMouseEventParameter p) { if (p.buttons == UIMouseButton.Right) { c.ClosePopup(); p.Use(); } }
private void CloseButtonClick(UIComponent component, UIMouseEventParameter eventparam) { closeButton.eventClick -= CloseButtonClick; TryPopModal(); Hide(); Unfocus(); eventparam.Use(); }
protected override void OnClick(UIMouseEventParameter p) { base.OnClick(p); if (!p.used && p.buttons == UIMouseButton.Left) { p.Use(); DropDown.Invoke("OpenPopup", 0); } }
/// <summary> /// Handle right click, it's filtered out from OnClick() callback /// </summary> /// <param name="p"></param> protected override void OnMouseDown(UIMouseEventParameter p) { if ((p.buttons & UIMouseButton.Right) != 0) { p.Use(); UIInput.MouseUsed(); AllowDespawn.AllowDespawningPanel.OpenModal(); } }
protected void OnClick(UIComponent comp, UIMouseEventParameter p) { p.Use(); UIButton uIButton = comp as UIButton; if (uIButton != null && uIButton.parent == this.m_strip) { } }
private void OnBindingMouseDown(UIComponent comp, UIMouseEventParameter evParam) { var editable = (KeybindSetting.Editable)evParam.source.objectUserData; var keybindButton = evParam.source as UIButton; // This will only work if the user is not in the process of changing the shortcut if (currentlyEditedBinding_ == null) { evParam.Use(); StartKeybindEditMode(editable, keybindButton); } else if (!Keybind.IsUnbindableMouseButton(evParam.buttons)) { // This will work if the user clicks while the shortcut change is in progress evParam.Use(); var editedBinding = currentlyEditedBinding_; // will be nulled by closing modal UIView.PopModal(); var inputKey = SavedInputKey.Encode(Keybind.ButtonToKeycode(evParam.buttons), Keybind.IsControlDown(), Keybind.IsShiftDown(), Keybind.IsAltDown()); var category = editable.Target.Category; var maybeConflict = FindConflict(editedBinding.Value, inputKey, category); if (maybeConflict != string.Empty) { var message = Translation.Options.Get("Keybinds.Dialog.Text:Keybind conflict") + "\n\n" + maybeConflict; Log.Info($"Keybind conflict: {message}"); UIView.library .ShowModal <ExceptionPanel>("ExceptionPanel") .SetMessage("Key Conflict", message, false); } else { editedBinding.Value.TargetKey.value = inputKey; editedBinding.Value.Target.NotifyKeyChanged(); } keybindButton.buttonsMask = UIMouseButton.Left; keybindButton.text = Keybind.ToLocalizedString(editedBinding.Value.TargetKey); currentlyEditedBinding_ = null; } }
public static void RollInteger(UIComponent component, UIMouseEventParameter eventParam) { if (component is UITextField tf && tf.numericalOnly && float.TryParse(tf.text, out float currentValue)) { bool shiftPressed = Event.current.shift; tf.text = Mathf.Max(tf.allowNegative ? float.MinValue : 0, currentValue + 0.0003f + (eventParam.wheelDelta * (shiftPressed ? 10 : 1))).ToString("F0"); m_submitField.Invoke(tf, new object[0]); eventParam.Use(); } }
protected void OnClick(UIComponent comp, UIMouseEventParameter p) { p.Use(); UIButton uIButton = comp as UIButton; if (uIButton != null && uIButton.parent == this.m_scrollablePanel) { this.OnButtonClicked(uIButton); this.m_selectedIndex = this.m_scrollablePanel.components.IndexOf(uIButton); } }
private void PTLineDetectorClick(UIComponent component, UIMouseEventParameter eventparam) { eventparam.Use(); OnBeforeStart(); _runningScan = StartCoroutine(ModService.Instance.SearchForDisconnectedPtStops()); _runningProgress = StartCoroutine(UpdateProgress(() => { OnAfterStop(); ShowPtResults(); })); }
private void OpenLineLabel(UIComponent component, UIMouseEventParameter eventParam) { if (ushort.TryParse(component.stringUserData, out ushort lineId) && lineId != 0) { Vector3 position = Singleton <NetManager> .instance.m_nodes.m_buffer[Singleton <TransportManager> .instance.m_lines.m_buffer[lineId].m_stops].m_position; InstanceID iid = InstanceID.Empty; iid.TransportLine = lineId; WorldInfoPanel.Show <PublicTransportWorldInfoPanel>(position, iid); eventParam.Use(); } }
private void StartButtonClick(UIComponent component, UIMouseEventParameter eventparam) { eventparam.Use(); OnBeforeStart(); ModService.Instance.StartDetector(); _runningScan = StartCoroutine(Countdown(5, () => { ModService.Instance.StopDetector(); OnAfterStop(); ShowResults(); })); }
private void GhostNodesButtonClick(UIComponent component, UIMouseEventParameter eventparam) { eventparam.Use(); OnBeforeStart(); _runningScan = StartCoroutine(ModService.Instance.SearchForGhostNodes()); _runningProgress = StartCoroutine(Countdown(5, () => { ShowGhostNodesResult(); OnAfterStop(); })); }
private void StartScanBuildingsClick(UIComponent component, UIMouseEventParameter eventparam) { eventparam.Use(); OnBeforeStart(); _runningScan = StartCoroutine(ModService.Instance.ScanForDisconnectedBuildings()); _runningProgress = StartCoroutine(UpdateProgress(() => { OnAfterStop(); ShowBuildingResult(); })); }
private void ShortSegmentsButtonClick(UIComponent component, UIMouseEventParameter eventparam) { eventparam.Use(); OnBeforeStart(); _runningScan = StartCoroutine(ModService.Instance.SearchForShortSegments()); _runningProgress = StartCoroutine(UpdateProgress(() => { OnAfterStop(); ShowShortSegmentsResult(); })); }
protected override void OnClick(UIMouseEventParameter p) { p.Use(); try { if (UGCDetails.publishedFileId.AsUInt64 != 0 && UGCDetails.publishedFileId != PublishedFileId.invalid) { CheckSubsUtil.Instance.Redownload(UGCDetails.publishedFileId); } } catch (Exception ex) { ex.Log(); } base.OnClick(p); }
private void OnTooltipClicked(UIComponent c, UIMouseEventParameter p) { if (!p.used && p.buttons == UIMouseButton.Right && currentData != null && currentData.asset != null) { PublishedFileId publishedFileId = new PublishedFileId(currentData.asset.steamID); if (publishedFileId != PublishedFileId.invalid) { PlatformService.ActivateGameOverlayToWorkshopItem(publishedFileId); p.Use(); } } }
private void OnBindingMouseDown(UIComponent comp, UIMouseEventParameter p) { if (EditBinding == null) { p.Use(); EditBinding = (SavedInputKey)p.source.objectUserData; var button = p.source as UIButton; button.buttonsMask = UIMouseButton.Left | UIMouseButton.Right | UIMouseButton.Middle | UIMouseButton.Special0 | UIMouseButton.Special1 | UIMouseButton.Special2 | UIMouseButton.Special3; button.text = Locale.Get("KEYMAPPING_PRESSANYKEY"); p.source.Focus(); UIView.PushModal(p.source); } else if (!IsUnbindableMouseButton(p.buttons)) { p.Use(); UIView.PopModal(); EditBinding.value = SavedInputKey.Encode(ButtonToKeycode(p.buttons), Utility.CtrlIsPressed, Utility.ShiftIsPressed, Utility.AltIsPressed); var button = p.source as UIButton; button.text = EditBinding.ToLocalizedString("KEYNAME"); button.buttonsMask = UIMouseButton.Left; EditBinding = null; } }
/// <summary> /// Handles click of the "close dialog" button; pops the dialog off the modal stack. /// </summary> /// /// <param name="component">Handle to the close button UI component (not used).</param> /// <param name="eventparam">Details about the click event.</param> private void CloseButtonClick(UIComponent component, UIMouseEventParameter eventparam) { CloseDialog(); eventparam.Use(); }
/// <summary> /// MouseDown event handler to handle mouse clicks; primarily used to prime hotkey entry. /// </summary> /// <param name="mouseEvent">Mouse button event parameter</param> public void OnMouseDown(UIMouseEventParameter mouseEvent) { // Use the event. mouseEvent.Use(); // Check to see if we're already primed for hotkey entry. if (isPrimed) { // We were already primed; is this a bindable mouse button? if (mouseEvent.buttons == UIMouseButton.Left || mouseEvent.buttons == UIMouseButton.Right) { // Not a bindable mouse button - set the button text and cancel priming. button.text = SavedInputKey.ToLocalizedString("KEYNAME", ModSettings.CurrentHotkey); UIView.PopModal(); isPrimed = false; } else { // Bindable mouse button - do keybinding as if this was a keystroke. KeyCode mouseCode; switch (mouseEvent.buttons) { // Convert buttons to keycodes (we don't bother with left and right buttons as they're non-bindable). case UIMouseButton.Middle: mouseCode = KeyCode.Mouse2; break; case UIMouseButton.Special0: mouseCode = KeyCode.Mouse3; break; case UIMouseButton.Special1: mouseCode = KeyCode.Mouse4; break; case UIMouseButton.Special2: mouseCode = KeyCode.Mouse5; break; case UIMouseButton.Special3: mouseCode = KeyCode.Mouse6; break; default: // No valid button pressed: exit without doing anything. return; } // We got a valid mouse button key - apply settings and save. ApplyKey(SavedInputKey.Encode(mouseCode, IsControlDown(), IsShiftDown(), IsAltDown())); } } else { // We weren't already primed - set our text and focus the button. button.buttonsMask = (UIMouseButton.Left | UIMouseButton.Right | UIMouseButton.Middle | UIMouseButton.Special0 | UIMouseButton.Special1 | UIMouseButton.Special2 | UIMouseButton.Special3); button.text = Translations.Translate("KEY_PRS"); button.Focus(); // Prime for new keybinding entry. isPrimed = true; UIView.PushModal(button); } }