From 562e50b3c9127ec5f15593e58d896c9c50d1ba9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thea=20Sch=C3=B6bl?= Date: Sun, 4 Jun 2023 13:52:57 +0200 Subject: [PATCH] Add install flow --- godot/install_status_button.gd | 13 +++++ godot/installer.tscn | 99 ++++++++++++++++++++++++++++++++++ godot/kart/entry.tscn | 24 +++++++-- godot/kart/maps/ufo/ufo.tscn | 10 +--- godot/main.gd | 3 ++ godot/main.tscn | 22 ++++++-- godot/project.godot | 2 +- 7 files changed, 156 insertions(+), 17 deletions(-) create mode 100644 godot/install_status_button.gd create mode 100644 godot/installer.tscn diff --git a/godot/install_status_button.gd b/godot/install_status_button.gd new file mode 100644 index 0000000..005eee2 --- /dev/null +++ b/godot/install_status_button.gd @@ -0,0 +1,13 @@ +extends Button + +@export var game: String + +func _ready(): + if FileAccess.file_exists("user://%s.pck" % game): + text = "✅" + else: + text = "⚠️" + +func _pressed(): + if !FileAccess.file_exists("user://%s.pck" % game): + get_tree().change_scene_to_file("res://installer.tscn") diff --git a/godot/installer.tscn b/godot/installer.tscn new file mode 100644 index 0000000..4bc55fa --- /dev/null +++ b/godot/installer.tscn @@ -0,0 +1,99 @@ +[gd_scene load_steps=2 format=3 uid="uid://dbpjxkadvcs0l"] + +[sub_resource type="GDScript" id="GDScript_huaxa"] +script/source = "extends CenterContainer + +@onready var progress_bar = %progress +@onready var status = %status +@onready var back = %back +@onready var installer = Mhk3Map.new() + +var thread: Thread + +func _ready(): + installer = Mhk3Map.new() + +func _on_file_dialog_file_selected(path): + back.disabled = true + thread = Thread.new() + thread.start(self.perform_install.bind(path, \"mhk3\")) + +func perform_install(path, game): + status.text = \"Preparing...\" + installer.start_install(path, game) + while true: + var result = installer.tick_install() + if typeof(result) == TYPE_STRING: + progress_bar.value = installer.progress * 100 + status.text = result + else: + status.text = \"Finishing up...\" + installer.end_install() + progress_bar.value = 100 + status.text = \"Done!\" + back.disabled = false + return + +func _exit_tree(): + if thread != null: + thread.wait_to_finish() + + +func _on_back_pressed(): + get_tree().change_scene_to_file(\"res://main.tscn\") +" + +[node name="installer" type="CenterContainer"] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = SubResource("GDScript_huaxa") + +[node name="VBoxContainer2" type="VBoxContainer" parent="."] +layout_mode = 2 +alignment = 1 + +[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer2"] +custom_minimum_size = Vector2(256, 0) +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 4 +alignment = 1 + +[node name="Label2" type="Label" parent="VBoxContainer2/VBoxContainer"] +layout_mode = 2 +theme_override_font_sizes/font_size = 42 +text = "Installing" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="progress" type="ProgressBar" parent="VBoxContainer2/VBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 + +[node name="status" type="Label" parent="VBoxContainer2"] +unique_name_in_owner = true +layout_mode = 2 +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="back" type="Button" parent="VBoxContainer2"] +unique_name_in_owner = true +layout_mode = 2 +text = "Back" + +[node name="FileDialog" type="FileDialog" parent="."] +initial_position = 1 +title = "Open a File" +size = Vector2i(533, 455) +visible = true +always_on_top = true +popup_window = true +ok_button_text = "Open" +file_mode = 0 +access = 2 + +[connection signal="pressed" from="VBoxContainer2/back" to="." method="_on_back_pressed"] +[connection signal="file_selected" from="FileDialog" to="." method="_on_file_dialog_file_selected"] diff --git a/godot/kart/entry.tscn b/godot/kart/entry.tscn index 751d11b..d21a2ed 100644 --- a/godot/kart/entry.tscn +++ b/godot/kart/entry.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=5 format=3 uid="uid://4n26dt3e4pv3"] +[gd_scene load_steps=6 format=3 uid="uid://4n26dt3e4pv3"] [ext_resource type="Shader" path="res://kart/flag.gdshader" id="1_myhy7"] [ext_resource type="FontFile" uid="uid://b50bdb32aerbb" path="res://remakes/font/LondrinaSolid-Regular.otf" id="2_os5ao"] @@ -15,6 +15,13 @@ shader_parameter/color2 = Color(1, 1, 1, 1) [sub_resource type="Theme" id="Theme_ugqrn"] +[sub_resource type="GDScript" id="GDScript_2emc5"] +script/source = "extends PanelContainer + +func _select_map(map): + get_tree().change_scene_to_file(\"res://kart/maps/ufo/ufo.tscn\") +" + [node name="Control" type="PanelContainer"] material = SubResource("ShaderMaterial_y6o8u") anchors_preset = 15 @@ -23,6 +30,7 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 theme = SubResource("Theme_ugqrn") +script = SubResource("GDScript_2emc5") [node name="Logo" type="Control" parent="."] custom_minimum_size = Vector2(300, 200) @@ -80,12 +88,18 @@ vertical_alignment = 1 [node name="MarginContainer" type="MarginContainer" parent="."] layout_mode = 2 -[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] +[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"] layout_mode = 2 -size_flags_horizontal = 4 size_flags_vertical = 4 alignment = 1 -[node name="Button" type="Button" parent="MarginContainer/VBoxContainer"] +[node name="Button" type="Button" parent="MarginContainer/HBoxContainer"] layout_mode = 2 -text = "Start" +text = "UFO" + +[node name="Button2" type="Button" parent="MarginContainer/HBoxContainer"] +layout_mode = 2 +disabled = true +text = "Shimalaya" + +[connection signal="pressed" from="MarginContainer/HBoxContainer/Button" to="." method="_select_map" binds= ["ufo"]] diff --git a/godot/kart/maps/ufo/ufo.tscn b/godot/kart/maps/ufo/ufo.tscn index bae9e2a..b744fc6 100644 --- a/godot/kart/maps/ufo/ufo.tscn +++ b/godot/kart/maps/ufo/ufo.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=142 format=3 uid="uid://c0r3rywql7mm1"] +[gd_scene load_steps=141 format=3 uid="uid://c0r3rywql7mm1"] [ext_resource type="Script" path="res://kart/map.gd" id="1_kg2pw"] [ext_resource type="ArrayMesh" path="res://games/mhk3/D/Moorhuhnkart/3dobjects_tracks/track07_ufo/CullingPlane.lwo/layer_0.res" id="2_i2nmm"] @@ -122,7 +122,6 @@ [ext_resource type="ArrayMesh" path="res://games/mhk3/D/Moorhuhnkart/3dobjects_tracks/track07_ufo/waende.lwo/layer_8.res" id="120_x0lm7"] [ext_resource type="ArrayMesh" path="res://games/mhk3/D/Moorhuhnkart/3dobjects_tracks/track07_ufo/waende.lwo/layer_9.res" id="121_jfm1k"] [ext_resource type="Script" path="res://kart/FinishLine.gd" id="123_1kl2a"] -[ext_resource type="LightmapGIData" uid="uid://xevskp8ah5fi" path="res://kart/maps/ufo/ufo.lmbake" id="123_ln603"] [sub_resource type="Environment" id="Environment_jmqkf"] reflected_light_source = 1 @@ -369,7 +368,6 @@ environment = SubResource("Environment_jmqkf") [node name="Sun" type="DirectionalLight3D" parent="."] transform = Transform3D(-0.771433, -0.0339059, 0.635407, 0.126327, 0.970542, 0.205159, -0.623645, 0.238535, -0.744424, 262.612, 0, -1.24118) -visible = false light_bake_mode = 1 shadow_normal_bias = 10.0 shadow_reverse_cull_face = true @@ -1562,6 +1560,7 @@ omni_range = 9.60262 [node name="sun blocker" type="MeshInstance3D" parent="."] transform = Transform3D(492.265, 0, 0, 0, 1, 0, 0, 0, 719.198, -67.3466, 25.5562, 46.1811) +visible = false mesh = SubResource("QuadMesh_enhn7") [node name="colmesh" type="StaticBody3D" parent="."] @@ -1589,11 +1588,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -142.945, 15.6906, 21.2187) size = Vector3(81.587, 19.4637, 51.5803) material = SubResource("FogMaterial_018wf") -[node name="LightmapGI" type="LightmapGI" parent="."] -directional = true -interior = true -light_data = ExtResource("123_ln603") - [node name="FinishLine" type="Area3D" parent="."] unique_name_in_owner = true script = ExtResource("123_1kl2a") diff --git a/godot/main.gd b/godot/main.gd index eadf105..80eaf28 100644 --- a/godot/main.gd +++ b/godot/main.gd @@ -2,3 +2,6 @@ extends ScrollContainer func _on_install(): pass + +func _start_mhk(): + get_tree().change_scene_to_file("res://kart/entry.tscn") diff --git a/godot/main.tscn b/godot/main.tscn index d814bde..d5b41fc 100644 --- a/godot/main.tscn +++ b/godot/main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=21 format=3 uid="uid://cmqfu6cc780h4"] +[gd_scene load_steps=22 format=3 uid="uid://cmqfu6cc780h4"] [ext_resource type="Theme" uid="uid://ks2uyxqg6u4k" path="res://mhjnr/theme.tres" id="1_knjtf"] [ext_resource type="Script" path="res://main.gd" id="2_p7swk"] @@ -9,6 +9,7 @@ [ext_resource type="Texture2D" uid="uid://bk5a3xob0raqj" path="res://cover_art/mh_kart.jpg" id="7_2e20o"] [ext_resource type="Texture2D" uid="uid://dkhygfyylbjov" path="res://cover_art/mh_kart2.jpg" id="8_txpwp"] [ext_resource type="Texture2D" uid="uid://l8groudaf385" path="res://cover_art/mh_kart3.webp" id="9_lxivp"] +[ext_resource type="Script" path="res://install_status_button.gd" id="10_5ntk6"] [ext_resource type="Texture2D" uid="uid://cjp0ilsodyu4j" path="res://cover_art/mh_kart4.jpg" id="10_7ea4r"] [ext_resource type="Texture2D" uid="uid://wetnflcj1b0w" path="res://cover_art/mh1.jpg" id="11_jg4b8"] [ext_resource type="Texture2D" uid="uid://baqjofchj6yaw" path="res://cover_art/mhw.webp" id="12_rg2iw"] @@ -55,6 +56,7 @@ layout_mode = 2 [node name="Schatzjaeger1" type="Button" parent="margins/VBoxContainer/JNR/JNR"] custom_minimum_size = Vector2(200, 256) layout_mode = 2 +disabled = true icon = ExtResource("3_5nh86") flat = true icon_alignment = 1 @@ -63,6 +65,7 @@ expand_icon = true [node name="Schatzjaeger2" type="Button" parent="margins/VBoxContainer/JNR/JNR"] custom_minimum_size = Vector2(200, 256) layout_mode = 2 +disabled = true icon = ExtResource("4_f32r0") flat = true icon_alignment = 1 @@ -71,6 +74,7 @@ expand_icon = true [node name="Schatzjaeger3" type="Button" parent="margins/VBoxContainer/JNR/JNR"] custom_minimum_size = Vector2(200, 256) layout_mode = 2 +disabled = true icon = ExtResource("5_wx0lg") flat = true icon_alignment = 1 @@ -88,11 +92,18 @@ expand_icon = true [node name="Kart" type="VBoxContainer" parent="margins/VBoxContainer"] layout_mode = 2 -[node name="Label2" type="Label" parent="margins/VBoxContainer/Kart"] +[node name="HBoxContainer" type="HBoxContainer" parent="margins/VBoxContainer/Kart"] +layout_mode = 2 + +[node name="Label2" type="Label" parent="margins/VBoxContainer/Kart/HBoxContainer"] layout_mode = 2 theme_override_font_sizes/font_size = 40 text = "Moorhuhn Kart" +[node name="Button" type="Button" parent="margins/VBoxContainer/Kart/HBoxContainer"] +layout_mode = 2 +text = "Start" + [node name="JNR2" type="HFlowContainer" parent="margins/VBoxContainer/Kart"] layout_mode = 2 @@ -117,11 +128,14 @@ expand_icon = true [node name="Kart3" type="Button" parent="margins/VBoxContainer/Kart/JNR2"] custom_minimum_size = Vector2(200, 256) layout_mode = 2 -disabled = true +theme_override_font_sizes/font_size = 76 +text = "✅" icon = ExtResource("9_lxivp") flat = true icon_alignment = 1 expand_icon = true +script = ExtResource("10_5ntk6") +game = "mhk3" [node name="Kart4" type="Button" parent="margins/VBoxContainer/Kart/JNR2"] custom_minimum_size = Vector2(200, 256) @@ -232,3 +246,5 @@ icon = ExtResource("20_bo8ks") flat = true icon_alignment = 1 expand_icon = true + +[connection signal="pressed" from="margins/VBoxContainer/Kart/HBoxContainer/Button" to="." method="_start_mhk"] diff --git a/godot/project.godot b/godot/project.godot index 4911587..c2c2997 100644 --- a/godot/project.godot +++ b/godot/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="MHJNR" -run/main_scene="res://mhjnr/level.tscn" +run/main_scene="res://main.tscn" config/features=PackedStringArray("4.0", "GL Compatibility") boot_splash/bg_color=Color(0, 0, 0, 0) boot_splash/image="res://icon.png"