Use GDScript for terrain editing plugin

Also moved TerrainEditingControls out of plugin.
main
copygirl 1 month ago
parent f7a9dfa2f1
commit e1a6c15f5f
  1. 39
      addons/terrain-editing/TerrainEditingPlugin.cs
  2. 2
      addons/terrain-editing/plugin.cfg
  3. 26
      addons/terrain-editing/terrain_editing_plugin.gd
  4. 0
      assets/textures/terrain/editing/circle.png
  5. 6
      assets/textures/terrain/editing/circle.png.import
  6. 0
      assets/textures/terrain/editing/corner.png
  7. 6
      assets/textures/terrain/editing/corner.png.import
  8. 0
      assets/textures/terrain/editing/height.png
  9. 6
      assets/textures/terrain/editing/height.png.import
  10. 0
      assets/textures/terrain/editing/paint.png
  11. 6
      assets/textures/terrain/editing/paint.png.import
  12. 0
      assets/textures/terrain/editing/square.png
  13. 6
      assets/textures/terrain/editing/square.png.import
  14. 0
      terrain/editing/TerrainEditingControls+Editing.cs
  15. 0
      terrain/editing/TerrainEditingControls.cs
  16. 13
      terrain/editing/TerrainEditingControls.tscn

@ -1,39 +0,0 @@
#if TOOLS
[Tool]
public partial class TerrainEditingPlugin
: EditorPlugin
{
const string ScenePath = "res://addons/terrain-editing/TerrainEditingControls.tscn";
// The container to which the editing controls get added to when Terrain is selected.
const CustomControlContainer Container = CustomControlContainer.SpatialEditorSideRight;
TerrainEditingControls _controls;
public override bool _Handles(GodotObject obj)
=> obj is Terrain;
public override void _EnterTree()
{
var scene = GD.Load<PackedScene>(ScenePath);
_controls = scene.Instantiate<TerrainEditingControls>();
}
public override void _ExitTree()
{
if (_controls == null) return;
if (_controls.GetParent() != null)
RemoveControlFromContainer(Container, _controls);
_controls.Free();
_controls = null;
}
public override void _MakeVisible(bool visible)
{
if (visible)
AddControlToContainer(Container, _controls);
else if (_controls.GetParent() != null)
RemoveControlFromContainer(Container, _controls);
}
}
#endif

@ -4,4 +4,4 @@ name="Terrain Editing"
description=""
author="copygirl"
version="1.0.0"
script="TerrainEditingPlugin.cs"
script="terrain_editing_plugin.gd"

@ -0,0 +1,26 @@
@tool
extends EditorPlugin
const CONTAINER := CustomControlContainer.CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT
var controls_scene := preload("res://terrain/editing/TerrainEditingControls.tscn")
var controls_script := preload("res://terrain/editing/TerrainEditingControls.cs")
var controls : Control;
func _handles(object: Object) -> bool:
return object.get_script() == controls_script
func _enter_tree() -> void:
controls = controls_scene.instantiate()
func _exit_tree() -> void:
if controls.get_parent():
remove_control_from_container(CONTAINER, controls)
controls.free()
func _make_visible(visible: bool) -> void:
if visible:
add_control_to_container(CONTAINER, controls)
elif controls.get_parent():
remove_control_from_container(CONTAINER, controls)

Before

Width:  |  Height:  |  Size: 193 B

After

Width:  |  Height:  |  Size: 193 B

@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://2u1ldmh0osbx"
path="res://.godot/imported/circle.png-7ef635c7ab3f0bfc0f9202fc8a8f1dd4.ctex"
path="res://.godot/imported/circle.png-480be724d6b688a76820398ea30097a4.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/terrain-editing/icons/circle.png"
dest_files=["res://.godot/imported/circle.png-7ef635c7ab3f0bfc0f9202fc8a8f1dd4.ctex"]
source_file="res://assets/textures/terrain/editing/circle.png"
dest_files=["res://.godot/imported/circle.png-480be724d6b688a76820398ea30097a4.ctex"]
[params]

Before

Width:  |  Height:  |  Size: 129 B

After

Width:  |  Height:  |  Size: 129 B

@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://btl3jsqeldix2"
path="res://.godot/imported/corner.png-c9f5b33637b5a9c1ee2a2ae62a163672.ctex"
path="res://.godot/imported/corner.png-b3e3cf9873b34b5d334d6e85884e6746.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/terrain-editing/icons/corner.png"
dest_files=["res://.godot/imported/corner.png-c9f5b33637b5a9c1ee2a2ae62a163672.ctex"]
source_file="res://assets/textures/terrain/editing/corner.png"
dest_files=["res://.godot/imported/corner.png-b3e3cf9873b34b5d334d6e85884e6746.ctex"]
[params]

Before

Width:  |  Height:  |  Size: 168 B

After

Width:  |  Height:  |  Size: 168 B

@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://dqbtbf8pe05qv"
path="res://.godot/imported/height.png-a11588cb8bcd4e93c189a14ad0809338.ctex"
path="res://.godot/imported/height.png-dfdcad891e41d3086ffca9947f565f65.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/terrain-editing/icons/height.png"
dest_files=["res://.godot/imported/height.png-a11588cb8bcd4e93c189a14ad0809338.ctex"]
source_file="res://assets/textures/terrain/editing/height.png"
dest_files=["res://.godot/imported/height.png-dfdcad891e41d3086ffca9947f565f65.ctex"]
[params]

Before

Width:  |  Height:  |  Size: 169 B

After

Width:  |  Height:  |  Size: 169 B

@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://btdpyu4n3pgkx"
path="res://.godot/imported/paint.png-7f2ce8187160ce862842aed3c583971f.ctex"
path="res://.godot/imported/paint.png-fd14d265b51ee1ac5604bd82d9114189.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/terrain-editing/icons/paint.png"
dest_files=["res://.godot/imported/paint.png-7f2ce8187160ce862842aed3c583971f.ctex"]
source_file="res://assets/textures/terrain/editing/paint.png"
dest_files=["res://.godot/imported/paint.png-fd14d265b51ee1ac5604bd82d9114189.ctex"]
[params]

Before

Width:  |  Height:  |  Size: 147 B

After

Width:  |  Height:  |  Size: 147 B

@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://btjd1704xtdjv"
path="res://.godot/imported/square.png-ee9f4ef6bc1f78130e7829ecfc4538ca.ctex"
path="res://.godot/imported/square.png-1bc8a7ae7e9504f37db6cb7269dd99e4.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/terrain-editing/icons/square.png"
dest_files=["res://.godot/imported/square.png-ee9f4ef6bc1f78130e7829ecfc4538ca.ctex"]
source_file="res://assets/textures/terrain/editing/square.png"
dest_files=["res://.godot/imported/square.png-1bc8a7ae7e9504f37db6cb7269dd99e4.ctex"]
[params]

@ -1,12 +1,11 @@
[gd_scene load_steps=15 format=3 uid="uid://bmljchm3fj42"]
[ext_resource type="Script" path="res://addons/terrain-editing/TerrainEditingControls.cs" id="1_fklx3"]
[ext_resource type="Texture2D" uid="uid://btl3jsqeldix2" path="res://addons/terrain-editing/icons/corner.png" id="1_w5qr7"]
[ext_resource type="Texture2D" uid="uid://dqbtbf8pe05qv" path="res://addons/terrain-editing/icons/height.png" id="2_hrmm4"]
[ext_resource type="Texture2D" uid="uid://2u1ldmh0osbx" path="res://addons/terrain-editing/icons/circle.png" id="2_yvc34"]
[ext_resource type="Texture2D" uid="uid://btdpyu4n3pgkx" path="res://addons/terrain-editing/icons/paint.png" id="3_5x55r"]
[ext_resource type="Texture2D" uid="uid://btjd1704xtdjv" path="res://addons/terrain-editing/icons/square.png" id="3_aaaoe"]
[ext_resource type="Script" path="res://terrain/editing/TerrainEditingControls.cs" id="1_fklx3"]
[ext_resource type="Texture2D" uid="uid://btl3jsqeldix2" path="res://assets/textures/terrain/editing/corner.png" id="1_w5qr7"]
[ext_resource type="Texture2D" uid="uid://dqbtbf8pe05qv" path="res://assets/textures/terrain/editing/height.png" id="2_hrmm4"]
[ext_resource type="Texture2D" uid="uid://2u1ldmh0osbx" path="res://assets/textures/terrain/editing/circle.png" id="2_yvc34"]
[ext_resource type="Texture2D" uid="uid://btdpyu4n3pgkx" path="res://assets/textures/terrain/editing/paint.png" id="3_5x55r"]
[ext_resource type="Texture2D" uid="uid://btjd1704xtdjv" path="res://assets/textures/terrain/editing/square.png" id="3_aaaoe"]
[ext_resource type="Image" uid="uid://b0jp1dyxugbr7" path="res://assets/textures/terrain/grass.png" id="Image_d41co"]
[ext_resource type="Image" uid="uid://bpo7mkr6sctqr" path="res://assets/textures/terrain/dirt.png" id="Image_y3rra"]
[ext_resource type="Image" uid="uid://dqyqg6yt7yk3k" path="res://assets/textures/terrain/rock.png" id="Image_x8cdn"]
Loading…
Cancel
Save