Start work on map editor
This commit is contained in:
parent
a01a0215cd
commit
91b29162aa
13 changed files with 565 additions and 151 deletions
46
Graphics/IngameSpace.shader
Normal file
46
Graphics/IngameSpace.shader
Normal file
|
@ -0,0 +1,46 @@
|
|||
shader_type canvas_item;
|
||||
|
||||
uniform sampler2D noise_sparse;
|
||||
uniform sampler2D noise_fine;
|
||||
|
||||
uniform float scroll_speed = 0.0;
|
||||
uniform float warp_boost: hint_range(1, 10) = 1.0;
|
||||
uniform float warp_opacity : hint_range(0, 1) = 0.0;
|
||||
|
||||
const float noise_sparse_scale = 0.0007;
|
||||
const float noise_fine_scale = 0.003;
|
||||
const float warp_clouds_scale = 0.0003;
|
||||
const vec2 scroll_dir = vec2(1,0);
|
||||
const vec2 blink_scroll = vec2(50.0, 0);
|
||||
const float PI = 3.1415;
|
||||
|
||||
render_mode unshaded;
|
||||
|
||||
void fragment() {
|
||||
float scroll = scroll_speed * TIME;
|
||||
float sparse = texture(noise_sparse, (FRAGCOORD.xy + scroll_dir * scroll)*noise_sparse_scale).r;
|
||||
sparse = ((sparse * sparse) - 0.2) * 1.2;
|
||||
float fine = texture(noise_fine, (FRAGCOORD.xy + scroll_dir * scroll)*noise_fine_scale).r;
|
||||
fine = fine - 0.6;
|
||||
if (fine > 0.) {
|
||||
fine = fine * 10.0;
|
||||
}
|
||||
if (fine > 0.3) {
|
||||
float fine_blink_fade = texture(noise_sparse, (FRAGCOORD.xy + blink_scroll*TIME)*noise_sparse_scale).r;
|
||||
fine = fine - ((fine_blink_fade * fine_blink_fade) - 0.2) * 1.2;
|
||||
}
|
||||
vec4 clouds = vec4(vec3(0.3, 0.5, 0.7) * sparse, 1.0);
|
||||
vec4 stars = vec4(fine);
|
||||
|
||||
vec2 warp_scroll = scroll_dir * scroll;
|
||||
vec2 warp_uv = (FRAGCOORD.xy * sin(SCREEN_UV.y * PI) + warp_scroll)*warp_clouds_scale;
|
||||
vec2 warp_uv_inv = (FRAGCOORD.xy * sin((abs(SCREEN_UV.y-0.5)) * SCREEN_UV.x * PI) + warp_scroll*0.5)*warp_clouds_scale;
|
||||
float warp_clouds_sparse = texture(noise_sparse, vec2(0.5,1) * warp_uv).r;
|
||||
float warp_clouds_fine = texture(noise_sparse, vec2(2,1) * warp_uv_inv).r;
|
||||
|
||||
vec4 warp = vec4(vec3(0), 1);
|
||||
warp += vec4(vec3(0.3,0.2,0.9)*warp_clouds_sparse, 0);
|
||||
warp += vec4(vec3(0.5,0.0,0.5)*(warp_clouds_fine*0.5+warp_clouds_sparse)*abs(SCREEN_UV.y-0.5), 0);
|
||||
|
||||
COLOR = mix(clouds + stars, warp*warp_boost, warp_opacity);
|
||||
}
|
BIN
Graphics/UI/grid.png
Normal file
BIN
Graphics/UI/grid.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
34
Graphics/UI/grid.png.import
Normal file
34
Graphics/UI/grid.png.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/grid.png-dcf3a2dc07c07f64832e0ff565fb3712.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Graphics/UI/grid.png"
|
||||
dest_files=[ "res://.import/grid.png-dcf3a2dc07c07f64832e0ff565fb3712.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=1
|
||||
flags/filter=false
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
|
@ -38,6 +38,17 @@ expand_margin_bottom = 8.0
|
|||
|
||||
[resource]
|
||||
default_font = ExtResource( 1 )
|
||||
Button/colors/font_color = Color( 0.88, 0.88, 0.88, 1 )
|
||||
Button/colors/font_color_disabled = Color( 0.9, 0.9, 0.9, 0.2 )
|
||||
Button/colors/font_color_hover = Color( 0.94, 0.94, 0.94, 1 )
|
||||
Button/colors/font_color_pressed = Color( 1, 1, 1, 1 )
|
||||
Button/constants/hseparation = 2
|
||||
Button/fonts/font = null
|
||||
Button/styles/disabled = null
|
||||
Button/styles/focus = null
|
||||
Button/styles/hover = null
|
||||
Button/styles/normal = null
|
||||
Button/styles/pressed = null
|
||||
Panel/styles/panel = SubResource( 1 )
|
||||
PanelContainer/styles/panel = SubResource( 1 )
|
||||
PopupDialog/styles/panel = SubResource( 1 )
|
||||
|
@ -59,3 +70,14 @@ PopupMenu/styles/labeled_separator_right = null
|
|||
PopupMenu/styles/panel = SubResource( 2 )
|
||||
PopupMenu/styles/panel_disabled = null
|
||||
PopupMenu/styles/separator = null
|
||||
ToolButton/colors/font_color = Color( 0.88, 0.88, 0.88, 1 )
|
||||
ToolButton/colors/font_color_disabled = Color( 0.9, 0.95, 1, 0.3 )
|
||||
ToolButton/colors/font_color_hover = Color( 0.94, 0.94, 0.94, 1 )
|
||||
ToolButton/colors/font_color_pressed = Color( 1, 1, 1, 1 )
|
||||
ToolButton/constants/hseparation = 3
|
||||
ToolButton/fonts/font = null
|
||||
ToolButton/styles/disabled = null
|
||||
ToolButton/styles/focus = null
|
||||
ToolButton/styles/hover = null
|
||||
ToolButton/styles/normal = null
|
||||
ToolButton/styles/pressed = null
|
||||
|
|
74
Graphics/deepspace_mat.tres
Normal file
74
Graphics/deepspace_mat.tres
Normal file
|
@ -0,0 +1,74 @@
|
|||
[gd_resource type="ShaderMaterial" load_steps=6 format=2]
|
||||
|
||||
[sub_resource type="Shader" id=1]
|
||||
code = "shader_type canvas_item;
|
||||
|
||||
uniform sampler2D noise_sparse;
|
||||
uniform sampler2D noise_fine;
|
||||
|
||||
uniform float scroll_speed = 0.0;
|
||||
uniform float warp_boost: hint_range(1, 10) = 1.0;
|
||||
uniform float warp_opacity : hint_range(0, 1) = 0.0;
|
||||
|
||||
const float noise_sparse_scale = 0.0007;
|
||||
const float noise_fine_scale = 0.003;
|
||||
const float warp_clouds_scale = 0.0003;
|
||||
const vec2 scroll_dir = vec2(1,0);
|
||||
const vec2 blink_scroll = vec2(50.0, 0);
|
||||
const float PI = 3.1415;
|
||||
|
||||
render_mode unshaded;
|
||||
|
||||
void fragment() {
|
||||
float scroll = scroll_speed * TIME;
|
||||
float sparse = texture(noise_sparse, (FRAGCOORD.xy + scroll_dir * scroll)*noise_sparse_scale).r;
|
||||
sparse = ((sparse * sparse) - 0.2) * 1.2;
|
||||
float fine = texture(noise_fine, (FRAGCOORD.xy + scroll_dir * scroll)*noise_fine_scale).r;
|
||||
fine = fine - 0.6;
|
||||
if (fine > 0.) {
|
||||
fine = fine * 10.0;
|
||||
}
|
||||
if (fine > 0.3) {
|
||||
float fine_blink_fade = texture(noise_sparse, (FRAGCOORD.xy + blink_scroll*TIME)*noise_sparse_scale).r;
|
||||
fine = fine - ((fine_blink_fade * fine_blink_fade) - 0.2) * 1.2;
|
||||
}
|
||||
vec4 clouds = vec4(vec3(0.3, 0.5, 0.7) * sparse, 1.0);
|
||||
vec4 stars = vec4(fine);
|
||||
|
||||
vec2 warp_scroll = scroll_dir * scroll;
|
||||
vec2 warp_uv = (FRAGCOORD.xy * sin(SCREEN_UV.y * PI) + warp_scroll)*warp_clouds_scale;
|
||||
vec2 warp_uv_inv = (FRAGCOORD.xy * sin((abs(SCREEN_UV.y-0.5)) * SCREEN_UV.x * PI) + warp_scroll*0.5)*warp_clouds_scale;
|
||||
float warp_clouds_sparse = texture(noise_sparse, vec2(0.5,1) * warp_uv).r;
|
||||
float warp_clouds_fine = texture(noise_sparse, vec2(2,1) * warp_uv_inv).r;
|
||||
|
||||
vec4 warp = vec4(vec3(0), 1);
|
||||
warp += vec4(vec3(0.3,0.2,0.9)*warp_clouds_sparse, 0);
|
||||
warp += vec4(vec3(0.5,0.0,0.5)*(warp_clouds_fine*0.5+warp_clouds_sparse)*abs(SCREEN_UV.y-0.5), 0);
|
||||
|
||||
COLOR = mix(clouds + stars, warp*warp_boost, warp_opacity);
|
||||
}"
|
||||
|
||||
[sub_resource type="OpenSimplexNoise" id=2]
|
||||
period = 2.0
|
||||
persistence = 0.6
|
||||
lacunarity = 3.0
|
||||
|
||||
[sub_resource type="NoiseTexture" id=3]
|
||||
seamless = true
|
||||
noise = SubResource( 2 )
|
||||
|
||||
[sub_resource type="OpenSimplexNoise" id=4]
|
||||
|
||||
[sub_resource type="NoiseTexture" id=5]
|
||||
width = 1024
|
||||
height = 1024
|
||||
seamless = true
|
||||
noise = SubResource( 4 )
|
||||
|
||||
[resource]
|
||||
shader = SubResource( 1 )
|
||||
shader_param/scroll_speed = 0.0
|
||||
shader_param/warp_boost = 0.0
|
||||
shader_param/warp_opacity = 0.0
|
||||
shader_param/noise_sparse = SubResource( 5 )
|
||||
shader_param/noise_fine = SubResource( 3 )
|
37
Scenes/InEditorMap.gd
Normal file
37
Scenes/InEditorMap.gd
Normal file
|
@ -0,0 +1,37 @@
|
|||
extends Node2D
|
||||
|
||||
var debug_areas = false
|
||||
|
||||
const ProbeElectricity = preload("res://Actors/Systems/Electricity/ElectricProbe.tscn")
|
||||
|
||||
onready var tilemaps = [ $tiles/base, $tiles/cables, $tiles/floor, $tiles/walls ]
|
||||
|
||||
onready var pois = $pois
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
# Run autotile conversions and generate occlusions
|
||||
#$tiles/walls.run_conversions()
|
||||
|
||||
# Electricity setup
|
||||
#make_electric_probes($tiles/cables, "Wire")
|
||||
|
||||
# Tileset related functions
|
||||
|
||||
func make_electric_probes(tilemap: TileMap, tile_name: String):
|
||||
var tile_id = tilemap.tile_set.find_tile_by_name(tile_name)
|
||||
for cell in tilemap.get_used_cells_by_id(tile_id):
|
||||
var coord = tilemap.map_to_world(cell)
|
||||
var probe = ProbeElectricity.instance()
|
||||
probe.position = coord
|
||||
tilemap.add_child(probe)
|
||||
|
||||
func get_pois(type_filter, class_filter) -> Array:
|
||||
var filtered = []
|
||||
for child in $pois.get_children():
|
||||
if type_filter != null and child.poitype != type_filter:
|
||||
continue
|
||||
if class_filter != null and child.poiclass != class_filter:
|
||||
continue
|
||||
filtered.append(child)
|
||||
return filtered
|
58
Scenes/MapEditor.gd
Normal file
58
Scenes/MapEditor.gd
Normal file
|
@ -0,0 +1,58 @@
|
|||
extends Control
|
||||
|
||||
onready var map_menu = $menu/menubar/MapMenu.get_popup()
|
||||
onready var map_node = $map
|
||||
|
||||
const MAP_SCALE_MAX = 8
|
||||
const MAP_SCALE_MIN = 0.25
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
# Prevent input handler from running when other dialogs/actions are focused
|
||||
var input_lock = false
|
||||
|
||||
# Drag variables
|
||||
var dragging = false
|
||||
var view_origin = Vector2.ZERO
|
||||
var mouse_origin = Vector2.ZERO
|
||||
|
||||
func _input(ev: InputEvent):
|
||||
if input_lock:
|
||||
return
|
||||
|
||||
if ev is InputEventMouseMotion:
|
||||
if dragging:
|
||||
map_node.position = view_origin - (mouse_origin - ev.global_position)
|
||||
else:
|
||||
# Map cursor location to grid
|
||||
var mouseOffset = ev.global_position - map_node.global_position
|
||||
|
||||
|
||||
if ev is InputEventMouseButton:
|
||||
var mouse = ev as InputEventMouseButton
|
||||
if mouse.pressed:
|
||||
match ev.button_index:
|
||||
BUTTON_WHEEL_UP:
|
||||
# Zoom in
|
||||
if map_node.scale.x < MAP_SCALE_MAX:
|
||||
if map_node.scale.x < 1:
|
||||
map_node.scale *= 2
|
||||
else:
|
||||
map_node.scale += Vector2.ONE
|
||||
BUTTON_WHEEL_DOWN:
|
||||
# Zoom out
|
||||
if map_node.scale.x > MAP_SCALE_MIN:
|
||||
if map_node.scale.x <= 1:
|
||||
map_node.scale /= 2
|
||||
else:
|
||||
map_node.scale -= Vector2.ONE
|
||||
BUTTON_MIDDLE:
|
||||
view_origin = map_node.position
|
||||
mouse_origin = ev.global_position
|
||||
dragging = true
|
||||
else:
|
||||
match ev.button_index:
|
||||
BUTTON_MIDDLE:
|
||||
dragging = false
|
||||
map_node.position = view_origin - (mouse_origin - ev.global_position)
|
293
Scenes/MapEditor.tscn
Normal file
293
Scenes/MapEditor.tscn
Normal file
|
@ -0,0 +1,293 @@
|
|||
[gd_scene load_steps=23 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/tgstation/1x1.tres" type="TileSet" 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]
|
||||
[ext_resource path="res://Scenes/Rendering/MapTiles.gd" type="Script" id=8]
|
||||
[ext_resource path="res://Graphics/UI/uifont.tres" type="DynamicFont" id=9]
|
||||
[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/tgstation/floors.png" type="Texture" id=12]
|
||||
[ext_resource path="res://Graphics/tgstation/wires-l2.png" type="Texture" id=13]
|
||||
[ext_resource path="res://Graphics/tgstation/wall.png" type="Texture" id=14]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
content_margin_left = 15.0
|
||||
content_margin_right = 15.0
|
||||
content_margin_top = 5.0
|
||||
content_margin_bottom = 5.0
|
||||
bg_color = Color( 0.0588235, 0.0627451, 0.105882, 0.784314 )
|
||||
corner_radius_top_left = 10
|
||||
corner_radius_top_right = 10
|
||||
corner_radius_bottom_right = 10
|
||||
corner_radius_bottom_left = 10
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=2]
|
||||
content_margin_left = 10.0
|
||||
content_margin_right = 10.0
|
||||
bg_color = Color( 0.364706, 0.45098, 0.607843, 0.392157 )
|
||||
corner_radius_top_left = 3
|
||||
corner_radius_top_right = 3
|
||||
corner_radius_bottom_right = 3
|
||||
corner_radius_bottom_left = 3
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=3]
|
||||
content_margin_left = 10.0
|
||||
content_margin_right = 10.0
|
||||
bg_color = Color( 0.305882, 0.368627, 0.576471, 0.784314 )
|
||||
corner_radius_top_left = 3
|
||||
corner_radius_top_right = 3
|
||||
corner_radius_bottom_right = 3
|
||||
corner_radius_bottom_left = 3
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id=4]
|
||||
content_margin_left = 10.0
|
||||
content_margin_right = 10.0
|
||||
|
||||
[sub_resource type="ButtonGroup" id=6]
|
||||
|
||||
[sub_resource type="AtlasTexture" id=5]
|
||||
atlas = ExtResource( 12 )
|
||||
region = Rect2( 32, 192, 32, 32 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=7]
|
||||
atlas = ExtResource( 13 )
|
||||
region = Rect2( 64, 224, 32, 32 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=8]
|
||||
atlas = ExtResource( 12 )
|
||||
region = Rect2( 96, 160, 32, 32 )
|
||||
|
||||
[node name="Control" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 10 )
|
||||
__meta__ = {
|
||||
"_edit_lock_": true,
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="background" type="ColorRect" parent="."]
|
||||
material = ExtResource( 1 )
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
color = Color( 0, 0, 0, 1 )
|
||||
__meta__ = {
|
||||
"_edit_lock_": true,
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="map" type="Node2D" parent="."]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="cursor" type="Node2D" parent="map"]
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="map/cursor"]
|
||||
texture = ExtResource( 14 )
|
||||
centered = false
|
||||
|
||||
[node name="grid" type="Sprite" parent="map"]
|
||||
position = Vector2( -2560, -2800 )
|
||||
texture = ExtResource( 11 )
|
||||
centered = false
|
||||
region_enabled = true
|
||||
region_rect = Rect2( 0, 0, 6400, 6400 )
|
||||
__meta__ = {
|
||||
"_edit_lock_": true
|
||||
}
|
||||
|
||||
[node name="tiles" type="Node2D" parent="map"]
|
||||
|
||||
[node name="base" type="TileMap" parent="map/tiles"]
|
||||
z_index = 1
|
||||
z_as_relative = false
|
||||
tile_set = ExtResource( 5 )
|
||||
cell_size = Vector2( 32, 32 )
|
||||
cell_quadrant_size = 32
|
||||
occluder_light_mask = -2147483647
|
||||
format = 1
|
||||
|
||||
[node name="cables" type="TileMap" parent="map/tiles"]
|
||||
z_index = 2
|
||||
z_as_relative = false
|
||||
tile_set = ExtResource( 7 )
|
||||
cell_size = Vector2( 32, 32 )
|
||||
cell_quadrant_size = 32
|
||||
occluder_light_mask = -2147483647
|
||||
format = 1
|
||||
|
||||
[node name="floor" type="TileMap" parent="map/tiles"]
|
||||
z_index = 3
|
||||
z_as_relative = false
|
||||
tile_set = ExtResource( 6 )
|
||||
cell_size = Vector2( 32, 32 )
|
||||
cell_quadrant_size = 32
|
||||
occluder_light_mask = -2147483647
|
||||
format = 1
|
||||
|
||||
[node name="walls" type="TileMap" parent="map/tiles"]
|
||||
z_index = 4
|
||||
z_as_relative = false
|
||||
tile_set = ExtResource( 3 )
|
||||
cell_size = Vector2( 32, 32 )
|
||||
cell_quadrant_size = 32
|
||||
occluder_light_mask = -2147483647
|
||||
format = 1
|
||||
script = ExtResource( 8 )
|
||||
extended_tilemap_node = NodePath("../../../VBoxContainer/map/tiles/1x1")
|
||||
|
||||
[node name="1x1" type="TileMap" parent="map/tiles"]
|
||||
z_index = 5
|
||||
z_as_relative = false
|
||||
tile_set = ExtResource( 4 )
|
||||
cell_size = Vector2( 16, 16 )
|
||||
format = 1
|
||||
|
||||
[node name="engines" type="Node2D" parent="map"]
|
||||
modulate = Color( 0.980392, 0.980392, 0.980392, 1 )
|
||||
__meta__ = {
|
||||
"_edit_group_": true,
|
||||
"_edit_lock_": true
|
||||
}
|
||||
|
||||
[node name="objects" type="Node2D" parent="map"]
|
||||
z_index = 10
|
||||
__meta__ = {
|
||||
"_editor_description_": ""
|
||||
}
|
||||
|
||||
[node name="sockets" type="Node2D" parent="map"]
|
||||
z_index = 2
|
||||
z_as_relative = false
|
||||
|
||||
[node name="lights" type="Node2D" parent="map"]
|
||||
modulate = Color( 0.980392, 0.980392, 0.980392, 1 )
|
||||
z_index = 11
|
||||
__meta__ = {
|
||||
"_edit_group_": true,
|
||||
"_edit_lock_": true
|
||||
}
|
||||
|
||||
[node name="pois" type="Node2D" parent="map"]
|
||||
z_index = 999
|
||||
|
||||
[node name="areas" type="Node2D" parent="map"]
|
||||
|
||||
[node name="menu" type="PanelContainer" parent="."]
|
||||
margin_left = 5.0
|
||||
margin_top = 5.0
|
||||
margin_right = 1275.0
|
||||
margin_bottom = 43.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Label" type="Label" parent="menu"]
|
||||
margin_left = 526.0
|
||||
margin_top = 5.0
|
||||
margin_right = 744.0
|
||||
margin_bottom = 33.0
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 6
|
||||
custom_styles/normal = SubResource( 1 )
|
||||
custom_fonts/font = ExtResource( 9 )
|
||||
text = "- Untitled (untitled.omd) -"
|
||||
align = 1
|
||||
|
||||
[node name="menubar" type="HBoxContainer" parent="menu"]
|
||||
margin_left = 4.0
|
||||
margin_top = 4.0
|
||||
margin_right = 1266.0
|
||||
margin_bottom = 34.0
|
||||
rect_min_size = Vector2( 0, 30 )
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="MapMenu" type="MenuButton" parent="menu/menubar"]
|
||||
margin_right = 46.0
|
||||
margin_bottom = 30.0
|
||||
custom_styles/hover = SubResource( 2 )
|
||||
custom_styles/pressed = SubResource( 3 )
|
||||
custom_styles/normal = SubResource( 4 )
|
||||
custom_fonts/font = ExtResource( 9 )
|
||||
text = "Map"
|
||||
flat = false
|
||||
switch_on_hover = true
|
||||
|
||||
[node name="PlayMenu" type="MenuButton" parent="menu/menubar"]
|
||||
visible = false
|
||||
margin_left = 50.0
|
||||
margin_right = 98.0
|
||||
margin_bottom = 30.0
|
||||
custom_styles/hover = SubResource( 2 )
|
||||
custom_styles/pressed = SubResource( 3 )
|
||||
custom_styles/normal = SubResource( 4 )
|
||||
custom_fonts/font = ExtResource( 9 )
|
||||
text = "Play"
|
||||
flat = false
|
||||
|
||||
[node name="layers" type="PanelContainer" parent="."]
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 5.0
|
||||
margin_top = -177.0
|
||||
margin_right = 57.0
|
||||
margin_bottom = -5.0
|
||||
size_flags_vertical = 13
|
||||
|
||||
[node name="buttons" type="VBoxContainer" parent="layers"]
|
||||
margin_left = 4.0
|
||||
margin_top = 4.0
|
||||
margin_right = 48.0
|
||||
margin_bottom = 168.0
|
||||
alignment = 2
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="walls" type="Button" parent="layers/buttons"]
|
||||
margin_right = 44.0
|
||||
margin_bottom = 38.0
|
||||
rect_min_size = Vector2( 32, 32 )
|
||||
size_flags_horizontal = 13
|
||||
size_flags_vertical = 13
|
||||
toggle_mode = true
|
||||
group = SubResource( 6 )
|
||||
icon = ExtResource( 14 )
|
||||
|
||||
[node name="floor" type="Button" parent="layers/buttons"]
|
||||
margin_top = 42.0
|
||||
margin_right = 44.0
|
||||
margin_bottom = 80.0
|
||||
rect_min_size = Vector2( 32, 32 )
|
||||
size_flags_horizontal = 13
|
||||
size_flags_vertical = 13
|
||||
toggle_mode = true
|
||||
group = SubResource( 6 )
|
||||
icon = SubResource( 5 )
|
||||
|
||||
[node name="cables" type="Button" parent="layers/buttons"]
|
||||
margin_top = 84.0
|
||||
margin_right = 44.0
|
||||
margin_bottom = 122.0
|
||||
rect_min_size = Vector2( 32, 32 )
|
||||
size_flags_horizontal = 13
|
||||
size_flags_vertical = 13
|
||||
toggle_mode = true
|
||||
group = SubResource( 6 )
|
||||
icon = SubResource( 7 )
|
||||
|
||||
[node name="base" type="Button" parent="layers/buttons"]
|
||||
margin_top = 126.0
|
||||
margin_right = 44.0
|
||||
margin_bottom = 164.0
|
||||
rect_min_size = Vector2( 32, 32 )
|
||||
size_flags_horizontal = 13
|
||||
size_flags_vertical = 13
|
||||
toggle_mode = true
|
||||
group = SubResource( 6 )
|
||||
icon = SubResource( 8 )
|
|
@ -1,7 +0,0 @@
|
|||
[plugin]
|
||||
|
||||
name="PowerNetworkHelper"
|
||||
description="Helper tools for connecting devices to power networks"
|
||||
author="Hamcha"
|
||||
version="0.1"
|
||||
script="plugin.gd"
|
|
@ -1,13 +0,0 @@
|
|||
tool
|
||||
extends EditorPlugin
|
||||
|
||||
var dock
|
||||
|
||||
func _enter_tree():
|
||||
dock = preload("res://addons/pnhelper/pngui.tscn").instance()
|
||||
dock.api = self
|
||||
add_control_to_dock(DOCK_SLOT_RIGHT_BL, dock)
|
||||
|
||||
func _exit_tree():
|
||||
remove_control_from_docks(dock)
|
||||
dock.free()
|
|
@ -1,57 +0,0 @@
|
|||
tool
|
||||
|
||||
extends Control
|
||||
|
||||
var socketTemplate = preload("res://Actors/Objects/ElectricSocket/ElectricSocket.tscn")
|
||||
|
||||
var api : EditorPlugin
|
||||
|
||||
onready var socket_types = $Commands/MakeSocket/Type
|
||||
|
||||
func _ready():
|
||||
# Add make_socket options
|
||||
socket_types.add_item("SNK", 0)
|
||||
socket_types.add_item("SRC", 1)
|
||||
socket_types.add_item("BID", 2)
|
||||
|
||||
func _make_socket(direction: String) -> void:
|
||||
var socket_dir = null
|
||||
var socket_type = null
|
||||
var offset = Vector2.ZERO
|
||||
match direction:
|
||||
"up":
|
||||
socket_dir = ElectricSocket.Direction.DOWN
|
||||
offset.y = -32
|
||||
"left":
|
||||
socket_dir = ElectricSocket.Direction.RIGHT
|
||||
offset.x = -32
|
||||
"down":
|
||||
socket_dir = ElectricSocket.Direction.UP
|
||||
offset.y = 32
|
||||
"right":
|
||||
socket_dir = ElectricSocket.Direction.LEFT
|
||||
offset.x = 32
|
||||
match socket_types.get_selected_id():
|
||||
0:
|
||||
socket_type = ElectricSocket.Flow.SINK
|
||||
1:
|
||||
socket_type = ElectricSocket.Flow.SOURCE
|
||||
2:
|
||||
socket_type = ElectricSocket.Flow.BIDIRECTIONAL
|
||||
var map = api.get_editor_interface().get_edited_scene_root()
|
||||
var sockets = map.get_node("sockets")
|
||||
var nodes = api.get_editor_interface().get_selection().get_selected_nodes()
|
||||
for node in nodes:
|
||||
var socket = socketTemplate.instance()
|
||||
sockets.add_child(socket)
|
||||
socket.direction = socket_dir
|
||||
socket.flow = socket_type
|
||||
socket.owner = map
|
||||
socket.global_position = node.global_position + offset
|
||||
socket.connectionPaths = [socket.get_path_to(node)]
|
||||
|
||||
func _area_debug_modified(button_pressed):
|
||||
var map = api.get_editor_interface().get_edited_scene_root() as GameMap
|
||||
map.debug_areas = button_pressed
|
||||
for area in map.get_node("areas").get_children():
|
||||
area.update()
|
|
@ -1,73 +0,0 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/pnhelper/pngui.gd" type="Script" id=1]
|
||||
|
||||
[node name="Mapping tools" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Commands" type="VBoxContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="MakeSocket" type="HBoxContainer" parent="Commands"]
|
||||
margin_right = 1280.0
|
||||
margin_bottom = 20.0
|
||||
|
||||
[node name="Label" type="Label" parent="Commands/MakeSocket"]
|
||||
margin_top = 3.0
|
||||
margin_right = 84.0
|
||||
margin_bottom = 17.0
|
||||
text = "Make socket "
|
||||
|
||||
[node name="Type" type="OptionButton" parent="Commands/MakeSocket"]
|
||||
margin_left = 88.0
|
||||
margin_right = 142.0
|
||||
margin_bottom = 20.0
|
||||
text = "SNK"
|
||||
items = [ "SNK", null, false, 0, null, "SRC", null, false, 1, null, "BID", null, false, 2, null ]
|
||||
selected = 0
|
||||
|
||||
[node name="Left" type="Button" parent="Commands/MakeSocket"]
|
||||
margin_left = 146.0
|
||||
margin_right = 166.0
|
||||
margin_bottom = 20.0
|
||||
text = "<"
|
||||
|
||||
[node name="Up" type="Button" parent="Commands/MakeSocket"]
|
||||
margin_left = 170.0
|
||||
margin_right = 189.0
|
||||
margin_bottom = 20.0
|
||||
text = "^"
|
||||
|
||||
[node name="Down" type="Button" parent="Commands/MakeSocket"]
|
||||
margin_left = 193.0
|
||||
margin_right = 212.0
|
||||
margin_bottom = 20.0
|
||||
text = "v"
|
||||
|
||||
[node name="Right" type="Button" parent="Commands/MakeSocket"]
|
||||
margin_left = 216.0
|
||||
margin_right = 236.0
|
||||
margin_bottom = 20.0
|
||||
text = ">"
|
||||
|
||||
[node name="DebugAreas" type="CheckBox" parent="Commands"]
|
||||
margin_top = 24.0
|
||||
margin_right = 1280.0
|
||||
margin_bottom = 48.0
|
||||
text = "Show areas"
|
||||
[connection signal="pressed" from="Commands/MakeSocket/Left" to="." method="_make_socket" binds= [ "left" ]]
|
||||
[connection signal="pressed" from="Commands/MakeSocket/Up" to="." method="_make_socket" binds= [ "up" ]]
|
||||
[connection signal="pressed" from="Commands/MakeSocket/Down" to="." method="_make_socket" binds= [ "down" ]]
|
||||
[connection signal="pressed" from="Commands/MakeSocket/Right" to="." method="_make_socket" binds= [ "right" ]]
|
||||
[connection signal="toggled" from="Commands/DebugAreas" to="." method="_area_debug_modified"]
|
|
@ -177,7 +177,7 @@ window/size/height=800
|
|||
|
||||
[editor_plugins]
|
||||
|
||||
enabled=PoolStringArray( "pnhelper" )
|
||||
enabled=PoolStringArray( )
|
||||
|
||||
[gui]
|
||||
|
||||
|
|
Reference in a new issue