Пример #1
0
 /// <summary>
 /// Start dragging
 /// </summary>
 protected internal override bool MouseDownCore(MapMouseEventArgs e)
 {
     if (e.MouseEventArgs.Button == MouseButtons.Left)
     {
         _isDragging = true;
         _startPosition = CreateGamePoint(e.MouseEventArgs.Location);
         _lastPosition = _startPosition;
         _parent.SetFullControlManipulator(this);
     }
     return false;
 }
Пример #2
0
 /// <summary>
 /// Moves the center of the map
 /// </summary>
 protected internal override bool MouseDownCore(MapMouseEventArgs e)
 {
     // TODO: looks like this if is never true. And that this is implemented by MapDraggerManipulator
     if ((e.Village == null && e.MouseEventArgs.Button == MouseButtons.Right && RightClickToMove) ||
         (e.MouseEventArgs.Button == MouseButtons.Left && LeftClickToMove))
     {
         // Look at this whenever we break here.
         // If this disappears: rename it to KeyboardMapMoverManipulator
         Debug.Assert(false);
         Point game = _map.Display.GetGameLocation(e.MouseEventArgs.Location);
         _map.SetCenter(game);
         return true;
     }
     return false;
 }
        /// <summary>
        /// Save new Monitoring ActiveRectangle or remove FullControl
        /// </summary>
        protected internal override bool MouseDownCore(MapMouseEventArgs e)
        {
            if (e.MouseEventArgs.Button == MouseButtons.Left)
            {
                string text = string.Format("Set this as the new Monitoring Area? This is the area you monitor growth for in the Monitoring tab.");
                var saveActiveRectangle = MessageBox.Show(text, "Set Monitoring Area", MessageBoxButtons.YesNoCancel);
                if (saveActiveRectangle == DialogResult.Cancel)
                {
                    return false;
                }

                if (saveActiveRectangle == DialogResult.Yes)
                {
                    var game = _map.Display.GetGameRectangle(_activeRectangle);
                    World.Default.Monitor.ActiveRectangle = game;
                    World.Default.SaveSettings();

                    _hasSetNew = true;
                }
            }
            _map.Manipulators.CurrentManipulator.RemoveFullControlManipulator();
            return true;
        }
Пример #4
0
 protected internal virtual bool MouseUpCore(MapMouseEventArgs e)
 {
     return false;
 }
Пример #5
0
        protected internal override bool MouseDownCore(MapMouseEventArgs e)
        {
            IsAddingTarget = false;
            if (e.Village != null)
            {
                AttackPlan existingPlan = GetExistingPlan(e.Village, true);
                AttackPlanFrom[] existingAttacks = GetAttackers(e.Village).ToArray();

                if (e.MouseEventArgs.Button == MouseButtons.Left)
                {
                    if (existingPlan == null)
                    {
                        if (!existingAttacks.Any())
                        {
                            _map.EventPublisher.AttackAddTarget(this, e.Village);
                        }
                        else
                        {
                            if (!existingAttacks.Contains(ActiveAttacker))
                            {
                                _map.EventPublisher.AttackSelect(this, existingAttacks.First());
                            }
                            else
                            {
                                // Already selected village is perhaps used in multiple plans
                                if (existingAttacks.Length == 1)
                                {
                                    return false;
                                }
                                else
                                {
                                    // Cycle through the attackers
                                    AttackPlanFrom selectAttacker;
                                    if (ActiveAttacker == null || !existingAttacks.Contains(ActiveAttacker) || existingAttacks.Last() == ActiveAttacker)
                                    {
                                        selectAttacker = existingAttacks.First();
                                    }
                                    else
                                    {
                                        selectAttacker = existingAttacks.SkipWhile(x => x != ActiveAttacker).Take(2).Last();
                                    }
                                    _map.EventPublisher.AttackSelect(this, selectAttacker);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (existingPlan == ActivePlan && ActivePlan != null)
                        {
                            var existingAttack = existingAttacks.FirstOrDefault();
                            if (existingAttack != ActiveAttacker)
                            {
                                if (existingAttack == null)
                                {
                                    _map.EventPublisher.AttackSelect(this, ActivePlan);
                                }
                                else
                                {
                                    _map.EventPublisher.AttackSelect(this, existingAttack);
                                }
                            }
                            else
                            {
                                return false;
                            }
                        }
                        else
                        {
                            _map.EventPublisher.AttackSelect(this, existingPlan);
                        }
                    }
                    return true;
                }
                else if (e.MouseEventArgs.Button == MouseButtons.Right)
                {
                    if (e.Village.Player == World.Default.You && ActivePlan != null)
                    {
                        if (e.Village == ActivePlan.Target)
                        {
                            // Can't add attacker to target
                            return false;
                        }
                        else
                        {
                            if (existingAttacks.Any())
                            {
                                // Show contextmenu instead
                                return false;
                            }
                            else
                            {
                                // Add new attacker
                                var attackEventArgs = AttackUpdateEventArgs.AddAttackFrom(new AttackPlanFrom(ActivePlan, e.Village, WorldUnits.Default[World.Default.Map.Manipulators.AttackManipulator.DefaultSpeed]));
                                _map.EventPublisher.AttackUpdateTarget(this, attackEventArgs);
                                IsAddingTarget = true;
                                return true;
                            }
                        }
                    }
                }
            }
            return false;
        }
Пример #6
0
 /// <summary>
 /// Stop polygon creation.
 /// </summary>
 protected internal override bool MouseUpCore(MapMouseEventArgs e)
 {
     if (e.MouseEventArgs.Button == MouseButtons.Left)
     {
         if (_activePolygon != null && _activePolygon.Drawing)
         {
             if (_activePolygon.List.Count > 2)
             {
                 // Polygon completed
                 _activePolygon.Stop(e.MouseEventArgs.Location);
                 _nextId++;
                 DeleteIfEmpty(_activePolygon);
             }
             else
             {
                 // Too small area to be a polygon
                 // try to select an existing one instead
                 Delete(_activePolygon);
                 Select(e.MouseEventArgs.Location);
             }
         }
         return true;
     }
     else if (e.MouseEventArgs.Button == MouseButtons.Right)
     {
         Select(e.MouseEventArgs.Location);
         return true;
     }
     return false;
 }
Пример #7
0
 /// <summary>
 /// Start creation of a new polygon
 /// </summary>
 protected internal override bool MouseDownCore(MapMouseEventArgs e)
 {
     if (e.MouseEventArgs.Button == MouseButtons.Left)
     {
         if (_activePolygon == null || !_activePolygon.Drawing)
         {
             StartNewPolygon(e.MouseEventArgs.Location);
             return true;
         }
     }
     return false;
 }
Пример #8
0
 /// <summary>
 /// Stop dragging
 /// </summary>
 protected internal override bool MouseUpCore(MapMouseEventArgs e)
 {
     if (e.MouseEventArgs.Button == MouseButtons.Left && _isDragging)
     {
         _isDragging = false;
         _parent.RemoveFullControlManipulator();
     }
     return false;
 }
Пример #9
0
 public bool MouseUpCore(MapMouseEventArgs e)
 {
     if (_fullControllManipulator != null)
     {
         return _fullControllManipulator.MouseUpCore(e);
     }
     else
     {
         bool redraw = false;
         foreach (ManipulatorBase m in _manipulators) redraw |= m.MouseUpCore(e);
         return redraw;
     }
 }
Пример #10
0
        /// <summary>
        /// Informs all the manipulators the user
        /// has clicked the map
        /// </summary>
        public bool MouseDownCore(MapMouseEventArgs e)
        {
            if (e.MouseEventArgs.Button == MouseButtons.XButton1)
            {

            }
            if (e.MouseEventArgs.Button == MouseButtons.XButton2)
            {

            }

            if (e.MouseEventArgs.Button == MouseButtons.Middle)
            {
                _map.Manipulators.SwitchManipulator();
                return true;
            }

            if (_fullControllManipulator != null)
            {
                return _fullControllManipulator.MouseDownCore(e);
            }
            else
            {
                bool redraw = false;
                foreach (ManipulatorBase m in _manipulators) redraw |= m.MouseDownCore(e);
                return redraw;
            }
        }