From 0fa89de9729aea393b016ae0a8df91dac22f0f23 Mon Sep 17 00:00:00 2001 From: Hamcha Date: Fri, 18 Sep 2020 01:47:16 +0200 Subject: [PATCH] More work on map editor --- Graphics/UI/editor-icons.png | Bin 0 -> 411 bytes Graphics/UI/editor-icons.png.import | 34 +++++++ Scenes/Editor/Styles/ToolHover.tres | 13 +++ Scenes/Editor/Styles/ToolNormal.tres | 7 ++ Scenes/Editor/Styles/ToolPressed.tres | 19 ++++ Scenes/Editor/TileTab.gd | 6 +- Scenes/Editor/ToolButtonTheme.tres | 28 ++++++ Scenes/MapEditor.gd | 100 ++++++++++++++------- Scenes/MapEditor.tscn | 125 +++++++++++++++++++++++++- Scenes/Maps/odyssey.tscn | 51 +++++++++++ 10 files changed, 347 insertions(+), 36 deletions(-) create mode 100644 Graphics/UI/editor-icons.png create mode 100644 Graphics/UI/editor-icons.png.import create mode 100644 Scenes/Editor/Styles/ToolHover.tres create mode 100644 Scenes/Editor/Styles/ToolNormal.tres create mode 100644 Scenes/Editor/Styles/ToolPressed.tres create mode 100644 Scenes/Editor/ToolButtonTheme.tres diff --git a/Graphics/UI/editor-icons.png b/Graphics/UI/editor-icons.png new file mode 100644 index 0000000000000000000000000000000000000000..416ef72f02f9e4360a55dbfeb1bbf67c723dd09e GIT binary patch literal 411 zcmV;M0c8G(P)Px$RY^oaR9J=WSX~dpAPCfE|Nk$$hlPY*kq?C}U3xD~6}c0XvbFZ$x9I$3j4@n` zdha;K*GltVn`I0J9MfzhaUQOH#UH$~93fC-dc?^uCnORg*WNWjvj|sg;>dQ0=bVeq zJUWEa5%NUd>zE7gz4r?7trcY8+c;$)atAEO(w(Y6dIs>!m)8CURS1c+$fFpnOj;SW zs#pYN-+`*Sf8pUTw{9gK{1avk-z|XMYc-!(g;p=yPI-)OmUu23Ku7p3s1UOQwVB%y zv)aH}fx;{we8S@(DkeJ{A)nD|G5~x$iwkY0&0I8cl09xBqr74U)Rur2;GERRS)^z; z^RavfG-4!=^h^{nt+R~)GayzWO}yot>}M_cF5DT=&Mb=Y{*uc8X5hd{Yw^s6i b.x: + x_ord = Vector2(b.x, a.x) + if a.y > b.y: + y_ord = Vector2(b.y, a.y) + var positions = [] + for x in range(x_ord.x, x_ord.y+1): + layer.set_cellv(Vector2(x, a.y), id) + layer.set_cellv(Vector2(x, b.y), id) + for y in range(y_ord.x, y_ord.y+1): + layer.set_cellv(Vector2(a.x, y), id) + layer.set_cellv(Vector2(b.x, y), id) + layer.update_bitmask_region(a, b) + +func place_tiles(positions: Array, id: int): + if placing_layer == null: + return + var layer := placing_layer as TileMap + for pos in positions: + # Place tile + layer.set_cellv(pos, id) + for pos in positions: + # Update bitmask + layer.update_bitmask_area(pos) var group := ButtonGroup.new() @@ -169,7 +187,21 @@ func make_tile_texture(tileset: TileSet, id: int) -> AtlasTexture: tileset.autotile_get_icon_coordinate(id) * tile_size, tile_size ) - print(tile_icon.region) TileSet.SINGLE_TILE: tile_icon.region = tileset.tile_get_region(id) return tile_icon + +onready var layers_panel = $layers +onready var brush_panel = $tools/brushPanel +func _tool_selected(tool_type): + layers_panel.visible = false + brush_panel.visible = false + placing_mode = PlacingMode.NONE + match tool_type: + "tile": + layers_panel.visible = true + brush_panel.visible = true + placing_mode = PlacingMode.TILEMAP + +func _set_brush(brush_type: String): + current_brush = brush_type diff --git a/Scenes/MapEditor.tscn b/Scenes/MapEditor.tscn index 43421a5..c9e2245 100644 --- a/Scenes/MapEditor.tscn +++ b/Scenes/MapEditor.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=16 format=2] +[gd_scene load_steps=25 format=2] [ext_resource path="res://Graphics/deepspace_mat.tres" type="Material" id=1] [ext_resource path="res://Scenes/InEditorMap.gd" type="Script" id=2] [ext_resource path="res://Graphics/tgstation/walls.tres" type="TileSet" id=3] +[ext_resource path="res://Graphics/UI/editor-icons.png" type="Texture" id=4] [ext_resource path="res://Graphics/tgstation/base.tres" type="TileSet" id=5] [ext_resource path="res://Graphics/tgstation/floor.tres" type="TileSet" id=6] [ext_resource path="res://Graphics/tgstation/cables.tres" type="TileSet" id=7] @@ -11,6 +12,7 @@ [ext_resource path="res://Scenes/MapEditor.gd" type="Script" id=10] [ext_resource path="res://Graphics/UI/grid.png" type="Texture" id=11] [ext_resource path="res://Graphics/UI/ui_theme.tres" type="Theme" id=12] +[ext_resource path="res://Scenes/Editor/ToolButtonTheme.tres" type="Theme" id=13] [sub_resource type="StyleBoxFlat" id=1] content_margin_left = 15.0 @@ -45,6 +47,30 @@ corner_radius_bottom_left = 3 content_margin_left = 10.0 content_margin_right = 10.0 +[sub_resource type="ButtonGroup" id=5] + +[sub_resource type="AtlasTexture" id=6] +atlas = ExtResource( 4 ) +region = Rect2( 0, 0, 16, 16 ) + +[sub_resource type="AtlasTexture" id=7] +atlas = ExtResource( 4 ) +region = Rect2( 16, 0, 16, 16 ) + +[sub_resource type="ButtonGroup" id=8] + +[sub_resource type="AtlasTexture" id=9] +atlas = ExtResource( 4 ) +region = Rect2( 0, 16, 16, 16 ) + +[sub_resource type="AtlasTexture" id=11] +atlas = ExtResource( 4 ) +region = Rect2( 32, 16, 16, 16 ) + +[sub_resource type="AtlasTexture" id=10] +atlas = ExtResource( 4 ) +region = Rect2( 16, 16, 16, 16 ) + [node name="Control" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 @@ -214,7 +240,96 @@ custom_fonts/font = ExtResource( 9 ) text = "Play" flat = false +[node name="tools" type="HBoxContainer" parent="."] +margin_left = 9.0 +margin_top = 54.0 +margin_right = 35.0 +margin_bottom = 140.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="toolsPanel" type="PanelContainer" parent="tools"] +margin_right = 55.0 +margin_bottom = 64.0 +size_flags_vertical = 0 + +[node name="tools" type="VBoxContainer" parent="tools/toolsPanel"] +margin_left = 4.0 +margin_top = 4.0 +margin_right = 51.0 +margin_bottom = 60.0 + +[node name="placeTile" type="ToolButton" parent="tools/toolsPanel/tools"] +margin_right = 47.0 +margin_bottom = 26.0 +theme = ExtResource( 13 ) +toggle_mode = true +group = SubResource( 5 ) +text = "tile" +icon = SubResource( 6 ) +flat = false +align = 0 + +[node name="placeObject" type="ToolButton" parent="tools/toolsPanel/tools"] +margin_top = 30.0 +margin_right = 47.0 +margin_bottom = 56.0 +theme = ExtResource( 13 ) +toggle_mode = true +group = SubResource( 5 ) +text = "obj" +icon = SubResource( 7 ) +flat = false +align = 0 + +[node name="brushPanel" type="PanelContainer" parent="tools"] +visible = false +margin_left = 59.0 +margin_right = 93.0 +margin_bottom = 94.0 +size_flags_vertical = 0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="brush" type="VBoxContainer" parent="tools/brushPanel"] +margin_left = 4.0 +margin_top = 4.0 +margin_right = 30.0 +margin_bottom = 90.0 + +[node name="FreeHand" type="ToolButton" parent="tools/brushPanel/brush"] +margin_right = 26.0 +margin_bottom = 26.0 +theme = ExtResource( 13 ) +toggle_mode = true +group = SubResource( 8 ) +icon = SubResource( 9 ) +flat = false + +[node name="Rect" type="ToolButton" parent="tools/brushPanel/brush"] +margin_top = 30.0 +margin_right = 26.0 +margin_bottom = 56.0 +theme = ExtResource( 13 ) +toggle_mode = true +group = SubResource( 8 ) +icon = SubResource( 11 ) +flat = false + +[node name="Fill" type="ToolButton" parent="tools/brushPanel/brush"] +margin_top = 60.0 +margin_right = 26.0 +margin_bottom = 86.0 +theme = ExtResource( 13 ) +toggle_mode = true +group = SubResource( 8 ) +icon = SubResource( 10 ) +flat = false + [node name="layers" type="MarginContainer" parent="."] +visible = false anchor_top = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 @@ -233,5 +348,13 @@ margin_bottom = 84.0 rect_min_size = Vector2( 0, 80 ) theme = ExtResource( 12 ) tab_align = 0 +__meta__ = { +"_edit_use_anchors_": false +} [connection signal="mouse_entered" from="background" to="." method="_toggle_tile_input" binds= [ true ]] [connection signal="mouse_exited" from="background" to="." method="_toggle_tile_input" binds= [ false ]] +[connection signal="pressed" from="tools/toolsPanel/tools/placeTile" to="." method="_tool_selected" binds= [ "tile" ]] +[connection signal="pressed" from="tools/toolsPanel/tools/placeObject" to="." method="_tool_selected" binds= [ "obj" ]] +[connection signal="pressed" from="tools/brushPanel/brush/FreeHand" to="." method="_set_brush" binds= [ "freehand" ]] +[connection signal="pressed" from="tools/brushPanel/brush/Rect" to="." method="_set_brush" binds= [ "rect" ]] +[connection signal="pressed" from="tools/brushPanel/brush/Fill" to="." method="_set_brush" binds= [ "fill" ]] diff --git a/Scenes/Maps/odyssey.tscn b/Scenes/Maps/odyssey.tscn index 7ee3c91..4704ea0 100644 --- a/Scenes/Maps/odyssey.tscn +++ b/Scenes/Maps/odyssey.tscn @@ -177,7 +177,9 @@ position = Vector2( -736, -96 ) [node name="Computer" parent="objects" instance=ExtResource( 6 )] position = Vector2( 800, 0 ) +object_name = "" direction = 0 +computer_type = 0 [node name="Door" parent="objects" instance=ExtResource( 4 )] position = Vector2( -704, 0 ) @@ -212,39 +214,49 @@ interlockTargetPath = NodePath("../Door6") [node name="Computer2" parent="objects" instance=ExtResource( 6 )] position = Vector2( -864, -32 ) +object_name = "" direction = 1 computer_type = 4 [node name="Computer3" parent="objects" instance=ExtResource( 6 )] position = Vector2( -864, 0 ) +object_name = "" direction = 1 computer_type = 5 [node name="Computer4" parent="objects" instance=ExtResource( 6 )] position = Vector2( 736, -96 ) +object_name = "" +direction = 3 computer_type = 4 [node name="Computer5" parent="objects" instance=ExtResource( 6 )] position = Vector2( 704, -96 ) +object_name = "" +direction = 3 computer_type = 5 [node name="Computer6" parent="objects" instance=ExtResource( 6 )] position = Vector2( 800, 32 ) +object_name = "" direction = 0 computer_type = 7 [node name="Computer8" parent="objects" instance=ExtResource( 6 )] position = Vector2( 736, 96 ) +object_name = "" direction = 2 computer_type = 6 [node name="Computer9" parent="objects" instance=ExtResource( 6 )] position = Vector2( 704, 96 ) +object_name = "" direction = 2 computer_type = 3 [node name="Computer7" parent="objects" instance=ExtResource( 6 )] position = Vector2( 800, -32 ) +object_name = "" direction = 0 computer_type = 1 @@ -319,160 +331,199 @@ flow = 2 position = Vector2( -928, 96 ) direction = 0 connectionPaths = [ NodePath("../../engines/Engine3") ] +flow = 1 [node name="ElectricSocket6" parent="sockets" instance=ExtResource( 14 )] position = Vector2( -832, -192 ) direction = 0 connectionPaths = [ NodePath("../../engines/Engine4") ] +flow = 1 [node name="ElectricSocket7" parent="sockets" instance=ExtResource( 14 )] position = Vector2( -928, 0 ) direction = 0 connectionPaths = [ NodePath("../../engines/Engine5") ] +flow = 1 [node name="ElectricSocket8" parent="sockets" instance=ExtResource( 14 )] position = Vector2( -832, 192 ) direction = 0 connectionPaths = [ NodePath("../../engines/Engine2") ] +flow = 1 [node name="ElectricSocket9" parent="sockets" instance=ExtResource( 14 )] position = Vector2( -928, -96 ) direction = 0 connectionPaths = [ NodePath("../../engines/Engine") ] +flow = 1 [node name="ElectricSocket10" parent="sockets" instance=ExtResource( 14 )] position = Vector2( 768, 0 ) direction = 1 connectionPaths = [ NodePath("../../objects/Computer") ] +flow = 1 [node name="ElectricSocket12" parent="sockets" instance=ExtResource( 14 )] position = Vector2( 576, 0 ) direction = 1 connectionPaths = [ NodePath("../../objects/Door2") ] +flow = 1 [node name="ElectricSocket11" parent="sockets" instance=ExtResource( 14 )] position = Vector2( -736, 0 ) direction = 1 connectionPaths = [ NodePath("../../objects/Door") ] +flow = 1 [node name="ElectricSocket13" parent="sockets" instance=ExtResource( 14 )] position = Vector2( 96, -96 ) direction = 2 connectionPaths = [ NodePath("../../objects/Door3") ] +flow = 1 [node name="ElectricSocket14" parent="sockets" instance=ExtResource( 14 )] position = Vector2( 160, -96 ) direction = 2 connectionPaths = [ NodePath("../../objects/Door4") ] +flow = 1 [node name="ElectricSocket15" parent="sockets" instance=ExtResource( 14 )] position = Vector2( 64, -224 ) direction = 2 connectionPaths = [ NodePath("../../objects/Door7") ] +flow = 1 [node name="ElectricSocket16" parent="sockets" instance=ExtResource( 14 )] position = Vector2( 64, -288 ) direction = 2 connectionPaths = [ NodePath("../../objects/Door5") ] +flow = 1 [node name="ElectricSocket17" parent="sockets" instance=ExtResource( 14 )] position = Vector2( 192, -288 ) direction = 2 connectionPaths = [ NodePath("../../objects/Door6") ] +flow = 1 [node name="ElectricSocket18" parent="sockets" instance=ExtResource( 14 )] position = Vector2( 192, -224 ) direction = 2 connectionPaths = [ NodePath("../../objects/Door8") ] +flow = 1 [node name="ElectricSocket19" parent="sockets" instance=ExtResource( 14 )] position = Vector2( -832, 0 ) direction = 0 connectionPaths = [ NodePath("../../objects/Computer3") ] +flow = 1 [node name="ElectricSocket20" parent="sockets" instance=ExtResource( 14 )] position = Vector2( -832, -32 ) direction = 0 connectionPaths = [ NodePath("../../objects/Computer2") ] +flow = 1 [node name="ElectricSocket22" parent="sockets" instance=ExtResource( 14 )] position = Vector2( 736, -64 ) direction = 2 connectionPaths = [ NodePath("../../objects/Computer4") ] +flow = 1 [node name="ElectricSocket21" parent="sockets" instance=ExtResource( 14 )] position = Vector2( 704, -64 ) direction = 2 connectionPaths = [ NodePath("../../objects/Computer5") ] +flow = 1 [node name="ElectricSocket23" parent="sockets" instance=ExtResource( 14 )] position = Vector2( 704, 64 ) +direction = 3 connectionPaths = [ NodePath("../../objects/Computer9") ] +flow = 1 [node name="ElectricSocket24" parent="sockets" instance=ExtResource( 14 )] position = Vector2( 736, 64 ) +direction = 3 connectionPaths = [ NodePath("../../objects/Computer8") ] +flow = 1 [node name="ElectricSocket25" parent="sockets" instance=ExtResource( 14 )] position = Vector2( 768, -32 ) direction = 1 connectionPaths = [ NodePath("../../objects/Computer7") ] +flow = 1 [node name="ElectricSocket26" parent="sockets" instance=ExtResource( 14 )] position = Vector2( 768, 32 ) direction = 1 connectionPaths = [ NodePath("../../objects/Computer6") ] +flow = 1 [node name="ElectricSocket27" parent="sockets" instance=ExtResource( 14 )] position = Vector2( -512, 224 ) direction = 0 connectionPaths = [ NodePath("../../objects/Door9") ] +flow = 1 [node name="ElectricSocket28" parent="sockets" instance=ExtResource( 14 )] position = Vector2( -448, 32 ) +direction = 3 connectionPaths = [ NodePath("../../objects/Door10") ] +flow = 1 [node name="ElectricSocket29" parent="sockets" instance=ExtResource( 14 )] position = Vector2( -320, 128 ) direction = 0 connectionPaths = [ NodePath("../../objects/Door12") ] +flow = 1 [node name="ElectricSocket30" parent="sockets" instance=ExtResource( 14 )] position = Vector2( -224, 32 ) +direction = 3 connectionPaths = [ NodePath("../../objects/Door11") ] +flow = 1 [node name="ElectricSocket31" parent="sockets" instance=ExtResource( 14 )] position = Vector2( -128, 192 ) direction = 1 connectionPaths = [ NodePath("../../objects/Door13") ] +flow = 1 [node name="ElectricSocket32" parent="sockets" instance=ExtResource( 14 )] position = Vector2( 224, 128 ) direction = 1 connectionPaths = [ NodePath("../../objects/Door16") ] +flow = 1 [node name="ElectricSocket33" parent="sockets" instance=ExtResource( 14 )] position = Vector2( 224, 160 ) direction = 1 connectionPaths = [ NodePath("../../objects/Door17") ] +flow = 1 [node name="ElectricSocket34" parent="sockets" instance=ExtResource( 14 )] position = Vector2( 352, 32 ) +direction = 3 connectionPaths = [ NodePath("../../objects/Door14") ] +flow = 1 [node name="ElectricSocket35" parent="sockets" instance=ExtResource( 14 )] position = Vector2( 416, 32 ) +direction = 3 connectionPaths = [ NodePath("../../objects/Door15") ] +flow = 1 [node name="ElectricSocket36" parent="sockets" instance=ExtResource( 14 )] position = Vector2( 192, -160 ) direction = 1 connectionPaths = [ NodePath("../../objects/Door19") ] +flow = 1 [node name="ElectricSocket37" parent="sockets" instance=ExtResource( 14 )] position = Vector2( 416, -32 ) direction = 2 connectionPaths = [ NodePath("../../objects/Door18") ] +flow = 1 [node name="lights" type="Node2D" parent="."] modulate = Color( 0.980392, 0.980392, 0.980392, 1 )