Add a level sequence, show congrats after level, deal with empty puzzle dirs

This commit is contained in:
Sebastian Morr 2020-09-16 16:16:46 +02:00
parent 5066840ae9
commit cc54f33c78
4 changed files with 62 additions and 13 deletions

41
main.gd
View file

@ -43,10 +43,41 @@ func list_levels():
dir.list_dir_end() dir.list_dir_end()
levels.sort() levels.sort()
return levels
var level_sequence = [
"welcome",
"basics",
"blob-create",
"blob-remove",
"index-add",
"index-remove",
"index-update",
"tree-create",
"tree-read",
"tree-nested",
"commit-create",
"commit-parents",
"commit-rhombus",
"ref-create",
"ref-move",
"ref-remove",
"symref-create",
"symref-no-deref",
]
for level in level_sequence:
if not levels.has(level):
push_error("Level '%s' is specified in the sequence, but could not be found" % level)
levels.erase(level)
level_sequence += levels
return level_sequence
func load_level(id): func load_level(id):
$NextLevelButton.hide() $NextLevelButton.hide()
$LevelCongrats.hide()
$LevelDescription.show()
current_level = id current_level = id
var levels = list_levels() var levels = list_levels()
@ -62,6 +93,11 @@ func load_level(id):
var description_file = level_prefix+level+"/description" var description_file = level_prefix+level+"/description"
var description = game.read_file(description_file, "no description") var description = game.read_file(description_file, "no description")
$LevelDescription.bbcode_text = description $LevelDescription.bbcode_text = description
var congrats_file = level_prefix+level+"/congrats"
var congrats = game.read_file(congrats_file, "Good job, you solved the level!\n\nFeel free to try a few more things or click 'Next Level'.")
$LevelCongrats.bbcode_text = congrats
$LevelName.text = level $LevelName.text = level
# We're actually destroying stuff here. # We're actually destroying stuff here.
@ -147,7 +183,8 @@ func save_message():
func show_win_status(): func show_win_status():
$NextLevelButton.show() $NextLevelButton.show()
$LevelDescription.text = "Yay, you solved the puzzle! Enjoy the view or continue to the next level!" $LevelDescription.hide()
$LevelCongrats.show()
func repopulate_levels(): func repopulate_levels():

View file

@ -131,6 +131,20 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="LevelCongrats" type="RichTextLabel" parent="."]
visible = false
margin_left = 1224.0
margin_top = 121.0
margin_right = 1908.0
margin_bottom = 605.0
custom_fonts/normal_font = ExtResource( 5 )
bbcode_enabled = true
bbcode_text = "Level description here!"
text = "Level congrats here!"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="NextLevelButton" type="Button" parent="."] [node name="NextLevelButton" type="Button" parent="."]
margin_left = 1688.03 margin_left = 1688.03
margin_top = 16.2615 margin_top = 16.2615

View file

@ -13,8 +13,6 @@ var _simplified_view = false
func _ready(): func _ready():
$Nodes.rect_pivot_offset = $Nodes.rect_size / 2 $Nodes.rect_pivot_offset = $Nodes.rect_size / 2
print($Nodes.rect_pivot_offset)
pass
func _process(_delta): func _process(_delta):
if path: if path:
@ -28,6 +26,8 @@ func _input(event):
$Nodes.rect_scale += Vector2(0.05, 0.05) $Nodes.rect_scale += Vector2(0.05, 0.05)
func update_everything(): func update_everything():
$Index.text = ""
if shell.run("test -d .git && echo yes || echo no") == "yes\n":
update_head() update_head()
update_refs() update_refs()
update_index() update_index()
@ -167,9 +167,9 @@ func update_head():
n.children = {ref_target("HEAD"): ""} n.children = {ref_target("HEAD"): ""}
func all_objects(): func all_objects():
var objects = git("cat-file --batch-check='%(objectname)' --batch-all-objects", true) var obj = git("cat-file --batch-check='%(objectname)' --batch-all-objects", true)
var dict = {} var dict = {}
for o in objects: for o in obj:
dict[o] = "" dict[o] = ""
return dict return dict

View file

@ -23,8 +23,6 @@ margin_top = 80.0
margin_right = 375.079 margin_right = 375.079
margin_bottom = 1044.0 margin_bottom = 1044.0
custom_fonts/font = ExtResource( 2 ) custom_fonts/font = ExtResource( 2 )
text = "file1
file2"
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }