doing some messy work on stage select save data

will definitely need to clean it up
so far just showing saved metrics like time to complete level
This commit is contained in:
Harmony Monroe 2020-11-16 14:24:04 -05:00
parent 1997a19cee
commit 6f9529ca7a
6 changed files with 108 additions and 16 deletions

View file

@ -76,13 +76,3 @@ map_name = "map_tread"
[node name="Exit" parent="Actors" instance=ExtResource( 8 )]
position = Vector2( 40, -34 )
gravity = 0.2
is_moving = false
is_solid = false
is_colliding = false
is_using_gravity = false
is_using_tread = false
dust_count = 5
star_count = 5
star_speed = 6
star_orbit = 10

56
Scene/select.tscn Normal file
View file

@ -0,0 +1,56 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://Font/m3x6.tres" type="DynamicFont" id=1]
[ext_resource path="res://Script/MapSelect.gd" type="Script" id=2]
[node name="Node2D" type="Node2D"]
position = Vector2( 1, 1 )
script = ExtResource( 2 )
map_list = "map0
map1
map2
map3
map4
map5
map6
map_jump_test
map_switch
map_tread
"
[node name="Control" type="Control" parent="."]
margin_right = 320.0
margin_bottom = 180.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="List" type="RichTextLabel" parent="Control"]
margin_left = 17.764
margin_top = 90.0
margin_right = 106.764
margin_bottom = 180.0
custom_fonts/normal_font = ExtResource( 1 )
text = "list"
fit_content_height = true
scroll_active = false
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Info" type="RichTextLabel" parent="Control"]
margin_left = 160.0
margin_top = 10.0
margin_right = 320.0
margin_bottom = 170.0
custom_fonts/normal_font = ExtResource( 1 )
text = "info"
scroll_active = false
[node name="Cursor" type="Label" parent="Control"]
margin_left = 10.0
margin_top = 90.0
margin_right = 50.0
margin_bottom = 104.0
custom_fonts/font = ExtResource( 1 )
text = ">"

View file

@ -259,6 +259,7 @@ func win():
# reset scene
Shared.start_reset("hub")
Shared.is_clear = true
queue_free()
dev.out("map complete")
Shared.win()

View file

@ -9,6 +9,7 @@ var stage : Stage
var is_reset = false
var reset_clock := 0.0
var reset_time := 1.0
var is_clear = false
var _window_scale := 1.0
var map_name := "hub"
@ -57,8 +58,12 @@ func start_reset(arg = ""):
func do_reset():
is_reset = false
dev.out("loading scene: " + "res://Map/" + map_name + ".tscn")
get_tree().change_scene("res://Map/" + map_name + ".tscn")
if is_clear:
is_clear = false
get_tree().change_scene("res://Scene/select.tscn")
else:
dev.out("loading scene: " + "res://Map/" + map_name + ".tscn")
get_tree().change_scene("res://Map/" + map_name + ".tscn")
func death():
death_count += 1
@ -72,6 +77,7 @@ func win():
"name": stage.stage_name,
"time": stage.timer,
"death": death_count,
"file": stage.filename,
}
for i in stage_data:
@ -90,10 +96,8 @@ func save_data(save_file, arg):
file.open("user://" + str(save_file), File.WRITE)
file.store_string(arg)
file.close()
#dev.out("(Shared.save) user://box.save")
#dev.out("[\n" + str(arg) + "\n]")
func load_data(fname):
func load_data(fname = "box.save"):
var file = File.new()
file.open("user://" + str(fname), File.READ)
var content = file.get_as_text()

41
Script/MapSelect.gd Normal file
View file

@ -0,0 +1,41 @@
extends Node2D
var label_list : RichTextLabel
var label_info : RichTextLabel
export(String, MULTILINE) var map_list : String
var maps : PoolStringArray = []
var cursor := 0
var line_height = 9
func _ready():
label_list = $Control/List
label_info = $Control/Info
maps.append_array(map_list.split("\n", false))
label_list.text = map_list
func _process(delta):
var btny = btn.p("down") - btn.p("up")
if btny:
cursor = clamp(cursor + btny, 0, maps.size() - 1)
label_list.rect_position.y = 90 - (cursor * line_height)
label_info.text = str(cursor) + " / " + maps[cursor] + "\n"
for i in Shared.stage_data:
if i.has("file") and i.file == "res://Map/" + maps[cursor] + ".tscn":
label_info.text += "name: " + str(i.name) + "\n"
label_info.text += "file: " + str(i.file) + "\n"
label_info.text += "time: " + str(i.time) + "\n"
label_info.text += "deaths: " + str(i.death) + "\n"
break
if btn.p("action"):
get_tree().change_scene("res://Map/" + maps[cursor] + ".tscn")

View file

@ -87,7 +87,7 @@ _global_script_class_icons={
[application]
config/name="gdBox"
run/main_scene="res://Map/hub.tscn"
run/main_scene="res://Scene/select.tscn"
config/icon="res://icon.png"
[autoload]