diff --git a/ExportPanel.gd b/ExportPanel.gd new file mode 100644 index 0000000..b97b689 --- /dev/null +++ b/ExportPanel.gd @@ -0,0 +1,15 @@ +extends PanelContainer + +func _ready() -> void: + pass + +func show_panel(ob : Dictionary) -> void: + var text = JSON.stringify(ob, " ") + var b64 = Marshalls.utf8_to_base64(text) + $VBoxContainer/ExportedCode.text = b64 + visible = true + $VBoxContainer/ExportedCode.select_all() + $VBoxContainer/ExportedCode.copy() + +func _on_close_pressed() -> void: + visible = false diff --git a/Fonts/Ac437_Trident_8x8.ttf b/Fonts/Ac437_Trident_8x8.ttf new file mode 100644 index 0000000..481524b Binary files /dev/null and b/Fonts/Ac437_Trident_8x8.ttf differ diff --git a/Fonts/Ac437_Trident_8x8.ttf.import b/Fonts/Ac437_Trident_8x8.ttf.import new file mode 100644 index 0000000..2ca8e16 --- /dev/null +++ b/Fonts/Ac437_Trident_8x8.ttf.import @@ -0,0 +1,33 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://c7hlot6dsm01s" +path="res://.godot/imported/Ac437_Trident_8x8.ttf-700703d9d4f422a555a6606f86fe6f3a.fontdata" + +[deps] + +source_file="res://Fonts/Ac437_Trident_8x8.ttf" +dest_files=["res://.godot/imported/Ac437_Trident_8x8.ttf-700703d9d4f422a555a6606f86fe6f3a.fontdata"] + +[params] + +Rendering=null +antialiasing=0 +generate_mipmaps=false +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +allow_system_fallback=true +force_autohinter=false +hinting=1 +subpixel_positioning=1 +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[] +language_support={} +script_support={} +opentype_features={} diff --git a/Icons/Internal.png b/Icons/Internal.png new file mode 100644 index 0000000..d14a8b1 Binary files /dev/null and b/Icons/Internal.png differ diff --git a/icon.svg.import b/Icons/Internal.png.import similarity index 63% rename from icon.svg.import rename to Icons/Internal.png.import index 6f5a69f..c57ec79 100644 --- a/icon.svg.import +++ b/Icons/Internal.png.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://yd2mphfafhah" -path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +uid="uid://cxjq8xhs0a7lg" +path="res://.godot/imported/Internal.png-271ce861b95dc4d3723bafb9fe9d4a5d.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://icon.svg" -dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] +source_file="res://Icons/Internal.png" +dest_files=["res://.godot/imported/Internal.png-271ce861b95dc4d3723bafb9fe9d4a5d.ctex"] [params] @@ -32,6 +32,3 @@ process/hdr_as_srgb=false process/hdr_clamp_exposure=false process/size_limit=0 detect_3d/compress_to=1 -svg/scale=1.0 -editor/scale_with_editor_scale=false -editor/convert_colors_with_editor_theme=false diff --git a/Icons/User.png b/Icons/User.png new file mode 100644 index 0000000..8415866 Binary files /dev/null and b/Icons/User.png differ diff --git a/Icons/User.png.import b/Icons/User.png.import new file mode 100644 index 0000000..87b096a --- /dev/null +++ b/Icons/User.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bhp4jjlq62fmu" +path="res://.godot/imported/User.png-6910c28b928ba74ae97b734bee82a7d1.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Icons/User.png" +dest_files=["res://.godot/imported/User.png-6910c28b928ba74ae97b734bee82a7d1.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +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/ImportPanel.gd b/ImportPanel.gd new file mode 100644 index 0000000..2d23b36 --- /dev/null +++ b/ImportPanel.gd @@ -0,0 +1,18 @@ +extends PanelContainer + +signal object_imported(data : Dictionary) + +func show_panel() -> void: + $VBoxContainer/ImportedCode.text = "" + $VBoxContainer/ImportedCode.grab_focus() + visible = true + +func _on_import_pressed() -> void: + var text = Marshalls.base64_to_utf8($VBoxContainer/ImportedCode.text) + var ob = JSON.parse_string(text) + if ob != null: + object_imported.emit(ob) + visible = false + +func _on_cancel_pressed() -> void: + visible = false diff --git a/LevelEditor.gd b/LevelEditor.gd index fff048e..f5c3912 100644 --- a/LevelEditor.gd +++ b/LevelEditor.gd @@ -4,10 +4,7 @@ extends Node2D func _on_background_item_selected(index: int) -> void: $Background.texture = load($VBoxContainer/Background.get_item_metadata(index)) - -func _on_save_pressed() -> void: - if $VBoxContainer/Name.text == "": - return +func get_level_object() -> Dictionary: var data : Dictionary = { "name": $VBoxContainer/Name.text, "left": $VBoxContainer/Left.get_selected_text(), @@ -21,6 +18,12 @@ func _on_save_pressed() -> void: var brick = get_node("Bricks/Row%d/Col%d" % [row, col]) s += brick.type data.data.push_back(s) + return data + +func _on_save_pressed() -> void: + if $VBoxContainer/Name.text == "": + return + var data : Dictionary = get_level_object() DirAccess.make_dir_recursive_absolute("user://Levels") var f = FileAccess.open("user://Levels/%s.json" % data.name, FileAccess.WRITE) f.store_string(JSON.stringify(data, " ")) @@ -43,17 +46,20 @@ func _on_load_pressed() -> void: func _on_load_panel_load_file(filename: String) -> void: if FileAccess.file_exists(filename): var data = JSON.parse_string(FileAccess.get_file_as_string(filename)) - if data != null: - $VBoxContainer/Name.text = data.name - $VBoxContainer/Left.select_by_name(data.left) - $VBoxContainer/Right.select_by_name(data.right) - $VBoxContainer/Background.select_by_name(data.background) - $Background.texture = load($VBoxContainer/Background.get_selected_filename()) - for row in 18: - for col in 13: - var brick = get_node("Bricks/Row%d/Col%d" % [row, col]) - var c = data.data[row].substr(col, 1) - brick.set_brick_type(c) + load_level_from_object(data) + +func load_level_from_object(data : Dictionary) -> void: + if data != null: + $VBoxContainer/Name.text = data.name + $VBoxContainer/Left.select_by_name(data.left) + $VBoxContainer/Right.select_by_name(data.right) + $VBoxContainer/Background.select_by_name(data.background) + $Background.texture = load($VBoxContainer/Background.get_selected_filename()) + for row in 18: + for col in 13: + var brick = get_node("Bricks/Row%d/Col%d" % [row, col]) + var c = data.data[row].substr(col, 1) + brick.set_brick_type(c) func _on_new_pressed() -> void: @@ -66,3 +72,16 @@ func _on_new_pressed() -> void: for col in 13: var brick = get_node("Bricks/Row%d/Col%d" % [row, col]) brick.set_brick_type(" ") + + +func _on_export_pressed() -> void: + $ExportPanel.show_panel(get_level_object()) + + +func _on_import_pressed() -> void: + $ImportPanel.show_panel() + + +func _on_import_panel_object_imported(data: Dictionary) -> void: + load_level_from_object(data) + pass # Replace with function body. diff --git a/LevelEditor.tscn b/LevelEditor.tscn index 5912dfb..f1ef717 100644 --- a/LevelEditor.tscn +++ b/LevelEditor.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=9 format=3 uid="uid://bxkneahqum6hb"] +[gd_scene load_steps=11 format=3 uid="uid://bxkneahqum6hb"] [ext_resource type="Script" path="res://LevelEditor.gd" id="1_p7hit"] [ext_resource type="Script" path="res://LevelEditCell.gd" id="2_ayd4g"] @@ -8,6 +8,8 @@ [ext_resource type="Script" path="res://LevelSelector.gd" id="6_brm2b"] [ext_resource type="Script" path="res://BackgroundSelector.gd" id="7_x1vot"] [ext_resource type="Script" path="res://LoadPanel.gd" id="8_0o6x4"] +[ext_resource type="Script" path="res://ExportPanel.gd" id="9_nmcps"] +[ext_resource type="Script" path="res://ImportPanel.gd" id="10_q6s0l"] [node name="LevelEditor" type="Node2D"] texture_filter = 1 @@ -2027,6 +2029,23 @@ focus_mode = 0 theme = ExtResource("4_usb0o") text = "SAVE" +[node name="HBoxContainer3" type="HBoxContainer" parent="VBoxContainer"] +layout_mode = 2 + +[node name="Import" type="Button" parent="VBoxContainer/HBoxContainer3"] +layout_mode = 2 +size_flags_horizontal = 3 +focus_mode = 0 +theme = ExtResource("4_usb0o") +text = "IMPORT" + +[node name="Export" type="Button" parent="VBoxContainer/HBoxContainer3"] +layout_mode = 2 +size_flags_horizontal = 3 +focus_mode = 0 +theme = ExtResource("4_usb0o") +text = "EXPORT" + [node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer"] layout_mode = 2 @@ -2075,10 +2094,77 @@ focus_mode = 0 theme = ExtResource("4_usb0o") text = "CANCEL" +[node name="ExportPanel" type="PanelContainer" parent="."] +visible = false +offset_left = 464.0 +offset_top = 16.0 +offset_right = 624.0 +offset_bottom = 344.0 +theme = ExtResource("4_usb0o") +script = ExtResource("9_nmcps") + +[node name="VBoxContainer" type="VBoxContainer" parent="ExportPanel"] +layout_mode = 2 + +[node name="ExportedCode" type="TextEdit" parent="ExportPanel/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +theme = ExtResource("4_usb0o") +text = "ewogICJiYWNrZ3JvdW5kIjogIlJlZEJveGVzIiwKICAiZGF0YSI6IFsKICAgICIgICAgICAgICAgICAgIiwKICAgICIgICAgICAgICAgICAgIiwKICAgICIgICAgICAgICAgICAgIiwKICAgICIgICAgICAgICAgICAgIiwKICAgICIgICAgIHNzcyAgICAgIiwKICAgICIgICAgIENDQyAgICAgIiwKICAgICIgICAgIEdHRyAgICAgIiwKICAgICIgICAgIFJSUiAgICAgIiwKICAgICIgICAgIEJCQiAgICAgIiwKICAgICIgICAgIE1NTSAgICAgIiwKICAgICIgICAgIHNzcyAgICAgIiwKICAgICIgICAgICAgICAgICAgIiwKICAgICIgIGcgICBnICAgZyAgIiwKICAgICIgICAgICAgICAgICAgIiwKICAgICIgICAgICAgICAgICAgIiwKICAgICIgICAgICAgICAgICAgIiwKICAgICIgICAgICAgICAgICAgIiwKICAgICIgICAgICAgICAgICAgIgogIF0sCiAgImxlZnQiOiAiRFVOS0FOT0lEIiwKICAibmFtZSI6ICJUT1dFUiIsCiAgInJpZ2h0IjogIkRVTktBTk9JRCIKfQ==" +editable = false +wrap_mode = 1 +autowrap_mode = 1 + +[node name="Close" type="Button" parent="ExportPanel/VBoxContainer"] +layout_mode = 2 +theme = ExtResource("4_usb0o") +text = "CLOSE" + +[node name="ImportPanel" type="PanelContainer" parent="."] +visible = false +offset_left = 464.0 +offset_top = 16.0 +offset_right = 624.0 +offset_bottom = 344.0 +theme = ExtResource("4_usb0o") +script = ExtResource("10_q6s0l") + +[node name="VBoxContainer" type="VBoxContainer" parent="ImportPanel"] +layout_mode = 2 + +[node name="ImportedCode" type="TextEdit" parent="ImportPanel/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +theme = ExtResource("4_usb0o") +placeholder_text = "Paste code here" +wrap_mode = 1 +autowrap_mode = 1 + +[node name="HBoxContainer" type="HBoxContainer" parent="ImportPanel/VBoxContainer"] +layout_mode = 2 + +[node name="Import" type="Button" parent="ImportPanel/VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +theme = ExtResource("4_usb0o") +text = "IMPORT" + +[node name="Cancel" type="Button" parent="ImportPanel/VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +theme = ExtResource("4_usb0o") +text = "CANCEL" + [connection signal="item_selected" from="VBoxContainer/Background" to="." method="_on_background_item_selected"] [connection signal="pressed" from="VBoxContainer/HBoxContainer/Load" to="." method="_on_load_pressed"] [connection signal="pressed" from="VBoxContainer/HBoxContainer/Save" to="." method="_on_save_pressed"] +[connection signal="pressed" from="VBoxContainer/HBoxContainer3/Import" to="." method="_on_import_pressed"] +[connection signal="pressed" from="VBoxContainer/HBoxContainer3/Export" to="." method="_on_export_pressed"] [connection signal="pressed" from="VBoxContainer/HBoxContainer2/New" to="." method="_on_new_pressed"] [connection signal="pressed" from="VBoxContainer/HBoxContainer2/Exit" to="." method="_on_exit_pressed"] [connection signal="load_file" from="LoadPanel" to="." method="_on_load_panel_load_file"] [connection signal="pressed" from="LoadPanel/VBoxContainer/HBoxContainer/Cancel" to="LoadPanel" method="_on_cancel_pressed"] +[connection signal="pressed" from="ExportPanel/VBoxContainer/Close" to="ExportPanel" method="_on_close_pressed"] +[connection signal="object_imported" from="ImportPanel" to="." method="_on_import_panel_object_imported"] +[connection signal="pressed" from="ImportPanel/VBoxContainer/HBoxContainer/Import" to="ImportPanel" method="_on_import_pressed"] +[connection signal="pressed" from="ImportPanel/VBoxContainer/HBoxContainer/Cancel" to="ImportPanel" method="_on_cancel_pressed"] diff --git a/LoadPanel.gd b/LoadPanel.gd index 45123a7..4254ee3 100644 --- a/LoadPanel.gd +++ b/LoadPanel.gd @@ -9,26 +9,31 @@ func update_level_list() -> void: vb.remove_child(k) k.queue_free() - for file in DirAccess.get_files_at("res://Levels"): - if file.ends_with(".json"): - var data = JSON.parse_string(FileAccess.get_file_as_string("res://Levels/%s" % file)) - var b = Button.new() - b.theme = load("res://MainTheme.tres") - b.text = data.name - b.size_flags_horizontal = Control.SIZE_EXPAND_FILL - b.pressed.connect(_on_load_file_pressed.bind(b)) - b.set_meta("filename", "res://Levels/%s" % file) - vb.add_child(b) for file in DirAccess.get_files_at("user://Levels"): if file.ends_with(".json"): var data = JSON.parse_string(FileAccess.get_file_as_string("user://Levels/%s" % file)) var b = Button.new() b.theme = load("res://MainTheme.tres") b.text = data.name + b.theme_type_variation = "UserFile" b.size_flags_horizontal = Control.SIZE_EXPAND_FILL b.pressed.connect(_on_load_file_pressed.bind(b)) b.set_meta("filename", "user://Levels/%s" % file) + b.icon = load("res://Icons/User.png") vb.add_child(b) + for file in DirAccess.get_files_at("res://Levels"): + if file.ends_with(".json"): + var data = JSON.parse_string(FileAccess.get_file_as_string("res://Levels/%s" % file)) + var b = Button.new() + b.theme = load("res://MainTheme.tres") + b.theme_type_variation = "InternalFile" + b.text = data.name + b.size_flags_horizontal = Control.SIZE_EXPAND_FILL + b.pressed.connect(_on_load_file_pressed.bind(b)) + b.set_meta("filename", "res://Levels/%s" % file) + b.icon = load("res://Icons/Internal.png") + vb.add_child(b) + func show_panel() -> void: update_level_list() diff --git a/MainTheme.tres b/MainTheme.tres index 091a2d8..5957631 100644 --- a/MainTheme.tres +++ b/MainTheme.tres @@ -1,8 +1,9 @@ -[gd_resource type="Theme" load_steps=14 format=3 uid="uid://cfvww0geatnnk"] +[gd_resource type="Theme" load_steps=15 format=3 uid="uid://cfvww0geatnnk"] [ext_resource type="FontFile" uid="uid://dfkm2dibf0c3b" path="res://Fonts/fonts-DSEG_v046/DSEG7-Classic-MINI/DSEG7ClassicMini-Italic.ttf" id="1_17to7"] [ext_resource type="FontFile" uid="uid://bx41ej4o03nbx" path="res://Fonts/arkanoid/Arka_solid.ttf" id="1_s07ae"] [ext_resource type="FontFile" uid="uid://by778rb8miy2e" path="res://Fonts/Ac437_Trident_9x16.ttf" id="2_7inlg"] +[ext_resource type="FontFile" uid="uid://c7hlot6dsm01s" path="res://Fonts/Ac437_Trident_8x8.ttf" id="4_btndm"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_tyvdl"] content_margin_left = 3.0 @@ -102,6 +103,8 @@ Button/styles/hover = SubResource("StyleBoxFlat_l4f7v") Button/styles/normal = SubResource("StyleBoxFlat_ibocc") Button/styles/pressed = SubResource("StyleBoxFlat_ebwwv") HSeparator/styles/separator = SubResource("StyleBoxEmpty_y3y82") +InternalFile/base_type = &"Button" +InternalFile/colors/font_color = Color(0.670588, 0.458824, 0.52549, 1) Label/font_sizes/font_size = 20 Label/fonts/font = ExtResource("2_7inlg") LineEdit/font_sizes/font_size = 20 @@ -120,8 +123,12 @@ Numbers/constants/shadow_outline_size = 3 Numbers/font_sizes/font_size = 18 Numbers/fonts/font = ExtResource("1_17to7") PanelContainer/styles/panel = SubResource("StyleBoxFlat_sf0ln") +TextEdit/font_sizes/font_size = 9 +TextEdit/fonts/font = ExtResource("4_btndm") Upgrade/base_type = &"Label" Upgrade/colors/font_color = Color(0, 0, 0, 1) Upgrade/font_sizes/font_size = 16 Upgrade/fonts/font = ExtResource("2_7inlg") +UserFile/base_type = &"Button" +UserFile/colors/font_color = Color(0.439216, 0.603922, 0.529412, 1) VSeparator/styles/separator = SubResource("StyleBoxEmpty_m7r63") diff --git a/export_presets.cfg b/export_presets.cfg index 43e3ac8..19eeb69 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -109,16 +109,16 @@ codesign/timestamp_server_url="" codesign/digest_algorithm=1 codesign/description="" codesign/custom_options=PackedStringArray() -application/modify_resources=false -application/icon="" -application/console_wrapper_icon="" +application/modify_resources=true +application/icon="res://icon.ico" +application/console_wrapper_icon="res://icon.ico" application/icon_interpolation=4 application/file_version="" application/product_version="" application/company_name="Majenko Technologies" application/product_name="Dunkanoid" -application/file_description="" -application/copyright="" +application/file_description="Dunkanoid" +application/copyright="2024 Majenko Technologies" application/trademarks="" application/export_angle=0 ssh_remote_deploy/enabled=false diff --git a/icon.ico b/icon.ico new file mode 100644 index 0000000..ae3ac00 Binary files /dev/null and b/icon.ico differ diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..92fef5c Binary files /dev/null and b/icon.png differ diff --git a/icon.png.import b/icon.png.import new file mode 100644 index 0000000..6262a8e --- /dev/null +++ b/icon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c1lw7q41h1m8f" +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/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +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/icon.svg b/icon.svg deleted file mode 100644 index b370ceb..0000000 --- a/icon.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/project.godot b/project.godot index 6461776..7cf7e4e 100644 --- a/project.godot +++ b/project.godot @@ -11,11 +11,14 @@ config_version=5 [application] config/name="Dunkanoid" +config/version="0.5.2" run/main_scene="res://Intro.tscn" config/features=PackedStringArray("4.2", "Forward Plus") run/max_fps=30 boot_splash/show_image=false -config/icon="res://icon.svg" +config/icon="res://icon.png" +config/macos_native_icon="res://icon.png" +config/windows_native_icon="res://icon.ico" [autoload]