From 99e977930083d1bc1d8c7e62bcb6125c350d4d91 Mon Sep 17 00:00:00 2001 From: copygirl Date: Sat, 31 Aug 2024 19:34:07 +0200 Subject: [PATCH] Quick and dirty terrain texture editing --- terrain/Terrain+Editing.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/terrain/Terrain+Editing.cs b/terrain/Terrain+Editing.cs index 7b42e7a..1090caf 100644 --- a/terrain/Terrain+Editing.cs +++ b/terrain/Terrain+Editing.cs @@ -84,6 +84,25 @@ public partial class Terrain NotifyPropertyListChanged(); } + if ((ev is InputEventMouseButton { ButtonIndex: var wheel2, Pressed: var pressed2, CtrlPressed: true }) + && (wheel2 is MouseButton.WheelUp or MouseButton.WheelDown) && (_selection != null)) + { + GetViewport().SetInputAsHandled(); + if (!pressed2) return; + + var amount = (wheel2 == MouseButton.WheelUp) ? 1 : -1; + var selection = TileRegion.From(_selection.Value); + + foreach (var pos in selection.GetAllTiles()) { + var tile = GetTile(pos); + tile.TexturePrimary = PosMod(tile.TexturePrimary + amount, 4); + SetTile(pos, tile); + } + + UpdateMeshAndShape(); + NotifyPropertyListChanged(); + } + if (ev is InputEventMouseMotion) _unhandledMotion = true; }