@@ -457,7 +457,9 @@ private void AdjustZoom(float delta) {
457457
458458 private void HandleLeftMouseButton ( InputEventMouseButton eventMouseButton ) {
459459 GetViewport ( ) . SetInputAsHandled ( ) ;
460- if ( eventMouseButton . IsPressed ( ) ) {
460+ Control uiHover = GetViewport ( ) . GuiGetHoveredControl ( ) ;
461+ // Can't drag the map when the mouse is over a ui element
462+ if ( eventMouseButton . IsPressed ( ) && uiHover is not TextureButton ) {
461463 OldPosition = eventMouseButton . Position ;
462464 IsMovingCamera = true ;
463465
@@ -595,9 +597,6 @@ private void HandleKeyboardInput(InputEventKey eventKeyDown) {
595597 if ( eventKeyDown . Keycode == Godot . Key . O && eventKeyDown . ShiftPressed && eventKeyDown . IsCommandOrControlPressed ( ) && eventKeyDown . AltPressed ) {
596598 ToggleObserverMode ( ) ;
597599 }
598- if ( eventKeyDown . Keycode == Godot . Key . G && eventKeyDown . ShiftPressed && eventKeyDown . IsCommandOrControlPressed ( ) && eventKeyDown . AltPressed ) {
599- ToggleGridCoordinates ( ) ;
600- }
601600 if ( eventKeyDown . Keycode == Godot . Key . T && eventKeyDown . ShiftPressed && eventKeyDown . IsCommandOrControlPressed ( ) && eventKeyDown . AltPressed ) {
602601 ToggleC7Graphics ( ) ;
603602 }
@@ -622,6 +621,32 @@ private void HandleKeyboardInput(InputEventKey eventKeyDown) {
622621 mapView . centerCameraOnTile ( capital . location ) ;
623622 }
624623 }
624+ // For inputs that have the same keys mapped to multiple actions like G
625+ // we need to manually handle what is triggered by adding extra conditions.
626+ // Otherwise when pressing CTRL + G for example, both the go-to
627+ // and the toggle grid actions are triggered, because godot does not distinguish
628+ // single key presses from combos, it sends both signals.
629+ // Sometimes even worse, when pressing CTRL + G, it only sends the go-to signal.
630+ // We continue to map these to an action and not call them directly,
631+ // because we could add a button in the ui that does the same and this would call the action too.
632+ if ( eventKeyDown . Keycode == Godot . Key . G ) {
633+ // Toggle Coordinates
634+ if ( eventKeyDown . IsCommandOrControlPressed ( )
635+ && eventKeyDown . ShiftPressed
636+ && eventKeyDown . AltPressed ) {
637+ ProcessAction ( C7Action . ToggleCoordinates ) ;
638+ }
639+ // Toggle Grid
640+ else if ( eventKeyDown . IsCommandOrControlPressed ( ) ) {
641+ ProcessAction ( C7Action . ToggleGrid ) ;
642+ }
643+ // Trigger Unit go-to
644+ else if ( ! eventKeyDown . IsCommandOrControlPressed ( )
645+ && ! eventKeyDown . ShiftPressed
646+ && ! eventKeyDown . AltPressed ) {
647+ ProcessAction ( C7Action . UnitGoto ) ;
648+ }
649+ }
625650 }
626651
627652 private void ToggleObserverMode ( ) {
@@ -679,10 +704,18 @@ private void ProcessActions() {
679704 foreach ( StringName action in actions ) {
680705 if ( Input . IsActionJustPressed ( action ) ) {
681706 ProcessAction ( action . ToString ( ) ) ;
707+ } else if ( Input . IsActionJustReleased ( action ) ) {
708+ ProcessOnReleaseAction ( action . ToString ( ) ) ;
682709 }
683710 }
684711 }
685712
713+ private void ProcessOnReleaseAction ( string currentAction ) {
714+ if ( currentAction == C7Action . EnableTempAnimations ) {
715+ animationController . SetAnimationsEnabled ( true ) ;
716+ }
717+ }
718+
686719 private void ProcessAction ( string currentAction ) {
687720 if ( currentAction == C7Action . Escape && popupOverlay . ShowingPopup ) {
688721 popupOverlay . OnHidePopup ( ) ;
@@ -731,6 +764,10 @@ private void ProcessAction(string currentAction) {
731764 this . mapView . gridLayer . visible = ! this . mapView . gridLayer . visible ;
732765 }
733766
767+ if ( currentAction == C7Action . ToggleCoordinates ) {
768+ ToggleGridCoordinates ( ) ;
769+ }
770+
734771 if ( currentAction == C7Action . Escape && this . gotoInfo == null ) {
735772 log . Debug ( "Got request for escape/quit" ) ;
736773 popupOverlay . ShowPopup ( new EscapeQuitPopup ( ) , PopupOverlay . PopupCategory . Info ) ;
@@ -745,9 +782,11 @@ private void ProcessAction(string currentAction) {
745782 }
746783
747784 if ( currentAction == C7Action . ToggleAnimations ) {
785+ animationController . ToggleAnimationsEnabled ( ) ;
786+ }
787+
788+ if ( currentAction == C7Action . EnableTempAnimations ) {
748789 animationController . SetAnimationsEnabled ( false ) ;
749- } else if ( Input . IsActionJustReleased ( C7Action . ToggleAnimations ) ) {
750- animationController . SetAnimationsEnabled ( true ) ;
751790 }
752791
753792 // actions with unit buttons, which are only relevant during the player
@@ -770,6 +809,9 @@ private void ProcessAction(string currentAction) {
770809 }
771810
772811 if ( currentAction == C7Action . UnitDisband ) {
812+ if ( CurrentlySelectedUnit == null || CurrentlySelectedUnit == MapUnit . NONE ) {
813+ return ;
814+ }
773815 popupOverlay . ShowPopup (
774816 new ConfirmationPopup (
775817 $ "Disband { CurrentlySelectedUnit . unitType . name } ? Pardon me but these are OUR people. Do \n you really want to disband them?",
0 commit comments