Skip to content

Commit

Permalink
Add quodot plugin, viewports now work
Browse files Browse the repository at this point in the history
  • Loading branch information
yaelatletl committed Mar 19, 2020
1 parent d9a6429 commit b47b054
Show file tree
Hide file tree
Showing 87 changed files with 6,437 additions and 133 deletions.
285 changes: 154 additions & 131 deletions UI.tscn

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions Viewports.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
tool
extends PanelContainer

var status = "released"
var mpos = Vector2()

onready var Top = $HorizontalDiv/VerticalDivTop/TopLeft/Top
onready var Left = $HorizontalDiv/VerticalDivBottom/BottomLeft/Left
onready var Front = $HorizontalDiv/VerticalDivTop/TopRigth/Front
Expand Down Expand Up @@ -57,3 +61,63 @@ func _on_BackGround_resized():
yield(get_tree(),"idle_frame")
yield(get_tree(),"idle_frame")
_resize_viewport()


func _process(delta):
mpos *= delta
if status == "dragging TopLeft":
Top.get_node("Camera").translate(Vector3((mpos).x,(mpos).y,0))
if status == "dragging TopRight":
Front.get_node("Camera").translate(Vector3((mpos).x,(mpos).y,0))
if status == "dragging BottomLeft":
Left.get_node("Camera").translate(Vector3(mpos.x,(mpos).y,0))


func _input(ev):

if (status!=null or status != "released") and ev is InputEventMouseMotion:
print(status)
mpos=ev.relative
if status == "released":
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)



func _on_TopLeft_gui_input(event):
if event is InputEventMouseButton:
if event.pressed:
status = "dragging TopLeft"
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
else:
status = "released"



func _on_BottomLeft_gui_input(event):
if event is InputEventMouseButton:
if event.pressed:
status = "dragging BottomLeft"
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
else:
status = "released"



func _on_TopRigth_gui_input(event):
if event is InputEventMouseButton:
if event.pressed:
status = "dragging TopRight"
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
else:
status = "released"



func _on_BottomRight_gui_input(event):
if event is InputEventMouseButton:
if event.pressed:
status = "dragging BottomRight"
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
else:
status = "released"

Binary file added addons/inspector-gadget/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions addons/inspector-gadget/plugin.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[plugin]

name="Inspector Gadget"
description="A general-purpose GDScript object-editing inspector UI for building your own editors inside Godot."
author="Shifty"
version="1.0.0"
script="src/inspector_gadget_plugin.gd"
85 changes: 85 additions & 0 deletions addons/inspector-gadget/scenes/example.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
[gd_scene load_steps=3 format=2]

[ext_resource path="res://addons/inspector-gadget/src/inspector_gadget.gd" type="Script" id=1]
[ext_resource path="res://addons/inspector-gadget/src/property_visualizer.gd" type="Script" id=2]

[node name="InspectorGadgetExample" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="ColorRect" type="ColorRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
color = Color( 0, 0, 0, 1 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="HBoxContainer" type="HBoxContainer" parent="ColorRect"]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="VisualizerScrollContainer" type="ScrollContainer" parent="ColorRect/HBoxContainer"]
margin_right = 478.0
margin_bottom = 960.0
size_flags_horizontal = 3

[node name="PropertyVisualizer" type="Control" parent="ColorRect/HBoxContainer/VisualizerScrollContainer"]
margin_right = 466.0
margin_bottom = 4290.0
rect_min_size = Vector2( 0, 4290 )
size_flags_horizontal = 3
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
float_value = 3.14159
quat_value = Quat( -0.176777, -0.306186, -0.306186, 0.883883 )
basis_value = Basis( 0.853553, 0.5, 0.146447, -0.146447, 0.5, -0.853553, -0.5, 0.707107, 0.5 )
dictionary_value = {
"bar": "bar string",
"baz": "baz string",
"foo": "foo string"
}

[node name="InspectorGadgetScrollContainer" type="ScrollContainer" parent="ColorRect/HBoxContainer"]
margin_left = 482.0
margin_right = 960.0
margin_bottom = 960.0
size_flags_horizontal = 3
__meta__ = {
"_edit_use_anchors_": false
}

[node name="InspectorGadget" type="MarginContainer" parent="ColorRect/HBoxContainer/InspectorGadgetScrollContainer"]
margin_right = 466.0
margin_bottom = 4124.0
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
node_path = NodePath("../../VisualizerScrollContainer/PropertyVisualizer")
subnames = ""
editable = true
property_blacklist = [ "blacklisted_property" ]
custom_gadget_paths = {

}
custom_gadget_metadata = {

}
container_type_hints = {
":array_value:4": 0,
":array_value:5": "",
":dictionary_value:[keys]": "",
":dictionary_value:[values]": ""
}
filter_built_in_properties = true
84 changes: 84 additions & 0 deletions addons/inspector-gadget/src/gadgets/gadget_aabb.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
class_name GadgetAABB
extends InspectorGadgetBase
tool

func _init(in_node_path: NodePath = NodePath(), in_subnames: String = "").(in_node_path, in_subnames):
pass

func set_node_path(new_node_path: NodePath):
.set_node_path(new_node_path)

if not has_controls():
return

var vbox = get_controls()[0]
var position_gadget = vbox.get_node("PositionGadget")
var size_gadget = vbox.get_node("SizeGadget")
position_gadget.node_path = node_path
size_gadget.node_path = node_path

func set_subnames(new_subnames: String):
.set_subnames(new_subnames)

if not has_controls():
return

var vbox = get_controls()[0]
var position_gadget = vbox.get_node("PositionGadget")
var size_gadget = vbox.get_node("SizeGadget")
position_gadget.subnames = subnames + ":position"
size_gadget.subnames = subnames + ":size"

static func supports_type(value) -> bool:
if value is AABB:
return true
return false

func has_controls() -> bool:
return has_node("VBoxContainer")

func get_controls() -> Array:
return [$VBoxContainer]

func populate_controls() -> void:
var position_label = Label.new()
position_label.text = "Position"

var size_label = Label.new()
size_label.text = "Size"

var position_gadget = GadgetVector3.new("../../" + node_path, subnames + ":position")
position_gadget.name = "PositionGadget"
position_gadget.size_flags_horizontal = SIZE_EXPAND_FILL
position_gadget.connect("change_property_begin", self, "change_property_begin")
position_gadget.connect("change_property_end", self, "change_property_end")

var size_gadget = GadgetVector3.new("../../" + node_path, subnames + ":size")
size_gadget.name = "SizeGadget"
size_gadget.size_flags_horizontal = SIZE_EXPAND_FILL
size_gadget.connect("change_property_begin", self, "change_property_begin")
size_gadget.connect("change_property_end", self, "change_property_end")

var vbox = VBoxContainer.new()
vbox.name = "VBoxContainer"
vbox.set_anchors_and_margins_preset(PRESET_WIDE)
vbox.add_child(position_label)
vbox.add_child(position_gadget)
vbox.add_child(size_label)
vbox.add_child(size_gadget)

add_child(vbox)

func populate_value(value) -> void:
var vbox = get_controls()[0]
var position_gadget = vbox.get_node("PositionGadget")
var size_gadget = vbox.get_node("SizeGadget")
position_gadget.populate_value(value.position)
size_gadget.populate_value(value.size)

func depopulate_value() -> void:
var vbox = get_controls()[0]
var position_gadget = vbox.get_node("PositionGadget")
var size_gadget = vbox.get_node("SizeGadget")
position_gadget.depopulate_value()
size_gadget.depopulate_value()
103 changes: 103 additions & 0 deletions addons/inspector-gadget/src/gadgets/gadget_basis.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
class_name GadgetBasis
extends InspectorGadgetBase
tool

func _init(in_node_path: NodePath = NodePath(), in_subnames: String = "").(in_node_path, in_subnames):
pass

func set_node_path(new_node_path: NodePath):
.set_node_path(new_node_path)

if not has_controls():
return

var hbox = get_controls()[0]
var x_axis_gadget = hbox.get_node("XAxisGadget")
var y_axis_gadget = hbox.get_node("YAxisGadget")
var z_axis_gadget = hbox.get_node("ZAxisGadget")
x_axis_gadget.node_path = node_path
y_axis_gadget.node_path = node_path
z_axis_gadget.node_path = node_path

func set_subnames(new_subnames: String):
.set_subnames(new_subnames)

if not has_controls():
return

var hbox = get_controls()[0]
var x_axis_gadget = hbox.get_node("XAxisGadget")
var y_axis_gadget = hbox.get_node("YAxisGadget")
var z_axis_gadget = hbox.get_node("ZAxisGadget")
x_axis_gadget.subnames = subnames + ":x"
y_axis_gadget.subnames = subnames + ":y"
z_axis_gadget.subnames = subnames + ":z"

static func supports_type(value) -> bool:
if value is Basis:
return true
return false

func has_controls() -> bool:
return has_node("VBoxContainer")

func get_controls() -> Array:
return [$VBoxContainer]

func populate_controls() -> void:
var label_x_axis = Label.new()
label_x_axis.text = "X Axis"

var label_y_axis = Label.new()
label_y_axis.text = "Y Axis"

var label_z_axis = Label.new()
label_z_axis.text = "Z Axis"

var x_axis_gadget = GadgetVector3.new("../../" + node_path, subnames + ":x")
x_axis_gadget.name = "XAxisGadget"
x_axis_gadget.size_flags_horizontal = SIZE_EXPAND_FILL
x_axis_gadget.connect("change_property_begin", self, "change_property_begin")
x_axis_gadget.connect("change_property_end", self, "change_property_end")

var y_axis_gadget = GadgetVector3.new("../../" + node_path, subnames + ":y")
y_axis_gadget.name = "YAxisGadget"
y_axis_gadget.size_flags_horizontal = SIZE_EXPAND_FILL
y_axis_gadget.connect("change_property_begin", self, "change_property_begin")
y_axis_gadget.connect("change_property_end", self, "change_property_end")

var z_axis_gadget = GadgetVector3.new("../../" + node_path, subnames + ":z")
z_axis_gadget.name = "ZAxisGadget"
z_axis_gadget.size_flags_horizontal = SIZE_EXPAND_FILL
z_axis_gadget.connect("change_property_begin", self, "change_property_begin")
z_axis_gadget.connect("change_property_end", self, "change_property_end")

var hbox = VBoxContainer.new()
hbox.name = "VBoxContainer"
hbox.set_anchors_and_margins_preset(PRESET_WIDE)
hbox.add_child(label_x_axis)
hbox.add_child(x_axis_gadget)
hbox.add_child(label_y_axis)
hbox.add_child(y_axis_gadget)
hbox.add_child(label_z_axis)
hbox.add_child(z_axis_gadget)

add_child(hbox)

func populate_value(value) -> void:
var hbox = get_controls()[0]
var x_axis_gadget = hbox.get_node("XAxisGadget")
var y_axis_gadget = hbox.get_node("YAxisGadget")
var z_axis_gadget = hbox.get_node("ZAxisGadget")
x_axis_gadget.populate_value(value.x)
y_axis_gadget.populate_value(value.y)
z_axis_gadget.populate_value(value.z)

func depopulate_value() -> void:
var hbox = get_controls()[0]
var x_axis_gadget = hbox.get_node("XAxisGadget")
var y_axis_gadget = hbox.get_node("YAxisGadget")
var z_axis_gadget = hbox.get_node("ZAxisGadget")
x_axis_gadget.depopulate_value()
y_axis_gadget.depopulate_value()
z_axis_gadget.depopulate_value()
38 changes: 38 additions & 0 deletions addons/inspector-gadget/src/gadgets/gadget_bool.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
class_name GadgetBool
extends InspectorGadgetBase
tool

func _init(in_node_path: NodePath = NodePath(), in_subnames: String = "").(in_node_path, in_subnames):
pass

static func supports_type(value) -> bool:
if value is bool:
return true
return false

func has_controls() -> bool:
return has_node("CheckBox")

func get_controls() -> Array:
return [$CheckBox]

func populate_controls() -> void:
var check_box = CheckBox.new()
check_box.name = "CheckBox"
check_box.set_anchors_and_margins_preset(PRESET_WIDE)
check_box.connect("toggled", self, "set_node_value")
add_child(check_box)

func populate_value(value) -> void:
var check_box = get_controls()[0]
check_box.set_block_signals(true)
check_box.pressed = value
check_box.set_block_signals(false)
check_box.disabled = !editable

func depopulate_value() -> void:
var check_box = get_controls()[0]
check_box.set_block_signals(true)
check_box.pressed = false
check_box.set_block_signals(false)
check_box.disabled = true
Loading

0 comments on commit b47b054

Please sign in to comment.