@@ -445,7 +445,9 @@ private void AdjustZoom(float delta) {
445445
446446 private void HandleLeftMouseButton ( InputEventMouseButton eventMouseButton ) {
447447 GetViewport ( ) . SetInputAsHandled ( ) ;
448- if ( eventMouseButton . IsPressed ( ) ) {
448+ Control uiHover = GetViewport ( ) . GuiGetHoveredControl ( ) ;
449+ // Can't drag the map when the mouse is over a ui element
450+ if ( eventMouseButton . IsPressed ( ) && uiHover is not TextureButton ) {
449451 OldPosition = eventMouseButton . Position ;
450452 IsMovingCamera = true ;
451453
@@ -583,9 +585,6 @@ private void HandleKeyboardInput(InputEventKey eventKeyDown) {
583585 if ( eventKeyDown . Keycode == Godot . Key . O && eventKeyDown . ShiftPressed && eventKeyDown . IsCommandOrControlPressed ( ) && eventKeyDown . AltPressed ) {
584586 ToggleObserverMode ( ) ;
585587 }
586- if ( eventKeyDown . Keycode == Godot . Key . G && eventKeyDown . ShiftPressed && eventKeyDown . IsCommandOrControlPressed ( ) && eventKeyDown . AltPressed ) {
587- ToggleGridCoordinates ( ) ;
588- }
589588 if ( eventKeyDown . Keycode == Godot . Key . T && eventKeyDown . ShiftPressed && eventKeyDown . IsCommandOrControlPressed ( ) && eventKeyDown . AltPressed ) {
590589 ToggleC7Graphics ( ) ;
591590 }
@@ -610,6 +609,32 @@ private void HandleKeyboardInput(InputEventKey eventKeyDown) {
610609 mapView . centerCameraOnTile ( capital . location ) ;
611610 }
612611 }
612+ // For inputs that have the same keys mapped to multiple actions like G
613+ // we need to manually handle what is triggered by adding extra conditions.
614+ // Otherwise when pressing CTRL + G for example, both the go-to
615+ // and the toggle grid actions are triggered, because godot does not distinguish
616+ // single key presses from combos, it sends both signals.
617+ // Sometimes even worse, when pressing CTRL + G, it only sends the go-to signal.
618+ // We continue to map these to an action and not call them directly,
619+ // because we could add a button in the ui that does the same and this would call the action too.
620+ if ( eventKeyDown . Keycode == Godot . Key . G ) {
621+ // Toggle Coordinates
622+ if ( eventKeyDown . IsCommandOrControlPressed ( )
623+ && eventKeyDown . ShiftPressed
624+ && eventKeyDown . AltPressed ) {
625+ ProcessAction ( C7Action . ToggleCoordinates ) ;
626+ }
627+ // Toggle Grid
628+ else if ( eventKeyDown . IsCommandOrControlPressed ( ) ) {
629+ ProcessAction ( C7Action . ToggleGrid ) ;
630+ }
631+ // Trigger Unit go-to
632+ else if ( ! eventKeyDown . IsCommandOrControlPressed ( )
633+ && ! eventKeyDown . ShiftPressed
634+ && ! eventKeyDown . AltPressed ) {
635+ ProcessAction ( C7Action . UnitGoto ) ;
636+ }
637+ }
613638 }
614639
615640 private void ToggleObserverMode ( ) {
@@ -667,10 +692,18 @@ private void ProcessActions() {
667692 foreach ( StringName action in actions ) {
668693 if ( Input . IsActionJustPressed ( action ) ) {
669694 ProcessAction ( action . ToString ( ) ) ;
695+ } else if ( Input . IsActionJustReleased ( action ) ) {
696+ ProcessOnReleaseAction ( action . ToString ( ) ) ;
670697 }
671698 }
672699 }
673700
701+ private void ProcessOnReleaseAction ( string currentAction ) {
702+ if ( currentAction == C7Action . EnableTempAnimations ) {
703+ animationController . SetAnimationsEnabled ( true ) ;
704+ }
705+ }
706+
674707 private void ProcessAction ( string currentAction ) {
675708 if ( currentAction == C7Action . Escape && popupOverlay . ShowingPopup ) {
676709 popupOverlay . OnHidePopup ( ) ;
@@ -719,6 +752,10 @@ private void ProcessAction(string currentAction) {
719752 this . mapView . gridLayer . visible = ! this . mapView . gridLayer . visible ;
720753 }
721754
755+ if ( currentAction == C7Action . ToggleCoordinates ) {
756+ ToggleGridCoordinates ( ) ;
757+ }
758+
722759 if ( currentAction == C7Action . Escape && this . gotoInfo == null ) {
723760 log . Debug ( "Got request for escape/quit" ) ;
724761 popupOverlay . ShowPopup ( new EscapeQuitPopup ( ) , PopupOverlay . PopupCategory . Info ) ;
@@ -733,9 +770,11 @@ private void ProcessAction(string currentAction) {
733770 }
734771
735772 if ( currentAction == C7Action . ToggleAnimations ) {
773+ animationController . ToggleAnimationsEnabled ( ) ;
774+ }
775+
776+ if ( currentAction == C7Action . EnableTempAnimations ) {
736777 animationController . SetAnimationsEnabled ( false ) ;
737- } else if ( Input . IsActionJustReleased ( C7Action . ToggleAnimations ) ) {
738- animationController . SetAnimationsEnabled ( true ) ;
739778 }
740779
741780 // actions with unit buttons, which are only relevant during the player
@@ -758,6 +797,9 @@ private void ProcessAction(string currentAction) {
758797 }
759798
760799 if ( currentAction == C7Action . UnitDisband ) {
800+ if ( CurrentlySelectedUnit == null || CurrentlySelectedUnit == MapUnit . NONE ) {
801+ return ;
802+ }
761803 popupOverlay . ShowPopup (
762804 new ConfirmationPopup (
763805 $ "Disband { CurrentlySelectedUnit . unitType . name } ? Pardon me but these are OUR people. Do \n you really want to disband them?",
0 commit comments