Allow multiple level sets, pull out default order into "sequence" file

This commit is contained in:
Sebastian Morr 2020-09-22 16:12:03 +02:00
parent a9f096636a
commit 5031009dd5
96 changed files with 37 additions and 29 deletions

18
levels/bottom-up/sequence Normal file
View file

@ -0,0 +1,18 @@
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

1
levels/top-down/sequence Normal file
View file

@ -0,0 +1 @@
welcome

View file

@ -0,0 +1 @@
Hiiii!

38
main.gd
View file

@ -2,6 +2,8 @@ extends Control
var dragged = null
var level_set = "top-down"
#var level_set = "bottom-up"
var current_level = 0
export(NodePath) var terminal_path
@ -42,48 +44,34 @@ func _ready():
func list_levels():
var levels = []
var dir = Directory.new()
dir.open("res://levels")
dir.open("res://levels/%s" % level_set)
dir.list_dir_begin()
while true:
var file = dir.get_next()
if file == "":
break
elif not file.begins_with("."):
elif not file.begins_with(".") and file != "sequence":
levels.append(file)
dir.list_dir_end()
levels.sort()
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",
]
var final_level_sequence = []
var level_sequence = Array(game.read_file("res://levels/%s/sequence" % level_set, "").split("\n"))
for level in level_sequence:
if level == "":
continue
if not levels.has(level):
push_error("Level '%s' is specified in the sequence, but could not be found" % level)
levels.erase(level)
final_level_sequence.push_back(level)
level_sequence += levels
final_level_sequence += levels
return level_sequence
return final_level_sequence
func load_level(id):
next_level_button.hide()
@ -94,7 +82,7 @@ func load_level(id):
var levels = list_levels()
var level = levels[id]
var level_prefix = "res://levels/"
var level_prefix = "res://levels/%s/" % level_set
var goal_repository_path = "/tmp/goal/"
var active_repository_path = "/tmp/active/"

View file

@ -19,9 +19,9 @@ anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -117.279
margin_left = -114.396
margin_top = -59.399
margin_right = -17.2788
margin_right = -14.3955
margin_bottom = -14.399
focus_mode = 0
custom_fonts/font = ExtResource( 1 )
@ -34,9 +34,9 @@ __meta__ = {
[node name="CloseButton" type="Button" parent="."]
anchor_left = 1.0
anchor_right = 1.0
margin_left = -50.0
margin_left = -54.3247
margin_top = 12.0
margin_right = -10.0
margin_right = -14.3247
margin_bottom = 52.0
focus_mode = 0
custom_fonts/font = ExtResource( 1 )