public override bool OnMouse(Vector2 pos, MouseButton button, PressType type) { if (button == MouseButton.Left && this.FruitTimer <= TimeSpan.Zero) { var game = GameImpl.Instance; var closeEnough = Vector2.DistanceSquared(game.Player.Position, this.Position) <= 1; if (closeEnough && type == PressType.Pressed) { foreach (var off in FruitOffsets) { var offset = this.Position + this.RenderBounds.Position + off + new Vector2(0.5F, 0.5F); var obj = new ItemObject(this.Type.Drop.Instance(), this.Map, offset); obj.DestinationY = this.Position.Y + off.Y; obj.Velocity.X = this.Map.Random.NextDouble() < 0.5 ? -0.01F : 0.01F; this.Map.AddObject(obj); } this.FruitTimer = this.Type.Time; return(true); } else { InterfaceManager.SetCursorType(CursorType.Pick, closeEnough ? 1F : 0.5F); } } return(false); }
public override bool OnMouse(MouseButton button, PressType type) { if (this.CursorItem != null && type == PressType.Pressed) { if (button == MouseButton.Right) { this.OnClose(); return(true); } else if (button == MouseButton.Left) { var furniture = this.CursorItem as ItemFurniture; if (furniture != null) { var pos = GameImpl.Instance.Camera.ToWorldPos(Mouse.GetState().Position.ToVector2()).Floor() + Vector2.One * 0.5F; if (!MapObject.IsCollidingPos(this.Player.Map, pos, furniture.Type.PlacementBounds[this.PlacementDirection])) { var obj = new Furniture(furniture.Type, this.Player.Map, pos, this.PlacementDirection); this.Player.Map.AddObject(obj); this.CursorItem = null; this.PlacementDirection = Direction.Down; return(true); } } } } return(base.OnMouse(button, type)); }
public KeybindModel(string name, HotKey hotKey, PressType pressType, Action action) { Name = name; HotKey = hotKey; PressType = pressType; Action = action; }
private static void ProcessMouse(MouseEventArgs mouseEventArgs, PressType pressType) { foreach (var keybindModel in KeybindModels) { keybindModel.InvokeIfMatched(mouseEventArgs.Button, pressType); } }
public override bool OnMouse(Vector2 pos, MouseButton button, PressType type) { if (button == MouseButton.Right && this.CanPickUp()) { if (type == PressType.Pressed) { InterfaceManager.Overlay.CursorItem = this.Type.Instance(); InterfaceManager.Overlay.PlacementDirection = this.Direction; this.Map.Objects.Remove(this); return(true); } else { InterfaceManager.SetCursorType(CursorType.Pick, 1F); } } else if (button == MouseButton.Left && this.Storage != null) { var player = GameImpl.Instance.Player; var closeEnough = Vector2.DistanceSquared(player.Position, this.Position + this.CollisionBounds.Position + (Vector2)this.CollisionBounds.Size / 2F) <= 1; if (closeEnough && type == PressType.Pressed) { InterfaceManager.SetInterface(new Storage(player, this)); return(true); } else { InterfaceManager.SetCursorType(CursorType.Chest, closeEnough ? 1 : 0.5F); } } return(false); }
private void Add(Input input) { if (input == Input.Any && !_inputReader.Flags.HasFlag(InputReaderFlags.AllowKeywordAny)) { throw CreateException($"Input '{input.ToTokenString()}' not allowed at this location."); } if (_pressType != PressType.None) { Helper.RequireTrue(!_createChord && _multiplier == 1 && _modifiers == Modifiers.None); _inputReader._injectorStream.Add(input, _pressType == PressType.Hold); _pressType = PressType.None; } else { if (_createChord) { Helper.RequireTrue(_multiplier == 1); _inputReader._combos.Add(new Combo(input, _modifiers)); } else { _inputReader._injectorStream.Add(input, _modifiers, _multiplier); _multiplier = 1; } _modifiers = Modifiers.None; } }
/// <summary> /// Starts the button pressed animation. /// </summary> /// <param name="isPressed">If true, transitions into presesd; if false, transitions out of it.</param> private void doStartPressAnim(PressType pressType) { lock (animLO) { // If invoked but we're fully unpressed: nothing to do. if (pressType == PressType.NotPressed && pressAnimVal == 0) { return; } // If "not pressed" but we're just transitioning into pressed: make it a return trip. // Also make it a return trip if we're fully unpressed and just need to flash. if (pressType == PressType.NotPressed && pressAnimState == 1) { pressAnimState = 2; } else if (pressType == PressType.Flash) { pressAnimState = 2; } else { pressAnimState = pressType == PressType.Pressed ? 1 : -1; } } SubscribeToTimer(); MakeMePaint(false, RenderMode.Invalidate); }
public KeybindModel(string name, MouseButtons mouseButtons, PressType pressType, Action action) { Name = name; MouseButtons = mouseButtons; PressType = pressType; Action = action; }
private void HookEx_Events(object sender, WindowsHookExEventArgs e) { if (KeyChange == null) { return; } KeyboardLLHookStruct @struct = (KeyboardLLHookStruct)Marshal.PtrToStructure((IntPtr)e.lParam, typeof(KeyboardLLHookStruct)); PressType pressType = PressType.None; VirtualKeys vk = (VirtualKeys)@struct.VirtualKeyCode; KeyboardState state = KeyboardState.FromCurrentState(); char?inputChar = null; if (e.wParam.ToInt64() == WM.KEYDOWN || e.wParam.ToInt64() == WM.SYSKEYDOWN) { pressType = PressType.KeyDown; } else if (e.wParam.ToInt64() == WM.KEYUP || e.wParam.ToInt64() == WM.SYSKEYUP) { pressType = PressType.KeyUp; } // Get Press Char char?PressKey = null; byte[] inBuffer = new byte[2]; if (User32.ToAscii(@struct.VirtualKeyCode, @struct.ScanCode, state.Bytes, inBuffer, @struct.Flags) == 1) { char ch = (char)inBuffer[0]; if (!char.IsControl(ch)) { PressKey = ch; if ((state.CapsLockToggled ^ state.ShiftPressed) && char.IsLetter(ch)) { PressKey = char.ToUpper(ch); } inputChar = PressKey; } } var args = new KeyChangeEventArgs() { Handled = false, PressType = pressType, Key = vk, KeyboardState = state, InputChar = inputChar, }; foreach (var action in KeyChange.GetInvocationList().Reverse()) { action.DynamicInvoke(this, args); if (args.Handled) { e.Handled = true; return; } } }
public override bool OnMouse(Vector2 pos, MouseButton button, PressType type) { if (button == MouseButton.Right && this.DestinationY == 0) { var game = GameImpl.Instance; var closeEnough = Vector2.DistanceSquared(game.Player.Position, this.Position) <= 1; if (closeEnough && type == PressType.Pressed) { var inv = GameImpl.Instance.Player.Inventory; for (var i = 0; i < inv.Length; i++) { if (inv[i] == null) { inv[i] = this.Item; this.Map.Objects.Remove(this); return(true); } } } else { InterfaceManager.SetCursorType(CursorType.Pick, closeEnough ? 1F : 0.5F); } } return(false); }
public KeySet(InputAction Action, KeyCode Key, PressType Press, Action Function) { this.Action = Action; this.Key = Key; this.Press = Press; this.Function = Function; }
public static bool HandleMouse(MouseButton button, PressType type) { if (Overlay.OnMouse(button, type)) { return(true); } return(CurrentInterface != null && CurrentInterface.OnMouse(button, type)); }
void Respond(PointerEventData.InputButton button, PressType interaction) { foreach (var binding in bindings) { if (binding.interaction == interaction && binding.button == button) { binding.Response.Invoke(); } } }
private void Update() { if (_pressType == PressType.PressDown) { if (Time.realtimeSinceStartup - _pressDownRealStartTime >= 0.2) { _pressType = PressType.LongPress; _longPressDown.Invoke(); } } }
public virtual bool OnKeyboard(string bind, PressType type) { for (var i = 0; i < this.Components.Count; i++) { if (this.Components[i].OnKeyboard(bind, type)) { return(true); } } return(false); }
public static void HandleKeyboard(string bind, PressType type) { if (Overlay.OnKeyboard(bind, type)) { return; } if (CurrentInterface != null) { CurrentInterface.OnKeyboard(bind, type); } }
public virtual bool OnMouse(MouseButton button, PressType type) { for (var i = 0; i < this.Components.Count; i++) { if (this.Components[i].OnMouse(button, type)) { return(true); } } return(false); }
public void InvokeIfMatched(MouseButtons mouseButtons, PressType pressType) { if (PressType != pressType) { return; } if (mouseButtons.Equals(MouseButtons)) { Action?.Invoke(); } }
public override void OnPointerDown(PointerEventData eventData) { if (!interactable) { return; } base.OnPointerDown(eventData); _pressDownRealStartTime = Time.realtimeSinceStartup; _pressType = PressType.PressDown; }
public void InvokeIfMatched(HotKey hotKey, PressType pressType) { if (HotKey == null || hotKey == null || PressType != pressType) { return; } if (hotKey.Equals(HotKey)) { Action?.Invoke(); } }
/// <summary> /// Sets a keybind to call the provided function /// </summary> /// <param name="name">Name of the keybind</param> /// <param name="hotKey">Hotkey in string format, per example: ALT+CTRL+SHIFT+D</param> /// <param name="pressType">The key type, either key up or key down</param> /// <param name="function">LUA function to call</param> /// <param name="args">Optional arguments for the passed function</param> public void SetKeybind(string name, string hotKey, PressType pressType, DynValue function, params DynValue[] args) { if (pressType != PressType.Down && pressType != PressType.Up) { throw new ScriptRuntimeException("Key type must either be Down or Up."); } var modifierKeys = ModifierKeys.None; var key = Key.System; var hotKeyParts = hotKey.Split('+').Select(p => p.Trim()); foreach (var hotKeyPart in hotKeyParts) { if (hotKeyPart == "ALT") { modifierKeys |= ModifierKeys.Alt; } else if (hotKeyPart == "CTRL") { modifierKeys |= ModifierKeys.Control; } else if (hotKeyPart == "SHIFT") { modifierKeys |= ModifierKeys.Shift; } else { Enum.TryParse(hotKeyPart, true, out key); } } if (key == Key.System) { throw new ScriptRuntimeException($"Hotkey '{hotKey}' couldn't be parsed."); } var hk = new HotKey(key, modifierKeys); var model = args != null ? new KeybindModel("LUA-" + name, hk, pressType, () => LuaManager.Call(function, args)) : new KeybindModel("LUA-" + name, hk, pressType, () => LuaManager.Call(function)); KeybindManager.AddOrUpdate(model); var existing = _keybindModels.FirstOrDefault(k => k.Name == model.Name); if (existing != null) { _keybindModels.Remove(existing); } _keybindModels.Add(model); }
private void HandleHoldRelease(PressType pressType) { if (!_inputReader.Flags.HasFlag(InputReaderFlags.AllowHoldRelease)) { throw CreateException("Cannot use a hold/release token at this location."); } if (_pressType != PressType.None) { throw CreateException("Unexpected token."); } _pressType = pressType; CheckConflict(); }
public ButtonAlias(Keys k, double holdable, double holdableRepeat, String a) { _association = a; _key = k; _holdable = holdable; // If they specified a repeated holdable, make sure we specify the initial to that // repeat by default if (_holdable == -1 && holdableRepeat >= 0) { _holdable = holdableRepeat; } _holdableRepeat = holdableRepeat; Pressed = PressType.None; }
public void Send(JavaMouseButton mouseType, PressType press) { if (m_isInPause) { return; } string instruction = "ms:"; if (press == PressType.Press) { instruction = "mp:"; } if (press == PressType.Release) { instruction = "mr:"; } m_toSend.Enqueue(instruction + (int)mouseType); }
public void Send(JavaKeyEvent keyToType, PressType press) { if (m_isInPause) { return; } string instruction = "ks:"; if (press == PressType.Press) { instruction = "kp:"; } if (press == PressType.Release) { instruction = "kr:"; } m_toSend.Enqueue(instruction + keyToType.ToString()); }
public override bool OnMouse(MouseButton button, PressType type) { if (button == MouseButton.Left && type == PressType.Pressed) { if (!this.IsMousedComponent()) { return(false); } var temp = this.Interface.CursorItem; if (temp != null && this.fits != null && !this.fits(temp)) { return(false); } this.Interface.CursorItem = this.Items[this.Index]; this.Items[this.Index] = temp; return(true); } return(false); }
private static void ProcessKey(KeyEventArgs keyEventArgs, PressType pressType) { // Don't trigger if the key itself is a modifier if (keyEventArgs.KeyCode == Keys.LShiftKey || keyEventArgs.KeyCode == Keys.RShiftKey || keyEventArgs.KeyCode == Keys.LControlKey || keyEventArgs.KeyCode == Keys.RControlKey || keyEventArgs.KeyCode == Keys.LMenu || keyEventArgs.KeyCode == Keys.RMenu) { return; } // Create a WPF ModifierKeys enum var modifiers = ModifierKeysFromBooleans(keyEventArgs.Alt, keyEventArgs.Control, keyEventArgs.Shift); // Create a HotKey object for comparison var hotKey = new HotKey(KeyInterop.KeyFromVirtualKey(keyEventArgs.KeyValue), modifiers); foreach (var keybindModel in KeybindModels) { keybindModel.InvokeIfMatched(hotKey, pressType); } }
public override void OnPointerUp(PointerEventData eventData) { if (!interactable) { return; } base.OnPointerUp(eventData); switch (_pressType) { case PressType.LongPress: _longPressUp.Invoke(); break; case PressType.PressDown: _pressClick.Invoke(); break; } _pressType = PressType.Unknow; }
public override bool OnMouse(MouseButton button, PressType type) { if (type == PressType.Pressed) { var moused = this.GetMousedComponent(); if (this.ContextMenu != null && moused != this.ContextMenu) { this.ContextMenu.Close(); } if (button == MouseButton.Right) { var slot = moused as ItemSlot; if (slot?.Items[slot.Index] != null) { this.ContextMenu = new InvContextMenu(this, slot, MousePos); this.AddComponent(this.ContextMenu); return(true); } } } return(base.OnMouse(button, type)); }
public override bool OnMouse(Vector2 pos, MouseButton button, PressType type) { if (button == MouseButton.Left) { var game = GameImpl.Instance; var closeEnough = Vector2.DistanceSquared(game.Player.Position, this.Position + new Vector2(2.5F, 0)) <= 2 * 2; if (closeEnough && type == PressType.Pressed) { CutsceneManager.Fade(0.03F, () => { var map = game.Maps[this.destination]; game.Player.Teleport(map, map.EntryPoint); game.Player.StopAndFace(Direction.Up); CutsceneManager.Fade(-0.03F); }); return(true); } else { InterfaceManager.SetCursorType(CursorType.Door, closeEnough ? 1F : 0.5F); } } return(false); }
internal StreamType() { this.ContentList = new List<ContentType>(); this.Press = new PressType(); }
public void DoPress(PressType press) { /* if (_isCalledInThisFrame) { _isCalledInThisFrame = false; return; } */ if (_goalId < 0) return; //Debug.Log("Pressed: " + press); if (NextGoalPress() == press) { _currentPresses.Add(press); if(_currentPresses.Count == 1) { //AudioMngr.success.pitch = 1f; AudioMngr.ChangeSuccessPitch(1f); AudioMngr.SuccessPlay(); if(OneImg.sprite == ShortSprite) { OneImg.sprite = SuccessShortSprite; } else { OneImg.sprite = SuccessLongSprite; } } else if(_currentPresses.Count == 2) { //AudioMngr.success.pitch = 1.2f; AudioMngr.ChangeSuccessPitch(1.15f); AudioMngr.SuccessPlay(); if(TwoImg.sprite == ShortSprite) { TwoImg.sprite = SuccessShortSprite; } else { TwoImg.sprite = SuccessLongSprite; } } else if(_currentPresses.Count == 3) { //AudioMngr.success.pitch = 1.4f; AudioMngr.ChangeSuccessPitch(1.4f); AudioMngr.SuccessPlay(); if(ThreeImg.sprite == ShortSprite) { ThreeImg.sprite = SuccessShortSprite; } else { ThreeImg.sprite = SuccessLongSprite; } } if (_currentPresses.Count != _currentGoal.Count) return; PoseSucceeded(); } else { PoseFailed(); ScoreSystem.comboCount = 0; ScoreSystem.comboTimeReset(); } }
public void MouseClick(JavaMouseButton button, PressType press = PressType.Stroke) { m_linkedProcessUse.Send(button, press); }
/// <summary> /// Starts the button pressed animation. /// </summary> /// <param name="isPressed">If true, transitions into presesd; if false, transitions out of it.</param> private void doStartPressAnim(PressType pressType) { lock (animLO) { // If invoked but we're fully unpressed: nothing to do. if (pressType == PressType.NotPressed && pressAnimVal == 0) return; // If "not pressed" but we're just transitioning into pressed: make it a return trip. // Also make it a return trip if we're fully unpressed and just need to flash. if (pressType == PressType.NotPressed && pressAnimState == 1) pressAnimState = 2; else if (pressType == PressType.Flash) pressAnimState = 2; else pressAnimState = pressType == PressType.Pressed ? 1 : -1; } SubscribeToTimer(); MakeMePaint(false, RenderMode.Invalidate); }
internal StreamType(XmlNode node) : this() { foreach (var childObj in node.ChildNodes) { var child = (XmlNode)childObj; var text = child.InnerText; switch (child.Name) { case "id": this.Id = int.Parse(text.Substring(2)); break; case "title": this.Title = text; break; case "description": this.Description = text; break; case "comment_count": this.CommentCount = StrUtil.ToInt(text, 0); break; case "watch_count": this.WatchCount = StrUtil.ToInt(text, 0); break; case "danjo_comment_mode": this.DanjoCommentMode = StrUtil.ToBool(text, false); break; case "nicoden": this.IsNicoDen = StrUtil.ToBool(text, false); break; case "allow_netduetto": this.AllowNetduetto = StrUtil.ToBool(text, false); break; case "relay_comment": this.RelayComment = text; break; case "park": this.IsPark = StrUtil.ToBool(text, false); break; case "nd_token": this.NdToken = text; break; case "bourbon_url": this.BourbonUrl = text; break; case "full_video": this.FullVideo = text; break; case "after_video": this.AfterVideo = text; break; case "before_video": this.BeforeVideo = text; break; case "kickout_video": this.KickoutVideo = text; break; case "header_comment": this.HeaderComment = text; break; case "footer_comment": this.FooterComment = text; break; case "plugin_delay": this.PluginDelay = text; break; case "plugin_url": this.PluginUrl = text; break; case "provider_type": this.ProviderType = StrUtil.ToProvider(text); break; case "default_community": this.DefaultCommunity = text; break; case "archive": this.IsArchive = StrUtil.ToBool(text, false); break; case "is_dj_stream": this.IsDjStream = StrUtil.ToBool(text, false); break; case "twitter_tag": this.TwitterTag = text; break; case "is_owner": this.IsOwner = StrUtil.ToBool(text, false); break; case "owner_id": this.OwnerId = StrUtil.ToInt(text, -1); break; case "owner_name": this.OwnerName = text; break; case "is_reserved": this.IsReserved = StrUtil.ToBool(text, false); break; case "base_time": this.BaseTime = StrUtil.ToDateTime(text); break; case "open_time": this.OpenTime = StrUtil.ToDateTime(text); break; case "start_time": this.StartTime = StrUtil.ToDateTime(text); break; case "end_time": this.EndTime = StrUtil.ToDateTime(text); break; case "ichiba_notice_enable": this.IsIchibaNoticeEnable = StrUtil.ToBool(text, false); break; case "comment_lock": this.IsCommentLock = StrUtil.ToBool(text, false); break; case "background_comment": this.IsBackgroundComment = StrUtil.ToBool(text, false); break; case "contents_list": foreach (var childObj2 in child.ChildNodes) { var child2 = (XmlNode)childObj2; if (child2.Name == "contents") { var content = new ContentType(child2); this.ContentList.Add(content); } } break; case "press": this.Press = new PressType(child); break; } } }