integrate scoreboards into main menu (closes #195)
This commit is contained in:
parent
481edb15b7
commit
95cb7ee138
4 changed files with 99 additions and 13 deletions
|
@ -39,3 +39,9 @@ func _on_SoundTest_button_down():
|
|||
yield(Fade, "fade_finished")
|
||||
SceneManager.current_scene = load("res://menus/sound_test.tscn").instance()
|
||||
|
||||
|
||||
|
||||
func _on_HighScores_button_down() -> void:
|
||||
Fade.fade_out(0.4)
|
||||
yield(Fade, "fade_finished")
|
||||
SceneManager.current_scene = load("res://menus/scoreboards.tscn").instance()
|
||||
|
|
|
@ -105,7 +105,7 @@ hframes = 3
|
|||
[node name="Panel" type="Panel" parent="."]
|
||||
material = SubResource( 6 )
|
||||
margin_left = 16.0
|
||||
margin_top = 28.0
|
||||
margin_top = 15.0
|
||||
margin_right = 136.0
|
||||
margin_bottom = 132.0
|
||||
theme = ExtResource( 1 )
|
||||
|
@ -121,6 +121,7 @@ file select
|
|||
marathon mode
|
||||
augmentations
|
||||
options
|
||||
high scores
|
||||
sound test
|
||||
exit"
|
||||
|
||||
|
@ -179,25 +180,35 @@ margin_top = 61.0
|
|||
margin_right = 16.0
|
||||
margin_bottom = 69.0
|
||||
focus_neighbour_top = NodePath("../Augmentations")
|
||||
focus_neighbour_bottom = NodePath("../SoundTest")
|
||||
focus_neighbour_bottom = NodePath("../HighScores")
|
||||
texture_focused = ExtResource( 4 )
|
||||
|
||||
[node name="SoundTest" type="TextureButton" parent="Panel"]
|
||||
[node name="HighScores" type="TextureButton" parent="Panel"]
|
||||
material = SubResource( 4 )
|
||||
margin_left = 8.0
|
||||
margin_top = 74.0
|
||||
margin_right = 16.0
|
||||
margin_bottom = 82.0
|
||||
focus_neighbour_top = NodePath("../Options")
|
||||
focus_neighbour_bottom = NodePath("../SoundTest")
|
||||
texture_focused = ExtResource( 4 )
|
||||
|
||||
[node name="SoundTest" type="TextureButton" parent="Panel"]
|
||||
material = SubResource( 4 )
|
||||
margin_left = 8.0
|
||||
margin_top = 87.0
|
||||
margin_right = 16.0
|
||||
margin_bottom = 95.0
|
||||
focus_neighbour_top = NodePath("../HighScores")
|
||||
focus_neighbour_bottom = NodePath("../Exit")
|
||||
texture_focused = ExtResource( 4 )
|
||||
|
||||
[node name="Exit" type="TextureButton" parent="Panel"]
|
||||
material = SubResource( 4 )
|
||||
margin_left = 8.0
|
||||
margin_top = 87.0
|
||||
margin_top = 100.0
|
||||
margin_right = 16.0
|
||||
margin_bottom = 95.0
|
||||
margin_bottom = 108.0
|
||||
focus_neighbour_top = NodePath("../SoundTest")
|
||||
focus_neighbour_bottom = NodePath("../Continue")
|
||||
texture_focused = ExtResource( 4 )
|
||||
|
@ -224,8 +235,7 @@ margin_top = 3.0
|
|||
margin_right = 175.0
|
||||
margin_bottom = 52.0
|
||||
theme = ExtResource( 1 )
|
||||
text = "Welcome to the future...
|
||||
2083"
|
||||
text = "Welcome to the future... 2083!"
|
||||
align = 1
|
||||
|
||||
[node name="MenuSounds" parent="." instance=ExtResource( 9 )]
|
||||
|
@ -239,6 +249,9 @@ align = 1
|
|||
[connection signal="focus_entered" from="Panel/MarathonMode" to="MenuSounds" method="play_select_sound"]
|
||||
[connection signal="focus_entered" from="Panel/Augmentations" to="MenuSounds" method="play_select_sound"]
|
||||
[connection signal="focus_entered" from="Panel/Options" to="MenuSounds" method="play_select_sound"]
|
||||
[connection signal="button_down" from="Panel/HighScores" to="." method="_on_HighScores_button_down"]
|
||||
[connection signal="button_down" from="Panel/HighScores" to="MenuSounds" method="play_confirm_sound"]
|
||||
[connection signal="focus_entered" from="Panel/HighScores" to="MenuSounds" method="play_select_sound"]
|
||||
[connection signal="button_down" from="Panel/SoundTest" to="." method="_on_SoundTest_button_down"]
|
||||
[connection signal="button_down" from="Panel/SoundTest" to="MenuSounds" method="play_confirm_sound"]
|
||||
[connection signal="focus_entered" from="Panel/SoundTest" to="MenuSounds" method="play_select_sound"]
|
||||
|
|
|
@ -16,6 +16,7 @@ var selected_type: int = ScoreType.SCORE
|
|||
|
||||
var _scoreboard_id: int = -1
|
||||
var _scoreboard_tag: String = "spicy-any%"
|
||||
var _page: int = 0
|
||||
|
||||
|
||||
onready var level_title: Button = $"%LevelTitle"
|
||||
|
@ -26,10 +27,13 @@ onready var completion: Button = $"%Completion"
|
|||
onready var type: Button = $"%Type"
|
||||
onready var scores: VBoxContainer = $"%Scores"
|
||||
onready var scoreboard_tabs: TabContainer = $"%ScoreboardTabs"
|
||||
onready var prev_board: TextureRect = $"%PrevBoard"
|
||||
onready var next_board: TextureRect = $"%NextBoard"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
Fade.fade_in(0.4)
|
||||
yield(get_tree(), "idle_frame")
|
||||
level_title.text = LevelData.levels[selected_level].title
|
||||
level_title.grab_focus()
|
||||
|
@ -40,7 +44,13 @@ func _ready() -> void:
|
|||
_scoreboard_id = LevelData.levels[selected_level].times_id
|
||||
if Time.get_ticks_msec() > 5000:
|
||||
reload_scores()
|
||||
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
Fade.fade_out(0.4)
|
||||
yield(Fade, "fade_finished")
|
||||
SceneManager.current_scene = preload("res://menus/main_menu.tscn").instance()
|
||||
|
||||
|
||||
# reload scores from newgrounds
|
||||
|
@ -53,7 +63,7 @@ func reload_scores() -> void:
|
|||
var response = yield(Ngio.request_execute("ScoreBoard.getScores", {
|
||||
id = _scoreboard_id,
|
||||
limit = scores.get_child_count(),
|
||||
skip = 0,
|
||||
skip = _page * 8,
|
||||
period = "A",
|
||||
tag = _scoreboard_tag,
|
||||
}), "completed")
|
||||
|
@ -124,6 +134,7 @@ func _on_LevelTitle_gui_input(event: InputEvent) -> void:
|
|||
_scoreboard_id = LevelData.levels[selected_level].scores_id
|
||||
ScoreType.TIME:
|
||||
_scoreboard_id = LevelData.levels[selected_level].times_id
|
||||
_page = 0
|
||||
reload_scores()
|
||||
elif event.is_action_pressed("ui_right"):
|
||||
selected_level = posmod(selected_level + 1, LevelData.levels.size())
|
||||
|
@ -135,6 +146,7 @@ func _on_LevelTitle_gui_input(event: InputEvent) -> void:
|
|||
_scoreboard_id = LevelData.levels[selected_level].scores_id
|
||||
ScoreType.TIME:
|
||||
_scoreboard_id = LevelData.levels[selected_level].times_id
|
||||
_page = 0
|
||||
reload_scores()
|
||||
|
||||
# difficulty selector
|
||||
|
@ -143,6 +155,7 @@ func _on_Difficulty_pressed() -> void:
|
|||
return
|
||||
selected_difficulty = posmod(selected_difficulty + 1, 4)
|
||||
difficulty.text = Game.DIFFICULTY_NAMES[selected_difficulty]
|
||||
_page = 0
|
||||
reload_scores()
|
||||
|
||||
# completion amount selector
|
||||
|
@ -151,6 +164,7 @@ func _on_Completion_pressed() -> void:
|
|||
return
|
||||
selected_completion = posmod(selected_completion + 1, 2)
|
||||
completion.text = COMPLETION_NAMES[selected_completion]
|
||||
_page = 0
|
||||
reload_scores()
|
||||
|
||||
# score type selector
|
||||
|
@ -166,4 +180,26 @@ func _on_Type_pressed() -> void:
|
|||
_scoreboard_id = LevelData.levels[selected_level].times_id
|
||||
completion.visible = true
|
||||
type.text = SCORE_TYPE_NAMES[selected_type]
|
||||
_page = 0
|
||||
reload_scores()
|
||||
|
||||
|
||||
func _on_Scoreboard_focus_entered() -> void:
|
||||
prev_board.visible = true
|
||||
next_board.visible = true
|
||||
|
||||
|
||||
func _on_Scoreboard_focus_exited() -> void:
|
||||
prev_board.visible = false
|
||||
next_board.visible = false
|
||||
|
||||
|
||||
func _on_Scoreboard_gui_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("ui_left"):
|
||||
_page -= 1
|
||||
if _page <= 0:
|
||||
_page = 0
|
||||
reload_scores()
|
||||
elif event.is_action_pressed("ui_right"):
|
||||
_page += 1
|
||||
reload_scores()
|
||||
|
|
|
@ -109,6 +109,7 @@ margin_right = 100.0
|
|||
margin_bottom = 13.0
|
||||
rect_min_size = Vector2( 48, 0 )
|
||||
focus_neighbour_right = NodePath("../Type")
|
||||
focus_neighbour_bottom = NodePath("../../Scoreboard")
|
||||
size_flags_vertical = 4
|
||||
theme = ExtResource( 5 )
|
||||
custom_colors/font_color_focus = Color( 1, 0.968627, 0.709804, 1 )
|
||||
|
@ -125,6 +126,7 @@ margin_bottom = 13.0
|
|||
rect_min_size = Vector2( 48, 0 )
|
||||
focus_neighbour_left = NodePath("../Difficulty")
|
||||
focus_neighbour_right = NodePath("../SpaceReserve/Completion")
|
||||
focus_neighbour_bottom = NodePath("../../Scoreboard")
|
||||
size_flags_vertical = 4
|
||||
theme = ExtResource( 5 )
|
||||
custom_colors/font_color_focus = Color( 1, 0.968627, 0.709804, 1 )
|
||||
|
@ -153,6 +155,7 @@ margin_right = 24.0
|
|||
margin_bottom = 5.0
|
||||
rect_min_size = Vector2( 48, 0 )
|
||||
focus_neighbour_left = NodePath("../../Type")
|
||||
focus_neighbour_bottom = NodePath("../../../Scoreboard")
|
||||
theme = ExtResource( 5 )
|
||||
custom_colors/font_color_focus = Color( 1, 0.968627, 0.709804, 1 )
|
||||
custom_colors/font_color = Color( 1, 1, 1, 1 )
|
||||
|
@ -160,19 +163,33 @@ custom_fonts/font = ExtResource( 8 )
|
|||
text = "Any%"
|
||||
icon_align = 1
|
||||
|
||||
[node name="Scoreboard" type="MarginContainer" parent="BoardsScreen"]
|
||||
[node name="Scoreboard" type="HBoxContainer" parent="BoardsScreen"]
|
||||
margin_top = 32.0
|
||||
margin_right = 256.0
|
||||
margin_bottom = 192.0
|
||||
focus_neighbour_top = NodePath("../SelectScoreType/Type")
|
||||
focus_mode = 2
|
||||
size_flags_vertical = 3
|
||||
custom_constants/margin_right = 16
|
||||
custom_constants/margin_left = 16
|
||||
custom_constants/margin_bottom = 16
|
||||
alignment = 1
|
||||
|
||||
[node name="PrevBoard" type="TextureRect" parent="BoardsScreen/Scoreboard"]
|
||||
unique_name_in_owner = true
|
||||
material = SubResource( 2 )
|
||||
margin_left = 6.0
|
||||
margin_top = 76.0
|
||||
margin_right = 12.0
|
||||
margin_bottom = 84.0
|
||||
size_flags_vertical = 4
|
||||
texture = ExtResource( 6 )
|
||||
flip_h = true
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="BoardsScreen/Scoreboard"]
|
||||
margin_left = 16.0
|
||||
margin_right = 240.0
|
||||
margin_bottom = 144.0
|
||||
rect_min_size = Vector2( 224, 144 )
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 0
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="BoardsScreen/Scoreboard/PanelContainer"]
|
||||
margin_left = 3.0
|
||||
|
@ -296,9 +313,23 @@ margin_right = 154.0
|
|||
margin_bottom = 59.0
|
||||
text = "Failed to load"
|
||||
|
||||
[node name="NextBoard" type="TextureRect" parent="BoardsScreen/Scoreboard"]
|
||||
unique_name_in_owner = true
|
||||
material = SubResource( 3 )
|
||||
margin_left = 244.0
|
||||
margin_top = 76.0
|
||||
margin_right = 250.0
|
||||
margin_bottom = 84.0
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 4
|
||||
texture = ExtResource( 6 )
|
||||
|
||||
[connection signal="focus_entered" from="BoardsScreen/SelectLevel/LevelTitle" to="." method="_on_LevelTitle_focus_entered"]
|
||||
[connection signal="focus_exited" from="BoardsScreen/SelectLevel/LevelTitle" to="." method="_on_LevelTitle_focus_exited"]
|
||||
[connection signal="gui_input" from="BoardsScreen/SelectLevel/LevelTitle" to="." method="_on_LevelTitle_gui_input"]
|
||||
[connection signal="pressed" from="BoardsScreen/SelectScoreType/Difficulty" to="." method="_on_Difficulty_pressed"]
|
||||
[connection signal="pressed" from="BoardsScreen/SelectScoreType/Type" to="." method="_on_Type_pressed"]
|
||||
[connection signal="pressed" from="BoardsScreen/SelectScoreType/SpaceReserve/Completion" to="." method="_on_Completion_pressed"]
|
||||
[connection signal="focus_entered" from="BoardsScreen/Scoreboard" to="." method="_on_Scoreboard_focus_entered"]
|
||||
[connection signal="focus_exited" from="BoardsScreen/Scoreboard" to="." method="_on_Scoreboard_focus_exited"]
|
||||
[connection signal="gui_input" from="BoardsScreen/Scoreboard" to="." method="_on_Scoreboard_gui_input"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue