score submission :)
This commit is contained in:
parent
f7581231e8
commit
5610401840
4 changed files with 335 additions and 5 deletions
|
@ -1,5 +1,7 @@
|
|||
extends Node
|
||||
|
||||
const Text3D = preload("res://objects/hud/3d_text.tscn")
|
||||
const SubmitScore = preload("res://menus/submit_score.tscn")
|
||||
|
||||
onready var shards: Node2D = $ShardsAndBonuses/Shards
|
||||
onready var score = $Score
|
||||
|
@ -12,7 +14,7 @@ onready var time_bonus_score = $ShardsAndBonuses/Bonuses/TimeBonus/TimeBonusScor
|
|||
onready var life_bonus_score = $ShardsAndBonuses/Bonuses/LifeBonus/LifeBonusScore
|
||||
onready var arrow_bonus_score = $ShardsAndBonuses/Bonuses/ArrowBonus/ArrowBonusScore
|
||||
onready var perfect_bonus_score = $ShardsAndBonuses/Bonuses/PerfectBonus/PerfectBonusScore
|
||||
const Text3D = preload("res://objects/hud/3d_text.tscn")
|
||||
|
||||
var text_3d = null
|
||||
|
||||
func _ready() -> void:
|
||||
|
@ -48,7 +50,6 @@ func final_score():
|
|||
|
||||
|
||||
func _on_AnimationPlayer_animation_finished(anim_name):
|
||||
Game.clear_collectibles()
|
||||
Fade.fade_out(0.4)
|
||||
yield(Fade, "fade_finished")
|
||||
SceneManager.change_scene(preload("res://menus/level_select_scholar.tscn").instance())
|
||||
SceneManager.change_scene(SubmitScore.instance())
|
||||
|
|
|
@ -38,7 +38,9 @@ func _ready() -> void:
|
|||
_scoreboard_id = LevelData.levels[selected_level].scores_id
|
||||
ScoreType.TIME:
|
||||
_scoreboard_id = LevelData.levels[selected_level].times_id
|
||||
reload_scores()
|
||||
if Time.get_ticks_msec() > 5000:
|
||||
reload_scores()
|
||||
|
||||
|
||||
|
||||
# reload scores from newgrounds
|
||||
|
@ -65,7 +67,7 @@ func reload_scores() -> void:
|
|||
ScoreType.SCORE:
|
||||
score_entry.score = "%05d" % score.value
|
||||
ScoreType.TIME:
|
||||
score_entry.score = Game.format_time(float(score.value * 1000))
|
||||
score_entry.score = Game.format_time(float(score.value) / 1000.0)
|
||||
else:
|
||||
score_entry.user = "--------"
|
||||
match selected_type:
|
||||
|
|
98
menus/submit_score.gd
Normal file
98
menus/submit_score.gd
Normal file
|
@ -0,0 +1,98 @@
|
|||
extends Node
|
||||
|
||||
|
||||
const NewgroundsLogin := preload("res://menus/newgrounds_login.tscn")
|
||||
const LevelSelect := preload("res://menus/level_select_scholar.tscn")
|
||||
|
||||
|
||||
var _scoreboard_id: int = -1
|
||||
var _scoreboard_tag: String = ""
|
||||
var _score_value: int = -1
|
||||
|
||||
|
||||
onready var tab_container: TabContainer = $"%TabContainer"
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
yield(get_tree(), "idle_frame")
|
||||
_set_tag()
|
||||
$"%YesScore".grab_focus()
|
||||
Fade.fade_in(0.4)
|
||||
|
||||
|
||||
func _on_YesScore_pressed() -> void:
|
||||
_scoreboard_id = LevelData.levels[Game.current_level].scores_id
|
||||
_score_value = Game.final_score
|
||||
print(_score_value)
|
||||
tab_container.current_tab = 2
|
||||
if yield(_submit(), "completed"):
|
||||
tab_container.current_tab = 3
|
||||
else:
|
||||
tab_container.current_tab = 4
|
||||
yield(get_tree().create_timer(1.0), "timeout")
|
||||
tab_container.current_tab = 1
|
||||
$"%YesTime".grab_focus()
|
||||
|
||||
|
||||
func _on_NoScore_pressed() -> void:
|
||||
tab_container.current_tab = 1
|
||||
$"%YesTime".grab_focus()
|
||||
|
||||
|
||||
func _on_YesTime_pressed() -> void:
|
||||
_scoreboard_id = LevelData.levels[Game.current_level].times_id
|
||||
_score_value = int(Game.time * 1000.0)
|
||||
print(_score_value)
|
||||
tab_container.current_tab = 2
|
||||
if yield(_submit(), "completed"):
|
||||
tab_container.current_tab = 3
|
||||
else:
|
||||
tab_container.current_tab = 4
|
||||
yield(get_tree().create_timer(1.0), "timeout")
|
||||
_next_screen()
|
||||
|
||||
|
||||
func _on_NoTime_pressed() -> void:
|
||||
_next_screen()
|
||||
|
||||
|
||||
func _next_screen() -> void:
|
||||
Game.clear_collectibles()
|
||||
Fade.fade_out(0.4)
|
||||
yield(Fade, "fade_finished")
|
||||
SceneManager.change_scene(LevelSelect.instance())
|
||||
|
||||
|
||||
func _set_tag() -> void:
|
||||
match Game.difficulty:
|
||||
Game.Difficulty.SWEET:
|
||||
_scoreboard_tag = "sweet"
|
||||
Game.Difficulty.SALTY:
|
||||
_scoreboard_tag = "salty"
|
||||
Game.Difficulty.SPICY:
|
||||
_scoreboard_tag = "spicy"
|
||||
Game.Difficulty.PUNGENT:
|
||||
_scoreboard_tag = "pungent"
|
||||
if Game.has_collection_bonus():
|
||||
_scoreboard_tag += "-100%"
|
||||
else:
|
||||
_scoreboard_tag += "-any%"
|
||||
|
||||
|
||||
# returns true if the score was successfully submitted
|
||||
func _submit() -> bool:
|
||||
if Ngio.session.user == null:
|
||||
var login_screen = NewgroundsLogin.instance()
|
||||
add_child(login_screen)
|
||||
yield(login_screen, "tree_exited")
|
||||
if Ngio.session.user == null:
|
||||
return false
|
||||
var response = yield(Ngio.request_execute("ScoreBoard.postScore", {
|
||||
id = _scoreboard_id,
|
||||
tag = _scoreboard_tag,
|
||||
value = _score_value,
|
||||
}), "completed")
|
||||
if Ngio.has_result(response):
|
||||
if response.result.data.success:
|
||||
return true
|
||||
return false
|
229
menus/submit_score.tscn
Normal file
229
menus/submit_score.tscn
Normal file
|
@ -0,0 +1,229 @@
|
|||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://menus/submit_score.gd" type="Script" id=1]
|
||||
[ext_resource path="res://ui/theme.tres" type="Theme" id=2]
|
||||
[ext_resource path="res://shaders/wibble_wobble.gdshader" type="Shader" id=3]
|
||||
[ext_resource path="res://graphics/hud/pause_arrow.png" type="Texture" id=4]
|
||||
[ext_resource path="res://ui/2ndpuberty_scholar_outline.fnt" type="BitmapFont" id=5]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=1]
|
||||
shader = ExtResource( 3 )
|
||||
shader_param/speed = Vector2( 4, 8 )
|
||||
shader_param/ammount = Vector2( 1, 1 )
|
||||
shader_param/offset = Vector2( 0, 0 )
|
||||
shader_param/delay = Vector2( 0, 0 )
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=2]
|
||||
shader = ExtResource( 3 )
|
||||
shader_param/speed = Vector2( 8, 4 )
|
||||
shader_param/ammount = Vector2( 12, 24 )
|
||||
shader_param/offset = Vector2( 0, 0 )
|
||||
shader_param/delay = Vector2( 0, 0 )
|
||||
|
||||
[node name="SubmitScore" type="Node"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
theme = ExtResource( 2 )
|
||||
|
||||
[node name="TabContainer" type="TabContainer" parent="CenterContainer"]
|
||||
unique_name_in_owner = true
|
||||
margin_left = 82.0
|
||||
margin_top = 78.0
|
||||
margin_right = 173.0
|
||||
margin_bottom = 114.0
|
||||
tabs_visible = false
|
||||
|
||||
[node name="SubmitScore" type="VBoxContainer" parent="CenterContainer/TabContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
||||
[node name="Label" type="Label" parent="CenterContainer/TabContainer/SubmitScore"]
|
||||
margin_right = 91.0
|
||||
margin_bottom = 10.0
|
||||
custom_fonts/font = ExtResource( 5 )
|
||||
text = "submit score?"
|
||||
|
||||
[node name="YesNoPrompt" type="PanelContainer" parent="CenterContainer/TabContainer/SubmitScore"]
|
||||
margin_left = 1.0
|
||||
margin_top = 14.0
|
||||
margin_right = 90.0
|
||||
margin_bottom = 36.0
|
||||
size_flags_horizontal = 4
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/TabContainer/SubmitScore/YesNoPrompt"]
|
||||
margin_left = 3.0
|
||||
margin_top = 3.0
|
||||
margin_right = 86.0
|
||||
margin_bottom = 19.0
|
||||
rect_min_size = Vector2( 0, 16 )
|
||||
rect_pivot_offset = Vector2( -174, -69 )
|
||||
custom_constants/separation = 0
|
||||
alignment = 1
|
||||
|
||||
[node name="YesScore" type="TextureButton" parent="CenterContainer/TabContainer/SubmitScore/YesNoPrompt/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
material = SubResource( 1 )
|
||||
margin_top = 4.0
|
||||
margin_right = 12.0
|
||||
margin_bottom = 12.0
|
||||
rect_min_size = Vector2( 12, 8 )
|
||||
focus_neighbour_right = NodePath("../NoScore")
|
||||
size_flags_vertical = 4
|
||||
texture_focused = ExtResource( 4 )
|
||||
expand = true
|
||||
stretch_mode = 3
|
||||
|
||||
[node name="YesLabel" type="Label" parent="CenterContainer/TabContainer/SubmitScore/YesNoPrompt/HBoxContainer"]
|
||||
margin_left = 12.0
|
||||
margin_top = 3.0
|
||||
margin_right = 33.0
|
||||
margin_bottom = 13.0
|
||||
text = "Yes"
|
||||
|
||||
[node name="Spacer" type="Control" parent="CenterContainer/TabContainer/SubmitScore/YesNoPrompt/HBoxContainer"]
|
||||
margin_left = 33.0
|
||||
margin_right = 45.0
|
||||
margin_bottom = 16.0
|
||||
rect_min_size = Vector2( 12, 0 )
|
||||
|
||||
[node name="NoScore" type="TextureButton" parent="CenterContainer/TabContainer/SubmitScore/YesNoPrompt/HBoxContainer"]
|
||||
material = SubResource( 1 )
|
||||
margin_left = 45.0
|
||||
margin_top = 4.0
|
||||
margin_right = 57.0
|
||||
margin_bottom = 12.0
|
||||
rect_min_size = Vector2( 12, 8 )
|
||||
focus_neighbour_left = NodePath("../YesScore")
|
||||
size_flags_vertical = 4
|
||||
texture_focused = ExtResource( 4 )
|
||||
expand = true
|
||||
stretch_mode = 3
|
||||
|
||||
[node name="NoLabel" type="Label" parent="CenterContainer/TabContainer/SubmitScore/YesNoPrompt/HBoxContainer"]
|
||||
margin_left = 57.0
|
||||
margin_top = 3.0
|
||||
margin_right = 71.0
|
||||
margin_bottom = 13.0
|
||||
text = "No"
|
||||
|
||||
[node name="Spacer2" type="Control" parent="CenterContainer/TabContainer/SubmitScore/YesNoPrompt/HBoxContainer"]
|
||||
margin_left = 71.0
|
||||
margin_right = 83.0
|
||||
margin_bottom = 16.0
|
||||
rect_min_size = Vector2( 12, 0 )
|
||||
|
||||
[node name="SubmitTime" type="VBoxContainer" parent="CenterContainer/TabContainer"]
|
||||
visible = false
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
||||
[node name="Label" type="Label" parent="CenterContainer/TabContainer/SubmitTime"]
|
||||
margin_right = 89.0
|
||||
margin_bottom = 10.0
|
||||
custom_fonts/font = ExtResource( 5 )
|
||||
text = "submit time?"
|
||||
|
||||
[node name="YesNoPrompt" type="PanelContainer" parent="CenterContainer/TabContainer/SubmitTime"]
|
||||
margin_top = 14.0
|
||||
margin_right = 89.0
|
||||
margin_bottom = 36.0
|
||||
size_flags_horizontal = 4
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/TabContainer/SubmitTime/YesNoPrompt"]
|
||||
margin_left = 3.0
|
||||
margin_top = 3.0
|
||||
margin_right = 86.0
|
||||
margin_bottom = 19.0
|
||||
rect_min_size = Vector2( 0, 16 )
|
||||
rect_pivot_offset = Vector2( -174, -69 )
|
||||
custom_constants/separation = 0
|
||||
alignment = 1
|
||||
|
||||
[node name="YesTime" type="TextureButton" parent="CenterContainer/TabContainer/SubmitTime/YesNoPrompt/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
material = SubResource( 1 )
|
||||
margin_top = 4.0
|
||||
margin_right = 12.0
|
||||
margin_bottom = 12.0
|
||||
rect_min_size = Vector2( 12, 8 )
|
||||
focus_neighbour_right = NodePath("../NoTime")
|
||||
size_flags_vertical = 4
|
||||
texture_focused = ExtResource( 4 )
|
||||
expand = true
|
||||
stretch_mode = 3
|
||||
|
||||
[node name="YesLabel" type="Label" parent="CenterContainer/TabContainer/SubmitTime/YesNoPrompt/HBoxContainer"]
|
||||
margin_left = 12.0
|
||||
margin_top = 3.0
|
||||
margin_right = 33.0
|
||||
margin_bottom = 13.0
|
||||
text = "Yes"
|
||||
|
||||
[node name="Spacer" type="Control" parent="CenterContainer/TabContainer/SubmitTime/YesNoPrompt/HBoxContainer"]
|
||||
margin_left = 33.0
|
||||
margin_right = 45.0
|
||||
margin_bottom = 16.0
|
||||
rect_min_size = Vector2( 12, 0 )
|
||||
|
||||
[node name="NoTime" type="TextureButton" parent="CenterContainer/TabContainer/SubmitTime/YesNoPrompt/HBoxContainer"]
|
||||
material = SubResource( 1 )
|
||||
margin_left = 45.0
|
||||
margin_top = 4.0
|
||||
margin_right = 57.0
|
||||
margin_bottom = 12.0
|
||||
rect_min_size = Vector2( 12, 8 )
|
||||
focus_neighbour_left = NodePath("../YesTime")
|
||||
size_flags_vertical = 4
|
||||
texture_focused = ExtResource( 4 )
|
||||
expand = true
|
||||
stretch_mode = 3
|
||||
|
||||
[node name="NoLabel" type="Label" parent="CenterContainer/TabContainer/SubmitTime/YesNoPrompt/HBoxContainer"]
|
||||
margin_left = 57.0
|
||||
margin_top = 3.0
|
||||
margin_right = 71.0
|
||||
margin_bottom = 13.0
|
||||
text = "No"
|
||||
|
||||
[node name="Spacer2" type="Control" parent="CenterContainer/TabContainer/SubmitTime/YesNoPrompt/HBoxContainer"]
|
||||
margin_left = 71.0
|
||||
margin_right = 83.0
|
||||
margin_bottom = 16.0
|
||||
rect_min_size = Vector2( 12, 0 )
|
||||
|
||||
[node name="LoadingGraphic" type="Label" parent="CenterContainer/TabContainer"]
|
||||
visible = false
|
||||
material = SubResource( 2 )
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_min_size = Vector2( 0, 64 )
|
||||
text = "§"
|
||||
align = 1
|
||||
valign = 1
|
||||
|
||||
[node name="Success" type="Label" parent="CenterContainer/TabContainer"]
|
||||
visible = false
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
custom_fonts/font = ExtResource( 5 )
|
||||
text = "success!"
|
||||
|
||||
[node name="Failure" type="Label" parent="CenterContainer/TabContainer"]
|
||||
visible = false
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
custom_fonts/font = ExtResource( 5 )
|
||||
text = "failture :("
|
||||
|
||||
[connection signal="pressed" from="CenterContainer/TabContainer/SubmitScore/YesNoPrompt/HBoxContainer/YesScore" to="." method="_on_YesScore_pressed"]
|
||||
[connection signal="pressed" from="CenterContainer/TabContainer/SubmitScore/YesNoPrompt/HBoxContainer/NoScore" to="." method="_on_NoScore_pressed"]
|
||||
[connection signal="pressed" from="CenterContainer/TabContainer/SubmitTime/YesNoPrompt/HBoxContainer/YesTime" to="." method="_on_YesTime_pressed"]
|
||||
[connection signal="pressed" from="CenterContainer/TabContainer/SubmitTime/YesNoPrompt/HBoxContainer/NoTime" to="." method="_on_NoTime_pressed"]
|
Loading…
Add table
Add a link
Reference in a new issue