mirror of
https://github.com/HarmonyHoney/tiny_crate.git
synced 2026-01-23 02:34:53 +00:00
new save format! save_maps := {}
This commit is contained in:
parent
ad572bf2b2
commit
917cf8cff4
5 changed files with 113 additions and 104 deletions
|
|
@ -48,7 +48,7 @@ func refresh_score(map_name):
|
|||
var s = SilentWolf.Scores.leaderboards[map_name]
|
||||
scores[map_name] = s
|
||||
emit_signal("new_score")
|
||||
print(s)
|
||||
#print(s)
|
||||
|
||||
func submit_score(board_name, score, _username := Shared.username):
|
||||
if !is_online: return
|
||||
|
|
|
|||
|
|
@ -13,8 +13,7 @@ var is_quit := false
|
|||
var is_level_select := false
|
||||
var is_in_game := false
|
||||
|
||||
var map_path := "res://src/map/"
|
||||
var scene_path := "res://src/menu/select.tscn"
|
||||
var map_dir := "res://src/map/"
|
||||
var main_menu_path := "res://src/menu/StartMenu.tscn"
|
||||
var options_menu_path := "res://src/menu/options/OptionsMenu.tscn"
|
||||
var level_select_path := "res://src/menu/select.tscn"
|
||||
|
|
@ -22,35 +21,34 @@ var win_screen_path := "res://src/menu/WinScreen.tscn"
|
|||
var credits_path := "res://src/menu/credits.tscn"
|
||||
var splash_path := "res://src/menu/splash.tscn"
|
||||
var creator_path := "res://src/menu/Creator.tscn"
|
||||
var scene_path := level_select_path
|
||||
|
||||
var save_data := {}
|
||||
var save_maps := {}
|
||||
var replays := {}
|
||||
var save_filename := "box.save"
|
||||
|
||||
var window_scale := 1
|
||||
var view_size := Vector2(228, 128)
|
||||
var bus_volume = [10, 10, 10]
|
||||
|
||||
var current_map := 0
|
||||
var maps := []
|
||||
var map_save := 0
|
||||
var map_name := ""
|
||||
var map_frame := 0
|
||||
var map_times := {}
|
||||
var deaths := {}
|
||||
var replays := {}
|
||||
var replay := {"frames" : 0, "x" : [], "y": [], "sprite" : []}
|
||||
var replaying := []
|
||||
var is_win := false
|
||||
var replay_name := ""
|
||||
|
||||
var actors := []
|
||||
var player
|
||||
|
||||
var is_note := false
|
||||
var notes := {}
|
||||
var is_replay_note := false
|
||||
var is_replay := false
|
||||
var map_select := 0
|
||||
var maps := []
|
||||
var map_name := ""
|
||||
var map_frame := 0
|
||||
var replay := {"frames" : 0, "x" : [], "y": [], "sprite" : []}
|
||||
var replaying := []
|
||||
var replay_map := ""
|
||||
var count_gems := 0
|
||||
var count_notes := 0
|
||||
|
||||
var is_win := false
|
||||
var is_note := false
|
||||
var is_replay := false
|
||||
var is_replay_note := false
|
||||
|
||||
var username := "crate_kid"
|
||||
export (Array, Color) var palette := []
|
||||
|
|
@ -86,8 +84,8 @@ func _ready():
|
|||
set_bus_volume(i, 7)
|
||||
|
||||
# get all maps
|
||||
for i in dir_list(map_path):
|
||||
scene_dict[map_path + i] = load(map_path + i)
|
||||
for i in dir_list(map_dir):
|
||||
scene_dict[map_dir + i] = load(map_dir + i)
|
||||
maps.append(i.split(".")[0])
|
||||
print("maps: ", maps, " ", maps.size(), " ", scene_dict)
|
||||
|
||||
|
|
@ -102,6 +100,7 @@ func _ready():
|
|||
# load save data
|
||||
load_save()
|
||||
load_replays()
|
||||
count_score()
|
||||
|
||||
Wipe.connect("finish", self, "wipe_finish")
|
||||
|
||||
|
|
@ -151,6 +150,7 @@ func wipe_finish():
|
|||
change_map()
|
||||
|
||||
func change_map():
|
||||
count_score()
|
||||
save()
|
||||
if is_win:
|
||||
save_replays()
|
||||
|
|
@ -158,11 +158,11 @@ func change_map():
|
|||
if !scene_dict.has(scene_path):
|
||||
scene_dict[scene_path] = load(scene_path)
|
||||
get_tree().change_scene_to(scene_dict[scene_path])
|
||||
|
||||
is_level_select = scene_path == level_select_path
|
||||
is_in_game = scene_path.begins_with(map_path) or scene_path.begins_with(win_screen_path)
|
||||
map_name = "" if !is_in_game else scene_path.split("/")[-1].trim_suffix(".tscn")
|
||||
|
||||
is_win = false
|
||||
is_level_select = scene_path == level_select_path
|
||||
is_in_game = scene_path.begins_with(map_dir)
|
||||
map_name = "" if !is_in_game else scene_path.split("/")[-1].trim_suffix(".tscn")
|
||||
map_frame = 0
|
||||
replay = {"frames" : 0, "x" : [], "y" : [], "sprite" : []}
|
||||
replaying = []
|
||||
|
|
@ -172,9 +172,9 @@ func change_map():
|
|||
Pause.set_process_input(true)
|
||||
is_note = false
|
||||
UI.notes.visible = is_level_select
|
||||
UI.notes_label.text = str(notes.size())
|
||||
UI.notes_label.text = str(count_notes)
|
||||
UI.gems.visible = is_level_select
|
||||
UI.gems_label.text = str(map_save)
|
||||
UI.gems_label.text = str(count_gems)
|
||||
UI.keys(false, false)
|
||||
UI.labels("pick", "erase" if scene_path == creator_path else "back", "score" if is_level_select else "menu")
|
||||
|
||||
|
|
@ -184,8 +184,6 @@ func change_map():
|
|||
|
||||
if is_replay or is_replay_note:
|
||||
var m = map_name + ("-note" if is_replay_note else "")
|
||||
is_replay_note = false
|
||||
is_replay = false
|
||||
|
||||
if replays.has(m):
|
||||
replays[m].sort_custom(self, "sort_replays")
|
||||
|
|
@ -197,6 +195,8 @@ func change_map():
|
|||
ghosts[i].visible = true
|
||||
|
||||
elif is_level_select:
|
||||
is_replay = false
|
||||
is_replay_note = false
|
||||
UI.keys(true, true, true, true)
|
||||
TouchScreen.turn_arrows(false)
|
||||
TouchScreen.show_keys(true, true, true, true)
|
||||
|
|
@ -222,7 +222,7 @@ func save_file(fname, arg):
|
|||
file.store_string(arg)
|
||||
file.close()
|
||||
|
||||
func load_file(fname = "user://box.save"):
|
||||
func load_file(fname = ""):
|
||||
var file = File.new()
|
||||
file.open(str(fname), File.READ)
|
||||
var content = file.get_as_text()
|
||||
|
|
@ -238,48 +238,37 @@ func save_replays(arg := replay_map):
|
|||
func load_save():
|
||||
var l = load_file(save_path + save_filename)
|
||||
if l:
|
||||
save_data = JSON.parse(l).result
|
||||
|
||||
# remove replays
|
||||
if save_data.has("replays"):
|
||||
save_data.erase("replays")
|
||||
var p = JSON.parse(l).result
|
||||
if p is Dictionary:
|
||||
save_data = p
|
||||
|
||||
# remove old keys
|
||||
for i in ["replays", "map", "notes", "times", "deaths"]:
|
||||
if save_data.has(i):
|
||||
save_data.erase(i)
|
||||
|
||||
#print("save_data: " + JSON.print(save_data, "\t"))
|
||||
if save_data.has("map"):
|
||||
map_save = int(save_data["map"])
|
||||
if save_data.has("notes"):
|
||||
var n = save_data["notes"]
|
||||
if n is Dictionary:
|
||||
notes = n
|
||||
# convert old saves
|
||||
elif n is Array:
|
||||
notes = {}
|
||||
for i in n:
|
||||
var key = i if (i is String) and ("-" in i) else maps[int(i)]
|
||||
notes[key] = 45260
|
||||
if save_data.has("times"):
|
||||
var d = save_data["times"]
|
||||
if d is Dictionary:
|
||||
map_times = d
|
||||
if save_data.has("deaths"):
|
||||
var d = save_data["deaths"]
|
||||
if d is Dictionary:
|
||||
deaths = d
|
||||
if save_data.has("username"):
|
||||
username = save_data["username"]
|
||||
|
||||
if save_data.has("player_colors"):
|
||||
player_colors = save_data["player_colors"]
|
||||
|
||||
if save_data.has("maps"):
|
||||
save_maps = save_data["maps"]
|
||||
|
||||
else:
|
||||
create_save()
|
||||
else:
|
||||
print(save_filename + " not found")
|
||||
print(save_path + save_filename + " not found")
|
||||
create_save()
|
||||
|
||||
func load_replays():
|
||||
for i in dir_list(save_path):
|
||||
var l = load_file(save_path + i)
|
||||
if l:
|
||||
replays[i.split(".")[0]] = JSON.parse(l).result
|
||||
var p = JSON.parse(l).result
|
||||
if p is Array and p[0] is Dictionary and p[0].has("frames"):
|
||||
replays[i.split(".")[0]] = p
|
||||
else:
|
||||
print(save_path + i + " not found")
|
||||
|
||||
|
|
@ -313,27 +302,29 @@ func create_save():
|
|||
save()
|
||||
|
||||
func unlock():
|
||||
map_save = 99
|
||||
save_data["map"] = map_save
|
||||
# nothing
|
||||
save()
|
||||
|
||||
func win():
|
||||
is_win = true
|
||||
var ms = map_save
|
||||
if map_save < current_map + 1:
|
||||
map_save = current_map + 1
|
||||
|
||||
if is_note and (!notes.has(map_name) or (notes.has(map_name) and map_frame < notes[map_name])):
|
||||
notes[map_name] = map_frame
|
||||
# map
|
||||
if !save_maps.has(map_name):
|
||||
save_maps[map_name] = {}
|
||||
var s = save_maps[map_name]
|
||||
|
||||
if !map_times.has(map_name) or (map_times.has(map_name) and (map_frame < map_times[map_name])):
|
||||
map_times[map_name] = map_frame
|
||||
var hn = s.has("note")
|
||||
if is_note and (!hn or(hn and map_frame < s["note"])):
|
||||
s["note"] = map_frame
|
||||
|
||||
save_data["map"] = map_save
|
||||
save_data["notes"] = notes
|
||||
save_data["times"] = map_times
|
||||
var ht = s.has("time")
|
||||
if !ht or (ht and map_frame < s["time"]):
|
||||
s["time"] = map_frame
|
||||
|
||||
save_data["maps"] = save_maps
|
||||
save_data["username"] = username
|
||||
|
||||
# replays
|
||||
var m = map_name + ("-note" if is_note else "")
|
||||
replay_map = m
|
||||
|
||||
|
|
@ -350,18 +341,30 @@ func win():
|
|||
|
||||
wipe_scene(level_select_path)
|
||||
|
||||
func count_score():
|
||||
count_gems = 0
|
||||
count_notes = 0
|
||||
for i in save_maps.values():
|
||||
if i.has("time"): count_gems += 1
|
||||
if i.has("note"): count_notes += 1
|
||||
|
||||
func sort_replays(a, b):
|
||||
if a["frames"] < b["frames"]:
|
||||
return true
|
||||
return false
|
||||
|
||||
func die():
|
||||
deaths[map_name] = 1 if !deaths.has(map_name) else (deaths[map_name] + 1)
|
||||
save_data["deaths"] = deaths
|
||||
#save()
|
||||
if !save_maps.has(map_name):
|
||||
save_maps[map_name] = {}
|
||||
var s = save_maps[map_name]
|
||||
if !s.has("die"):
|
||||
s["die"] = 1
|
||||
else:
|
||||
s["die"] += 1
|
||||
|
||||
Leaderboard.submit_score("death", 1)
|
||||
Leaderboard.submit_score("death", 1, map_name)
|
||||
print("you died")#, save_data: ", save_data)
|
||||
print("you died")
|
||||
|
||||
# look into a folder and return a list of filenames without file extension
|
||||
func dir_list(path : String):
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
script = ExtResource( 10 )
|
||||
|
||||
[node name="SolidTileMap" parent="." instance=ExtResource( 3 )]
|
||||
tile_data = PoolIntArray( -720896, 0, 0, -720895, 0, 0, -720894, 0, 0, -720893, 0, 0, -720892, 0, 0, -720891, 0, 0, -720890, 0, 0, -720889, 0, 0, -720888, 0, 0, -720887, 0, 0, -720886, 0, 0, -720885, 0, 0, -720884, 0, 0, -589825, 0, 0, -655360, 0, 0, -655348, 0, 0, -655347, 0, 0, -524289, 0, 0, -589811, 0, 0, -458758, 0, 0, -458757, 0, 0, -458756, 0, 0, -458755, 0, 0, -458754, 0, 0, -458753, 0, 0, -524275, 0, 0, -393222, 0, 0, -458739, 0, 0, -327686, 0, 0, -393203, 0, 0, -393202, 0, 0, -393201, 0, 0, -393200, 0, 0, -262150, 0, 0, -262149, 0, 0, -262148, 0, 0, -262147, 0, 0, -327664, 0, 0, -196611, 0, 0, -262128, 0, 0, -131075, 0, 0, -196592, 0, 0, -65539, 0, 0, -131056, 0, 0, -3, 0, 0, -2, 0, 0, -1, 0, 0, -65536, 0, 0, -65535, 0, 0, -65534, 0, 0, -65526, 0, 0, -65525, 0, 0, -65524, 0, 0, -65523, 0, 0, -65522, 0, 0, -65521, 0, 0, -65520, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7, 0, 0, 8, 0, 0, 9, 0, 0, 10, 0, 0 )
|
||||
tile_data = PoolIntArray( -1048585, 536870913, 0, -1048584, 536870913, 0, -1048583, 536870913, 0, -1048582, 536870913, 0, -1048581, 536870913, 0, -1048580, 536870913, 0, -1048579, 536870913, 0, -1048578, 536870913, 0, -1048577, 536870913, 0, -1114112, 536870913, 0, -1114111, 536870913, 0, -1114110, 536870913, 0, -1114109, 536870913, 0, -1114108, 536870913, 0, -1114107, 536870913, 0, -1114106, 536870913, 0, -1114105, 536870913, 0, -1114104, 536870913, 0, -1114103, 536870913, 0, -1114102, 536870913, 0, -1114101, 536870913, 0, -1114100, 536870913, 0, -1114099, 536870913, 0, -1114098, 536870913, 0, -1114097, 536870913, 0, -1114096, 536870913, 0, -1114095, 536870913, 0, -1114094, 536870913, 0, -1114093, 536870913, 0, -1114092, 536870913, 0, -983049, 536870913, 0, -1048556, 536870913, 0, -917513, 536870913, 0, -983020, 536870913, 0, -851977, 536870913, 0, -917484, 536870913, 0, -786441, 536870913, 0, -851948, 536870913, 0, -720905, 536870913, 0, -720897, 0, 0, -786412, 536870913, 0, -655369, 536870913, 0, -655361, 0, 0, -720896, 0, 1, -720895, 0, 0, -720894, 536870912, 1, -720893, 536870912, 1, -720892, 536870912, 0, -720891, 536870912, 1, -720890, 536870912, 1, -720889, 0, 0, -720888, 0, 0, -720887, 536870912, 1, -720886, 536870912, 1, -720885, 536870912, 1, -720884, 536870912, 0, -720876, 536870913, 0, -589833, 536870913, 0, -589825, 536870912, 1, -655360, 536870912, 0, -655348, 0, 0, -655347, 536870912, 1, -655340, 536870913, 0, -524297, 536870913, 0, -524289, 0, 0, -589811, 0, 0, -589804, 536870913, 0, -458761, 536870913, 0, -458760, 536870913, 0, -458759, 536870913, 0, -458758, 0, 0, -458757, 536870912, 1, -458756, 536870912, 1, -458753, 536870912, 1, -524275, 536870912, 1, -524268, 536870913, 0, -393222, 536870912, 1, -458739, 0, 0, -458732, 536870913, 0, -327686, 536870912, 1, -393203, 536870912, 1, -393202, 0, 0, -393201, 0, 0, -393200, 536870912, 1, -393199, 536870913, 0, -393198, 536870913, 0, -393197, 536870913, 0, -393196, 536870913, 0, -262150, 0, 0, -262149, 536870912, 1, -262148, 536870912, 1, -262147, 0, 0, -327664, 0, 0, -196611, 536870912, 1, -262128, 536870912, 1, -131075, 0, 0, -196592, 0, 0, -65539, 536870912, 1, -131056, 536870912, 1, -3, 0, 0, -2, 536870912, 1, -1, 536870912, 1, -65536, 536870912, 1, -65535, 536870912, 1, -65534, 0, 0, -65526, 0, 0, -65525, 536870912, 1, -65524, 536870912, 1, -65523, 536870912, 1, -65522, 536870912, 1, -65521, 536870912, 1, -65520, 0, 0, 2, 0, 0, 3, 536870912, 1, 4, 0, 0, 5, 536870912, 1, 6, 536870912, 1, 7, 536870912, 1, 8, 536870912, 0, 9, 536870912, 1, 10, 0, 0 )
|
||||
|
||||
[node name="SpikeTileMap" parent="." instance=ExtResource( 5 )]
|
||||
tile_data = PoolIntArray( -65533, 0, 0, -65532, 0, 0, -65531, 0, 0, -65530, 0, 0, -65529, 0, 0, -65528, 0, 0, -65527, 0, 0 )
|
||||
|
|
@ -24,6 +24,7 @@ tile_data = PoolIntArray( -65533, 0, 0, -65532, 0, 0, -65531, 0, 0, -65530, 0, 0
|
|||
z_index = -11
|
||||
|
||||
[node name="ObscureMap" parent="." instance=ExtResource( 4 )]
|
||||
tile_data = PoolIntArray( -983048, 536870912, 0, -983047, 536870912, 0, -983046, 536870912, 0, -983045, 536870912, 0, -983044, 536870912, 0, -983043, 536870912, 0, -983042, 536870912, 0, -983041, 536870912, 0, -1048576, 536870912, 0, -1048575, 536870912, 0, -1048574, 536870912, 0, -1048573, 536870912, 0, -1048572, 536870912, 0, -1048571, 536870912, 0, -1048570, 536870912, 0, -1048569, 536870912, 0, -1048568, 536870912, 0, -1048567, 536870912, 0, -1048566, 536870912, 0, -1048565, 536870912, 0, -1048564, 536870912, 0, -1048563, 536870912, 0, -1048562, 536870912, 0, -1048561, 536870912, 0, -1048560, 536870912, 0, -1048559, 536870912, 0, -1048558, 536870912, 0, -1048557, 536870912, 0, -917512, 536870912, 0, -917511, 536870912, 0, -917510, 536870912, 0, -917509, 536870912, 0, -917508, 536870912, 0, -917507, 536870912, 0, -917506, 536870912, 0, -917505, 536870912, 0, -983040, 536870912, 0, -983039, 536870912, 0, -983038, 536870912, 0, -983037, 536870912, 0, -983036, 536870912, 0, -983035, 536870912, 0, -983034, 536870912, 0, -983033, 536870912, 0, -983032, 536870912, 0, -983031, 536870912, 0, -983030, 536870912, 0, -983029, 536870912, 0, -983028, 536870912, 0, -983027, 536870912, 0, -983026, 536870912, 0, -983025, 536870912, 0, -983024, 536870912, 0, -983023, 536870912, 0, -983022, 536870912, 0, -983021, 536870912, 0, -851976, 536870912, 0, -851975, 536870912, 0, -851974, 536870912, 0, -851973, 536870912, 0, -851972, 536870912, 0, -851971, 536870912, 0, -851970, 536870912, 0, -851969, 536870912, 0, -917504, 536870912, 0, -917503, 536870912, 0, -917502, 536870912, 0, -917501, 536870912, 0, -917500, 536870912, 0, -917499, 536870912, 0, -917498, 536870912, 0, -917497, 536870912, 0, -917496, 536870912, 0, -917495, 536870912, 0, -917494, 536870912, 0, -917493, 536870912, 0, -917492, 536870912, 0, -917491, 536870912, 0, -917490, 536870912, 0, -917489, 536870912, 0, -917488, 536870912, 0, -917487, 536870912, 0, -917486, 536870912, 0, -917485, 536870912, 0, -786440, 536870912, 0, -786439, 536870912, 0, -786438, 536870912, 0, -786437, 536870912, 0, -786436, 536870912, 0, -786435, 536870912, 0, -786434, 536870912, 0, -786433, 536870912, 0, -851968, 536870912, 0, -851967, 536870912, 0, -851966, 536870912, 0, -851965, 536870912, 0, -851964, 536870912, 0, -851963, 536870912, 0, -851962, 536870912, 0, -851961, 536870912, 0, -851960, 536870912, 0, -851959, 536870912, 0, -851958, 536870912, 0, -851957, 536870912, 0, -851956, 536870912, 0, -851955, 536870912, 0, -851954, 536870912, 0, -851953, 536870912, 0, -851952, 536870912, 0, -851951, 536870912, 0, -851950, 536870912, 0, -851949, 536870912, 0, -720904, 536870912, 0, -720903, 536870912, 0, -720902, 536870912, 0, -720901, 536870912, 0, -720900, 536870912, 0, -720899, 536870912, 0, -720898, 536870912, 0, -720897, 536870912, 0, -786432, 536870912, 0, -786431, 536870912, 0, -786430, 536870912, 0, -786429, 536870912, 0, -786428, 536870912, 0, -786427, 536870912, 0, -786426, 536870912, 0, -786425, 536870912, 0, -786424, 536870912, 0, -786423, 536870912, 0, -786422, 536870912, 0, -786421, 536870912, 0, -786420, 536870912, 0, -786419, 536870912, 0, -786418, 536870912, 0, -786417, 536870912, 0, -786416, 536870912, 0, -786415, 536870912, 0, -786414, 536870912, 0, -786413, 536870912, 0, -655368, 536870912, 0, -655367, 536870912, 0, -655366, 536870912, 0, -655365, 536870912, 0, -655364, 536870912, 0, -655363, 536870912, 0, -655362, 536870912, 0, -655361, 536870912, 0, -720883, 536870912, 0, -720882, 536870912, 0, -720881, 536870912, 0, -720880, 536870912, 0, -720879, 536870912, 0, -720878, 536870912, 0, -720877, 536870912, 0, -589832, 536870912, 0, -589831, 536870912, 0, -589830, 536870912, 0, -589829, 536870912, 0, -589828, 536870912, 0, -589827, 536870912, 0, -589826, 536870912, 0, -655346, 536870912, 0, -655345, 536870912, 0, -655344, 536870912, 0, -655343, 536870912, 0, -655342, 536870912, 0, -655341, 536870912, 0, -524296, 536870912, 0, -524295, 536870912, 0, -524294, 536870912, 0, -524293, 536870912, 0, -524292, 536870912, 0, -524291, 536870912, 0, -524290, 536870912, 0, -589810, 536870912, 0, -589809, 536870912, 0, -589808, 536870912, 0, -589807, 536870912, 0, -589806, 536870912, 0, -589805, 536870912, 0, -458755, 536870914, 2, -458754, 2, 2, -524274, 536870912, 0, -524273, 536870912, 0, -524272, 536870912, 0, -524271, 536870912, 0, -524270, 536870912, 0, -524269, 536870912, 0, -458738, 536870912, 0, -458737, 536870912, 0, -458736, 536870912, 0, -458735, 536870912, 0, -458734, 536870912, 0, -458733, 536870912, 0 )
|
||||
|
||||
[node name="GameCamera" parent="." instance=ExtResource( 1 )]
|
||||
position = Vector2( 48, -46 )
|
||||
|
|
@ -40,6 +41,6 @@ position = Vector2( -35, -51 )
|
|||
position = Vector2( 117, -16 )
|
||||
|
||||
[node name="Note" parent="Actors" instance=ExtResource( 9 )]
|
||||
position = Vector2( -109, -69 )
|
||||
position = Vector2( 139, -69 )
|
||||
|
||||
[editable path="GameCamera"]
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ export var screen_size = Vector2(136, 104)
|
|||
export var columns = 8
|
||||
var screen_pos := []
|
||||
var screen_static := []
|
||||
var screen_max := 1
|
||||
|
||||
var overlays := []
|
||||
|
||||
|
|
@ -52,17 +53,16 @@ func _ready():
|
|||
|
||||
screen.rect_position -= Vector2.ONE * 500
|
||||
|
||||
map_limit = min(Shared.maps.size(), Shared.map_save)
|
||||
|
||||
# make screens
|
||||
screen_pos = []
|
||||
for i in map_limit:
|
||||
for i in Shared.maps.size():
|
||||
var sy = i / columns
|
||||
var sx = i % columns
|
||||
screen_pos.append((Vector2(sx + (sy % 2) * 0.5, sy) * (screen_size + screen_dist)))
|
||||
screen_list.append(i)
|
||||
screen_max = max(0, screen_pos.size() - 1)
|
||||
|
||||
scroll(Shared.current_map)
|
||||
scroll(Shared.map_select)
|
||||
cam.reset_smoothing()
|
||||
|
||||
screen_list.sort_custom(self, "sort_list")
|
||||
|
|
@ -140,27 +140,31 @@ func make_screen(i := 0):
|
|||
new.rect_position = screen_pos[i]
|
||||
new.get_node("Overlay/Label").text = map_name
|
||||
|
||||
var is_note := Shared.notes.has(map_name)
|
||||
new.get_node("Overlay/Notes").visible = is_note
|
||||
if is_note:
|
||||
new.get_node("Overlay/Notes/Label").text = time_to_string(Shared.notes[map_name])
|
||||
var s = {}
|
||||
if Shared.save_maps.has(map_name):
|
||||
s = Shared.save_maps[map_name]
|
||||
|
||||
var is_time := Shared.map_times.has(map_name)
|
||||
new.get_node("Overlay/Time").visible = is_time
|
||||
new.get_node("Overlay/Gem").modulate = color_gem if is_time else color_new
|
||||
if is_time:
|
||||
new.get_node("Overlay/Time/Label").text = time_to_string(Shared.map_times[map_name])
|
||||
var has_note = s.has("note")
|
||||
new.get_node("Overlay/Notes").visible = has_note
|
||||
if has_note:
|
||||
new.get_node("Overlay/Notes/Label").text = time_to_string(s["note"])
|
||||
|
||||
var is_death : bool = Shared.deaths.has(map_name) and Shared.deaths[map_name] > 0
|
||||
new.get_node("Overlay/Death").visible = is_death
|
||||
if is_death:
|
||||
new.get_node("Overlay/Death/Label").text = str(Shared.deaths[map_name])
|
||||
var has_time = s.has("time")
|
||||
new.get_node("Overlay/Time").visible = has_time
|
||||
new.get_node("Overlay/Gem").modulate = color_gem if has_time else color_new
|
||||
if has_time:
|
||||
new.get_node("Overlay/Time/Label").text = time_to_string(s["time"])
|
||||
|
||||
var has_die = s.has("die")
|
||||
new.get_node("Overlay/Death").visible = has_die
|
||||
if has_die:
|
||||
new.get_node("Overlay/Death/Label").text = str(s["die"])
|
||||
|
||||
screens_node.add_child(new)
|
||||
screens.append(new)
|
||||
overlays.append(new.get_node("Overlay"))
|
||||
screen_static.append(new.get_node("Vis/Static"))
|
||||
view_scene(new.get_node("Vis/ViewportContainer/Viewport"), Shared.map_path + Shared.maps[i] + ".tscn", i)
|
||||
view_scene(new.get_node("Vis/ViewportContainer/Viewport"), Shared.map_dir + Shared.maps[i] + ".tscn", i)
|
||||
|
||||
# view a scene inside the viewport by path
|
||||
func view_scene(port, path, arg):
|
||||
|
|
@ -171,12 +175,14 @@ func view_scene(port, path, arg):
|
|||
port_count += 1
|
||||
|
||||
func scroll(arg = 0):
|
||||
if overlays.size() > cursor:
|
||||
overlays[cursor].visible = true
|
||||
cursor = clamp(cursor + arg, 0, map_limit - 1)
|
||||
var o = overlays.size() > cursor
|
||||
if o: overlays[cursor].visible = true
|
||||
|
||||
cursor = clamp(cursor + arg, 0, screen_max)
|
||||
current_map = Shared.maps[cursor]
|
||||
if overlays.size() > cursor:
|
||||
overlays[cursor].visible = !score_node.visible
|
||||
|
||||
if o: overlays[cursor].visible = !score_node.visible
|
||||
|
||||
var sp = screen_pos[cursor]
|
||||
cursor_node.rect_position = sp
|
||||
score_node.rect_position = sp + Vector2(1, 1)
|
||||
|
|
@ -247,6 +253,5 @@ func time_to_string(arg := 0.0):
|
|||
return str(time / 60.0).pad_zeros(2).pad_decimals(0) + ":" + str(fposmod(time, 60.0)).pad_zeros(2).pad_decimals(0)
|
||||
|
||||
func open_map():
|
||||
if cursor <= Shared.map_save:
|
||||
Shared.current_map = cursor
|
||||
Shared.wipe_scene(Shared.map_path + Shared.maps[cursor] + ".tscn")
|
||||
Shared.map_select = cursor
|
||||
Shared.wipe_scene(Shared.map_dir + Shared.maps[cursor] + ".tscn")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
extends TileMap
|
||||
|
||||
var frac = 0.0
|
||||
var frac = 1.0
|
||||
export var speed := 10.0
|
||||
|
||||
func _ready():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue