Skip to content
This repository has been archived by the owner on Jun 15, 2024. It is now read-only.

Commit

Permalink
fix button weirdness, add oops + panic + error handling system
Browse files Browse the repository at this point in the history
  • Loading branch information
int-72h committed Jun 14, 2024
1 parent 6470f7b commit de3982d
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 55 deletions.
2 changes: 1 addition & 1 deletion init.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extends Control
#var oops = preload("res://oops.tscn")
var oops = preload("res://oops.tscn")

var spin_tween: Tween
var s: binding
Expand Down
45 changes: 40 additions & 5 deletions main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,27 @@ var current_game = ""
signal change_to(game)
signal update_game(game)
signal verify_game(game)
var oops_s = preload("res://oops.tscn")
var panic_s = preload("res://panic.tscn")

func panic(err_string):
var z = panic_s.instantiate()
z.find_child("Label2").set("text",err_string)
get_tree().get_root().add_child(z)
await get_tree().create_timer(1).timeout
get_tree().paused = true

func oops(err_string):
var z = oops_s.instantiate()
z.find_child("Label2").set("text",err_string)
get_tree().get_root().add_child(z)
await get_tree().create_timer(1).timeout
get_tree().paused = true

func load_image(path):
if path == "":
panic("no image path specified?")
return
if "res://" in path:
return load(path)
else:
Expand All @@ -43,8 +62,11 @@ func _on_game_verified(status,game):
func _on_game_updated(status,game):
call_deferred("t_game_updated",game)


func _on_error(error_detail):
print(error_detail)

func _on_install_pressed():
games[current_game]["status"] = "installing"
s.update_game(current_game)
$Install.disabled = true
$Install.text = "Installing..."
Expand All @@ -54,6 +76,7 @@ func _on_install_pressed():
tween.tween_property($ProgressBar,"modulate",Color.WHITE,0.2)

func _on_verify_pressed():
games[current_game]["status"] = "verifying"
print("[Belmont/VerifyPressed] Verifying %s" % [current_game])
s.verify_game(current_game)
$Install.disabled = true
Expand Down Expand Up @@ -88,6 +111,7 @@ func ready_after_sutton():
s.connect("game_verified",_on_game_verified)
s.connect("game_updated",_on_game_updated)
s.connect("progress_update",_on_progress_update)
s.connect("error",_on_error)
var z = s.get_server_games()
for x in z:
theme_json[x] = s.get_game_assets(x)
Expand Down Expand Up @@ -122,7 +146,7 @@ func t_progress_update(game,progress):
games[game]["progress"] = progress*100

func t_game_verified(game):
set_buttons(game)
change_game(game)
games[game]["progress"] = 0
if current_game == game:
var tween = get_tree().create_tween()
Expand All @@ -131,7 +155,7 @@ func t_game_verified(game):
$ProgressBar.hide()

func t_game_updated(game):
set_buttons(game)
change_game(game)
$InstalledVersion.text = "[left]Installed Version: [b]%s[/b]" % s.get_installed_version(game)
games[game]["progress"] = 0
if current_game == game:
Expand All @@ -154,21 +178,32 @@ func set_stylebox_colour(stylebox,colour):

func set_buttons(game_name):
if s.get_installed_version(game_name) == "":
if game_name in games.keys():
if "status" in games[game_name].keys():
if games[game_name]["status"] == "installing":
$Install.text = "Installing.."
else:
$Install.text = "Install"
$InstalledVersion.text = "[left]Not Installed!"
$Verify.disabled = true
$Install.disabled = false

else:
$InstalledVersion.text = "[left]Installed Version: [b]%s[/b]" % s.get_installed_version(game_name)
if s.get_installed_version(game_name) == s.get_latest_version(game_name):
$Install.disabled = true
$Install.text = "Installed"
$Verify.disabled = false
$Verify.text = "Verify"
elif int(s.get_installed_version(game_name)) < int(s.get_latest_version(game_name)):
$Verify.text = "Verify"
$Install.disabled = false
$Verify.disabled = false
$Install.text = "Update"
if game_name in games.keys(): # this is insanely cooked
if "status" in games[game_name].keys():
if games[game_name]["status"] == "installing":
$Install.text = "Installing.."
else:
$Install.text = "Install"



Expand Down
1 change: 0 additions & 1 deletion main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ offset_bottom = 350.0
texture = ExtResource("20_17qi8")
expand_mode = 1

[connection signal="change_to" from="Main" to="Main/HBoxContainer" method="_on_Main_change_to"]
[connection signal="pressed" from="Main/TopPanel/HomeButton" to="Main" method="_on_HomeButton_pressed"]
[connection signal="pressed" from="Main/TopPanel/AdvancedButton" to="Main" method="_on_Button4_pressed"]
[connection signal="pressed" from="Main/Install" to="Main" method="_on_install_pressed"]
Expand Down
4 changes: 3 additions & 1 deletion oops.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[gd_scene load_steps=5 format=3 uid="uid://da7m6swunt04t"]
[gd_scene load_steps=6 format=3 uid="uid://da7m6swunt04t"]

[ext_resource type="Texture2D" uid="uid://diee7uq3voana" path="res://assets/adastral-256.svg" id="1_878ms"]
[ext_resource type="Script" path="res://error.gd" id="1_fvxd1"]
[ext_resource type="FontFile" uid="uid://pskwpwxk0pd4" path="res://fonts/HankenGrotesk-SemiBold.ttf" id="2_cx3cw"]

[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_2ld2c"]
Expand All @@ -15,6 +16,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_fvxd1")

[node name="Panel" type="ColorRect" parent="."]
material = SubResource("CanvasItemMaterial_2ld2c")
Expand Down
2 changes: 1 addition & 1 deletion panic.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ theme_override_fonts/normal_font = ExtResource("1_rwsp8")
theme_override_font_sizes/normal_font_size = 20
bbcode_enabled = true
text = "[center]Adastral stopped itself to avoid further issues.
For support, please go to adastral.net and look for the support category.
This is to be expected. This is an alpha build.
To continue, you should restart Adastral.
"
scroll_active = false
Expand Down
74 changes: 28 additions & 46 deletions setup.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://dsp33e8s172n5"]
[gd_scene load_steps=3 format=3 uid="uid://dsp33e8s172n5"]

[ext_resource type="FontFile" uid="uid://culcak1g0byvy" path="res://fonts/HankenGrotesk-Medium.ttf" id="1_e5qvj"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_37v2i"]
bg_color = Color(0, 0.392157, 0.678431, 1)
Expand All @@ -13,63 +15,43 @@ grow_vertical = 2

[node name="Panel" type="Panel" parent="."]
layout_mode = 0
offset_right = 3080.0
offset_right = 770.0
offset_bottom = 350.0
theme_override_styles/panel = SubResource("StyleBoxFlat_37v2i")

[node name="Camera2D" type="Camera2D" parent="."]
offset = Vector2(770, 0)
anchor_mode = 0

[node name="Label" type="Label" parent="."]
layout_mode = 0
offset_right = 40.0
offset_bottom = 23.0
offset_left = 7.0
offset_top = 7.0
offset_right = 172.0
offset_bottom = 56.0
theme_override_fonts/font = ExtResource("1_e5qvj")
text = "Welcome to Adastral.
let's get you set up!"

[node name="Button" type="Button" parent="."]
layout_mode = 0
offset_left = 721.0
offset_top = 144.0
offset_right = 758.0
offset_bottom = 185.0

[node name="Button" type="Button" parent="Button"]
layout_mode = 0
offset_left = 770.0
offset_right = 807.0
offset_bottom = 41.0

[node name="Label2" type="Label" parent="."]
layout_mode = 0
offset_left = 773.0
offset_top = 4.0
offset_right = 890.0
offset_bottom = 28.0
text = "We've detected Steam at:"

[node name="Label4" type="Label" parent="."]
layout_mode = 0
offset_left = 775.0
offset_top = 112.0
offset_right = 1321.0
offset_bottom = 136.0
text = "You've already got this installed!"
offset_left = 6.0
offset_top = 65.0
offset_right = 301.0
offset_bottom = 88.0
theme_override_fonts/font = ExtResource("1_e5qvj")
text = "Sourcemod path:"

[node name="Label3" type="Label" parent="."]
layout_mode = 0
offset_left = 774.0
offset_top = 66.0
offset_right = 1320.0
offset_bottom = 90.0
text = "For some games, you need the Source SDK 2013 (Multiplayer) installed.
"
offset_left = 7.0
offset_top = 91.0
offset_right = 302.0
offset_bottom = 114.0
theme_override_fonts/font = ExtResource("1_e5qvj")
text = "TF2:"

[node name="Label5" type="Label" parent="."]
[node name="Label4" type="Label" parent="."]
layout_mode = 0
offset_left = 777.0
offset_top = 169.0
offset_right = 1323.0
offset_bottom = 193.0
text = "For a few games, you also need TF2 installed. "
offset_left = 6.0
offset_top = 116.0
offset_right = 301.0
offset_bottom = 139.0
theme_override_fonts/font = ExtResource("1_e5qvj")
text = "SDK 2013 Multiplayer:"

0 comments on commit de3982d

Please sign in to comment.