/// <summary>
        /// Called when the mouse pointer has been moved over the display.
        /// </summary>
        private void OnMouseMove(UISensitiveObject sender, UIMouseEventArgs evtArgs)
        {
            if (this.CurrentMouseStatus == MouseStatus.LeftDown)
            {
                this.CurrentMouseStatus = MouseStatus.Selecting;

                /// Actualize the selection box
                this.selectionBoxCurrPosition = evtArgs.Position;
                this.selectionBox             = this.CalculateSelectionBox();
            }
            else if (this.CurrentMouseStatus == MouseStatus.Selecting)
            {
                /// Actualize the selection box
                this.selectionBoxCurrPosition = evtArgs.Position;
                this.selectionBox             = this.CalculateSelectionBox();
            }
            else if (this.CurrentMouseStatus == MouseStatus.DoubleClicked)
            {
                this.CurrentMouseStatus = MouseStatus.Selecting;

                /// Actualize the selection box
                this.selectionBoxCurrPosition = evtArgs.Position;
                this.selectionBox             = this.CalculateSelectionBox();
            }
        }
Example #2
0
        /// <summary>
        /// Constructs a SelectTargetMouseHandler instance.
        /// </summary>
        /// <param name="scrollEventSource">The UISensitiveObject that will raise the events for scrolling.</param>
        /// <param name="mapDisplay">Reference to the target map display.</param>
        /// <param name="normalMouseEventSource">The UISensitiveObject that will raise the additional mouse events.</param>
        /// <param name="sprites">The sprites to be used when displaying object placement box.</param>
        public SelectTargetMouseHandler(UISensitiveObject scrollEventSource, IMapDisplay mapDisplay,
                                        UISensitiveObject normalMouseEventSource, SpriteGroup sprites)
            : base(scrollEventSource, mapDisplay)
        {
            if (normalMouseEventSource == null)
            {
                throw new ArgumentNullException("normalMouseEventSource");
            }
            if (sprites == null)
            {
                throw new ArgumentNullException("sprites");
            }
            if (this.CommandView.TargetSelectionMode == TargetSelectionModeEnum.NoTargetSelection)
            {
                throw new InvalidOperationException("Target selection is not possible currently!");
            }

            this.targetSelectionMode    = this.CommandView.TargetSelectionMode;
            this.multiplayerService     = ComponentManager.GetInterface <IMultiplayerService>();
            this.normalMouseEventSource = normalMouseEventSource;
            this.objectPlacementInfo    = this.targetSelectionMode == TargetSelectionModeEnum.BuildingLocationSelection
                ? new ObjectPlacementInfo(
                ComponentManager.GetInterface <IViewService>().CreateView <INormalModeMapObjectPlacementView>(),
                sprites)
                : null;

            this.normalMouseEventSource.MouseSensor.ButtonDown += this.OnMouseDown;
            this.multiplayerService.GameUpdated += this.OnGameUpdate;
        }
Example #3
0
 /// <summary>
 /// Called when a mouse button has been pushed over the minimap display.
 /// </summary>
 private void OnMouseDown(UISensitiveObject sender, UIMouseEventArgs evtArgs)
 {
     if (this.currentMouseStatus == MouseStatus.None)
     {
         if (evtArgs.Button == UIMouseButton.Left && (this.commandView.TargetSelectionMode == TargetSelectionModeEnum.NoTargetSelection ||
                                                      this.commandView.TargetSelectionMode == TargetSelectionModeEnum.BuildingLocationSelection) ||
             evtArgs.Button == UIMouseButton.Right && this.commandView.TargetSelectionMode == TargetSelectionModeEnum.TargetPositionSelection)
         {
             this.currentMouseStatus = MouseStatus.MovingDisplay;
             this.pressedButton      = evtArgs.Button;
             TraceManager.WriteAllTrace(string.Format("SCROLL_ON_MINIMAP {0}", evtArgs.Position), PresLogicTraceFilters.INFO);
             this.scrollService.ScrollToMinimapPosition(evtArgs.Position);
         }
         else if (evtArgs.Button == UIMouseButton.Left && this.commandView.TargetSelectionMode == TargetSelectionModeEnum.TargetPositionSelection)
         {
             this.currentMouseStatus = MouseStatus.SelectingTarget;
             this.pressedButton      = evtArgs.Button;
             TraceManager.WriteAllTrace(string.Format("SELECT_TARGET_ON_MINIMAP {0}", evtArgs.Position), PresLogicTraceFilters.INFO);
             this.commandService.SelectTargetPositionOnMinimap(evtArgs.Position);
         }
         else if (evtArgs.Button == UIMouseButton.Right && this.commandView.TargetSelectionMode == TargetSelectionModeEnum.NoTargetSelection)
         {
             this.currentMouseStatus = MouseStatus.SelectingTarget;
             this.pressedButton      = evtArgs.Button;
             TraceManager.WriteAllTrace(string.Format("SEND_FASTCOMMAND_ON_MINIMAP {0}", evtArgs.Position), PresLogicTraceFilters.INFO);
             this.commandService.SendFastCommandOnMinimap(evtArgs.Position);
         }
     }
 }
 /// <summary>
 /// Called when the selection in the palette listbox has been changed.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 private void OnPaletteListboxSelectionChanged(UISensitiveObject sender)
 {
     if (this.SelectedItemChanged != null)
     {
         this.SelectedItemChanged();
     }
 }
 /// <summary>
 /// Called when the mouse pointer has been moved over the display.
 /// </summary>
 private void OnMouseMove(UISensitiveObject sender, UIMouseEventArgs evtArgs)
 {
     if (this.drawPosition != evtArgs.Position)
     {
         this.drawPosition = evtArgs.Position - new RCIntVector(0, this.stringToRender.Font.MinimumLineHeight);
     }
 }
        /// <summary>
        /// Constructs a MouseHandlerBase instance.
        /// </summary>
        /// <param name="scrollEventSource">The UISensitiveObject that will raise the events for scrolling.</param>
        /// <param name="mapDisplay">Reference to the target map display.</param>
        public MouseHandlerBase(UISensitiveObject scrollEventSource, IMapDisplay mapDisplay)
        {
            if (scrollEventSource == null)
            {
                throw new ArgumentNullException("scrollEventSource");
            }
            if (mapDisplay == null)
            {
                throw new ArgumentNullException("mapDisplay");
            }

            this.selectionService = ComponentManager.GetInterface <ISelectionService>();
            this.commandService   = ComponentManager.GetInterface <ICommandService>();
            this.scrollService    = ComponentManager.GetInterface <IScrollService>();
            this.commandView      = ComponentManager.GetInterface <IViewService>().CreateView <ICommandView>();

            this.currentScrollDir    = ScrollDirectionEnum.NoScroll;
            this.timeSinceLastScroll = 0;
            this.isScrollEnabled     = true;
            this.mapDisplay          = mapDisplay;
            this.scrollEventSource   = scrollEventSource;
            this.scrollEventSource.MouseSensor.Move += this.OnMouseMove;
            UIRoot.Instance.GraphicsPlatform.RenderLoop.FrameUpdate += this.OnFrameUpdate;
            this.mapDisplay.AttachMouseHandler(this);
        }
Example #7
0
 private void OnDrag(UISensitiveObject sender, UIMouseEventArgs evtArgs)
 {
     if (this.hookPosition != RCIntVector.Undefined)
     {
         this.Position += evtArgs.Position - this.hookPosition;
     }
 }
Example #8
0
 /// <summary>
 /// Called when a mouse button has been released over the page.
 /// </summary>
 private void OnMouseUp(UISensitiveObject sender, UIMouseEventArgs evtArgs)
 {
     if (this.activatorBtn == evtArgs.Button)
     {
         this.activatorBtn = UIMouseButton.Undefined;
     }
 }
Example #9
0
        /// <summary>
        /// This method is called when this RCSelectionButton has been pressed.
        /// </summary>
        private void OnButtonPressed(UISensitiveObject sender)
        {
            if (sender != this)
            {
                throw new InvalidOperationException("Unexpected sender!");
            }

            /// Check if this selection button is really attached to a map object.
            if (this.layoutIndex >= this.selectionDetailsView.SelectionCount)
            {
                return;
            }

            int objectID = this.selectionDetailsView.GetObjectID(this.layoutIndex);

            if (UIRoot.Instance.KeyboardAccess.PressedKeys.Count == 0)
            {
                /// Simple click -> select object.
                this.selectionService.Select(objectID);
            }
            else if (UIRoot.Instance.KeyboardAccess.PressedKeys.Count == 1 &&
                     (UIRoot.Instance.KeyboardAccess.PressedKeys.Contains(UIKey.LeftShift) ||
                      UIRoot.Instance.KeyboardAccess.PressedKeys.Contains(UIKey.RightShift)))
            {
                /// SHIFT + Click -> deselect object.
                this.selectionService.RemoveFromSelection(objectID);
            }
            else if (UIRoot.Instance.KeyboardAccess.PressedKeys.Count == 1 &&
                     (UIRoot.Instance.KeyboardAccess.PressedKeys.Contains(UIKey.LeftControl) ||
                      UIRoot.Instance.KeyboardAccess.PressedKeys.Contains(UIKey.RightControl)))
            {
                /// CTRL + Click -> select type.
                this.selectionService.SelectTypeFromCurrentSelection(this.layoutIndex);
            }
        }
        /// <summary>
        /// Constructs a NormalMouseHandler instance.
        /// </summary>
        /// <param name="scrollEventSource">The UISensitiveObject that will raise the events for scrolling.</param>
        /// <param name="mapDisplay">Reference to the target map display.</param>
        /// <param name="normalMouseEventSource">The UISensitiveObject that will raise the additional mouse events.</param>
        public NormalMouseHandler(UISensitiveObject scrollEventSource, IMapDisplay mapDisplay,
                                  UISensitiveObject normalMouseEventSource)
            : base(scrollEventSource, mapDisplay)
        {
            if (normalMouseEventSource == null)
            {
                throw new ArgumentNullException("normalMouseEventSource");
            }
            if (this.CommandView.TargetSelectionMode != TargetSelectionModeEnum.NoTargetSelection)
            {
                throw new InvalidOperationException("Normal mouse input is not possible currently!");
            }

            this.multiplayerService     = ComponentManager.GetInterface <IMultiplayerService>();
            this.normalMouseEventSource = normalMouseEventSource;

            this.currentMouseStatus        = MouseStatus.None;
            this.selectionBoxStartPosition = RCIntVector.Undefined;
            this.selectionBoxCurrPosition  = RCIntVector.Undefined;
            this.selectionBox = RCIntRectangle.Undefined;

            this.normalMouseEventSource.MouseSensor.StateReset  += this.OnStateReset;
            this.normalMouseEventSource.MouseSensor.ButtonDown  += this.OnMouseDown;
            this.normalMouseEventSource.MouseSensor.Move        += this.OnMouseMove;
            this.normalMouseEventSource.MouseSensor.ButtonUp    += this.OnMouseUp;
            this.normalMouseEventSource.MouseSensor.DoubleClick += this.OnMouseDoubleClick;

            this.multiplayerService.GameUpdated += this.OnGameUpdate;
        }
 /// <summary>
 /// Called when the mouse pointer has been moved over the display.
 /// </summary>
 private void OnMouseMove(UISensitiveObject sender, UIMouseEventArgs evtArgs)
 {
     if (this.lastKnownMousePosition != evtArgs.Position)
     {
         this.lastKnownMousePosition = evtArgs.Position;
     }
 }
Example #12
0
 /// <summary>
 /// Called when the selection in the edit mode dropdown has been changed.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 private void OnEditModeSelectionChanged(UISensitiveObject sender)
 {
     this.ResetControls();
     if (this.EditModeChanged != null)
     {
         this.EditModeChanged();
     }
 }
Example #13
0
 /// <summary>
 /// Called when a mouse button has been released over the display.
 /// </summary>
 private void OnMouseUp(UISensitiveObject sender, UIMouseEventArgs evtArgs)
 {
     if (this.currentMouseStatus != MouseStatus.None && evtArgs.Button == this.pressedButton)
     {
         this.pressedButton      = UIMouseButton.Undefined;
         this.currentMouseStatus = MouseStatus.None;
     }
 }
Example #14
0
 /// <summary>
 /// Called when the mouse pointer has been moved over the display.
 /// </summary>
 private void OnMouseMove(UISensitiveObject sender, UIMouseEventArgs evtArgs)
 {
     if (this.currentMouseStatus == MouseStatus.MovingDisplay)
     {
         TraceManager.WriteAllTrace(string.Format("SCROLL_ON_MINIMAP {0}", evtArgs.Position), PresLogicTraceFilters.INFO);
         this.scrollService.ScrollToMinimapPosition(evtArgs.Position);
     }
 }
Example #15
0
        /// <summary>
        /// Called when a mouse button has been pushed over the page.
        /// </summary>
        private void OnMouseMove(UISensitiveObject sender, UIMouseEventArgs evtArgs)
        {
            RCNumVector mapCoordinates = new RCNumVector(evtArgs.Position) / CELL_SIZE - HALF_VECT;

            foreach (TestEntity entity in this.entities.GetContents())
            {
                entity.SetGoal(mapCoordinates);
            }
        }
Example #16
0
        /// <summary>
        /// This method is called if saving the map has been finished successfully.
        /// </summary>
        private void OnSaveMapFinished(IUIBackgroundTask sender, object message)
        {
            /// Unsubscribe from the events of the background task.
            this.saveMapTask.Finished -= this.OnSaveMapFinished;
            this.saveMapTask.Failed   -= this.OnSaveMapFailed;

            // TODO: display a "Please wait..." dialog instead!!!
            this.workspaceTmp.AttachSensitive(this);
            this.workspaceTmp = null;
        }
 /// <summary>
 /// Called when there was a double click happened over the display.
 /// </summary>
 private void OnMouseDoubleClick(UISensitiveObject sender, UIMouseEventArgs evtArgs)
 {
     if (evtArgs.Button == UIMouseButton.Left)
     {
         if (this.CurrentMouseStatus == MouseStatus.LeftDown)
         {
             this.CurrentMouseStatus = MouseStatus.DoubleClicked;
         }
     }
 }
Example #18
0
        /// <summary>
        /// This method is called when the "Save" button has been pressed.
        /// </summary>
        /// <param name="sender">Reference to the button.</param>
        private void OnSaveMapPressed(UISensitiveObject sender)
        {
            // TODO: display a "Please wait..." dialog instead!!!
            this.workspaceTmp = this.SensitiveParent;
            this.workspaceTmp.DetachSensitive(this);

            this.saveMapTask           = UITaskManager.StartParallelTask((param) => this.mapEditorService.SaveMap(this.fileName), "SaveMapTask");
            this.saveMapTask.Finished += this.OnSaveMapFinished;
            this.saveMapTask.Failed   += this.OnSaveMapFailed;
        }
Example #19
0
 /// <summary>
 /// Called when one of the navigation buttons has been pressed.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 private void OnButtonPressed(UISensitiveObject sender)
 {
     if (sender == this.okButtonPanel.NavigationButton)
     {
         this.NavigateToPage("MultiSetup");
     }
     else if (sender == this.cancelButtonPanel.NavigationButton)
     {
         this.NavigateToPage("SelectGame");
     }
 }
Example #20
0
 /// <summary>
 /// Called when the mouse wheel has been rotated.
 /// </summary>
 private void OnMouseWheel(UISensitiveObject sender, UIMouseEventArgs evtArgs)
 {
     if (this.activatorBtn == UIMouseButton.Undefined && this.mapEditorPanel.SelectedMode == RCMapEditorPanel.EditMode.PlaceResource)
     {
         int objectID = this.mapObjectView.GetMapObjectID(evtArgs.Position);
         if (objectID != -1)
         {
             this.mapEditorService.ChangeResourceAmount(objectID, Math.Sign(evtArgs.WheelDelta) * RESOURCE_AMOUNT_DELTA);
         }
     }
 }
Example #21
0
        /// <summary>
        /// This method is called if saving the map has been failed.
        /// </summary>
        private void OnSaveMapFailed(IUIBackgroundTask sender, object message)
        {
            this.saveMapTask.Finished -= this.OnSaveMapFinished;
            this.saveMapTask.Failed   -= this.OnSaveMapFailed;

            // TODO: display a "Please wait..." dialog instead!!!
            this.workspaceTmp.AttachSensitive(this);
            this.workspaceTmp = null;

            throw (Exception)message;
        }
Example #22
0
 private void OnButtonUp(UISensitiveObject sender, UIMouseEventArgs evtArgs)
 {
     if (this.activatorBtn == evtArgs.Button)
     {
         this.activatorBtn = UIMouseButton.Undefined;
         if (this.Inactivated != null)
         {
             this.Inactivated(this);
         }
     }
     TraceManager.WriteAllTrace(string.Format("{0}: {1} up", this.name, evtArgs.Button), TraceManager.GetTraceFilterID("RC.UI.Test.Info"));
 }
Example #23
0
 /// <summary>
 /// Called when one of the navigation buttons has been pressed.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 private void OnButtonPressed(UISensitiveObject sender)
 {
     if (sender == this.okButtonPanel.NavigationButton)
     {
         /// TODO: start countdown and begin the game
         this.NavigateToPage("Gameplay");
     }
     else if (sender == this.cancelButtonPanel.NavigationButton)
     {
         /// TODO: exit from the setup stage of the game
         this.NavigateToPage("SelectGame");
     }
 }
Example #24
0
 /// <summary>
 /// Called when a mouse button has been pushed over the page.
 /// </summary>
 private void OnMouseDown(UISensitiveObject sender, UIMouseEventArgs evtArgs)
 {
     if (this.activatorBtn == UIMouseButton.Undefined && evtArgs.Button == UIMouseButton.Left)
     {
         this.activatorBtn = evtArgs.Button;
         if (this.mapEditorPanel.SelectedMode == RCMapEditorPanel.EditMode.DrawTerrain)
         {
             this.mapEditorService.DrawTerrain(evtArgs.Position, this.mapEditorPanel.SelectedItem);
             this.mapEditorPanel.MinimapDisplay.UpdateTerrainSprite();
         }
         else if (this.mapEditorPanel.SelectedMode == RCMapEditorPanel.EditMode.PlaceTerrainObject)
         {
             this.mapEditorService.PlaceTerrainObject(evtArgs.Position, this.mapEditorPanel.SelectedItem);
             this.mapEditorPanel.MinimapDisplay.UpdateTerrainSprite();
         }
         else if (this.mapEditorPanel.SelectedMode == RCMapEditorPanel.EditMode.PlaceStartLocation)
         {
             this.mapEditorService.PlaceStartLocation(evtArgs.Position, this.mapEditorPanel.SelectedIndex);
         }
         else if (this.mapEditorPanel.SelectedMode == RCMapEditorPanel.EditMode.PlaceResource)
         {
             if (this.mapEditorPanel.SelectedItem == RCMapEditorPage.MINERALFIELD_NAME)
             {
                 this.mapEditorService.PlaceMineralField(evtArgs.Position);
             }
             else if (this.mapEditorPanel.SelectedItem == RCMapEditorPage.VESPENEGEYSER_NAME)
             {
                 this.mapEditorService.PlaceVespeneGeyser(evtArgs.Position);
             }
         }
     }
     else if (this.activatorBtn == UIMouseButton.Undefined && evtArgs.Button == UIMouseButton.Right)
     {
         this.activatorBtn = evtArgs.Button;
         if (this.mapEditorPanel.SelectedMode == RCMapEditorPanel.EditMode.PlaceTerrainObject)
         {
             this.mapEditorService.RemoveTerrainObject(evtArgs.Position);
             this.mapEditorPanel.MinimapDisplay.UpdateTerrainSprite();
         }
         else if (this.mapEditorPanel.SelectedMode == RCMapEditorPanel.EditMode.PlaceStartLocation ||
                  this.mapEditorPanel.SelectedMode == RCMapEditorPanel.EditMode.PlaceResource)
         {
             if (this.mapEditorService.RemoveEntity(evtArgs.Position))
             {
                 this.resourceAmountTooltipEx.StopReadingMapObject();
             }
         }
     }
 }
Example #25
0
        /// <summary>
        /// This method is called when this RCCommandButton has been pressed.
        /// </summary>
        private void OnButtonPressed(UISensitiveObject sender)
        {
            if (sender != this)
            {
                throw new InvalidOperationException("Unexpected sender!");
            }

            CommandButtonStateEnum buttonState = this.commandPanelView.GetCmdButtonState(this.slotCoords);

            if (buttonState == CommandButtonStateEnum.Invisible || buttonState == CommandButtonStateEnum.Disabled)
            {
                return;
            }
            this.commandService.PressCommandButton(this.slotCoords);
        }
Example #26
0
        /// <summary>
        /// This method is called when the "Exit" button has been pressed.
        /// </summary>
        /// <param name="sender">Reference to the button.</param>
        private void OnExitPressed(UISensitiveObject sender)
        {
            this.mouseHandler.Inactivate();
            this.mapDisplay.MouseSensor.Wheel      -= this.OnMouseWheel;
            this.mapDisplay.MouseSensor.ButtonDown -= this.OnMouseDown;
            this.mapDisplay.MouseSensor.ButtonUp   -= this.OnMouseUp;
            this.mapDisplay.MouseSensor.Move       -= this.OnMouseMoveOverDisplay;

            this.mapEditorPanel.EditModeChanged     -= this.OnEditModeChanged;
            this.mapEditorPanel.SelectedItemChanged -= this.OnSelectedItemChanged;
            this.mapEditorPanel.SaveButton.Pressed  -= this.OnSaveMapPressed;
            this.mapEditorPanel.ExitButton.Pressed  -= this.OnExitPressed;

            this.StatusChanged += this.OnPageStatusChanged;
            this.Deactivate();
        }
        /// <summary>
        /// This method is called when this RCProductionButton has been pressed.
        /// </summary>
        private void OnButtonPressed(UISensitiveObject sender)
        {
            if (sender != this)
            {
                throw new InvalidOperationException("Unexpected sender!");
            }

            /// Check if this production button is really attached to a production job.
            if (this.layoutIndex >= this.productionDetailsView.ProductionLineItemCount)
            {
                return;
            }

            /// Send the event to the command service.
            this.commandService.PressProductionButton(this.layoutIndex);
        }
Example #28
0
 /// <summary>
 /// Called when a menu button has been pressed.
 /// </summary>
 private void OnMenupointPressed(UISensitiveObject sender)
 {
     if (sender == this.menuPanel[START_GAME_MENUPOINT])
     {
         /// Navigate to the Registry page.
         this.NavigateToPage("Registry");
     }
     else if (sender == this.menuPanel[CREDITS_MENUPOINT])
     {
         /// Navigate to the Credits page.
         this.NavigateToPage("Credits");
     }
     else if (sender == this.menuPanel[EXIT_MENUPOINT])
     {
         /// Stop the render loop
         UIRoot.Instance.GraphicsPlatform.RenderLoop.Stop();
     }
 }
Example #29
0
 /// <summary>
 /// Called when one of the navigation buttons has been pressed.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 private void OnButtonPressed(UISensitiveObject sender)
 {
     if (sender == this.okButtonPanel.NavigationButton)
     {
         this.NavigateToPage("SelectGame");
     }
     else if (sender == this.cancelButtonPanel.NavigationButton)
     {
         this.NavigateToPage("MainMenu");
     }
     else if (sender == this.registryPanel.NewIdButton)
     {
         /// TODO: trace
     }
     else if (sender == this.registryPanel.DeleteButton)
     {
         /// TODO: trace
     }
 }
Example #30
0
 /// <summary>
 /// Called when a mouse button has been pushed over the display.
 /// </summary>
 private void OnMouseDown(UISensitiveObject sender, UIMouseEventArgs evtArgs)
 {
     if (!this.IsStillValid())
     {
         return;
     }
     if (evtArgs.Button == UIMouseButton.Right)
     {
         /// Target selection cancel.
         TraceManager.WriteAllTrace(string.Format("CANCEL_SELECT_TARGET {0}", evtArgs.Position), PresLogicTraceFilters.INFO);
         this.CommandService.CancelSelectingTargetPosition();
     }
     else if (evtArgs.Button == UIMouseButton.Left)
     {
         /// Target selection complete
         TraceManager.WriteAllTrace(string.Format("SELECT_TARGET {0}", evtArgs.Position), PresLogicTraceFilters.INFO);
         this.CommandService.SelectTargetPosition(evtArgs.Position);
     }
 }