Next Level Button and Switch to Bash for Commands

This commit is contained in:
bleeptrack 2020-09-11 13:12:12 +02:00
parent 7c82381e8d
commit 4c79dd24a7
5 changed files with 41 additions and 5 deletions

View file

@ -44,6 +44,7 @@ func list_levels():
return levels
func load_level(id):
$NextLevelButton.hide()
current_level = id
var levels = list_levels()
@ -123,3 +124,7 @@ func save_commit_message():
$CommitMessage.text = ""
$CommitMessage.hide()
input.grab_focus()
func show_win_status():
$NextLevelButton.show()
$LevelDescription.text = "Yay, you solved the puzzle! Enjoy the view or continue to the next level!"

View file

@ -1,10 +1,18 @@
[gd_scene load_steps=5 format=2]
[gd_scene load_steps=7 format=2]
[ext_resource path="res://terminal.tscn" type="PackedScene" id=1]
[ext_resource path="res://main.gd" type="Script" id=2]
[ext_resource path="res://repository.tscn" type="PackedScene" id=3]
[ext_resource path="res://styles/alert_button.tres" type="StyleBox" id=4]
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=5]
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0.847059, 0.0666667, 0.0666667, 1 )
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
[node name="Main" type="Node2D"]
script = ExtResource( 2 )
@ -106,4 +114,19 @@ text = "Level description here!"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="NextLevelButton" type="Button" parent="."]
visible = false
margin_left = 1403.0
margin_top = 16.0
margin_right = 1621.0
margin_bottom = 47.0
custom_styles/hover = SubResource( 1 )
custom_styles/normal = ExtResource( 4 )
custom_fonts/font = ExtResource( 5 )
text = "Next Level"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="CommitMessage/SaveButton" to="." method="save_commit_message"]
[connection signal="pressed" from="NextLevelButton" to="." method="load_next_level"]

View file

@ -59,9 +59,9 @@ func _shell_binary():
var os = OS.get_name()
if os == "X11":
return "sh"
return "bash"
elif os == "Windows":
return "dependencies\\windows\\git\\bin\\sh.exe"
return "dependencies\\windows\\git\\bin\\bash.exe"
else:
push_error("Unsupported OS")
get_tree().quit()

8
styles/alert_button.tres Normal file
View file

@ -0,0 +1,8 @@
[gd_resource type="StyleBoxFlat" format=2]
[resource]
bg_color = Color( 0.717647, 0.160784, 0.160784, 1 )
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3

View file

@ -57,5 +57,5 @@ func receive_output(text):
output.text += text
func check_win_condition():
if repo.shell.run("bash /tmp/win &>/dev/null && echo yes || echo no") == "yes\n":
main.load_next_level()
if repo.shell.run("bash /tmp/win 2>&1 >/dev/null && echo yes || echo no") == "yes\n":
main.show_win_status()