Ejemplo n.º 1
0
		private async Task onMouseDown(object sender, MouseButtonEventArgs e)
		{
			if (!_state.Player.Enabled)
				return;

			if (e.Button == MouseButton.Left)
			{
				if (_state.Player.Inventory == null || 
					_state.Player.Inventory.ActiveItem == null)
				{
					AGSLocation location = new AGSLocation(e.X, e.Y, _state.Player.Z);
					await _state.Player.WalkAsync(location).ConfigureAwait(true);
				}
				else
				{

				}
			}
			else if (e.Button == MouseButton.Right)
			{
				IInventory inventory = _state.Player.Inventory;
				if (inventory == null) return;
				if (inventory.ActiveItem == null)
				{
					IObject hotspot = _state.Room.GetObjectAt(e.X, e.Y);
					if (hotspot == null) return;
				}
				else
				{
					inventory.ActiveItem = null;
				}
			}
		}
Ejemplo n.º 2
0
 private void onMouseUp(object sender, MouseButtonEventArgs e)
 {
     if (_events.IsMouseIn)
     {
         _checked = !_checked;
     }
     onCheckChange();
 }
Ejemplo n.º 3
0
 private void onMouseDown(object sender, MouseButtonEventArgs args)
 {
     if (!IsDragEnabled || args.Button != MouseButton.Left) return;
     IsCurrentlyDragged = true;
     _dragObjectStartX = _transform.X;
     _dragObjectStartY = _transform.Y;
     _dragMouseStartX = _input.MouseX;
     _dragMouseStartY = _input.MouseY;
 }
Ejemplo n.º 4
0
		private async Task onMouseDown(object sender, MouseButtonEventArgs e)
		{
			var state = _game.State;
			if (_handlingClick || !state.Player.Enabled)
				return;

			if (e.Button == MouseButton.Left)
			{
				await onLeftMouseDown(e, state);
			}
			else if (e.Button == MouseButton.Right)
			{
				onRightMouseDown(e, state);
			}
		}
Ejemplo n.º 5
0
 private void onOkClicked(object sender, MouseButtonEventArgs args)
 {
     if (args.Button != MouseButton.Left) return;
     var item = _selectedItem ?? _fileTextBox.Text;
     _fileTextBox.Text = item;
     if (Hooks.FileSystem.DirectoryExists(item))
     {
         if (_fileSelection == FileSelection.FileOnly)
         {
             AGSMessageBox.Display("Please select a file.");
             return;
         }
     }
     else if (_fileSelection == FileSelection.FolderOnly)
     {
         AGSMessageBox.Display("Please select a folder.");
         return;
     }
     _tcs.TrySetResult(true);
 }
Ejemplo n.º 6
0
 private void onCancelClicked(object sender, MouseButtonEventArgs args)
 {
     if (args.Button != MouseButton.Left) return;
     _tcs.TrySetResult(false);
 }
Ejemplo n.º 7
0
 private void onMouseDownOutside(object sender, MouseButtonEventArgs args)
 {
     IsFocused = false;
 }
Ejemplo n.º 8
0
 private void onMouseDown(object sender, MouseButtonEventArgs args)
 {
     Debug.WriteLine("{0} is focused", _textComponent.Text);
     IsFocused = true;
 }
Ejemplo n.º 9
0
 private void onDropDownClicked(object sender, MouseButtonEventArgs args)
 {
     if (_tree.TreeNode.HasChild(DropDownPanel)) hidePanel();
     else showPanel();
 }
Ejemplo n.º 10
0
 private void onItemClicked(object sender, MouseButtonEventArgs args)
 {
     SelectedIndex = _itemButtons.IndexOf((IButton)sender);
     hidePanel();
 }
Ejemplo n.º 11
0
		private void onMouseUp(object sender, MouseButtonEventArgs e)
		{
			_animation.StartAnimation(_events.IsMouseIn ? HoverAnimation : IdleAnimation);
		}
Ejemplo n.º 12
0
		private void onMouseDown(object sender, MouseButtonEventArgs e)
		{
			_animation.StartAnimation(PushedAnimation);
		}
Ejemplo n.º 13
0
 private void onMouseUp(object sender, MouseButtonEventArgs args)
 {
     if (SkipTrigger != SkipCutsceneTrigger.AnyKeyOrMouse) return;
     BeginSkip();
 }
Ejemplo n.º 14
0
		private void onRightMouseDown(MouseButtonEventArgs e, IGameState state)
		{
			if (!RotatingEnabled) return;

			IInventory inventory = state.Player.Inventory;

			int startMode = _currentMode;
			Cursor cursor = _cursors[_currentMode];

			if (!cursor.Rotating) return;

			do
			{
				_currentMode = (_currentMode + 1) % _cursors.Count;
				cursor = _cursors[_currentMode];
			} while ((!cursor.Rotating || cursor.Animation == null) && _currentMode != startMode);

			setCursor();
		}
Ejemplo n.º 15
0
		private async Task onLeftMouseDown(MouseButtonEventArgs e, IGameState state)
		{
			string mode = CurrentMode;
			IObject hotspot = state.Room.GetObjectAt(e.X, e.Y);

			if (_game.Input.Cursor != _inventoryCursor.Animation)
			{
				if (hotspot != null && hotspot.Room == null) 
				{
					IInventoryItem inventoryItem = state.Player.Inventory.Items.FirstOrDefault(
						i => i.Graphics == hotspot);
					if (inventoryItem != null)
					{
						if (mode != LOOK_MODE)
						{
							if (inventoryItem.ShouldInteract) mode = INTERACT_MODE;
							else
							{
								state.Player.Inventory.ActiveItem = inventoryItem;
								SetInventoryCursor();
								return;
							}
						}
					}
					else return; //Blocking clicks when hovering UI objects
				}

				if (mode == WALK_MODE)
				{
                    AGSLocation location = new AGSLocation (e.X, e.Y, state.Player.Z);
					await state.Player.WalkAsync(location).ConfigureAwait(true);
				}
				else if (mode != WAIT_MODE)
				{
					_handlingClick = true;
					try
					{
						if (hotspot == null) return;

						if (mode == LOOK_MODE)
						{
                            await hotspot.Interactions.OnInteract(AGSInteractions.LOOK).InvokeAsync(this, new ObjectEventArgs (hotspot));
						}
						else if (mode == INTERACT_MODE)
						{
                            await hotspot.Interactions.OnInteract(AGSInteractions.INTERACT).InvokeAsync(this, new ObjectEventArgs (hotspot));
						}
						else
						{
                            await hotspot.Interactions.OnInteract(mode).InvokeAsync(this, new ObjectEventArgs (hotspot));
						}
					}
					finally
					{
						_handlingClick = false;
					}
				}
			}
			else if (hotspot != null)
			{
				if (hotspot.Room == null)
				{
					IInventoryItem inventoryItem = state.Player.Inventory.Items.FirstOrDefault(
						                              i => i.Graphics == hotspot);
					if (inventoryItem != null)
					{
						await state.Player.Inventory.OnCombination(state.Player.Inventory.ActiveItem,
							inventoryItem).InvokeAsync(this, new InventoryCombinationEventArgs (
							state.Player.Inventory.ActiveItem, inventoryItem));
					}
					return;
				}

                await hotspot.Interactions.OnInventoryInteract(AGSInteractions.INTERACT).InvokeAsync(this, new InventoryInteractEventArgs(hotspot,
					state.Player.Inventory.ActiveItem));
			}
		}
Ejemplo n.º 16
0
		private async Task handleMouseButton(Stopwatch sw, Stopwatch doubleClickSw, bool wasDown, bool isDown, MouseButton button)
		{
            bool fireDown = !wasDown && isDown && IsMouseIn;
            bool fireDownOutside = !wasDown && isDown && !IsMouseIn && _isFocused;
            _isFocused = fireDown;
			bool fireUp = wasDown && !isDown;
			if (fireDown)
			{
				sw.Restart();
			}
			bool fireClick = false;
            bool fireDoubleClick = false;
			if (fireUp)
			{
				if (IsMouseIn && sw.ElapsedMilliseconds < 1500 && sw.ElapsedMilliseconds != 0)
				{                    
					fireClick = true;
                    if (doubleClickSw.ElapsedMilliseconds == 0)
                    {
                        doubleClickSw.Restart();
                    }
                    else
                    {
                        if (doubleClickSw.ElapsedMilliseconds < 1500)
                        {
                            fireDoubleClick = true;
                        }
                        doubleClickSw.Stop();
                        doubleClickSw.Reset();
                    }                     
				}
				sw.Stop();
				sw.Reset();
			}

            if (fireDown || fireUp || fireClick || fireDownOutside)
			{
                MouseButtonEventArgs args = new MouseButtonEventArgs (button, _mouseX, _mouseY);
                if (fireDown) await MouseDown.InvokeAsync(_entity, args);
                else if (fireUp) await MouseUp.InvokeAsync(_entity, args);
                else if (fireDownOutside) await LostFocus.InvokeAsync(_entity, args);
				if (fireClick) await MouseClicked.InvokeAsync(_entity, args);
                if (fireDoubleClick) await MouseDoubleClicked.InvokeAsync(_entity, args);
            }
		}