Skip to content

Commit

Permalink
Add warning when wad cannot be found
Browse files Browse the repository at this point in the history
  • Loading branch information
popcar2 committed Apr 6, 2024
1 parent 70d248f commit 2d12aad
Show file tree
Hide file tree
Showing 9 changed files with 197 additions and 7 deletions.
Binary file added Art/warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Art/warning.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://cv2ui2qqrcq6"
path="res://.godot/imported/warning.png-1f5b3cafab3ebf8fceb7a36833996f6b.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Art/warning.png"
dest_files=["res://.godot/imported/warning.png-1f5b3cafab3ebf8fceb7a36833996f6b.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=true
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
File renamed without changes.
13 changes: 11 additions & 2 deletions Scenes/MainScene/main_scene.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@ func _on_start_button_pressed() -> void:
if launching_game:
return

# Check if there are any missing wads
for mod_panel: ModPanel in %ModsVBoxContainer.get_children():
if mod_panel.get_node("%CheckBox").button_pressed:
if mod_panel.get_node("%MissingWarning").visible:
%MissingModsPopup.show()
return

launching_game = true
start_game()
%StartButton.text = "Have fun!"
await get_tree().create_timer(1).timeout
%StartButton.text = "Start Game"
launching_game = false
if GlobalConfig.close_after_starting:
get_tree().quit()

func start_game() -> void:
var run_flatpak: bool = GlobalConfig.default_exe == "GZDoom (Flatpak)"
Expand Down Expand Up @@ -54,6 +59,10 @@ func start_game() -> void:
OS.create_process(GlobalConfig.default_exe, argument_strings)

save_profile()

if GlobalConfig.close_after_starting:
await get_tree().create_timer(1).timeout
get_tree().quit()

func _on_settings_button_pressed():
if $Settings.visible:
Expand Down
105 changes: 103 additions & 2 deletions Scenes/MainScene/main_scene.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=43 format=3 uid="uid://dvgched8fki6"]
[gd_scene load_steps=49 format=3 uid="uid://dvgched8fki6"]

[ext_resource type="FontFile" uid="uid://b75tskygvw2u6" path="res://Fonts/Roboto-Regular.ttf" id="1_4htwb"]
[ext_resource type="Script" path="res://Scenes/MainScene/main_scene.gd" id="2_7s6wy"]
Expand All @@ -9,13 +9,14 @@
[ext_resource type="Script" path="res://Scenes/MainScene/profile_select.gd" id="5_jbqkg"]
[ext_resource type="Texture2D" uid="uid://b54x4jpjoyi6r" path="res://Art/dropdown-icon.png" id="5_yykeh"]
[ext_resource type="FontFile" uid="uid://hi05li2fdpnu" path="res://Fonts/Roboto-Bold.ttf" id="6_ugyx2"]
[ext_resource type="Script" path="res://Scenes/MainScene/ConsoleCommandTextEdit.gd" id="7_v2i11"]
[ext_resource type="Script" path="res://Scenes/MainScene/ConsoleCommandLineEdit.gd" id="7_v2i11"]
[ext_resource type="Script" path="res://Scenes/Settings/Settings.gd" id="11_p0vs3"]
[ext_resource type="Theme" uid="uid://dnl67yen3fxii" path="res://Themes/tooltip_theme.tres" id="12_j5hen"]
[ext_resource type="Script" path="res://Scenes/Misc/show_if_flatpak_detected.gd" id="12_s8ut6"]
[ext_resource type="Texture2D" uid="uid://dq4x8d6ltfh3l" path="res://Art/tooltip-icon.png" id="13_dames"]
[ext_resource type="Texture2D" uid="uid://dkgocqv70qjfg" path="res://Art/Heart.png" id="13_vvfyf"]
[ext_resource type="Script" path="res://Scenes/Misc/donate_button.gd" id="14_65s0t"]
[ext_resource type="Script" path="res://Scenes/MainScene/missing_mods_popup.gd" id="17_76dfd"]

[sub_resource type="Theme" id="Theme_5w21q"]
default_font = ExtResource("1_4htwb")
Expand Down Expand Up @@ -181,6 +182,37 @@ corner_radius_top_right = 10
corner_radius_bottom_right = 10
corner_radius_bottom_left = 10

[sub_resource type="Theme" id="Theme_tl0mn"]
default_font = ExtResource("1_4htwb")

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_e5qfo"]
bg_color = Color(0.564706, 0.00784314, 0.027451, 1)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_7m1vi"]
bg_color = Color(0.815686, 0, 0, 1)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_un2vf"]
bg_color = Color(0.564706, 0.00784314, 0.027451, 1)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_j8t35"]
bg_color = Color(0.615686, 0.00784314, 0.0313726, 1)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5

[node name="MainScene" type="Control"]
layout_mode = 3
anchors_preset = 15
Expand Down Expand Up @@ -879,6 +911,71 @@ bbcode_enabled = true
text = "[center]Created by popcar2"
fit_content = true

[node name="MissingModsPopup" type="Window" parent="."]
unique_name_in_owner = true
title = "New Profile"
initial_position = 1
size = Vector2i(400, 120)
visible = false
transient = true
unresizable = true
popup_window = true
script = ExtResource("17_76dfd")

[node name="Control" type="Control" parent="MissingModsPopup"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = SubResource("Theme_tl0mn")

[node name="MissingModsText" type="RichTextLabel" parent="MissingModsPopup/Control"]
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_top = 20.0
offset_bottom = 58.0
grow_horizontal = 2
theme_override_fonts/bold_font = ExtResource("6_ugyx2")
bbcode_enabled = true
text = "[center]One or more enabled wads are missing!
Are you sure you want to start the game?"
fit_content = true

[node name="HBoxContainer" type="HBoxContainer" parent="MissingModsPopup/Control"]
layout_mode = 1
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 25.0
offset_top = -50.0
offset_right = -25.0
offset_bottom = -15.0
grow_horizontal = 2
grow_vertical = 0
theme_override_constants/separation = 20

[node name="Cancel" type="Button" parent="MissingModsPopup/Control/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 20
theme_override_styles/normal = SubResource("StyleBoxFlat_e5qfo")
theme_override_styles/hover = SubResource("StyleBoxFlat_7m1vi")
theme_override_styles/pressed = SubResource("StyleBoxFlat_un2vf")
text = "Cancel"

[node name="Start" type="Button" parent="MissingModsPopup/Control/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 20
theme_override_styles/normal = SubResource("StyleBoxFlat_j8t35")
theme_override_styles/hover = SubResource("StyleBoxFlat_7m1vi")
theme_override_styles/pressed = SubResource("StyleBoxFlat_un2vf")
text = "Start Anyways"

[connection signal="pressed" from="ModsMenu/Control/AddModButton" to="ModsMenu/Control/AddModButton" method="_on_pressed"]
[connection signal="files_selected" from="ModsMenu/Control/AddModButton/FileDialog" to="ModsMenu/Control/AddModButton" method="_on_files_selected"]
[connection signal="pressed" from="ModsMenu/Control/RemoveModButton" to="ModsMenu/Control/RemoveModButton" method="_on_pressed"]
Expand All @@ -904,3 +1001,7 @@ fit_content = true
[connection signal="mouse_entered" from="Settings/DonateButton" to="Settings/DonateButton" method="_on_mouse_entered"]
[connection signal="mouse_exited" from="Settings/DonateButton" to="Settings/DonateButton" method="_on_mouse_exited"]
[connection signal="pressed" from="Settings/DonateButton" to="Settings/DonateButton" method="_on_pressed"]
[connection signal="close_requested" from="MissingModsPopup" to="MissingModsPopup" method="_on_close_requested"]
[connection signal="pressed" from="MissingModsPopup/Control/HBoxContainer/Cancel" to="MissingModsPopup" method="_on_cancel_pressed"]
[connection signal="pressed" from="MissingModsPopup/Control/HBoxContainer/Start" to="." method="start_game"]
[connection signal="pressed" from="MissingModsPopup/Control/HBoxContainer/Start" to="MissingModsPopup" method="_on_start_pressed"]
7 changes: 7 additions & 0 deletions Scenes/MainScene/missing_mods_popup.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extends Window

func _on_cancel_pressed():
hide()

func _on_start_pressed():
hide()
13 changes: 13 additions & 0 deletions Scenes/ModPanel/mod_panel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ var is_grabbed: bool

func _ready() -> void:
start_color = self_modulate

await get_tree().process_frame

# Check if mod actually exists
if !FileAccess.file_exists(%ModPathText.text):
$MissingWarning.visible = true
%ModTitleText.position.x += 15
%ModTitleText.size.x -= 15

func flash_panel():
var tween: Tween = create_tween()
Expand Down Expand Up @@ -87,3 +95,8 @@ func _on_file_dialog_file_selected(path: String) -> void:

%ModPathText.text = path
%ModTitleText.text = path.get_file().split(".")[0]

if %MissingWarning.visible:
$MissingWarning.visible = false
%ModTitleText.position.x -= 15
%ModTitleText.size.x += 15
28 changes: 27 additions & 1 deletion Scenes/ModPanel/mod_panel.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[gd_scene load_steps=4 format=3 uid="uid://clnuxvf3lyana"]
[gd_scene load_steps=6 format=3 uid="uid://clnuxvf3lyana"]

[ext_resource type="Script" path="res://Scenes/ModPanel/mod_panel.gd" id="1_7qdrt"]
[ext_resource type="Script" path="res://Scenes/ModPanel/CheckBoxHitbox.gd" id="2_rl0ur"]
[ext_resource type="Texture2D" uid="uid://cv2ui2qqrcq6" path="res://Art/warning.png" id="3_b1t8j"]
[ext_resource type="Theme" uid="uid://dnl67yen3fxii" path="res://Themes/tooltip_theme.tres" id="3_k0xov"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_o12b3"]
bg_color = Color(1, 1, 1, 1)
Expand Down Expand Up @@ -39,6 +41,7 @@ size_flags_horizontal = 3
size_flags_vertical = 4
size_flags_stretch_ratio = 0.3
mouse_filter = 2
bbcode_enabled = true
text = "Hello"
autowrap_mode = 0

Expand Down Expand Up @@ -104,6 +107,29 @@ access = 2
filters = PackedStringArray("*.wad,*.pk3; Doom Wad", "*; All Files")
use_native_dialog = true

[node name="MissingWarning" type="TextureRect" parent="."]
unique_name_in_owner = true
visible = false
texture_filter = 4
layout_mode = 1
anchors_preset = 4
anchor_top = 0.5
anchor_bottom = 0.5
offset_left = 6.0
offset_top = -15.0
offset_right = 32.0
offset_bottom = 11.0
grow_vertical = 2
tooltip_text = "WARNING: This Wad cannot be found!
Have you deleted it or moved it somewhere else?
Double click this listing to update the path or press the - sign to remove it."
mouse_filter = 0
theme = ExtResource("3_k0xov")
texture = ExtResource("3_b1t8j")
expand_mode = 1

[connection signal="gui_input" from="." to="." method="_on_gui_input"]
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]
Expand Down
4 changes: 2 additions & 2 deletions Scenes/NewProfile/new_profile_window.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[gd_scene load_steps=12 format=3 uid="uid://can42bi8nub8n"]

[ext_resource type="FontFile" uid="uid://b75tskygvw2u6" path="res://Fonts/Roboto-Regular.ttf" id="1_7ijqi"]
[ext_resource type="Script" path="res://Scenes/MainScene/ConsoleCommandTextEdit.gd" id="1_gyuah"]
[ext_resource type="Script" path="res://Scenes/NewProfile/new_profile_window.gd" id="1_slyqa"]
[ext_resource type="Script" path="res://Scenes/MainScene/ConsoleCommandLineEdit.gd" id="3_2ig8a"]

[sub_resource type="Theme" id="Theme_x5ffo"]
default_font = ExtResource("1_7ijqi")
Expand Down Expand Up @@ -94,7 +94,7 @@ theme_override_styles/normal = SubResource("StyleBoxEmpty_wlik5")
theme_override_styles/focus = SubResource("StyleBoxEmpty_ca7ck")
placeholder_text = "Profile Name"
max_length = 30
script = ExtResource("1_gyuah")
script = ExtResource("3_2ig8a")

[node name="HBoxContainer" type="HBoxContainer" parent="Control"]
layout_mode = 1
Expand Down

0 comments on commit 2d12aad

Please sign in to comment.