diff --git a/MapImageLayerConfig.cs b/MapImageLayerConfig.cs index 3ea0a6e..16b2c38 100644 --- a/MapImageLayerConfig.cs +++ b/MapImageLayerConfig.cs @@ -48,6 +48,12 @@ public decimal Opacity set; } = 1m; + public decimal Speed + { + get; + set; + } = 50m; + public void SetPosition( Vector3 position ) { X = ( decimal ) position.x; diff --git a/README.md b/README.md index d9f98f2..0448e4e 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ To make your city planning more efficient, MapImageLayer offers these handy keyb - **(ALT + =)** Increase opacity of overlay - **(ALT + -)** Decrease opacity of overlay - **(ALT + I)** Force open image file selection dialog +- **(CTRL + Arrows)** Move the overlay ## Image Requirements diff --git a/Systems/ImageOverlaySystem.cs b/Systems/ImageOverlaySystem.cs index 444de41..0bc44b4 100644 --- a/Systems/ImageOverlaySystem.cs +++ b/Systems/ImageOverlaySystem.cs @@ -124,6 +124,36 @@ private void CreateKeyBinding( ) ReloadImage( ); }; inputAction.Enable( ); + + inputAction = new InputAction( "ImageOverlayMoveLeft" ); + inputAction.AddCompositeBinding( "ButtonWithOneModifier" ) + .With( "Modifier", "/ctrl" ) + .With( "Button", "/leftArrow" ); + inputAction.performed += OnImageOverlayMoveLeft; + inputAction.Enable(); + + inputAction = new InputAction( "ImageOverlayMoveRight" ); + inputAction.AddCompositeBinding( "ButtonWithOneModifier" ) + .With( "Modifier", "/ctrl" ) + .With( "Button", "/rightArrow" ); + inputAction.performed += OnImageOverlayMoveRight; + inputAction.Enable(); + + + inputAction = new InputAction( "ImageOverlayMoveForward" ); + inputAction.AddCompositeBinding( "ButtonWithOneModifier" ) + .With( "Modifier", "/ctrl" ) + .With( "Button", "/upArrow" ); + inputAction.performed += OnImageOverlayMoveForward; + inputAction.Enable(); + + + inputAction = new InputAction( "ImageOverlayMoveBackward" ); + inputAction.AddCompositeBinding( "ButtonWithOneModifier" ) + .With( "Modifier", "/ctrl" ) + .With( "Button", "/downArrow" ); + inputAction.performed += OnImageOverlayMoveBackward; + inputAction.Enable(); } private void ChooseInputFile() @@ -328,6 +358,62 @@ private void OnImageOverlayDecreaseTransparency( InputAction.CallbackContext obj MapImageLayerConfig.Save( _config ); } + private void OnImageOverlayMoveLeft( InputAction.CallbackContext obj ) + { + if ( !ShowImageOverlay || imageOverlayObj == null ) + return; + + imageOverlayObj.transform.position -= Vector3.right * (float)_config.Speed; + AudioManager.instance.PlayUISound( soundSettings.m_TransportLineStartSound ); + + _config.X = ( decimal ) imageOverlayObj.transform.position.x; + _config.Y = ( decimal ) imageOverlayObj.transform.position.y; + _config.Z = ( decimal ) imageOverlayObj.transform.position.z; + MapImageLayerConfig.Save( _config ); + } + + private void OnImageOverlayMoveRight( InputAction.CallbackContext obj ) + { + if ( !ShowImageOverlay || imageOverlayObj == null ) + return; + + imageOverlayObj.transform.position += Vector3.right * (float)_config.Speed; + AudioManager.instance.PlayUISound( soundSettings.m_PolygonToolDropPointSound ); + + _config.X = ( decimal ) imageOverlayObj.transform.position.x; + _config.Y = ( decimal ) imageOverlayObj.transform.position.y; + _config.Z = ( decimal ) imageOverlayObj.transform.position.z; + MapImageLayerConfig.Save( _config ); + } + + private void OnImageOverlayMoveForward( InputAction.CallbackContext obj ) + { + if ( !ShowImageOverlay || imageOverlayObj == null ) + return; + + imageOverlayObj.transform.position += Vector3.forward * (float)_config.Speed; + AudioManager.instance.PlayUISound( soundSettings.m_AreaMarqueeEndSound ); + + _config.X = ( decimal ) imageOverlayObj.transform.position.x; + _config.Y = ( decimal ) imageOverlayObj.transform.position.y; + _config.Z = ( decimal ) imageOverlayObj.transform.position.z; + MapImageLayerConfig.Save( _config ); + } + + private void OnImageOverlayMoveBackward( InputAction.CallbackContext obj ) + { + if ( !ShowImageOverlay || imageOverlayObj == null ) + return; + + imageOverlayObj.transform.position -= Vector3.forward * (float)_config.Speed; + AudioManager.instance.PlayUISound( soundSettings.m_TransportLineCompleteSound ); + + _config.X = ( decimal ) imageOverlayObj.transform.position.x; + _config.Y = ( decimal ) imageOverlayObj.transform.position.y; + _config.Z = ( decimal ) imageOverlayObj.transform.position.z; + MapImageLayerConfig.Save( _config ); + } + private Shader LoadAssetBundle( ) { var assembly = Assembly.GetExecutingAssembly( ); @@ -378,4 +464,4 @@ private float SampleWaterHeight( ) return ( float ) WaterUtils.SampleHeight( ref surfaceData, ref heightData, Vector3.zero ); } } -} +} \ No newline at end of file