Add Video singleton.
This enables multiple video views across the game and will aid in the upcoming multiplayer-driven refactoring.
This commit is contained in:
parent
437d361796
commit
cda5f5ac3b
|
@ -11,17 +11,8 @@ _data = [ Vector2( -1, -1 ), 0.0, 0.0, 0, 0, Vector2( 0, 0 ), 2.0, 2.0, 1, 1, Ve
|
||||||
|
|
||||||
[node name="Menu" type="Control"]
|
[node name="Menu" type="Control"]
|
||||||
material = ExtResource( 3 )
|
material = ExtResource( 3 )
|
||||||
margin_left = -540.0
|
|
||||||
margin_top = -540.0
|
|
||||||
margin_right = 540.0
|
|
||||||
margin_bottom = 540.0
|
|
||||||
rect_pivot_offset = Vector2( 540, 540 )
|
|
||||||
rect_clip_content = true
|
rect_clip_content = true
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
__meta__ = {
|
|
||||||
"_edit_use_anchors_": false
|
|
||||||
}
|
|
||||||
NoteHandlerPath = NodePath("../NoteHandler")
|
|
||||||
ease_curve = SubResource( 1 )
|
ease_curve = SubResource( 1 )
|
||||||
|
|
||||||
[node name="ScoreText" type="Node2D" parent="."]
|
[node name="ScoreText" type="Node2D" parent="."]
|
||||||
|
|
|
@ -71,7 +71,7 @@ __meta__ = {
|
||||||
[node name="PanelContainer" type="PanelContainer" parent="."]
|
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||||
margin_top = 38.0
|
margin_top = 38.0
|
||||||
margin_right = 267.0
|
margin_right = 267.0
|
||||||
margin_bottom = 374.0
|
margin_bottom = 626.0
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ __meta__ = {
|
||||||
margin_left = 7.0
|
margin_left = 7.0
|
||||||
margin_top = 7.0
|
margin_top = 7.0
|
||||||
margin_right = 260.0
|
margin_right = 260.0
|
||||||
margin_bottom = 329.0
|
margin_bottom = 581.0
|
||||||
|
|
||||||
[node name="cb_qsettings" type="CheckBox" parent="PanelContainer/VBoxContainer"]
|
[node name="cb_qsettings" type="CheckBox" parent="PanelContainer/VBoxContainer"]
|
||||||
margin_right = 253.0
|
margin_right = 253.0
|
||||||
|
@ -301,6 +301,23 @@ __meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[node name="HSeparator2" type="HSeparator" parent="PanelContainer/VBoxContainer"]
|
||||||
|
margin_top = 326.0
|
||||||
|
margin_right = 253.0
|
||||||
|
margin_bottom = 330.0
|
||||||
|
|
||||||
|
[node name="VidTextureRect" type="TextureRect" parent="PanelContainer/VBoxContainer" groups=[
|
||||||
|
"VideoTexRects",
|
||||||
|
]]
|
||||||
|
margin_top = 334.0
|
||||||
|
margin_right = 253.0
|
||||||
|
margin_bottom = 574.0
|
||||||
|
rect_min_size = Vector2( 240, 240 )
|
||||||
|
size_flags_horizontal = 7
|
||||||
|
size_flags_vertical = 7
|
||||||
|
expand = true
|
||||||
|
stretch_mode = 6
|
||||||
|
|
||||||
[connection signal="toggled" from="PanelContainer/VBoxContainer/cb_qsettings" to="PanelContainer/VBoxContainer/vbox_qsettings" method="set_visible"]
|
[connection signal="toggled" from="PanelContainer/VBoxContainer/cb_qsettings" to="PanelContainer/VBoxContainer/vbox_qsettings" method="set_visible"]
|
||||||
[connection signal="item_selected" from="PanelContainer/VBoxContainer/vbox_qsettings/hbox_language/btn_language" to="." method="_on_btn_language_item_selected"]
|
[connection signal="item_selected" from="PanelContainer/VBoxContainer/vbox_qsettings/hbox_language/btn_language" to="." method="_on_btn_language_item_selected"]
|
||||||
[connection signal="value_changed" from="PanelContainer/VBoxContainer/vbox_qsettings/sl_volume" to="." method="_on_sl_volume_value_changed"]
|
[connection signal="value_changed" from="PanelContainer/VBoxContainer/vbox_qsettings/sl_volume" to="." method="_on_sl_volume_value_changed"]
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
[gd_scene load_steps=20 format=2]
|
[gd_scene load_steps=19 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://scripts/InputHandler.gd" type="Script" id=1]
|
[ext_resource path="res://scripts/InputHandler.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://assets/text-4k.png" type="Texture" id=2]
|
[ext_resource path="res://assets/text-4k.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://scripts/video.gd" type="Script" id=3]
|
|
||||||
[ext_resource path="res://scripts/ScreenFilter.gd" type="Script" id=4]
|
[ext_resource path="res://scripts/ScreenFilter.gd" type="Script" id=4]
|
||||||
[ext_resource path="res://scripts/NoteViewport.gd" type="Script" id=5]
|
[ext_resource path="res://scripts/NoteViewport.gd" type="Script" id=5]
|
||||||
[ext_resource path="res://scripts/NotePainter.gd" type="Script" id=6]
|
[ext_resource path="res://scripts/NotePainter.gd" type="Script" id=6]
|
||||||
|
@ -72,34 +71,23 @@ min_value = -1.0
|
||||||
_data = [ Vector2( -1, -1 ), 0.0, 0.0, 0, 0, Vector2( 0, 0 ), 2.0, 2.0, 1, 1, Vector2( 1, 1 ), 0.0, 0.0, 0, 0 ]
|
_data = [ Vector2( -1, -1 ), 0.0, 0.0, 0, 0, Vector2( 0, 0 ), 2.0, 2.0, 1, 1, Vector2( 1, 1 ), 0.0, 0.0, 0, 0 ]
|
||||||
|
|
||||||
[node name="RadialGame" type="Control"]
|
[node name="RadialGame" type="Control"]
|
||||||
anchor_left = 0.5
|
anchor_right = 1.0
|
||||||
anchor_top = 0.5
|
anchor_bottom = 1.0
|
||||||
anchor_right = 0.5
|
|
||||||
anchor_bottom = 0.5
|
|
||||||
margin_left = -540.0
|
|
||||||
margin_top = -540.0
|
|
||||||
margin_right = 540.0
|
|
||||||
margin_bottom = 540.0
|
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="video" type="VideoPlayer" parent="."]
|
[node name="video" type="TextureRect" parent="." groups=[
|
||||||
anchor_left = 0.5
|
"VideoTexRects",
|
||||||
anchor_top = 0.5
|
]]
|
||||||
anchor_right = 0.5
|
anchor_right = 1.0
|
||||||
anchor_bottom = 0.5
|
anchor_bottom = 1.0
|
||||||
margin_left = -540.0
|
|
||||||
margin_top = -540.0
|
|
||||||
margin_right = 540.0
|
|
||||||
margin_bottom = 540.0
|
|
||||||
grow_horizontal = 2
|
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
|
||||||
volume_db = -80.0
|
expand = true
|
||||||
bus = "Music"
|
stretch_mode = 6
|
||||||
script = ExtResource( 3 )
|
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
@ -160,11 +148,6 @@ script = ExtResource( 6 )
|
||||||
[node name="Menu" parent="." instance=ExtResource( 15 )]
|
[node name="Menu" parent="." instance=ExtResource( 15 )]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
margin_left = 0.0
|
|
||||||
margin_top = 0.0
|
|
||||||
margin_right = 0.0
|
|
||||||
margin_bottom = 0.0
|
|
||||||
NoteHandlerPath = NodePath("../Center/NoteHandler")
|
|
||||||
ease_curve = SubResource( 6 )
|
ease_curve = SubResource( 6 )
|
||||||
|
|
||||||
[node name="Bezel" type="Control" parent="."]
|
[node name="Bezel" type="Control" parent="."]
|
||||||
|
|
|
@ -12,6 +12,14 @@ __meta__ = {
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="RadialGame" parent="." instance=ExtResource( 1 )]
|
[node name="RadialGame" parent="." instance=ExtResource( 1 )]
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
margin_left = -540.0
|
||||||
|
margin_top = -540.0
|
||||||
|
margin_right = 540.0
|
||||||
|
margin_bottom = 540.0
|
||||||
|
|
||||||
[node name="OptionPanel" parent="." instance=ExtResource( 13 )]
|
[node name="OptionPanel" parent="." instance=ExtResource( 13 )]
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ FileLoader="*res://singletons/FileLoader.gd"
|
||||||
Library="*res://singletons/Library.gd"
|
Library="*res://singletons/Library.gd"
|
||||||
GameTheme="*res://singletons/GameTheme.gd"
|
GameTheme="*res://singletons/GameTheme.gd"
|
||||||
SoundPlayer="*res://singletons/SoundPlayer.gd"
|
SoundPlayer="*res://singletons/SoundPlayer.gd"
|
||||||
|
Video="*res://singletons/Video.gd"
|
||||||
|
|
||||||
[debug]
|
[debug]
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,8 @@ signal finished_song(song_key, score_data)
|
||||||
var running := false
|
var running := false
|
||||||
var song_key = ''
|
var song_key = ''
|
||||||
|
|
||||||
export var VideoPlayerPath := @'../../video'
|
|
||||||
onready var MusicPlayer := SoundPlayer.music_player
|
onready var MusicPlayer := SoundPlayer.music_player
|
||||||
onready var VideoPlayer := get_node(VideoPlayerPath)
|
onready var VideoPlayer := Video.video
|
||||||
|
|
||||||
onready var Painter = $Painter
|
onready var Painter = $Painter
|
||||||
onready var SlideTrailHandler = $'Viewport/Center/SlideTrailHandler'
|
onready var SlideTrailHandler = $'Viewport/Center/SlideTrailHandler'
|
||||||
|
@ -480,7 +479,6 @@ func load_track(song_key: String, difficulty_key: String):
|
||||||
var videostream = FileLoader.load_video('songs/' + data.filepath.rstrip('/') + '/' + data.video_filelist[0])
|
var videostream = FileLoader.load_video('songs/' + data.filepath.rstrip('/') + '/' + data.video_filelist[0])
|
||||||
MusicPlayer.set_stream(FileLoader.load_ogg('songs/' + data.filepath.rstrip('/') + '/' + data.audio_filelist[0]))
|
MusicPlayer.set_stream(FileLoader.load_ogg('songs/' + data.filepath.rstrip('/') + '/' + data.audio_filelist[0]))
|
||||||
VideoPlayer.set_stream(videostream)
|
VideoPlayer.set_stream(videostream)
|
||||||
VideoPlayer.update_aspect_ratio(data.video_dimensions[0]/data.video_dimensions[1])
|
|
||||||
# all_notes = FileLoader.Test.stress_pattern()
|
# all_notes = FileLoader.Test.stress_pattern()
|
||||||
|
|
||||||
Note.process_note_list(all_notes, false)
|
Note.process_note_list(all_notes, false)
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
extends VideoPlayer
|
|
||||||
|
|
||||||
func _ready():
|
|
||||||
pass
|
|
||||||
# I need to put videoplayer resizing logic somewhere else, this is placeholder
|
|
||||||
update_aspect_ratio(1440.0/1080.0)
|
|
||||||
|
|
||||||
func update_aspect_ratio(ratio: float):
|
|
||||||
# e.g. for a 1920x1080 video you'd call update_aspect_ratio(1920.0/1080.0)
|
|
||||||
# e.g. for a 1440x1080 video you'd call update_aspect_ratio(1440.0/1080.0)
|
|
||||||
var height = 1080/ratio
|
|
||||||
margin_top = -height/2.0
|
|
||||||
margin_bottom = height/2.0
|
|
|
@ -45,7 +45,6 @@ class Song:
|
||||||
var audio_offsets: Array
|
var audio_offsets: Array
|
||||||
var video_offsets: Array
|
var video_offsets: Array
|
||||||
var audio_preview_times: Array
|
var audio_preview_times: Array
|
||||||
var video_dimensions: Array
|
|
||||||
var chart_difficulties := {}
|
var chart_difficulties := {}
|
||||||
const default_difficulty_keys = ['Z', 'B', 'A', 'E', 'M', 'R', '宴']
|
const default_difficulty_keys = ['Z', 'B', 'A', 'E', 'M', 'R', '宴']
|
||||||
const difficulty_key_ids = {'Z':0, 'B':1, 'A':2, 'E':3, 'M':4, 'R':5, '宴':6}
|
const difficulty_key_ids = {'Z':0, 'B':1, 'A':2, 'E':3, 'M':4, 'R':5, '宴':6}
|
||||||
|
@ -70,8 +69,7 @@ class Song:
|
||||||
video_filelist = values.get('video_filelist', ['%s.webm'%values.get('index', 'video')])
|
video_filelist = values.get('video_filelist', ['%s.webm'%values.get('index', 'video')])
|
||||||
audio_offsets = values.get('audio_filelist', [0.0, 240.0/BPM])
|
audio_offsets = values.get('audio_filelist', [0.0, 240.0/BPM])
|
||||||
video_offsets = values.get('video_filelist', [0.0, 240.0/BPM])
|
video_offsets = values.get('video_filelist', [0.0, 240.0/BPM])
|
||||||
video_dimensions = values.get('video_dimensions', [1.0, 1.0])
|
audio_preview_times = values.get('audio_preview_times', [1.0, 1.0])
|
||||||
audio_preview_times = values.get('video_dimensions', [1.0, 1.0])
|
|
||||||
genre = values.get('genre', 'None')
|
genre = values.get('genre', 'None')
|
||||||
|
|
||||||
chart_filelist = values.get('chart_filelist', ['%s.rgtm'%values.get('index', 'charts')])
|
chart_filelist = values.get('chart_filelist', ['%s.rgtm'%values.get('index', 'charts')])
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
# Video decoding is relatively expensive for Godot so we only want to do it once at a time.
|
||||||
|
|
||||||
|
var video := VideoPlayer.new()
|
||||||
|
|
||||||
|
var texture: Texture setget , get_texture
|
||||||
|
func get_texture() -> Texture:
|
||||||
|
return video.get_video_texture()
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
video.expand = false
|
||||||
|
add_child(video) # Needs to be in scene tree to make the textures
|
||||||
|
video.visible = false # Luckily this is enough to make the textures without rendering
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
get_tree().call_group('VideoTexRects', 'set_texture', self.texture)
|
Loading…
Reference in New Issue