diff --git a/material_maker/windows/new_painter/new_painter.gd b/material_maker/windows/new_painter/new_painter.gd index cbce6782..f0652c59 100644 --- a/material_maker/windows/new_painter/new_painter.gd +++ b/material_maker/windows/new_painter/new_painter.gd @@ -5,13 +5,14 @@ signal return_status(status) var mesh_filename = null var project_filename = null -onready var mesh_instance : MeshInstance = $VBoxContainer/HBoxContainer/ViewportContainer/Viewport/MeshPivot/MeshInstance - -func _ready(): - pass +onready var mesh_instance : MeshInstance = $VBoxContainer/Main/ViewportContainer/Viewport/MeshPivot/MeshInstance +onready var button_ok : Button = $VBoxContainer/Buttons/OK +onready var camera : Camera = $VBoxContainer/Main/ViewportContainer/Viewport/CameraPivot/Camera +onready var viewport_container : ViewportContainer = $VBoxContainer/Main/ViewportContainer +onready var viewport : Viewport = $VBoxContainer/Main/ViewportContainer/Viewport func _on_ViewportContainer_resized(): - $VBoxContainer/HBoxContainer/ViewportContainer/Viewport.size = $VBoxContainer/HBoxContainer/ViewportContainer.rect_size + viewport.size = $VBoxContainer/Main/ViewportContainer.rect_size func _on_ModelFile_pressed(): var dialog = preload("res://material_maker/windows/file_dialog/file_dialog.tscn").instance() @@ -33,18 +34,17 @@ func set_mesh(file_name : String) -> void: var mesh : Mesh = $ObjLoader.load_obj_file(mesh_filename) if mesh != null: mesh_instance.mesh = mesh - $VBoxContainer/HBoxContainer/VBoxContainer/GridContainer/ModelFile.text = mesh_filename.get_file() - $VBoxContainer/HBoxContainer2/OK.disabled = false + $VBoxContainer/Main/VBoxContainer/GridContainer/ModelFile.text = mesh_filename.get_file() + button_ok.disabled = false # Initialise project file name set_project(mesh_filename.get_basename()+".mmpp") # Center the mesh and move the camera to the whole object is visible var aabb : AABB = mesh_instance.get_aabb() mesh_instance.transform.origin = -aabb.position-0.5*aabb.size var d : float = aabb.size.length() - var camera = $VBoxContainer/HBoxContainer/ViewportContainer/Viewport/CameraPivot/Camera camera.transform.origin.z = 0.8*d else: - $VBoxContainer/HBoxContainer2/OK.disabled = true + button_ok.disabled = true func _on_ProjectFile_pressed(): var dialog = preload("res://material_maker/windows/file_dialog/file_dialog.tscn").instance() @@ -65,11 +65,11 @@ func set_project(file_name : String) -> void: if file_name == project_filename: return project_filename = file_name - $VBoxContainer/HBoxContainer/VBoxContainer/GridContainer/ProjectFile.text = project_filename.get_file() + $VBoxContainer/Main/VBoxContainer/GridContainer/ProjectFile.text = project_filename.get_file() func _on_OK_pressed(): var mesh = mesh_instance.mesh - emit_signal("return_status", { mesh=mesh, mesh_filename=mesh_filename, project_filename=project_filename, size=pow(2, $VBoxContainer/HBoxContainer/VBoxContainer/GridContainer/Resolution.size_value) }) + emit_signal("return_status", { mesh=mesh, mesh_filename=mesh_filename, project_filename=project_filename, size=pow(2, $VBoxContainer/Main/VBoxContainer/GridContainer/Resolution.size_value) }) func _on_Cancel_pressed(): emit_signal("return_status", null) @@ -86,4 +86,3 @@ func ask(obj_file_name = null) -> String: var result = yield(self, "return_status") queue_free() return result - diff --git a/material_maker/windows/new_painter/new_painter.tscn b/material_maker/windows/new_painter/new_painter.tscn index 273283e7..732e95ef 100644 --- a/material_maker/windows/new_painter/new_painter.tscn +++ b/material_maker/windows/new_painter/new_painter.tscn @@ -24,24 +24,22 @@ tracks/0/keys = { } [node name="NewPainterWindow" type="WindowDialog"] +visible = true margin_right = 520.0 margin_bottom = 288.0 +rect_min_size = Vector2( 400, 250 ) size_flags_horizontal = 0 size_flags_vertical = 0 window_title = "New paint project" +resizable = true script = ExtResource( 2 ) -__meta__ = { -"_edit_use_anchors_": false -} [node name="VBoxContainer" type="VBoxContainer" parent="."] anchor_right = 1.0 anchor_bottom = 1.0 -__meta__ = { -"_edit_use_anchors_": false -} +rect_min_size = Vector2( 400, 250 ) -[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"] +[node name="Main" type="HBoxContainer" parent="VBoxContainer"] margin_right = 520.0 margin_bottom = 256.0 size_flags_vertical = 3 @@ -49,34 +47,34 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/HBoxContainer"] +[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/Main"] margin_right = 157.0 margin_bottom = 256.0 -[node name="GridContainer" type="GridContainer" parent="VBoxContainer/HBoxContainer/VBoxContainer"] +[node name="GridContainer" type="GridContainer" parent="VBoxContainer/Main/VBoxContainer"] margin_right = 157.0 margin_bottom = 68.0 columns = 2 -[node name="ModelFileLabel" type="Label" parent="VBoxContainer/HBoxContainer/VBoxContainer/GridContainer"] +[node name="ModelFileLabel" type="Label" parent="VBoxContainer/Main/VBoxContainer/GridContainer"] margin_top = 3.0 margin_right = 72.0 margin_bottom = 17.0 text = "Model:" -[node name="ModelFile" type="Button" parent="VBoxContainer/HBoxContainer/VBoxContainer/GridContainer"] +[node name="ModelFile" type="Button" parent="VBoxContainer/Main/VBoxContainer/GridContainer"] margin_left = 76.0 margin_right = 157.0 margin_bottom = 20.0 text = "Model file" -[node name="ResolutionLabel" type="Label" parent="VBoxContainer/HBoxContainer/VBoxContainer/GridContainer"] +[node name="ResolutionLabel" type="Label" parent="VBoxContainer/Main/VBoxContainer/GridContainer"] margin_top = 27.0 margin_right = 72.0 margin_bottom = 41.0 text = "Resolution:" -[node name="Resolution" type="OptionButton" parent="VBoxContainer/HBoxContainer/VBoxContainer/GridContainer"] +[node name="Resolution" type="OptionButton" parent="VBoxContainer/Main/VBoxContainer/GridContainer"] margin_left = 76.0 margin_top = 24.0 margin_right = 157.0 @@ -85,45 +83,45 @@ script = ExtResource( 1 ) min_size = 8 max_size = 12 -[node name="ProjectFileLabel2" type="Label" parent="VBoxContainer/HBoxContainer/VBoxContainer/GridContainer"] +[node name="ProjectFileLabel2" type="Label" parent="VBoxContainer/Main/VBoxContainer/GridContainer"] margin_top = 51.0 margin_right = 72.0 margin_bottom = 65.0 text = "Project:" -[node name="ProjectFile" type="Button" parent="VBoxContainer/HBoxContainer/VBoxContainer/GridContainer"] +[node name="ProjectFile" type="Button" parent="VBoxContainer/Main/VBoxContainer/GridContainer"] margin_left = 76.0 margin_top = 48.0 margin_right = 157.0 margin_bottom = 68.0 text = "Project file" -[node name="ViewportContainer" type="ViewportContainer" parent="VBoxContainer/HBoxContainer"] +[node name="ViewportContainer" type="ViewportContainer" parent="VBoxContainer/Main"] margin_left = 161.0 margin_right = 520.0 margin_bottom = 256.0 size_flags_horizontal = 3 +stretch = true -[node name="Viewport" type="Viewport" parent="VBoxContainer/HBoxContainer/ViewportContainer"] -size = Vector2( 100, 100 ) +[node name="Viewport" type="Viewport" parent="VBoxContainer/Main/ViewportContainer"] +size = Vector2( 359, 256 ) handle_input_locally = false -render_target_update_mode = 0 +render_target_update_mode = 3 -[node name="MeshPivot" type="Spatial" parent="VBoxContainer/HBoxContainer/ViewportContainer/Viewport"] +[node name="MeshPivot" type="Spatial" parent="VBoxContainer/Main/ViewportContainer/Viewport"] -[node name="MeshInstance" type="MeshInstance" parent="VBoxContainer/HBoxContainer/ViewportContainer/Viewport/MeshPivot"] +[node name="MeshInstance" type="MeshInstance" parent="VBoxContainer/Main/ViewportContainer/Viewport/MeshPivot"] mesh = SubResource( 1 ) skeleton = NodePath("../..") -material/0 = null -[node name="AnimationPlayer" type="AnimationPlayer" parent="VBoxContainer/HBoxContainer/ViewportContainer/Viewport"] +[node name="AnimationPlayer" type="AnimationPlayer" parent="VBoxContainer/Main/ViewportContainer/Viewport"] autoplay = "rotate" anims/rotate = SubResource( 2 ) -[node name="CameraPivot" type="Spatial" parent="VBoxContainer/HBoxContainer/ViewportContainer/Viewport"] +[node name="CameraPivot" type="Spatial" parent="VBoxContainer/Main/ViewportContainer/Viewport"] transform = Transform( 1, 0, 0, 0, 0.866025, 0.5, 0, -0.5, 0.866025, 0, 0, 0 ) -[node name="Camera" type="Camera" parent="VBoxContainer/HBoxContainer/ViewportContainer/Viewport/CameraPivot"] +[node name="Camera" type="Camera" parent="VBoxContainer/Main/ViewportContainer/Viewport/CameraPivot"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 5 ) far = 50.0 @@ -132,21 +130,21 @@ margin_top = 260.0 margin_right = 520.0 margin_bottom = 264.0 -[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer"] +[node name="Buttons" type="HBoxContainer" parent="VBoxContainer"] margin_left = 203.0 margin_top = 268.0 margin_right = 317.0 margin_bottom = 288.0 size_flags_horizontal = 4 -[node name="OK" type="Button" parent="VBoxContainer/HBoxContainer2"] +[node name="OK" type="Button" parent="VBoxContainer/Buttons"] margin_right = 55.0 margin_bottom = 20.0 rect_min_size = Vector2( 55, 0 ) disabled = true text = "OK" -[node name="Cancel" type="Button" parent="VBoxContainer/HBoxContainer2"] +[node name="Cancel" type="Button" parent="VBoxContainer/Buttons"] margin_left = 59.0 margin_right = 114.0 margin_bottom = 20.0 @@ -157,8 +155,7 @@ text = "Cancel" script = ExtResource( 3 ) [connection signal="popup_hide" from="." to="." method="_on_NewPainterWindow_popup_hide"] -[connection signal="pressed" from="VBoxContainer/HBoxContainer/VBoxContainer/GridContainer/ModelFile" to="." method="_on_ModelFile_pressed"] -[connection signal="pressed" from="VBoxContainer/HBoxContainer/VBoxContainer/GridContainer/ProjectFile" to="." method="_on_ProjectFile_pressed"] -[connection signal="resized" from="VBoxContainer/HBoxContainer/ViewportContainer" to="." method="_on_ViewportContainer_resized"] -[connection signal="pressed" from="VBoxContainer/HBoxContainer2/OK" to="." method="_on_OK_pressed"] -[connection signal="pressed" from="VBoxContainer/HBoxContainer2/Cancel" to="." method="_on_Cancel_pressed"] +[connection signal="pressed" from="VBoxContainer/Main/VBoxContainer/GridContainer/ModelFile" to="." method="_on_ModelFile_pressed"] +[connection signal="pressed" from="VBoxContainer/Main/VBoxContainer/GridContainer/ProjectFile" to="." method="_on_ProjectFile_pressed"] +[connection signal="pressed" from="VBoxContainer/Buttons/OK" to="." method="_on_OK_pressed"] +[connection signal="pressed" from="VBoxContainer/Buttons/Cancel" to="." method="_on_Cancel_pressed"]