diff --git a/Map/hub.tscn b/Map/hub.tscn index 60accd4..fc9a5a3 100644 --- a/Map/hub.tscn +++ b/Map/hub.tscn @@ -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 diff --git a/Scene/select.tscn b/Scene/select.tscn new file mode 100644 index 0000000..cdd7391 --- /dev/null +++ b/Scene/select.tscn @@ -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 = ">" diff --git a/Script/Actor/Player.gd b/Script/Actor/Player.gd index 65e8a44..14d0427 100644 --- a/Script/Actor/Player.gd +++ b/Script/Actor/Player.gd @@ -259,6 +259,7 @@ func win(): # reset scene Shared.start_reset("hub") + Shared.is_clear = true queue_free() dev.out("map complete") Shared.win() diff --git a/Script/AutoLoad/Shared.gd b/Script/AutoLoad/Shared.gd index f11a79f..ea0f911 100644 --- a/Script/AutoLoad/Shared.gd +++ b/Script/AutoLoad/Shared.gd @@ -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() diff --git a/Script/MapSelect.gd b/Script/MapSelect.gd new file mode 100644 index 0000000..3424391 --- /dev/null +++ b/Script/MapSelect.gd @@ -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") + + diff --git a/project.godot b/project.godot index 95a8211..7fc5735 100644 --- a/project.godot +++ b/project.godot @@ -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]