Update most demos for Godot 4.0.beta10 (#782)

This commit is contained in:
Hugo Locurcio
2023-01-05 16:50:17 +01:00
committed by GitHub
parent 85ca2fb2a1
commit 1d5184e235
758 changed files with 24258 additions and 9624 deletions

View File

@@ -6,12 +6,12 @@ var silly_material_resource = preload("res://addons/material_creator/material_re
var editor_interface
func _ready():
# Connect all of the signals we'll need to save and load silly materials
get_node(^"VBoxContainer/ApplyButton").connect(&"pressed", self.apply_pressed)
get_node(^"VBoxContainer/SaveButton").connect(&"pressed", self.save_pressed)
get_node(^"VBoxContainer/LoadButton").connect(&"pressed", self.load_pressed)
get_node(^"SaveMaterialDialog").connect(&"file_selected", self.save_file_selected)
get_node(^"LoadMaterialDialog").connect(&"file_selected", self.load_file_selected)
# Connect all of the signals we'll need to save and load silly materials.
get_node(^"VBoxContainer/ApplyButton").pressed.connect(self.apply_pressed)
get_node(^"VBoxContainer/SaveButton").pressed.connect(self.save_pressed)
get_node(^"VBoxContainer/LoadButton").pressed.connect(self.load_pressed)
get_node(^"SaveMaterialDialog").file_selected.connect(self.save_file_selected)
get_node(^"LoadMaterialDialog").file_selected.connect(self.load_file_selected)
RenderingServer.canvas_item_set_clip(get_canvas_item(), true)
@@ -24,7 +24,7 @@ func load_pressed():
func apply_pressed():
# Using the passed in editor interface, get the selected nodes in the editor
# Using the passed in editor interface, get the selected nodes in the editor.
var editor_selection = editor_interface.get_selection()
var selected_nodes = editor_selection.get_selected_nodes()
if selected_nodes.size() == 0:
@@ -41,58 +41,53 @@ func apply_pressed():
func save_file_selected(path):
var silly_resource = _silly_resource_from_values()
# Make a file, store the silly material as a json string, then close the file.
var file = File.new()
file.open(path, File.WRITE)
# Make a file, store the silly material as a JSON string.
var file = FileAccess.open(path, FileAccess.WRITE)
file.store_string(silly_resource.make_json())
file.close()
return true
func load_file_selected(path):
var file = File.new()
var SpatialMaterial_Silly = null
# Make a new silly resource (which in this case actually is a node)
# and initialize it
# and initialize it.
var silly_resource = silly_material_resource.new()
silly_resource.init()
# If the file exists, then open it
if file.file_exists(path):
file.open(path, File.READ)
# If the file exists, then open it.
if FileAccess.file_exists(path):
var file = FileAccess.open(path, FileAccess.READ)
# Get the JSON string and convert it into a silly material.
var json_dict_as_string = file.get_line()
if json_dict_as_string != null:
silly_resource.from_json(json_dict_as_string)
else:
file.close()
return false
get_node(^"VBoxContainer/AlbedoColorPicker").color = silly_resource.albedo_color
get_node(^"VBoxContainer/MetallicSlider").value = silly_resource.metallic_strength
get_node(^"VBoxContainer/RoughnessSlider").value = silly_resource.roughness_strength
# Close the file and return true (success!)
file.close()
# Return `true` to indicate success.
return true
#else: If the file does not exist, then return false (failure)
# If the file does not exist, then return `false` to indicate failure.
return false
func _silly_resource_from_values():
# Get the values from the sliders and color picker
# Get the values from the sliders and color picker.
var color = get_node(^"VBoxContainer/AlbedoColorPicker").color
var metallic = get_node(^"VBoxContainer/MetallicSlider").value
var roughness = get_node(^"VBoxContainer/RoughnessSlider").value
# Make a new silly resource (which in this case actually is a node) and initialize it
# Make a new silly resource (which in this case actually is a node) and initialize it.
var silly_resource = silly_material_resource.new()
silly_resource.init()
# Assign the values
# Assign the values.
silly_resource.albedo_color = color
silly_resource.metallic_strength = metallic
silly_resource.roughness_strength = roughness

View File

@@ -1,139 +1,106 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=2 format=3 uid="uid://n44d53us24uu"]
[ext_resource path="res://addons/material_creator/material_creator.gd" type="Script" id=1]
[ext_resource type="Script" path="res://addons/material_creator/material_creator.gd" id="1"]
[node name="Material Creator Plugin" type="Panel"]
offset_right = 220.0
offset_bottom = 340.0
rect_min_size = Vector2(210, 410)
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
script = ExtResource("1")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchors_preset = 13
anchor_left = 0.5
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -100.0
offset_right = 100.0
rect_min_size = Vector2(0, 400)
grow_horizontal = 2
grow_vertical = 2
[node name="DockName" type="Label" parent="VBoxContainer"]
offset_right = 200.0
offset_bottom = 30.0
rect_min_size = Vector2(200, 30)
custom_constants/shadow_as_outline = 1
offset_bottom = 26.0
text = "Material creator"
align = 1
valign = 2
[node name="AlbedoLabel" type="Label" parent="VBoxContainer"]
offset_top = 34.0
offset_top = 30.0
offset_right = 200.0
offset_bottom = 64.0
rect_min_size = Vector2(200, 30)
offset_bottom = 56.0
text = "Albedo color"
align = 1
valign = 2
[node name="AlbedoColorPicker" type="ColorPickerButton" parent="VBoxContainer"]
offset_top = 68.0
offset_top = 60.0
offset_right = 200.0
offset_bottom = 98.0
rect_min_size = Vector2(200, 30)
offset_bottom = 68.0
color = Color(1, 1, 1, 1)
[node name="MetallicLabel" type="Label" parent="VBoxContainer"]
offset_top = 102.0
offset_top = 72.0
offset_right = 200.0
offset_bottom = 132.0
rect_min_size = Vector2(200, 30)
offset_bottom = 98.0
text = "Metallic strength"
align = 1
valign = 2
[node name="MetallicSlider" type="HSlider" parent="VBoxContainer"]
offset_top = 136.0
offset_top = 102.0
offset_right = 200.0
offset_bottom = 166.0
rect_min_size = Vector2(200, 30)
offset_bottom = 118.0
max_value = 1.0
step = 0.05
[node name="RoughnessLabel" type="Label" parent="VBoxContainer"]
offset_top = 170.0
offset_top = 122.0
offset_right = 200.0
offset_bottom = 200.0
rect_min_size = Vector2(200, 30)
offset_bottom = 148.0
text = "Roughness strength"
align = 1
valign = 2
[node name="RoughnessSlider" type="HSlider" parent="VBoxContainer"]
offset_top = 204.0
offset_top = 152.0
offset_right = 200.0
offset_bottom = 234.0
rect_min_size = Vector2(200, 30)
offset_bottom = 168.0
max_value = 1.0
step = 0.05
ticks_on_borders = true
[node name="HSeparator" type="HSeparator" parent="VBoxContainer"]
offset_top = 238.0
offset_top = 172.0
offset_right = 200.0
offset_bottom = 258.0
rect_min_size = Vector2(200, 20)
offset_bottom = 176.0
[node name="ApplyButton" type="Button" parent="VBoxContainer"]
offset_top = 262.0
offset_top = 180.0
offset_right = 200.0
offset_bottom = 312.0
rect_min_size = Vector2(200, 50)
offset_bottom = 211.0
text = "Apply material"
[node name="SaveButton" type="Button" parent="VBoxContainer"]
offset_top = 316.0
offset_top = 215.0
offset_right = 200.0
offset_bottom = 366.0
rect_min_size = Vector2(200, 50)
offset_bottom = 246.0
text = "Save material"
[node name="LoadButton" type="Button" parent="VBoxContainer"]
offset_top = 370.0
offset_top = 250.0
offset_right = 200.0
offset_bottom = 420.0
rect_min_size = Vector2(200, 50)
offset_bottom = 281.0
text = "Load material"
clip_text = true
[node name="Label" type="Label" parent="VBoxContainer/LoadButton"]
visible = false
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_bottom = -10.0
rect_min_size = Vector2(0, 50)
grow_horizontal = 2
grow_vertical = 2
text = "Load silly material and
apply to selected node(s)"
align = 1
valign = 1
autowrap = true
[node name="SaveMaterialDialog" type="FileDialog" parent="."]
offset_left = 150.0
offset_top = 20.0
offset_right = 600.0
offset_bottom = 360.0
resizable = true
filters = PackedStringArray("*.silly_mat")
[node name="LoadMaterialDialog" type="FileDialog" parent="."]
offset_left = 150.0
offset_top = 20.0
offset_right = 600.0
offset_bottom = 360.0
rect_min_size = Vector2(200, 100)
window_title = "Open a File"
resizable = true
mode = 0
title = "Open a File"
ok_button_text = "Open"
file_mode = 0
filters = PackedStringArray("*.silly_mat")