[WIP] transitioning from hardcoded test song to library loading
This commit is contained in:
parent
9e905879bc
commit
e85675f780
|
@ -96,4 +96,20 @@ class Test:
|
||||||
for i in range(1, 32):
|
for i in range(1, 32):
|
||||||
notes.push_back(Note.make_tap(bar*4 + (i/8.0), (bar + i)%8))
|
notes.push_back(Note.make_tap(bar*4 + (i/8.0), (bar + i)%8))
|
||||||
notes.push_back(Note.make_tap(bar*4 + (i/8.0), (bar + i + 3)%8))
|
notes.push_back(Note.make_tap(bar*4 + (i/8.0), (bar + i + 3)%8))
|
||||||
return notes
|
return notes
|
||||||
|
|
||||||
|
func load_folder(folder):
|
||||||
|
var file = File.new()
|
||||||
|
var err = file.open("%s/song.json" % folder, File.READ)
|
||||||
|
if err != OK:
|
||||||
|
print(err)
|
||||||
|
return err
|
||||||
|
var result_json = JSON.parse(file.get_as_text())
|
||||||
|
file.close()
|
||||||
|
if result_json.error != OK:
|
||||||
|
print("Error: ", result_json.error)
|
||||||
|
print("Error Line: ", result_json.error_line)
|
||||||
|
print("Error String: ", result_json.error_string)
|
||||||
|
return result_json.error
|
||||||
|
var result = result_json.result
|
||||||
|
return result
|
|
@ -27,6 +27,15 @@ const COLOR_STAR := Color(0, 0, 1, 1)
|
||||||
const COLOR_DOUBLE := Color(1, 1, 0, 1) # When two (or more in master) hit events coincide
|
const COLOR_DOUBLE := Color(1, 1, 0, 1) # When two (or more in master) hit events coincide
|
||||||
const COLOR_TEXT := Color(1, 1, 1, 1)
|
const COLOR_TEXT := Color(1, 1, 1, 1)
|
||||||
|
|
||||||
|
const COLOR_DIFFICULTY := PoolColorArray([ # Background, foreground for each
|
||||||
|
Color(0.435, 0.333, 1.000), Color(1.0, 1.0, 1.0),
|
||||||
|
Color(0.506, 0.851, 0.333), Color(1.0, 1.0, 1.0),
|
||||||
|
Color(0.973, 0.718, 0.039), Color(1.0, 1.0, 1.0),
|
||||||
|
Color(1.000, 0.541, 0.584), Color(1.0, 1.0, 1.0),
|
||||||
|
Color(0.761, 0.271, 0.902), Color(1.0, 1.0, 1.0),
|
||||||
|
Color(1.0, 1.0, 1.0), Color(0.737, 0.188, 0.894),
|
||||||
|
])
|
||||||
|
|
||||||
var COLOR_ARRAY_TAP := PoolColorArray([COLOR_TAP, COLOR_TAP, COLOR_TAP, COLOR_TAP])
|
var COLOR_ARRAY_TAP := PoolColorArray([COLOR_TAP, COLOR_TAP, COLOR_TAP, COLOR_TAP])
|
||||||
var COLOR_ARRAY_TAP2 := PoolColorArray([COLOR_TAP2, COLOR_TAP2, COLOR_TAP2, COLOR_TAP2])
|
var COLOR_ARRAY_TAP2 := PoolColorArray([COLOR_TAP2, COLOR_TAP2, COLOR_TAP2, COLOR_TAP2])
|
||||||
var COLOR_ARRAY_HOLD := PoolColorArray([
|
var COLOR_ARRAY_HOLD := PoolColorArray([
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
var song_defs = {}
|
||||||
|
var song_images = {}
|
||||||
|
|
||||||
|
func scan_library():
|
||||||
|
print("Scanning library")
|
||||||
|
var rootdir = "res://songs"
|
||||||
|
var dir = Directory.new()
|
||||||
|
var err = dir.open(rootdir)
|
||||||
|
if err == OK:
|
||||||
|
dir.list_dir_begin(true, true)
|
||||||
|
var file_name = dir.get_next()
|
||||||
|
while (file_name != ""):
|
||||||
|
if dir.current_is_dir():
|
||||||
|
if dir.file_exists(file_name + "/song.json"):
|
||||||
|
song_defs[file_name] = FileLoader.load_folder("%s/%s" % [rootdir, file_name])
|
||||||
|
print("Loaded song directory: %s" % file_name)
|
||||||
|
song_images[file_name] = load("%s/%s/%s" % [rootdir, file_name, song_defs[file_name]["tile_filename"]])
|
||||||
|
else:
|
||||||
|
print("Found directory: " + file_name)
|
||||||
|
else:
|
||||||
|
print("Found file: " + file_name)
|
||||||
|
file_name = dir.get_next()
|
||||||
|
dir.list_dir_end()
|
||||||
|
else:
|
||||||
|
print("An error occurred when trying to access the songs directory: ", err)
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
scan_library()
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
#func _process(delta):
|
||||||
|
# pass
|
||||||
|
|
||||||
|
func _draw():
|
||||||
|
var i = -512
|
||||||
|
for key in song_images:
|
||||||
|
draw_texture(song_images[key], Vector2(i, -256))
|
||||||
|
i += 512
|
|
@ -1,6 +1,7 @@
|
||||||
extends "res://main.gd"
|
extends "res://main.gd"
|
||||||
|
|
||||||
# This script will draw all note events.
|
# This script will draw all note events.
|
||||||
|
var running := false
|
||||||
|
|
||||||
var tex := preload("res://assets/spritesheet-4k.png")
|
var tex := preload("res://assets/spritesheet-4k.png")
|
||||||
var tex_judgement_text := preload("res://assets/text-4k.png")
|
var tex_judgement_text := preload("res://assets/text-4k.png")
|
||||||
|
@ -399,18 +400,6 @@ func set_time(seconds: float):
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
set_time(-3.0)
|
|
||||||
bpm = 120.0
|
|
||||||
active_notes = []
|
|
||||||
all_notes = []
|
|
||||||
next_note_to_load = 0
|
|
||||||
|
|
||||||
$meshinstance.material.set_shader_param("star_color", GameTheme.COLOR_STAR)
|
|
||||||
$meshinstance.material.set_shader_param("held_color", GameTheme.COLOR_HOLD_HELD)
|
|
||||||
$meshinstance.material.set_shader_param("bps", bpm/60.0)
|
|
||||||
$meshinstance.material.set_shader_param("screen_size", get_viewport().get_size())
|
|
||||||
$meshinstance.set_texture(tex)
|
|
||||||
|
|
||||||
var rec_scale1 = (float(screen_height)/float(GameTheme.receptor_ring_radius))*0.5
|
var rec_scale1 = (float(screen_height)/float(GameTheme.receptor_ring_radius))*0.5
|
||||||
var uv_array_playfield := PoolVector2Array([Vector2(-1.0, -1.0)*rec_scale1, Vector2(-1.0, 1.0)*rec_scale1, Vector2(1.0, -1.0)*rec_scale1, Vector2(1.0, 1.0)*rec_scale1])
|
var uv_array_playfield := PoolVector2Array([Vector2(-1.0, -1.0)*rec_scale1, Vector2(-1.0, 1.0)*rec_scale1, Vector2(1.0, -1.0)*rec_scale1, Vector2(1.0, 1.0)*rec_scale1])
|
||||||
var vertex_array_playfield := PoolVector2Array([
|
var vertex_array_playfield := PoolVector2Array([
|
||||||
|
@ -430,6 +419,16 @@ func _ready():
|
||||||
noteline_array_image.fill(Color(0.0, 0.0, 0.0))
|
noteline_array_image.fill(Color(0.0, 0.0, 0.0))
|
||||||
# Format: first 15 rows are for hit events, last row is for releases only (no ring glow)
|
# Format: first 15 rows are for hit events, last row is for releases only (no ring glow)
|
||||||
|
|
||||||
|
$"/root/main/InputHandler".connect("button_pressed", self, "button_pressed")
|
||||||
|
$"/root/main/InputHandler".connect("touchbutton_pressed", self, "touchbutton_pressed")
|
||||||
|
$"/root/main/InputHandler".connect("button_released", self, "button_released")
|
||||||
|
$"/root/main/InputHandler".connect("touchbutton_released", self, "touchbutton_released")
|
||||||
|
|
||||||
|
func load_track():
|
||||||
|
set_time(-3.0)
|
||||||
|
active_notes = []
|
||||||
|
all_notes = []
|
||||||
|
next_note_to_load = 0
|
||||||
# all_notes = FileLoader.SRT.load_file("res://songs/199_cirno_master.srt")
|
# all_notes = FileLoader.SRT.load_file("res://songs/199_cirno_master.srt")
|
||||||
all_notes = FileLoader.SRT.load_file("res://songs/199_cirno_adv.srt")
|
all_notes = FileLoader.SRT.load_file("res://songs/199_cirno_adv.srt")
|
||||||
bpm = 175.0
|
bpm = 175.0
|
||||||
|
@ -442,10 +441,11 @@ func _ready():
|
||||||
if note.type == Note.NOTE_SLIDE:
|
if note.type == Note.NOTE_SLIDE:
|
||||||
slide_trail_meshes[note.slide_id] = make_slide_trail_mesh(note)
|
slide_trail_meshes[note.slide_id] = make_slide_trail_mesh(note)
|
||||||
|
|
||||||
$"/root/main/InputHandler".connect("button_pressed", self, "button_pressed")
|
$meshinstance.material.set_shader_param("star_color", GameTheme.COLOR_STAR)
|
||||||
$"/root/main/InputHandler".connect("touchbutton_pressed", self, "touchbutton_pressed")
|
$meshinstance.material.set_shader_param("held_color", GameTheme.COLOR_HOLD_HELD)
|
||||||
$"/root/main/InputHandler".connect("button_released", self, "button_released")
|
$meshinstance.material.set_shader_param("bps", bpm/60.0)
|
||||||
$"/root/main/InputHandler".connect("touchbutton_released", self, "touchbutton_released")
|
$meshinstance.material.set_shader_param("screen_size", get_viewport().get_size())
|
||||||
|
$meshinstance.set_texture(tex)
|
||||||
|
|
||||||
|
|
||||||
func intro_click():
|
func intro_click():
|
||||||
|
@ -470,6 +470,9 @@ func audio_start_time() -> float:
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
var timers_set := false
|
var timers_set := false
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
|
if !running:
|
||||||
|
return
|
||||||
|
|
||||||
$meshinstance.material.set_shader_param("bps", bpm/60.0)
|
$meshinstance.material.set_shader_param("bps", bpm/60.0)
|
||||||
$notelines.material.set_shader_param("bps", bpm/60.0)
|
$notelines.material.set_shader_param("bps", bpm/60.0)
|
||||||
|
|
||||||
|
|
34
main.tscn
34
main.tscn
|
@ -1,19 +1,19 @@
|
||||||
[gd_scene load_steps=14 format=2]
|
[gd_scene load_steps=14 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://main.gd" type="Script" id=1]
|
[ext_resource path="res://main.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://songs/cirno_1080p_rt_cpu1_3M.webm" type="VideoStream" id=2]
|
[ext_resource path="res://video.gd" type="Script" id=2]
|
||||||
[ext_resource path="res://video.gd" type="Script" id=3]
|
[ext_resource path="res://Receptors.gd" type="Script" id=3]
|
||||||
[ext_resource path="res://Receptors.gd" type="Script" id=4]
|
[ext_resource path="res://NoteHandler.gd" type="Script" id=4]
|
||||||
[ext_resource path="res://NoteHandler.gd" type="Script" id=5]
|
[ext_resource path="res://assets/text-4k.png" type="Texture" id=5]
|
||||||
[ext_resource path="res://assets/text-4k.png" type="Texture" id=6]
|
[ext_resource path="res://shaders/notelines.shader" type="Shader" id=6]
|
||||||
[ext_resource path="res://shaders/notelines.shader" type="Shader" id=7]
|
[ext_resource path="res://shaders/notemesh.shader" type="Shader" id=7]
|
||||||
[ext_resource path="res://shaders/notemesh.shader" type="Shader" id=8]
|
[ext_resource path="res://Menu.gd" type="Script" id=8]
|
||||||
[ext_resource path="res://Bezel.gd" type="Script" id=9]
|
[ext_resource path="res://Bezel.gd" type="Script" id=9]
|
||||||
[ext_resource path="res://assets/NotoSans.tres" type="DynamicFont" id=10]
|
[ext_resource path="res://assets/NotoSans.tres" type="DynamicFont" id=10]
|
||||||
[ext_resource path="res://InputHandler.gd" type="Script" id=11]
|
[ext_resource path="res://InputHandler.gd" type="Script" id=11]
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id=1]
|
[sub_resource type="ShaderMaterial" id=1]
|
||||||
shader = ExtResource( 7 )
|
shader = ExtResource( 6 )
|
||||||
shader_param/line_color = Plane( 0.8, 0.8, 1, 0.8 )
|
shader_param/line_color = Plane( 0.8, 0.8, 1, 0.8 )
|
||||||
shader_param/line_color_double = Plane( 1, 1, 0.6, 0.9 )
|
shader_param/line_color_double = Plane( 1, 1, 0.6, 0.9 )
|
||||||
shader_param/dot_color = Plane( 1, 1, 1, 0.8 )
|
shader_param/dot_color = Plane( 1, 1, 1, 0.8 )
|
||||||
|
@ -25,7 +25,7 @@ shader_param/dot_fullbright_thickness = 0.013
|
||||||
shader_param/max_angle = 1.0708
|
shader_param/max_angle = 1.0708
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id=2]
|
[sub_resource type="ShaderMaterial" id=2]
|
||||||
shader = ExtResource( 8 )
|
shader = ExtResource( 7 )
|
||||||
shader_param/bps = null
|
shader_param/bps = null
|
||||||
shader_param/star_color = null
|
shader_param/star_color = null
|
||||||
shader_param/held_color = null
|
shader_param/held_color = null
|
||||||
|
@ -39,6 +39,8 @@ __meta__ = {
|
||||||
"_edit_vertical_guides_": [ 420.85, 1500.91 ]
|
"_edit_vertical_guides_": [ 420.85, 1500.91 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[node name="music" type="AudioStreamPlayer" parent="."]
|
||||||
|
|
||||||
[node name="video" type="VideoPlayer" parent="."]
|
[node name="video" type="VideoPlayer" parent="."]
|
||||||
margin_left = -540.0
|
margin_left = -540.0
|
||||||
margin_top = -540.0
|
margin_top = -540.0
|
||||||
|
@ -48,23 +50,22 @@ grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
rect_pivot_offset = Vector2( 540, 540 )
|
rect_pivot_offset = Vector2( 540, 540 )
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
stream = ExtResource( 2 )
|
volume_db = -80.0
|
||||||
volume_db = -10.92
|
script = ExtResource( 2 )
|
||||||
script = ExtResource( 3 )
|
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="Receptors" type="Node2D" parent="."]
|
[node name="Receptors" type="Node2D" parent="."]
|
||||||
script = ExtResource( 4 )
|
script = ExtResource( 3 )
|
||||||
|
|
||||||
[node name="NoteHandler" type="Node2D" parent="."]
|
[node name="NoteHandler" type="Node2D" parent="."]
|
||||||
script = ExtResource( 5 )
|
script = ExtResource( 4 )
|
||||||
|
|
||||||
[node name="SlideTrailHandler" type="Node2D" parent="NoteHandler"]
|
[node name="SlideTrailHandler" type="Node2D" parent="NoteHandler"]
|
||||||
|
|
||||||
[node name="JudgeText" type="MeshInstance2D" parent="NoteHandler"]
|
[node name="JudgeText" type="MeshInstance2D" parent="NoteHandler"]
|
||||||
texture = ExtResource( 6 )
|
texture = ExtResource( 5 )
|
||||||
|
|
||||||
[node name="notelines" type="MeshInstance2D" parent="NoteHandler"]
|
[node name="notelines" type="MeshInstance2D" parent="NoteHandler"]
|
||||||
material = SubResource( 1 )
|
material = SubResource( 1 )
|
||||||
|
@ -72,6 +73,9 @@ material = SubResource( 1 )
|
||||||
[node name="meshinstance" type="MeshInstance2D" parent="NoteHandler"]
|
[node name="meshinstance" type="MeshInstance2D" parent="NoteHandler"]
|
||||||
material = SubResource( 2 )
|
material = SubResource( 2 )
|
||||||
|
|
||||||
|
[node name="Menu" type="Node2D" parent="."]
|
||||||
|
script = ExtResource( 8 )
|
||||||
|
|
||||||
[node name="Bezel" type="Node2D" parent="."]
|
[node name="Bezel" type="Node2D" parent="."]
|
||||||
script = ExtResource( 9 )
|
script = ExtResource( 9 )
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue