diff --git a/gui/input_mapping/ActionRemapButton.gd b/gui/input_mapping/ActionRemapButton.gd index 94b6491d630..6aad90e57f8 100644 --- a/gui/input_mapping/ActionRemapButton.gd +++ b/gui/input_mapping/ActionRemapButton.gd @@ -25,8 +25,12 @@ func _unhandled_key_input(event): func remap_action_to(event): + # We first change the event in this game instance. InputMap.action_erase_events(action) InputMap.action_add_event(action, event) + # And then save it to the keymaps file + KeyPersistence.keymaps[action] = event + KeyPersistence.save_keymap() text = "%s Key" % event.as_text() diff --git a/gui/input_mapping/KeyPersistence.gd b/gui/input_mapping/KeyPersistence.gd new file mode 100644 index 00000000000..15ad58504c0 --- /dev/null +++ b/gui/input_mapping/KeyPersistence.gd @@ -0,0 +1,45 @@ +# This is an autoload (singleton) which will save +# the key maps in a simple way through a dictionary. +extends Node + +const keymaps_path = "user://keymaps.dat" +var keymaps: Dictionary + + +func _ready() -> void: + # First we create the keymap dictionary on startup with all + # the keymap actions we have. + for action in InputMap.get_actions(): + keymaps[action] = InputMap.get_action_list(action)[0] + load_keymap() + + +func load_keymap() -> void: + var file := File.new() + if not file.file_exists(keymaps_path): + save_keymap() # There is no save file yet, so let's create one. + return + #warning-ignore:return_value_discarded + file.open(keymaps_path, File.READ) + var temp_keymap: Dictionary = file.get_var(true) + file.close() + # We don't just replace the keymaps dictionary, because if you + # updated your game and removed/added keymaps, the data of this + # save file may have invalid actions. So we check one by one to + # make sure that the keymap dictionary really has all current actions. + for action in keymaps.keys(): + if temp_keymap.has(action): + keymaps[action] = temp_keymap[action] + # Whilst setting the keymap dictionary, we also set the + # correct InputMap event + InputMap.action_erase_events(action) + InputMap.action_add_event(action, keymaps[action]) + + +func save_keymap() -> void: + # For saving the keymap, we just save the entire dictionary as a var. + var file := File.new() + #warning-ignore:return_value_discarded + file.open(keymaps_path, File.WRITE) + file.store_var(keymaps, true) + file.close() diff --git a/gui/input_mapping/project.godot b/gui/input_mapping/project.godot index 723f6a357b4..1250daf3593 100644 --- a/gui/input_mapping/project.godot +++ b/gui/input_mapping/project.godot @@ -19,6 +19,10 @@ config/description="A demo showing how to build an input key remapping screen. run/main_scene="res://InputRemapMenu.tscn" config/icon="res://icon.png" +[autoload] + +KeyPersistence="*res://KeyPersistence.gd" + [display] window/size/width=640 diff --git a/loading/pck_loading/README.md b/loading/pck_loading/README.md new file mode 100644 index 00000000000..90b03778896 --- /dev/null +++ b/loading/pck_loading/README.md @@ -0,0 +1,15 @@ +# PCK loading demo + +This demo shows how you can load and unload exported PCK files at runtime. + +Language: GDScript + +Renderer: GLES 2 + +## Sub-projects + +There are three Godot projects under `sub_projects`. All have been exported to their respective PCK files and are loaded by the main project. + +## Screenshots + +![Screenshot](screenshots/screenshot.png) diff --git a/loading/pck_loading/Root.gd b/loading/pck_loading/Root.gd new file mode 100644 index 00000000000..a95b7f5c1d7 --- /dev/null +++ b/loading/pck_loading/Root.gd @@ -0,0 +1,78 @@ +extends Control + +@onready var vp_orig = $HBoxContainer/VBoxContainer/SubViewportContainer/ViewOrig +@onready var vp_a = $HBoxContainer/VBoxContainer2/SubViewportContainer/ViewA +@onready var vp_b = $HBoxContainer/VBoxContainer3/SubViewportContainer/ViewB +@onready var no_scene_lbl = $NoNodeLbl + +@export_file("*.pck") var pck_1 +@export_file("*.pck") var pck_2 +@export_file("*.pck") var pck_3 + + +func _ready(): + reload_scene() + + +func reload_scene(): + $LineEdit.text = "" + populate_file_list("res://") + + load_scene_at_node("res://orig.tscn", vp_orig) + load_scene_at_node("res://a.tscn", vp_a) + load_scene_at_node("res://b.tscn", vp_b) + + +func populate_file_list(path: String): + var dir = Directory.new() + dir.open(path) + dir.list_dir_begin() + var file_name = dir.get_next() + while file_name != "": + if dir.current_is_dir(): + populate_file_list(path + file_name + "/") + else: + $LineEdit.text += path + file_name + '\n' + file_name = dir.get_next() + + +func load_scene_at_node(scene_name: String, node: Node): + var child + if ResourceLoader.exists(scene_name): + child = load(scene_name).instantiate() + else: + child = no_scene_lbl.duplicate() + child.position = Vector2.ZERO + if node.get_child_count() > 0: + node.remove_child(node.get_child(0)) + node.add_child(child) + + +func _on_load1_pressed(): + ProjectSettings.load_resource_pack(pck_1, $VBoxContainer/HBoxContainer/CheckBox.is_pressed()) + reload_scene() + + +func _on_unload1_pressed(): + ProjectSettings.unload_resource_pack(pck_1) + reload_scene() + + +func _on_load2_pressed(): + ProjectSettings.load_resource_pack(pck_2, $VBoxContainer/HBoxContainer2/CheckBox.is_pressed()) + reload_scene() + + +func _on_unload2_pressed(): + ProjectSettings.unload_resource_pack(pck_2) + reload_scene() + + +func _on_load3_pressed(): + ProjectSettings.load_resource_pack(pck_3, $VBoxContainer/HBoxContainer3/CheckBox.is_pressed()) + reload_scene() + + +func _on_unload3_pressed(): + ProjectSettings.unload_resource_pack(pck_3) + reload_scene() diff --git a/loading/pck_loading/icon.png b/loading/pck_loading/icon.png new file mode 100755 index 00000000000..2b658158b6a Binary files /dev/null and b/loading/pck_loading/icon.png differ diff --git a/loading/pck_loading/icon.png.import b/loading/pck_loading/icon.png.import new file mode 100644 index 00000000000..be32693d7b0 --- /dev/null +++ b/loading/pck_loading/icon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://btpbmejdh00qx" +path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.png" +dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/loading/pck_loading/main.tscn b/loading/pck_loading/main.tscn new file mode 100644 index 00000000000..97b1212604b --- /dev/null +++ b/loading/pck_loading/main.tscn @@ -0,0 +1,200 @@ +[gd_scene load_steps=2 format=3 uid="uid://biqc8303kctlu"] + +[ext_resource type="Script" path="res://Root.gd" id="1_dd1mq"] + +[node name="Root" type="Control"] +script = ExtResource( "1_dd1mq" ) +pck_1 = "res://sub_projects/1.pck" +pck_2 = "res://sub_projects/2.pck" +pck_3 = "res://sub_projects/3.pck" + +[node name="LineEdit" type="Label" parent="."] +offset_left = 67.0 +offset_top = 75.0 +offset_right = 463.0 +offset_bottom = 375.0 +autowrap_mode = 1 +clip_text = true + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +offset_left = 552.0 +offset_top = 81.0 +offset_right = 932.0 +offset_bottom = 379.0 +theme_override_constants/separation = 20 + +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"] +offset_right = 380.0 +offset_bottom = 86.0 +size_flags_vertical = 3 +theme_override_constants/separation = 20 + +[node name="Load" type="Button" parent="VBoxContainer/HBoxContainer"] +offset_right = 125.0 +offset_bottom = 86.0 +size_flags_horizontal = 3 +text = "Load 1.pck" + +[node name="Unload" type="Button" parent="VBoxContainer/HBoxContainer"] +offset_left = 145.0 +offset_right = 271.0 +offset_bottom = 86.0 +size_flags_horizontal = 3 +text = "Unload 1.pck" + +[node name="CheckBox" type="CheckBox" parent="VBoxContainer/HBoxContainer"] +offset_left = 291.0 +offset_right = 380.0 +offset_bottom = 86.0 +text = "Replace +files?" + +[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer"] +offset_top = 106.0 +offset_right = 380.0 +offset_bottom = 192.0 +size_flags_vertical = 3 +theme_override_constants/separation = 20 + +[node name="Load" type="Button" parent="VBoxContainer/HBoxContainer2"] +offset_right = 125.0 +offset_bottom = 86.0 +size_flags_horizontal = 3 +text = "Load 2.pck" + +[node name="Unload" type="Button" parent="VBoxContainer/HBoxContainer2"] +offset_left = 145.0 +offset_right = 271.0 +offset_bottom = 86.0 +size_flags_horizontal = 3 +text = "Unload 2.pck" + +[node name="CheckBox" type="CheckBox" parent="VBoxContainer/HBoxContainer2"] +offset_left = 291.0 +offset_right = 380.0 +offset_bottom = 86.0 +text = "Replace +files?" + +[node name="HBoxContainer3" type="HBoxContainer" parent="VBoxContainer"] +offset_top = 212.0 +offset_right = 380.0 +offset_bottom = 298.0 +size_flags_vertical = 3 +theme_override_constants/separation = 20 + +[node name="Load" type="Button" parent="VBoxContainer/HBoxContainer3"] +offset_right = 125.0 +offset_bottom = 86.0 +size_flags_horizontal = 3 +text = "Load 3.pck" + +[node name="Unload" type="Button" parent="VBoxContainer/HBoxContainer3"] +offset_left = 145.0 +offset_right = 271.0 +offset_bottom = 86.0 +size_flags_horizontal = 3 +text = "Unload 3.pck" + +[node name="CheckBox" type="CheckBox" parent="VBoxContainer/HBoxContainer3"] +offset_left = 291.0 +offset_right = 380.0 +offset_bottom = 86.0 +text = "Replace +files?" + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +offset_left = 44.0 +offset_top = 415.0 +offset_right = 934.0 +offset_bottom = 569.0 +size_flags_horizontal = 3 + +[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer"] +offset_right = 294.0 +offset_bottom = 158.0 +size_flags_horizontal = 3 + +[node name="Label" type="Label" parent="HBoxContainer/VBoxContainer"] +offset_right = 294.0 +offset_bottom = 26.0 +text = "orig.tscn" + +[node name="SubViewportContainer" type="SubViewportContainer" parent="HBoxContainer/VBoxContainer"] +minimum_size = Vector2(256, 0) +offset_top = 30.0 +offset_right = 294.0 +offset_bottom = 158.0 +size_flags_vertical = 3 + +[node name="ViewOrig" type="SubViewport" parent="HBoxContainer/VBoxContainer/SubViewportContainer"] +handle_input_locally = false +size = Vector2i(256, 128) +render_target_update_mode = 4 + +[node name="VBoxContainer2" type="VBoxContainer" parent="HBoxContainer"] +offset_left = 298.0 +offset_right = 592.0 +offset_bottom = 158.0 +size_flags_horizontal = 3 + +[node name="Label" type="Label" parent="HBoxContainer/VBoxContainer2"] +offset_right = 294.0 +offset_bottom = 26.0 +text = "a.tscn" + +[node name="SubViewportContainer" type="SubViewportContainer" parent="HBoxContainer/VBoxContainer2"] +minimum_size = Vector2(256, 0) +offset_top = 30.0 +offset_right = 294.0 +offset_bottom = 158.0 +size_flags_vertical = 3 + +[node name="ViewA" type="SubViewport" parent="HBoxContainer/VBoxContainer2/SubViewportContainer"] +handle_input_locally = false +size = Vector2i(256, 128) +render_target_update_mode = 4 + +[node name="VBoxContainer3" type="VBoxContainer" parent="HBoxContainer"] +offset_left = 596.0 +offset_right = 890.0 +offset_bottom = 158.0 +size_flags_horizontal = 3 + +[node name="Label" type="Label" parent="HBoxContainer/VBoxContainer3"] +offset_right = 294.0 +offset_bottom = 26.0 +text = "b.tscn" + +[node name="SubViewportContainer" type="SubViewportContainer" parent="HBoxContainer/VBoxContainer3"] +minimum_size = Vector2(256, 0) +offset_top = 30.0 +offset_right = 294.0 +offset_bottom = 158.0 +size_flags_vertical = 3 + +[node name="ViewB" type="SubViewport" parent="HBoxContainer/VBoxContainer3/SubViewportContainer"] +handle_input_locally = false +size = Vector2i(256, 128) +render_target_update_mode = 4 + +[node name="NoNodeLbl" type="Label" parent="."] +offset_left = -184.0 +offset_top = -133.0 +offset_right = -144.0 +offset_bottom = -110.0 +text = "Missing scene file!" + +[node name="Label" type="Label" parent="."] +offset_left = 65.0 +offset_top = 49.0 +offset_right = 128.0 +offset_bottom = 75.0 +text = "File List:" + +[connection signal="pressed" from="VBoxContainer/HBoxContainer/Load" to="." method="_on_load1_pressed"] +[connection signal="pressed" from="VBoxContainer/HBoxContainer/Unload" to="." method="_on_unload1_pressed"] +[connection signal="pressed" from="VBoxContainer/HBoxContainer2/Load" to="." method="_on_load2_pressed"] +[connection signal="pressed" from="VBoxContainer/HBoxContainer2/Unload" to="." method="_on_unload2_pressed"] +[connection signal="pressed" from="VBoxContainer/HBoxContainer3/Load" to="." method="_on_load3_pressed"] +[connection signal="pressed" from="VBoxContainer/HBoxContainer3/Unload" to="." method="_on_unload3_pressed"] diff --git a/loading/pck_loading/orig.tscn b/loading/pck_loading/orig.tscn new file mode 100644 index 00000000000..9255c69e7a1 --- /dev/null +++ b/loading/pck_loading/orig.tscn @@ -0,0 +1,14 @@ +[gd_scene format=3 uid="uid://dr3ofl6lrt7v2"] + +[node name="Control" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="Label" type="Label" parent="."] +offset_right = 306.0 +offset_bottom = 104.0 +text = "Greetings from original data.pck +file! This should always be here; +if somehow this scene fails to +load, something messed up +`res://` lookup!" diff --git a/loading/pck_loading/project.godot b/loading/pck_loading/project.godot new file mode 100644 index 00000000000..301becc170b --- /dev/null +++ b/loading/pck_loading/project.godot @@ -0,0 +1,23 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="PCK loading" +config/description="This demo shows how you can load and unload exported PCK files at runtime." +run/main_scene="res://main.tscn" +config/icon="res://icon.png" +config/features=PackedStringArray("4.0") + +[rendering] + +quality/driver/driver_name="GLES2" +vram_compression/import_etc=true +vram_compression/import_etc2=false diff --git a/loading/pck_loading/screenshots/.gdignore b/loading/pck_loading/screenshots/.gdignore new file mode 100644 index 00000000000..e69de29bb2d diff --git a/loading/pck_loading/screenshots/screenshot.png b/loading/pck_loading/screenshots/screenshot.png new file mode 100644 index 00000000000..12c7a7d923f Binary files /dev/null and b/loading/pck_loading/screenshots/screenshot.png differ diff --git a/loading/pck_loading/sub_projects/.gdignore b/loading/pck_loading/sub_projects/.gdignore new file mode 100644 index 00000000000..e69de29bb2d diff --git a/loading/pck_loading/sub_projects/1.pck b/loading/pck_loading/sub_projects/1.pck new file mode 100644 index 00000000000..7f02e3bdefb Binary files /dev/null and b/loading/pck_loading/sub_projects/1.pck differ diff --git a/loading/pck_loading/sub_projects/1/a.tscn b/loading/pck_loading/sub_projects/1/a.tscn new file mode 100644 index 00000000000..a0049baf0d5 --- /dev/null +++ b/loading/pck_loading/sub_projects/1/a.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=3 format=3 uid="uid://cynxmx85sit6h"] + +[ext_resource type="Texture2D" uid="uid://deyknasv78sq2" path="res://icon.png" id="1_o57oj"] +[ext_resource type="Script" path="res://script1.gd" id="2_u8kao"] + +[node name="Node2D" type="Node2D"] + +[node name="Label" type="Label" parent="."] +offset_right = 40.0 +offset_bottom = 23.0 +text = "Greetings from 1.pck!" + +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(23, 41) +scale = Vector2(0.5, 0.5) +texture = ExtResource( "1_o57oj" ) +script = ExtResource( "2_u8kao" ) diff --git a/loading/pck_loading/sub_projects/1/icon.png b/loading/pck_loading/sub_projects/1/icon.png new file mode 100755 index 00000000000..2b658158b6a Binary files /dev/null and b/loading/pck_loading/sub_projects/1/icon.png differ diff --git a/loading/pck_loading/sub_projects/1/icon.png.import b/loading/pck_loading/sub_projects/1/icon.png.import new file mode 100644 index 00000000000..2ece35452d6 --- /dev/null +++ b/loading/pck_loading/sub_projects/1/icon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://deyknasv78sq2" +path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.png" +dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/loading/pck_loading/sub_projects/1/project.godot b/loading/pck_loading/sub_projects/1/project.godot new file mode 100644 index 00000000000..a2edcaa5712 --- /dev/null +++ b/loading/pck_loading/sub_projects/1/project.godot @@ -0,0 +1,15 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="Pck 1" +config/icon="res://icon.png" +config/features=PackedStringArray("4.0", "Vulkan Clustered") diff --git a/loading/pck_loading/sub_projects/1/script1.gd b/loading/pck_loading/sub_projects/1/script1.gd new file mode 100644 index 00000000000..ec0c42abf8f --- /dev/null +++ b/loading/pck_loading/sub_projects/1/script1.gd @@ -0,0 +1,11 @@ +extends Sprite2D + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + position.x = 100 + 50 * sin(Time.get_ticks_msec()/250.0) diff --git a/loading/pck_loading/sub_projects/2.pck b/loading/pck_loading/sub_projects/2.pck new file mode 100644 index 00000000000..f01babc8531 Binary files /dev/null and b/loading/pck_loading/sub_projects/2.pck differ diff --git a/loading/pck_loading/sub_projects/2/a.tscn b/loading/pck_loading/sub_projects/2/a.tscn new file mode 100644 index 00000000000..84128444a57 --- /dev/null +++ b/loading/pck_loading/sub_projects/2/a.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=3 format=3 uid="uid://mdkfwemejja8"] + +[ext_resource type="Texture2D" uid="uid://bqredrveocrnm" path="res://icon.png" id="1_is42x"] +[ext_resource type="Script" path="res://script2.gd" id="2_r4l84"] + +[node name="Node2D" type="Node2D"] + +[node name="Label" type="Label" parent="."] +offset_right = 40.0 +offset_bottom = 23.0 +text = "Greetings from 2.pck!" + +[node name="Icon" type="Sprite2D" parent="."] +position = Vector2(49, 42) +scale = Vector2(0.5, 0.5) +texture = ExtResource( "1_is42x" ) +script = ExtResource( "2_r4l84" ) diff --git a/loading/pck_loading/sub_projects/2/b.tscn b/loading/pck_loading/sub_projects/2/b.tscn new file mode 100644 index 00000000000..f0ea67b46e2 --- /dev/null +++ b/loading/pck_loading/sub_projects/2/b.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=3 format=3 uid="uid://bccwynfseyifu"] + +[ext_resource type="Texture2D" uid="uid://bqredrveocrnm" path="res://icon.png" id="1_yjmuf"] +[ext_resource type="Script" path="res://script2.gd" id="2_y8l7w"] + +[node name="Node2D" type="Node2D"] + +[node name="Label" type="Label" parent="."] +offset_right = 40.0 +offset_bottom = 23.0 +text = "Greetings from 2.pck!" + +[node name="Icon" type="Sprite2D" parent="."] +position = Vector2(49, 42) +scale = Vector2(0.5, 0.5) +texture = ExtResource( "1_yjmuf" ) +script = ExtResource( "2_y8l7w" ) diff --git a/loading/pck_loading/sub_projects/2/icon.png b/loading/pck_loading/sub_projects/2/icon.png new file mode 100755 index 00000000000..2b658158b6a Binary files /dev/null and b/loading/pck_loading/sub_projects/2/icon.png differ diff --git a/loading/pck_loading/sub_projects/2/icon.png.import b/loading/pck_loading/sub_projects/2/icon.png.import new file mode 100644 index 00000000000..8403197bc3e --- /dev/null +++ b/loading/pck_loading/sub_projects/2/icon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bqredrveocrnm" +path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.png" +dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/loading/pck_loading/sub_projects/2/project.godot b/loading/pck_loading/sub_projects/2/project.godot new file mode 100644 index 00000000000..183ac64a5ac --- /dev/null +++ b/loading/pck_loading/sub_projects/2/project.godot @@ -0,0 +1,15 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="Pck 2" +config/icon="res://icon.png" +config/features=PackedStringArray("4.0", "Vulkan Clustered") diff --git a/loading/pck_loading/sub_projects/2/script2.gd b/loading/pck_loading/sub_projects/2/script2.gd new file mode 100644 index 00000000000..2f93206ae27 --- /dev/null +++ b/loading/pck_loading/sub_projects/2/script2.gd @@ -0,0 +1,11 @@ +extends Sprite2D + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + position.y = 80 + 30 * sin(Time.get_ticks_msec()/250.0) diff --git a/loading/pck_loading/sub_projects/3.pck b/loading/pck_loading/sub_projects/3.pck new file mode 100644 index 00000000000..f281785ae67 Binary files /dev/null and b/loading/pck_loading/sub_projects/3.pck differ diff --git a/loading/pck_loading/sub_projects/3/b.tscn b/loading/pck_loading/sub_projects/3/b.tscn new file mode 100644 index 00000000000..124e6730c67 --- /dev/null +++ b/loading/pck_loading/sub_projects/3/b.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=3 format=3 uid="uid://iuwn33rjggi4"] + +[ext_resource type="Texture2D" uid="uid://b1lqstadc0m46" path="res://icon.png" id="1_yiyor"] +[ext_resource type="Script" path="res://script3.gd" id="2_530xv"] + +[node name="Node2D" type="Node2D"] + +[node name="Label" type="Label" parent="."] +offset_right = 40.0 +offset_bottom = 23.0 +text = "Greetings from 3.pck!" + +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(41, 39) +scale = Vector2(0.5, 0.5) +texture = ExtResource( "1_yiyor" ) +script = ExtResource( "2_530xv" ) diff --git a/loading/pck_loading/sub_projects/3/icon.png b/loading/pck_loading/sub_projects/3/icon.png new file mode 100755 index 00000000000..2b658158b6a Binary files /dev/null and b/loading/pck_loading/sub_projects/3/icon.png differ diff --git a/loading/pck_loading/sub_projects/3/icon.png.import b/loading/pck_loading/sub_projects/3/icon.png.import new file mode 100644 index 00000000000..1bc382aa6d3 --- /dev/null +++ b/loading/pck_loading/sub_projects/3/icon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b1lqstadc0m46" +path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.png" +dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/loading/pck_loading/sub_projects/3/project.godot b/loading/pck_loading/sub_projects/3/project.godot new file mode 100644 index 00000000000..3f6f8339a99 --- /dev/null +++ b/loading/pck_loading/sub_projects/3/project.godot @@ -0,0 +1,14 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="Pck 3" +config/features=PackedStringArray("4.0", "Vulkan Clustered") diff --git a/loading/pck_loading/sub_projects/3/script3.gd b/loading/pck_loading/sub_projects/3/script3.gd new file mode 100644 index 00000000000..2a0eaeef6f3 --- /dev/null +++ b/loading/pck_loading/sub_projects/3/script3.gd @@ -0,0 +1,12 @@ +extends Sprite2D + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + position.x = 80 + 50 * cos(Time.get_ticks_msec()/200.0) + position.y = 80 + 30 * sin(Time.get_ticks_msec()/250.0) diff --git a/networking/webrtc_signaling/README.md b/networking/webrtc_signaling/README.md index 7462834098d..95da639af8b 100644 --- a/networking/webrtc_signaling/README.md +++ b/networking/webrtc_signaling/README.md @@ -1,14 +1,14 @@ # A WebSocket signaling server/client for WebRTC. -This demo is devided in 4 parts: +This demo divided into 4 parts: - The `server` folder contains the signaling server implementation written in GDScript (so it can be run by a game server running Godot) -- The `server_node` folder contains the signaling server implementation written in Node.js (if you don't plan to run a game server but only match-making). -- The `client` part contains the client implementation in GDScript. - - Itself divided into raw protocol and `WebRTCMultiplayer` handling. +- The `server_node` folder contains the signaling server implementation written in Node.js (in case you dont want to run a godot game server). +- The `client` folder contains the client implementation in GDScript. + - It handles both the protocol and `WebRTCMultiplayer` separately. - The `demo` contains a small app that uses it. -**NOTE**: You must extract the [latest version](https://github.com/godotengine/webrtc-native/releases) of the WebRTC GDNative plugin in the project folder to run from desktop. +**NOTE**: You must extract the [latest version](https://github.com/godotengine/webrtc-native/releases) of the WebRTC GDNative plugin in the project folder to run on a desktop. Language: GDScript @@ -18,18 +18,18 @@ Check out this demo on the asset library: https://godotengine.org/asset-library/ ## Protocol -The protocol is text based, and composed by a command and possibly multiple payload arguments, each separated by a new line. +The protocol is text based, which is composed of a command and possibly multiple payload arguments, each separated by a new line. Messages without payload must still end with a newline and are the following: -- `J: ` (or `J: `), must be sent by client immediately after connection to get a lobby assigned or join a known one. - This messages is also sent by server back to the client to notify assigned lobby, or simply a successful join. -- `I: `, sent by server to identify the client when it joins a room. -- `N: `, sent by server to notify new peers in the same lobby. -- `D: `, sent by server to notify when a peer in the same lobby disconnects. -- `S: `, sent by client to seal the lobby (only the client that created it is allowed to seal a lobby). +- `J: ` (or `J: `), must be sent by the client immediately after connecting to get a lobby assigned or join a known one. + These messages are from the server back to the client to notify the client of the assigned lobby, or simply of a successful join. +- `I: `, sent by the server to identify the client when it joins a room. +- `N: `, sent by the server to notify new peers in the same lobby. +- `D: `, sent by the server to notify when a peer in the same lobby disconnects. +- `S: `, sent by a client to seal the lobby (only the client that created it is allowed to seal a lobby). -When a lobby is sealed, no new client will be able to join, and the lobby will be destroyed (and clients disconnected) after 10 seconds. +When a lobby is sealed, new clients will be unable to join, and the lobby will be destroyed (and clients disconnected) after 10 seconds. Messages with payload (used to transfer WebRTC parameters) are: @@ -37,7 +37,7 @@ Messages with payload (used to transfer WebRTC parameters) are: - `A: `, used to send an answer. - `C: `, used to send a candidate. -When sending the parameter, a client will set `` as the destination peer, the server will replace it with the id of the sending peer, and rely it to the proper destination. +When sending the parameter, a client will set `` as the destination peer, the server will replace it with the id of the sending peer, then relay it to the proper destination. ## Screenshots