Mapping tools done
This commit is contained in:
parent
48253e4133
commit
aed8b58954
5 changed files with 162 additions and 45 deletions
41
addons/editor_helper/NewLayer.svg
Normal file
41
addons/editor_helper/NewLayer.svg
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
width="16"
|
||||
height="16"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
sodipodi:docname="NewLayer.svg"
|
||||
inkscape:version="1.3.2 (091e20e, 2023-11-25)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs
|
||||
id="defs1" />
|
||||
<sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#505050"
|
||||
bordercolor="#eeeeee"
|
||||
borderopacity="1"
|
||||
inkscape:showpageshadow="0"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#505050"
|
||||
inkscape:zoom="37.375"
|
||||
inkscape:cx="8.4147157"
|
||||
inkscape:cy="8.2809365"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1080"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg1" />
|
||||
<path
|
||||
id="path1"
|
||||
d="M 8 2 L 6.25 3.375 L 8 4.75 L 9.75 3.375 L 8 2 z M 5.3769531 4.0625 L 3.6269531 5.4375 L 5.3769531 6.8125 L 7.1269531 5.4375 L 5.3769531 4.0625 z M 10.623047 4.0625 L 8.8730469 5.4375 L 10.623047 6.8125 L 12.373047 5.4375 L 10.623047 4.0625 z M 8 6.1230469 L 6.25 7.4980469 L 8 8.8730469 L 9.75 7.4980469 L 8 6.1230469 z M 2.75 6.125 L 1 7.5 L 2.75 8.875 L 4.5 7.5 L 2.75 6.125 z M 13.25 6.125 L 11.5 7.5 L 12.136719 8 L 14 8 L 14 8.2851562 L 15 7.5 L 13.25 6.125 z M 5.3730469 8.1875 L 3.6230469 9.5625 L 5.3730469 10.9375 L 7.1230469 9.5625 L 5.3730469 8.1875 z M 10 8.6796875 L 8.8769531 9.5625 L 9.4335938 10 L 10 10 L 10 8.6796875 z M 8 10.25 L 6.25 11.625 L 8 13 L 8 10.25 z "
|
||||
style="fill:#8da5f3;fill-opacity:1" />
|
||||
<path
|
||||
fill="#5fff97"
|
||||
d="m 11,9 v 2 H 9 v 2 h 2 v 2 h 2 v -2 h 2 V 11 H 13 V 9 Z"
|
||||
id="path2" />
|
||||
</svg>
|
After Width: | Height: | Size: 1.8 KiB |
37
addons/editor_helper/NewLayer.svg.import
Normal file
37
addons/editor_helper/NewLayer.svg.import
Normal file
|
@ -0,0 +1,37 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://xybiqt1dm6of"
|
||||
path="res://.godot/imported/NewLayer.svg-2c86262b51986b078abb0688f7162945.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/editor_helper/NewLayer.svg"
|
||||
dest_files=["res://.godot/imported/NewLayer.svg-2c86262b51986b078abb0688f7162945.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=2.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
|
@ -1,16 +1,58 @@
|
|||
@tool
|
||||
extends Control
|
||||
|
||||
#func _ready():
|
||||
#EditorInterface.get_selection().selection_changed.connect(update_layer_number)
|
||||
|
||||
func _process(_delta):
|
||||
update_layer_number()
|
||||
|
||||
func _on_expand_pressed():
|
||||
func _on_new_pressed():
|
||||
var dialog = EditorFileDialog.new()
|
||||
dialog.file_mode = EditorFileDialog.FILE_MODE_SAVE_FILE
|
||||
dialog.filters = ["*.tscn ; Godot Human Readable Text Scene"]
|
||||
EditorInterface.popup_dialog_centered_ratio(dialog)
|
||||
var file = await dialog.file_selected
|
||||
EditorInterface.open_scene_from_path("res://addons/editor_helper/template.tscn")
|
||||
get_scene().name = file.get_file().get_basename().to_camel_case()
|
||||
EditorInterface.save_scene_as(file)
|
||||
|
||||
func _on_new_layer_pressed():
|
||||
var scene = get_scene()
|
||||
if !is_scene_expanded(scene): return await error_not_expanded()
|
||||
|
||||
var maps = scene.get_node("TileMap")
|
||||
var layer = TileMapLayer.new()
|
||||
layer.tile_set = load("res://Assets/tileset.tres")
|
||||
layer.set("metadata/_edit_lock_", true)
|
||||
maps.add_child(layer)
|
||||
layer.owner = scene
|
||||
var index = layer.get_index()
|
||||
layer.name = "TileMap Layer %s" % str(index + 1)
|
||||
save_and_reload()
|
||||
#focus_node(scene.get_node("TileMap").get_child(index))
|
||||
|
||||
func _on_minify_pressed():
|
||||
var scene = get_scene()
|
||||
if !is_scene_expanded(scene): return await error_not_expanded()
|
||||
|
||||
focus_node(scene)
|
||||
scene.remove_child(scene.get_node("ProjectionViewport"))
|
||||
scene.get_node("HeightMap").mesh_library = load("res://Assets/heightmap_meshlibrary.tres")
|
||||
scene.remove_child(scene.get_node("NotMinified"))
|
||||
|
||||
func _on_expand_pressed():
|
||||
var scene = get_scene()
|
||||
if !is_scene_minified(scene): return await error_not_minified()
|
||||
|
||||
var not_minified = Node.new()
|
||||
not_minified.name = "NotMinified"
|
||||
scene.add_child(not_minified)
|
||||
scene.move_child(not_minified, 0)
|
||||
not_minified.owner = scene
|
||||
|
||||
var sv = SubViewport.new()
|
||||
sv.name = "ProjectionViewport"
|
||||
sv.disable_3d = true
|
||||
scene.add_child(sv)
|
||||
sv.owner = scene
|
||||
update_proj_map()
|
||||
|
||||
func _on_up_pressed():
|
||||
|
@ -55,26 +97,20 @@ func move_up_or_down(direction: int):
|
|||
if len(selection) != 1: return await error_not_editing_tilemap()
|
||||
selection = selection[0]
|
||||
if selection is GridMap:
|
||||
#EditorCommandPalette
|
||||
#var event = InputEventKey.new()
|
||||
#event.physical_keycode = KEY_Q
|
||||
#event.pressed = true
|
||||
#Input.parse_input_event(event)
|
||||
#event.pressed = false
|
||||
#Input.parse_input_event(event)
|
||||
#InputMap.action_get_events("floor")
|
||||
var floor: Vector3 = selection.get(&"metadata/_editor_floor_")
|
||||
floor.y += direction
|
||||
selection.set(&"metadata/_editor_floor_", floor)
|
||||
EditorInterface.save_scene()
|
||||
EditorInterface.reload_scene_from_path(get_scene().scene_file_path)
|
||||
save_and_reload()
|
||||
update_proj_map()
|
||||
elif selection is TileMapLayer:
|
||||
var index = selection.get_index() + direction
|
||||
if index == -1: return
|
||||
var target = selection.get_parent().get_child(index)
|
||||
if target != null: focus_node(target)
|
||||
#update_layer_number()
|
||||
|
||||
func save_and_reload():
|
||||
EditorInterface.save_scene()
|
||||
EditorInterface.reload_scene_from_path(get_scene().scene_file_path)
|
||||
|
||||
func update_layer_number():
|
||||
var s = "N/A ¯\\_(ツ)_/¯"
|
||||
|
@ -103,6 +139,10 @@ func is_scene_expanded(scene: Node) -> bool:
|
|||
if !scene: return false
|
||||
return scene.has_node("NotMinified")
|
||||
|
||||
func is_scene_minified(scene: Node) -> bool:
|
||||
if !scene: return false
|
||||
return scene.has_node("TileMap") && scene.has_node("HeightMap") && !scene.has_node("NotMinified")
|
||||
|
||||
func error(message: String):
|
||||
var dialog = AcceptDialog.new()
|
||||
dialog.dialog_text = message
|
||||
|
@ -113,6 +153,9 @@ func error(message: String):
|
|||
func error_not_expanded():
|
||||
error("This scene is not an expanded map!")
|
||||
|
||||
func error_not_minified():
|
||||
error("This scene is not a minified map!")
|
||||
|
||||
func error_not_editing_tilemap():
|
||||
error("Please start editing a map before using this button!")
|
||||
|
||||
|
@ -136,13 +179,11 @@ func update_proj_map():
|
|||
var proj_vp = scene.get_node("ProjectionViewport")
|
||||
if proj_vp.has_node("TileMap"): proj_vp.get_node("TileMap").free()
|
||||
proj_vp.add_child(maps)
|
||||
#maps.owner = scene
|
||||
|
||||
var total_rect = Rect2i()
|
||||
for map: TileMapLayer in maps.get_children():
|
||||
if map is not TileMapLayer: continue
|
||||
total_rect = total_rect.merge(map.get_used_rect())
|
||||
#map.owner = scene
|
||||
|
||||
maps.position = total_rect.position * -128
|
||||
proj_vp.size = total_rect.size.max(Vector2i.ONE) * 128
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=11 format=3 uid="uid://d1bj8t8yjv2uj"]
|
||||
[gd_scene load_steps=12 format=3 uid="uid://d1bj8t8yjv2uj"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://d21g7jrsdyc8p" path="res://addons/editor_helper/Up.svg" id="1_pbfaa"]
|
||||
[ext_resource type="Texture2D" uid="uid://djvtp1nbp5ib5" path="res://addons/editor_helper/New.svg" id="1_py207"]
|
||||
|
@ -6,6 +6,7 @@
|
|||
[ext_resource type="Texture2D" uid="uid://d3dtusyl30nq0" path="res://addons/editor_helper/Collapse.svg" id="2_d6cq4"]
|
||||
[ext_resource type="Texture2D" uid="uid://bqmald1jy1a2c" path="res://addons/editor_helper/Down.svg" id="2_ek7b6"]
|
||||
[ext_resource type="Texture2D" uid="uid://cg40j0yoi1sq0" path="res://addons/editor_helper/Expand.svg" id="3_73lev"]
|
||||
[ext_resource type="Texture2D" uid="uid://xybiqt1dm6of" path="res://addons/editor_helper/NewLayer.svg" id="3_iorsj"]
|
||||
[ext_resource type="Texture2D" uid="uid://71btnu3srsav" path="res://addons/editor_helper/TileMap.svg" id="3_ri7dm"]
|
||||
[ext_resource type="Texture2D" uid="uid://dhbqj6pa3geas" path="res://addons/editor_helper/HeightMap.svg" id="4_ie2iw"]
|
||||
[ext_resource type="Texture2D" uid="uid://df52p7ftdm52e" path="res://addons/editor_helper/Refresh.svg" id="8_aph12"]
|
||||
|
@ -34,6 +35,12 @@ text = "Create new map"
|
|||
icon = ExtResource("1_py207")
|
||||
expand_icon = true
|
||||
|
||||
[node name="New Layer" type="Button" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Create new layer"
|
||||
icon = ExtResource("3_iorsj")
|
||||
expand_icon = true
|
||||
|
||||
[node name="Minify" type="Button" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Removes editor-only elements from the map."
|
||||
|
@ -89,6 +96,9 @@ text = "Create HeightMap baseplate"
|
|||
icon = ExtResource("10_l2bcy")
|
||||
expand_icon = true
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/New" to="." method="_on_new_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/New Layer" to="." method="_on_new_layer_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/Minify" to="." method="_on_minify_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/Expand" to="." method="_on_expand_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/Up" to="." method="_on_up_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/Down" to="." method="_on_down_pressed"]
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
[gd_scene load_steps=8 format=4 uid="uid://cm7vfupftbsu8"]
|
||||
[gd_scene load_steps=8 format=3 uid="uid://cm7vfupftbsu8"]
|
||||
|
||||
[ext_resource type="TileSet" uid="uid://coub5ioem1v7o" path="res://Assets/tileset.tres" id="1_0y2ly"]
|
||||
[ext_resource type="Texture2D" uid="uid://773fvksy2hdp" path="res://Assets/Editor/voronoi-cube.png" id="2_7oxkx"]
|
||||
[ext_resource type="Shader" path="res://Assets/Editor/Project.gdshader" id="2_e7bie"]
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_qt304"]
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_qgw6l"]
|
||||
viewport_path = NodePath("ProjectionViewport")
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_qkhvu"]
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_op0ta"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("2_e7bie")
|
||||
shader_parameter/scale = Vector2(7, 7)
|
||||
shader_parameter/offset = Vector2(2, 2)
|
||||
shader_parameter/tilemap_camera = SubResource("ViewportTexture_qt304")
|
||||
shader_parameter/scale = Vector2(0, 0)
|
||||
shader_parameter/offset = Vector2(0, 0)
|
||||
shader_parameter/tilemap_camera = SubResource("ViewportTexture_qgw6l")
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_ce6ak"]
|
||||
material = SubResource("ShaderMaterial_qkhvu")
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_qpep1"]
|
||||
material = SubResource("ShaderMaterial_op0ta")
|
||||
|
||||
[sub_resource type="MeshLibrary" id="MeshLibrary_yl7gh"]
|
||||
[sub_resource type="MeshLibrary" id="MeshLibrary_b7j7j"]
|
||||
item/0/name = "Full Cube"
|
||||
item/0/mesh = SubResource("BoxMesh_ce6ak")
|
||||
item/0/mesh = SubResource("BoxMesh_qpep1")
|
||||
item/0/mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
|
||||
item/0/shapes = []
|
||||
item/0/navigation_mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
|
||||
|
@ -35,28 +35,16 @@ metadata/_edit_group_ = true
|
|||
[node name="TileMap" type="Node2D" parent="."]
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="TileMapLayer" type="TileMapLayer" parent="TileMap"]
|
||||
tile_map_data = PackedByteArray("AAD+/wEAAAAAAAAAAAD/////AAAAAAAAAAD//wEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAQAAAAAAAAAAAABAAAAAwAAAAAAAAABAAEAAgAAAAAAAAABAAIAAQAAAAAAAAABAAMAAQAAAAAAAAABAAQAAAAAAAAAAAACAAAAAwAAAAAAAAACAAEAAgAAAAAAAAACAAIAAQAAAAAAAAACAAMAAQAAAAAAAAACAAQAAAAAAAAAAAADAAAAAAAAAAAAAAADAAEAAAAAAAAAAAADAAIAAAAAAAAAAAADAAMAAAAAAAAAAAADAAQAAAAAAAAAAAAEAAEAAAAAAAAAAAAEAAIAAAAAAAAAAAAEAAMAAAAAAAAAAAD+//7/AAAAAAAAAAD///7/AAAAAAAAAAAAAP7/AAAAAAAAAAABAP7/AAAAAAAAAAACAP7/AAAAAAAAAAACAP//AAAAAAAAAAADAP//AAAAAAAAAAADAP7/AAAAAAAAAAABAP//AAAAAAAAAAAAAP//AAAAAAAAAAD//wAAAAAAAAAAAAD+/wAAAAAAAAAAAAD+////AAAAAAAAAAA=")
|
||||
tile_set = ExtResource("1_0y2ly")
|
||||
|
||||
[node name="TileMapLayer2" type="TileMapLayer" parent="TileMap"]
|
||||
tile_set = ExtResource("1_0y2ly")
|
||||
|
||||
[node name="TileMapLayer3" type="TileMapLayer" parent="TileMap"]
|
||||
tile_set = ExtResource("1_0y2ly")
|
||||
|
||||
[node name="TileMapLayer4" type="TileMapLayer" parent="TileMap"]
|
||||
[node name="TileMap Layer 1" type="TileMapLayer" parent="TileMap"]
|
||||
tile_set = ExtResource("1_0y2ly")
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="HeightMap" type="GridMap" parent="."]
|
||||
mesh_library = SubResource("MeshLibrary_yl7gh")
|
||||
mesh_library = SubResource("MeshLibrary_b7j7j")
|
||||
cell_size = Vector3(1, 1, 1)
|
||||
data = {
|
||||
"cells": PackedInt32Array(-65536, 0, 0, -65535, 0, 0, -65536, 1, 0, -65535, 1, 0, -65535, 65535, 0, -65535, 65534, 0, -65536, 65534, 0, -1, 65534, 0, -1, 65535, 0, -1, 0, 0, -65536, 65535, 0, -2, 0, 0, -2, 1, 0, -1, 1, 0, -2, 65535, 0, -2, 65534, 0, -65536, 2, 0, -65536, 3, 0, -65536, 4, 0, -65535, 4, 0, -65535, 3, 0, -65535, 2, 0, -65534, 4, 0, -65534, 3, 0, -65534, 2, 0, -65534, 1, 0, -65534, 0, 0, -65533, 0, 0, -65532, 1, 0, -65532, 2, 0, -65533, 2, 0, -65533, 3, 0, -65533, 4, 0, -65533, 1, 0, -65532, 3, 0, -65534, 65535, 0, -65533, 65535, 0, -65534, 65534, 0, -65533, 65534, 0, 2, 3, 0, 1, 3, 0, 1, 2, 0, 2, 2, 0, 65538, 2, 0, 65537, 2, 0, 65537, 3, 0, 65538, 3, 0)
|
||||
}
|
||||
metadata/_edit_lock_ = true
|
||||
metadata/_editor_floor_ = Vector3(0, -1, 0)
|
||||
metadata/_editor_floor_ = Vector3(0, 0, 0)
|
||||
|
||||
[node name="ProjectionViewport" type="SubViewport" parent="."]
|
||||
disable_3d = true
|
||||
size = Vector2i(896, 896)
|
||||
size = Vector2i(128, 128)
|
||||
|
|
Loading…
Add table
Reference in a new issue