Updated settings and dialogs

This commit is contained in:
Flairieve 2019-11-26 23:09:09 -06:00
parent f92049d2ae
commit 2b33048819
16 changed files with 333 additions and 306 deletions

View File

@ -0,0 +1,22 @@
extends Control
var util = preload("res://addons/graphics_editor/Util.gd")
func _ready():
var dialog_folder = get_script().resource_path.get_base_dir()
var files = util.get_files_from_path(dialog_folder.plus_file("Dialogs"))
for i in files:
var file_name = util.get_file_name(i)
if i.get_extension() == "tscn":
var new_scene = load(i).instance()
add_child(new_scene)
#new_scene.set_anchors_preset(PRESET_CENTER)
func show_dialog(dialog_name):
var dialog_node = get_node_or_null(dialog_name)
if dialog_node:
dialog_node.set_anchors_preset(PRESET_CENTER)
dialog_node.rect_position = Vector2((rect_size.x / 2) - (dialog_node.rect_size.x / 2), (rect_size.y / 2) - (dialog_node.rect_size.y / 2))
dialog_node.show()
else:
push_error("Can't load dialog! Either missing node or file?")

View File

@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/graphics_editor/ExpandCanvas.gd" type="Script" id=1]
[ext_resource path="res://addons/graphics_editor/Dialogs/ExpandCanvas.gd" type="Script" id=1]
[node name="ExpandCanvas" type="WindowDialog"]
anchor_right = 1.0

View File

@ -1,7 +1,7 @@
tool
extends FileDialog
onready var canvas = get_parent().get_node("PaintCanvasContainer/ViewportContainer/Viewport/PaintCanvas")
onready var canvas = get_parent().get_parent().get_node("PaintCanvasContainer/ViewportContainer/Viewport/PaintCanvas")
var file_path = ""

View File

@ -1,6 +1,7 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/graphics_editor/NewImage.gd" type="Script" id=1]
[ext_resource path="res://addons/graphics_editor/Dialogs/NewImage.gd" type="Script" id=1]
[node name="NewImage" type="WindowDialog"]
anchor_right = 1.0

View File

@ -1,7 +1,7 @@
tool
extends FileDialog
onready var canvas = get_parent().get_node("PaintCanvasContainer/ViewportContainer/Viewport/PaintCanvas")
onready var canvas = get_parent().get_parent().get_node("PaintCanvasContainer/ViewportContainer/Viewport/PaintCanvas")
var file_path = ""

View File

@ -0,0 +1,197 @@
tool
extends Control
#TODO: Make the settings auto generate!
onready var editor = get_parent().get_parent()
onready var canvas_outline = editor.get_node("PaintCanvasContainer/ViewportContainer/Viewport/PaintCanvas/CanvasOutline")
onready var visual_grid_1 = editor.get_node("PaintCanvasContainer/ViewportContainer/Viewport/PaintCanvas/Grids/VisualGrid")
onready var visual_grid_2 = editor.get_node("PaintCanvasContainer/ViewportContainer/Viewport/PaintCanvas/Grids/VisualGrid2")
onready var scroll_container = get_node("ScrollContainer")
#{
# "CATEGORY": {
# "SETTINGNAME": {
# "node": "PATHTONODE",
# "valueMod": "VALUETOMODIFY",
# "setterType": "SETTERTYPE"
# }
# }
#}
#ValueSetterType List:
#ColorPicker
#CheckButton
#SpinBox
var setting_storage = {
"Canvas Outline": {
"Enabled": {
"node": canvas_outline,
"valueMod": "visible",
"setterType": "CheckBox"
},
"Color": {
"node": canvas_outline,
"valueMod": "color",
"setterType": "ColorPicker"
},
"Width": {
"node": canvas_outline,
"valueMod": "width",
"setterType": "SpinBox"
}
},
"Grids": {
"Grid1_Color": {
"node": visual_grid_1,
"valueMod": "color",
"setterType": "ColorPicker"
},
"Grid1_Size": {
"node": visual_grid_1,
"valueMod": "grid_size",
"setterType": "SpinBox"
},
"Grid2_Color": {
"node": visual_grid_2,
"valueMod": "color",
"setterType": "ColorPicker"
},
"Grid2_Size": {
"node": visual_grid_2,
"valueMod": "grid_size",
"setterType": "SpinBox"
},
}
}
#TODO: Instead of this current system, we can make a function type of system instead like this
#generate_category(name)
#generate_property(category_name, node, valueMod) # setterType is automatically detected from the property it gets from the node
func _ready():
generate_category_container("Canvas Outline")
generate_property_container("Canvas Outline", canvas_outline, "Enabled", "visible")
generate_property_container("Canvas Outline", canvas_outline, "Color", "color")
generate_property_container("Canvas Outline", canvas_outline, "Width", "width")
generate_category_container("Grids")
generate_property_container("Grids", visual_grid_1, "Grid1 Enabled", "visible")
generate_property_container("Grids", visual_grid_1, "Grid1 Color", "color")
generate_property_container("Grids", visual_grid_1, "Grid1 Size", "size")
generate_property_container("Grids", visual_grid_2, "Grid2 Enabled", "visible")
generate_property_container("Grids", visual_grid_2, "Grid2 Color", "color")
generate_property_container("Grids", visual_grid_2, "Grid2 Size", "size")
func generate_settings():
for i in setting_storage:
generate_category_container(i)
for j in setting_storage[i]:
var valuemod = setting_storage[i][j]["valueMod"]
var settertype = setting_storage[i][j]["setterType"]
generate_property_container(i, j, valuemod, settertype)
func generate_category_container(category):
var vboxContainer = VBoxContainer.new()
vboxContainer.name = category
var label = Label.new()
label.text = category + ":"
label.valign = Label.ALIGN_CENTER
vboxContainer.add_child(label)
var vboxPropertiesContainer = VBoxContainer.new()
vboxPropertiesContainer.name = "VBoxContainer"
vboxContainer.add_child(vboxPropertiesContainer)
get_node("ScrollContainer/VBoxContainer").add_child(vboxContainer)
func generate_property_container(category, node, propertyname, valuemod):
var hbox = HBoxContainer.new()
hbox.rect_min_size = Vector2(scroll_container.rect_size.x, 20)
hbox.name = propertyname
hbox.add_constant_override("separation", 0)
var label = Label.new()
label.rect_min_size = Vector2(scroll_container.rect_size.x / 2, 20)
label.text = propertyname.capitalize()
label.align = Label.ALIGN_CENTER
label.valign = Label.ALIGN_CENTER
var settertypenode
print(node, valuemod)
var get_value = node.get(valuemod)
match typeof(get_value):
TYPE_INT:
settertypenode = SpinBox.new()
settertypenode.max_value = 9999
settertypenode.value = get_value
settertypenode.connect("value_changed", self, "on_setting_changed", [node, valuemod, settertypenode, "value"])
pass
TYPE_REAL:
settertypenode = SpinBox.new()
settertypenode.max_value = 9999
settertypenode.value = get_value
settertypenode.connect("value_changed", self, "on_setting_changed", [node, valuemod, settertypenode, "value"])
pass
TYPE_COLOR:
settertypenode = ColorPickerButton.new()
settertypenode.color = get_value
settertypenode.connect("color_changed", self, "on_setting_changed", [node, valuemod, settertypenode, "color"])
pass
TYPE_VECTOR2:
pass
TYPE_BOOL:
settertypenode = CheckBox.new()
settertypenode.text = "On"
settertypenode.pressed = get_value
var styleboxflat = StyleBoxFlat.new()
styleboxflat.bg_color = Color(0.254902, 0.254902, 0.254902)
settertypenode.add_stylebox_override("normal", styleboxflat)
settertypenode.add_stylebox_override("hover", styleboxflat)
settertypenode.add_stylebox_override("pressed", styleboxflat)
settertypenode.connect("pressed", self, "on_setting_changed", [null, node, valuemod, settertypenode, "pressed"])
pass
# match settertype:
# "ColorPicker":
# settertypenode = ColorPickerButton.new()
# "CheckBox":
# settertypenode = CheckBox.new()
# settertypenode.text = "On"
# var styleboxflat = StyleBoxFlat.new()
# styleboxflat.bg_color = Color(0.254902, 0.254902, 0.254902)
# settertypenode.add_stylebox_override("normal", styleboxflat)
# settertypenode.add_stylebox_override("hover", styleboxflat)
# settertypenode.add_stylebox_override("pressed", styleboxflat)
# "SpinBox":
# settertypenode = SpinBox.new()
if settertypenode == null:
push_error("Setter type not found! Returning! DEBUG_INFO: %s | %s | %s" % [node, node.name, typeof(get_value)])
return
settertypenode.rect_min_size = Vector2(scroll_container.rect_size.x / 2, 20)
hbox.add_child(label)
hbox.add_child(settertypenode)
get_node("ScrollContainer/VBoxContainer/%s/VBoxContainer" % [category]).add_child(hbox)
func _on_Ok_pressed():
hide()
func on_setting_changed(default_signal, node, value_to_get, setter, value_setter_get):
var setter_new_value = setter.get(value_setter_get)
node.set(value_to_get, setter_new_value)
func _on_CanvasOutline_Enabled_value_changed(button_pressed):
canvas_outline.visible = button_pressed
func _on_CanvasOutline_Color_value_changed(color):
canvas_outline.color = color
func _on_CanvasOutline_SpinBox_value_changed(value):
canvas_outline.width = value
func _on_Grids_Grid1Color_value_changed(color):
visual_grid_1.color = color
func _on_Grids_Grid1Size_value_changed(value):
visual_grid_1.size = value
func _on_Grids_Grid2Color_value_changed(color):
visual_grid_2.color = color
func _on_Grids_Grid2Size_value_changed(value):
visual_grid_2.size = value

View File

@ -0,0 +1,36 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/graphics_editor/Dialogs/Settings.gd" type="Script" id=1]
[node name="Settings" type="WindowDialog"]
visible = true
margin_top = 20.0
margin_right = 250.0
margin_bottom = 270.0
popup_exclusive = true
window_title = "Settings"
script = ExtResource( 1 )
[node name="Ok" type="Button" parent="."]
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -90.0
margin_top = -30.0
margin_right = -10.0
margin_bottom = -10.0
text = "Ok"
[node name="ScrollContainer" type="ScrollContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_right = -12.0
margin_bottom = -40.0
scroll_horizontal_enabled = false
[node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer"]
margin_right = 100.0
margin_bottom = 36.0
custom_constants/separation = 0
[connection signal="pressed" from="Ok" to="." method="_on_Ok_pressed"]

View File

@ -133,11 +133,12 @@ var zoom_amount = 0.5
func _input(event):
if event is InputEventMouseButton:
if event.is_pressed():
if event.button_index == BUTTON_WHEEL_UP:
if camera.zoom - Vector2(zoom_amount, zoom_amount) > Vector2(0, 0):
camera.zoom -= Vector2(zoom_amount, zoom_amount)
elif event.button_index == BUTTON_WHEEL_DOWN:
camera.zoom += Vector2(zoom_amount, zoom_amount)
if paint_canvas_container_node.mouse_in_region and paint_canvas_container_node.mouse_on_top:
if event.button_index == BUTTON_WHEEL_UP:
if camera.zoom - Vector2(zoom_amount, zoom_amount) > Vector2(0, 0):
camera.zoom -= Vector2(zoom_amount, zoom_amount)
elif event.button_index == BUTTON_WHEEL_DOWN:
camera.zoom += Vector2(zoom_amount, zoom_amount)
func add_text_info_variables():
textinfo.add_text_info("FPS")

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=19 format=2]
[gd_scene load_steps=17 format=2]
[ext_resource path="res://addons/graphics_editor/Editor.gd" type="Script" id=1]
[ext_resource path="res://addons/graphics_editor/PaintCanvasContainer.gd" type="Script" id=2]
@ -11,12 +11,10 @@
[ext_resource path="res://addons/graphics_editor/ColorPicker.gd" type="Script" id=9]
[ext_resource path="res://addons/graphics_editor/Layers.gd" type="Script" id=10]
[ext_resource path="res://addons/graphics_editor/TextInfo.gd" type="Script" id=11]
[ext_resource path="res://addons/graphics_editor/SaveFileDialog.gd" type="Script" id=12]
[ext_resource path="res://addons/graphics_editor/Settings.tscn" type="PackedScene" id=13]
[ext_resource path="res://addons/graphics_editor/NewImage.tscn" type="PackedScene" id=14]
[ext_resource path="res://addons/graphics_editor/LoadFileDialog.gd" type="Script" id=15]
[ext_resource path="res://addons/graphics_editor/ExpandCanvas.tscn" type="PackedScene" id=16]
[ext_resource path="res://addons/graphics_editor/ToolManager.gd" type="Script" id=17]
[ext_resource path="res://addons/graphics_editor/Dialogs.gd" type="Script" id=12]
[ext_resource path="res://addons/graphics_editor/Dialogs/SaveFileDialog.gd" type="Script" id=13]
[ext_resource path="res://addons/graphics_editor/Dialogs/LoadFileDialog.gd" type="Script" id=14]
[ext_resource path="res://addons/graphics_editor/ToolManager.gd" type="Script" id=15]
[sub_resource type="World" id=1]
@ -31,6 +29,7 @@ __meta__ = {
}
[node name="PaintCanvasContainer" type="Control" parent="."]
editor/display_folded = true
show_behind_parent = true
anchor_right = 1.0
anchor_bottom = 1.0
@ -75,6 +74,10 @@ anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 1600.0
margin_bottom = 1600.0
grid_size = 16
canvas_size = Vector2( 100, 100 )
chunk_size = Vector2( 10, 10 )
can_draw = true
[node name="PixelCursorHighlight" type="Control" parent="PaintCanvasContainer/ViewportContainer/Viewport/PaintCanvas"]
anchor_right = 1.0
@ -96,11 +99,16 @@ __meta__ = {
[node name="VisualGrid" parent="PaintCanvasContainer/ViewportContainer/Viewport/PaintCanvas/Grids" instance=ExtResource( 6 )]
mouse_filter = 2
color = Color( 0.639216, 0.639216, 0.639216, 1 )
size = 16
zoom = 0
offset = Vector2( 0, 0 )
[node name="VisualGrid2" parent="PaintCanvasContainer/ViewportContainer/Viewport/PaintCanvas/Grids" instance=ExtResource( 6 )]
mouse_filter = 2
color = Color( 1, 1, 1, 1 )
size = 160.0
zoom = 0
offset = Vector2( 0, 0 )
[node name="CanvasOutline" type="Control" parent="PaintCanvasContainer/ViewportContainer/Viewport/PaintCanvas"]
anchor_right = 1.0
@ -114,6 +122,7 @@ color = Color( 0, 1, 0, 1 )
width = 3.0
[node name="Navbar" type="Control" parent="."]
editor/display_folded = true
anchor_right = 1.0
margin_bottom = 20.0
script = ExtResource( 8 )
@ -240,7 +249,16 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="SaveFileDialog" type="FileDialog" parent="."]
[node name="Dialogs" type="Control" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
script = ExtResource( 12 )
__meta__ = {
"_edit_lock_": true
}
[node name="SaveFileDialog" type="FileDialog" parent="Dialogs"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
@ -250,29 +268,9 @@ margin_top = -165.0
margin_right = 340.0
margin_bottom = 165.0
filters = PoolStringArray( "*.png ; PNG Images" )
script = ExtResource( 12 )
script = ExtResource( 13 )
[node name="Settings" parent="." instance=ExtResource( 13 )]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -155.0
margin_top = -150.0
margin_right = 155.0
margin_bottom = 150.0
[node name="NewImage" parent="." instance=ExtResource( 14 )]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -145.0
margin_top = -40.0
margin_right = 145.0
margin_bottom = 40.0
[node name="LoadFileDialog" type="FileDialog" parent="."]
[node name="LoadFileDialog" type="FileDialog" parent="Dialogs"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
@ -284,23 +282,13 @@ margin_bottom = 165.0
window_title = "Open a File"
mode = 0
filters = PoolStringArray( "*.png ; PNG Images" )
script = ExtResource( 15 )
script = ExtResource( 14 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ExpandCanvas" parent="." instance=ExtResource( 16 )]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -145.0
margin_top = -40.0
margin_right = 145.0
margin_bottom = 40.0
[node name="ToolManager" type="Node" parent="."]
script = ExtResource( 17 )
script = ExtResource( 15 )
[connection signal="mouse_entered" from="PaintCanvasContainer" to="PaintCanvasContainer" method="_on_PaintCanvasContainer_mouse_entered"]
[connection signal="mouse_exited" from="PaintCanvasContainer" to="PaintCanvasContainer" method="_on_PaintCanvasContainer_mouse_exited"]
[connection signal="pressed" from="ToolMenu/Buttons/PaintTool" to="." method="_on_PaintTool_pressed"]
@ -311,11 +299,11 @@ script = ExtResource( 17 )
[connection signal="mouse_entered" from="ToolMenu/Buttons/ColorPicker" to="ToolMenu/Buttons/ColorPicker" method="_on_ColorPicker_mouse_entered"]
[connection signal="mouse_exited" from="ToolMenu/Buttons/ColorPicker" to="ToolMenu/Buttons/ColorPicker" method="_on_ColorPicker_mouse_exited"]
[connection signal="pressed" from="ToolMenu/Layers/Panel/AddLayer" to="ToolMenu/Layers" method="_on_AddLayer_pressed"]
[connection signal="about_to_show" from="SaveFileDialog" to="SaveFileDialog" method="_on_SaveFileDialog_about_to_show"]
[connection signal="confirmed" from="SaveFileDialog" to="SaveFileDialog" method="_on_SaveFileDialog_confirmed"]
[connection signal="file_selected" from="SaveFileDialog" to="SaveFileDialog" method="_on_SaveFileDialog_file_selected"]
[connection signal="visibility_changed" from="SaveFileDialog" to="SaveFileDialog" method="_on_SaveFileDialog_visibility_changed"]
[connection signal="about_to_show" from="LoadFileDialog" to="LoadFileDialog" method="_on_LoadFileDialog_about_to_show"]
[connection signal="confirmed" from="LoadFileDialog" to="LoadFileDialog" method="_on_LoadFileDialog_confirmed"]
[connection signal="file_selected" from="LoadFileDialog" to="LoadFileDialog" method="_on_LoadFileDialog_file_selected"]
[connection signal="visibility_changed" from="LoadFileDialog" to="LoadFileDialog" method="_on_LoadFileDialog_visibility_changed"]
[connection signal="about_to_show" from="Dialogs/SaveFileDialog" to="Dialogs/SaveFileDialog" method="_on_SaveFileDialog_about_to_show"]
[connection signal="confirmed" from="Dialogs/SaveFileDialog" to="Dialogs/SaveFileDialog" method="_on_SaveFileDialog_confirmed"]
[connection signal="file_selected" from="Dialogs/SaveFileDialog" to="Dialogs/SaveFileDialog" method="_on_SaveFileDialog_file_selected"]
[connection signal="visibility_changed" from="Dialogs/SaveFileDialog" to="Dialogs/SaveFileDialog" method="_on_SaveFileDialog_visibility_changed"]
[connection signal="about_to_show" from="Dialogs/LoadFileDialog" to="Dialogs/LoadFileDialog" method="_on_LoadFileDialog_about_to_show"]
[connection signal="confirmed" from="Dialogs/LoadFileDialog" to="Dialogs/LoadFileDialog" method="_on_LoadFileDialog_confirmed"]
[connection signal="file_selected" from="Dialogs/LoadFileDialog" to="Dialogs/LoadFileDialog" method="_on_LoadFileDialog_file_selected"]
[connection signal="visibility_changed" from="Dialogs/LoadFileDialog" to="Dialogs/LoadFileDialog" method="_on_LoadFileDialog_visibility_changed"]

View File

@ -14,6 +14,8 @@ var navbar_storage = {
}
}
onready var dialogs = get_parent().get_node("Dialogs")
func _ready():
var x_to_add = 0
var menu_button_script = load("res://addons/graphics_editor/MenuButtonExtended.gd")
@ -44,16 +46,17 @@ func _ready():
func button_pressed(button_name, button_item):
if button_name == "File":
if button_item == "New":
get_parent().get_node("NewImage").show()
dialogs.show_dialog("NewImage")
if button_item == "Load":
get_parent().get_node("LoadFileDialog").show()
dialogs.show_dialog("LoadFileDialog")
if button_item == "Save":
get_parent().get_node("SaveFileDialog").show()
dialogs.show_dialog("SaveFileDialog")
if button_item == "Quit":
get_tree().quit()
elif button_name == "Editor":
if button_item == "Settings":
get_parent().get_node("Settings").show()
dialogs.show_dialog("Settings")
#get_parent().get_node("Settings").show()
elif button_item == "Toggle Grid":
var grids_node = get_parent().get_node("PaintCanvasContainer/ViewportContainer/Viewport/PaintCanvas/Grids")
grids_node.visible = !grids_node.visible
@ -61,4 +64,4 @@ func button_pressed(button_name, button_item):
get_parent().camera.position = Vector2(0, 0)
elif button_name == "Image":
if button_item == "Resize":
get_parent().get_node("ExpandCanvas").show()
dialogs.show_dialog("ExpandCanvas")

View File

@ -1,45 +0,0 @@
tool
extends Control
#TODO: Make the settings auto generate!
onready var editor = get_parent()
onready var canvas_outline = get_parent().get_node("PaintCanvasContainer/ViewportContainer/Viewport/PaintCanvas/CanvasOutline")
onready var visual_grid_1 = get_parent().get_node("PaintCanvasContainer/ViewportContainer/Viewport/PaintCanvas/Grids/VisualGrid")
onready var visual_grid_2 = get_parent().get_node("PaintCanvasContainer/ViewportContainer/Viewport/PaintCanvas/Grids/VisualGrid2")
func _ready():
#CanvasOutline settings
get_node("CanvasOutline/Enabled/CheckButton").pressed = canvas_outline.visible
get_node("CanvasOutline/Color/ColorPickerButton").color = canvas_outline.color
get_node("CanvasOutline/Width/SpinBox").value = canvas_outline.width
#Grid settings
get_node("Grids/Grid1Color/ColorPickerButton").color = visual_grid_1.color
get_node("Grids/Grid1Size/SpinBox").value = visual_grid_1.size
get_node("Grids/Grid2Color/ColorPickerButton").color = visual_grid_2.color
get_node("Grids/Grid2Size/SpinBox").value = visual_grid_2.size
func _on_Ok_pressed():
hide()
func _on_CanvasOutline_Enabled_value_changed(button_pressed):
canvas_outline.visible = button_pressed
func _on_CanvasOutline_Color_value_changed(color):
canvas_outline.color = color
func _on_CanvasOutline_SpinBox_value_changed(value):
canvas_outline.width = value
func _on_Grids_Grid1Color_value_changed(color):
visual_grid_1.color = color
func _on_Grids_Grid1Size_value_changed(value):
visual_grid_1.size = value
func _on_Grids_Grid2Color_value_changed(color):
visual_grid_2.color = color
func _on_Grids_Grid2Size_value_changed(value):
visual_grid_2.size = value

View File

@ -1,193 +0,0 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/graphics_editor/Settings.gd" type="Script" id=1]
[node name="Settings" type="WindowDialog"]
margin_right = 310.0
margin_bottom = 300.0
window_title = "Settings"
script = ExtResource( 1 )
[node name="Ok" type="Button" parent="."]
margin_left = 220.0
margin_top = 270.0
margin_right = 300.0
margin_bottom = 290.0
text = "Ok"
[node name="CanvasOutline" type="Control" parent="."]
margin_left = 10.0
margin_top = 10.0
margin_right = 300.0
margin_bottom = 120.0
__meta__ = {
"_edit_group_": true
}
[node name="Label" type="Label" parent="CanvasOutline"]
margin_right = 100.0
margin_bottom = 14.0
text = "Canvas Outline:"
[node name="Enabled" type="Control" parent="CanvasOutline"]
margin_left = 10.0
margin_top = 20.0
margin_right = 290.0
margin_bottom = 40.0
[node name="Label" type="Label" parent="CanvasOutline/Enabled"]
margin_right = 130.0
margin_bottom = 20.0
text = "Enabled:"
valign = 1
[node name="CheckButton" type="CheckButton" parent="CanvasOutline/Enabled"]
margin_left = 210.0
margin_top = -10.0
margin_right = 286.0
margin_bottom = 30.0
pressed = true
[node name="Color" type="Control" parent="CanvasOutline"]
editor/display_folded = true
margin_left = 10.0
margin_top = 50.0
margin_right = 290.0
margin_bottom = 70.0
[node name="Label" type="Label" parent="CanvasOutline/Color"]
margin_right = 130.0
margin_bottom = 20.0
text = "Color:"
valign = 1
[node name="ColorPickerButton" type="ColorPickerButton" parent="CanvasOutline/Color"]
margin_left = 170.0
margin_right = 280.0
margin_bottom = 20.0
[node name="Width" type="Control" parent="CanvasOutline"]
margin_left = 10.0
margin_top = 80.0
margin_right = 290.0
margin_bottom = 100.0
[node name="Label" type="Label" parent="CanvasOutline/Width"]
margin_right = 130.0
margin_bottom = 20.0
rect_rotation = -0.00812905
text = "Width:"
valign = 1
[node name="SpinBox" type="SpinBox" parent="CanvasOutline/Width"]
margin_left = 210.0
margin_right = 284.0
margin_bottom = 24.0
max_value = 9999.0
allow_greater = true
allow_lesser = true
[node name="Grids" type="Control" parent="."]
margin_left = 10.0
margin_top = 120.0
margin_right = 300.0
margin_bottom = 260.0
[node name="Label" type="Label" parent="Grids"]
margin_right = 100.0
margin_bottom = 14.0
text = "Grids:"
[node name="Grid1Color" type="Control" parent="Grids"]
margin_left = 10.0
margin_top = 20.0
margin_right = 290.0
margin_bottom = 40.0
__meta__ = {
"_edit_group_": true
}
[node name="Label" type="Label" parent="Grids/Grid1Color"]
margin_right = 130.0
margin_bottom = 20.0
text = "Grid1 Color:"
valign = 1
[node name="ColorPickerButton" type="ColorPickerButton" parent="Grids/Grid1Color"]
margin_left = 170.0
margin_right = 280.0
margin_bottom = 20.0
[node name="Grid2Color" type="Control" parent="Grids"]
margin_left = 10.0
margin_top = 80.0
margin_right = 290.0
margin_bottom = 100.0
__meta__ = {
"_edit_group_": true
}
[node name="Label" type="Label" parent="Grids/Grid2Color"]
margin_right = 130.0
margin_bottom = 20.0
text = "Grid2 Color:"
valign = 1
[node name="ColorPickerButton" type="ColorPickerButton" parent="Grids/Grid2Color"]
margin_left = 170.0
margin_right = 280.0
margin_bottom = 20.0
[node name="Grid1Size" type="Control" parent="Grids"]
margin_left = 10.0
margin_top = 50.0
margin_right = 290.0
margin_bottom = 70.0
__meta__ = {
"_edit_group_": true
}
[node name="Label" type="Label" parent="Grids/Grid1Size"]
margin_right = 130.0
margin_bottom = 20.0
text = "Grid1 Size:"
valign = 1
[node name="SpinBox" type="SpinBox" parent="Grids/Grid1Size"]
margin_left = 210.0
margin_right = 284.0
margin_bottom = 24.0
max_value = 10000.0
allow_greater = true
allow_lesser = true
[node name="Grid2Size" type="Control" parent="Grids"]
margin_left = 10.0
margin_top = 110.0
margin_right = 290.0
margin_bottom = 130.0
__meta__ = {
"_edit_group_": true
}
[node name="Label" type="Label" parent="Grids/Grid2Size"]
margin_right = 130.0
margin_bottom = 20.0
text = "Grid2 Size:"
valign = 1
[node name="SpinBox" type="SpinBox" parent="Grids/Grid2Size"]
margin_left = 210.0
margin_right = 284.0
margin_bottom = 24.0
max_value = 10000.0
allow_greater = true
allow_lesser = true
[connection signal="pressed" from="Ok" to="." method="_on_Ok_pressed"]
[connection signal="toggled" from="CanvasOutline/Enabled/CheckButton" to="." method="_on_CanvasOutline_Enabled_value_changed"]
[connection signal="color_changed" from="CanvasOutline/Color/ColorPickerButton" to="." method="_on_CanvasOutline_Color_value_changed"]
[connection signal="value_changed" from="CanvasOutline/Width/SpinBox" to="." method="_on_CanvasOutline_SpinBox_value_changed"]
[connection signal="color_changed" from="Grids/Grid1Color/ColorPickerButton" to="." method="_on_Grids_Grid1Color_value_changed"]
[connection signal="color_changed" from="Grids/Grid2Color/ColorPickerButton" to="." method="_on_Grids_Grid2Color_value_changed"]
[connection signal="value_changed" from="Grids/Grid1Size/SpinBox" to="." method="_on_Grids_Grid1Size_value_changed"]
[connection signal="value_changed" from="Grids/Grid2Size/SpinBox" to="." method="_on_Grids_Grid2Size_value_changed"]

View File

@ -1,6 +1,7 @@
tool
extends Node
var util = preload("res://addons/graphics_editor/Util.gd")
var active_tool
func _ready():
@ -8,11 +9,9 @@ func _ready():
func set_active_tool(tool_to_use):
var tool_manager_folder = get_script().resource_path.get_base_dir()
var tool_scripts = get_files_from_path(tool_manager_folder.plus_file("Tools"))
var tool_scripts = util.get_files_from_path(tool_manager_folder.plus_file("Tools"))
for i in tool_scripts:
var file_name_raw = i.get_file()
var file_extension = i.get_extension()
var file_name = file_name_raw.substr(0, file_name_raw.length()-(file_extension.length()+1))
var file_name = util.get_file_name(i)
if file_name == tool_to_use:
var node = Node.new()
node.name = file_name

View File

@ -46,6 +46,24 @@ static func random_color_alt():
static func get_line_string(file, number):
return file.get_as_text().split("\n")[number - 1].strip_edges()
static func get_file_name(path):
var file_name_raw = path.get_file()
var file_extension = path.get_extension()
var file_name = file_name_raw.substr(0, file_name_raw.length()-(file_extension.length()+1))
return file_name
static func get_files_from_path(path):
var file_array = PoolStringArray()
var dir = Directory.new()
if dir.open(path) == OK:
dir.list_dir_begin()
var file_name = dir.get_next()
while (file_name != ""):
if !dir.current_is_dir():
file_array.append(path.plus_file(file_name))
file_name = dir.get_next()
return file_array
static func printv(variable):
var stack = get_stack()[get_stack().size() - 1]
var line = stack.line