diff --git a/.gitignore b/.gitignore index fb85297..d6037ed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .import/ build/ -ngio.ini \ No newline at end of file +ngio.ini +scoreboard_host.txt diff --git a/autoloads/debug.gd b/autoloads/debug.gd index e6d493c..606b626 100644 --- a/autoloads/debug.gd +++ b/autoloads/debug.gd @@ -37,7 +37,7 @@ func _ready(): func _physics_process(delta): #DEBUG - if debug == true && !entry && !entry_index > 0: + if debug == true && !entry && !entry_index > 0 && !Options.entry: #Move player to mouse if Input.is_action_just_pressed("debug_move_player"): Audio.play_sound(Audio.a_mkey,Audio.ac_jump) @@ -67,6 +67,9 @@ func _physics_process(delta): if infinite_arrows: Game.arrows = 99 func _input(event): + if Options.entry: + return + if event is InputEventKey && event.is_pressed(): var character = OS.get_scancode_string(event.scancode) if character.length() > 1: diff --git a/autoloads/game.gd b/autoloads/game.gd index 6c6ee40..83dc856 100644 --- a/autoloads/game.gd +++ b/autoloads/game.gd @@ -9,6 +9,9 @@ enum Difficulty { PUNGENT, # faster enemies, 3 lives } +# score multiplier for easy mode +const EASY_DIFFICULTY_MODIFIER: float = 0.75 + ## resolution the game renders at const RESOLUTION := Vector2(256,192) @@ -37,6 +40,7 @@ var time_bonus: int = 0 var life_bonus: int = 0 var perfect_bonus: int = 0 var final_score: int = 0 +var old_high_score: int = 0 #== state ==# var current_sector := Vector2.ZERO var respawn_point := Vector2(32,166) @@ -60,9 +64,6 @@ var marathon_shards: int = 0 var marathon_deaths: int = 0 -func _ready(): - pause_mode = Node.PAUSE_MODE_PROCESS - func _get_stars() -> int: return stars_collected.count(true) @@ -141,6 +142,9 @@ func tally_scores() -> void: perfect_bonus += 1000 # final score final_score = score + arrows_bonus + collection_bonus + time_bonus + life_bonus + perfect_bonus + # easy mode modifier + if difficulty == Difficulty.SWEET: + final_score *= EASY_DIFFICULTY_MODIFIER if marathon_mode: marathon_shards += shards_collected.count(true) marathon_score += final_score @@ -197,6 +201,8 @@ func save(): var save_id = LevelData.levels[current_level].save_id var save_data: Save.LevelSaveData = Save.current_file.levels[save_id] + old_high_score = max(save_data.score_100, save_data.score_any) + # save score and time depending on completion if _get_shards() >= 5 && keys >= 50: save_data.score_100 = max(save_data.score_100, final_score) as int diff --git a/autoloads/level_data.tscn b/autoloads/level_data.tscn index e2a8193..fe92a6f 100644 --- a/autoloads/level_data.tscn +++ b/autoloads/level_data.tscn @@ -29,8 +29,7 @@ shards_required_spicy = 0 shards_required_pungent = 0 boss_required = "" boss = false -scores_id = 13253 -times_id = 13255 +has_scoreboard = true scene = ExtResource( 2 ) [sub_resource type="Resource" id=2] @@ -45,8 +44,7 @@ shards_required_spicy = 0 shards_required_pungent = 0 boss_required = "" boss = false -scores_id = 13254 -times_id = 13257 +has_scoreboard = true scene = ExtResource( 3 ) [sub_resource type="Resource" id=4] @@ -61,8 +59,7 @@ shards_required_spicy = 0 shards_required_pungent = 0 boss_required = "" boss = false -scores_id = 13263 -times_id = 13270 +has_scoreboard = true scene = ExtResource( 6 ) [sub_resource type="Resource" id=6] @@ -77,8 +74,7 @@ shards_required_spicy = 16 shards_required_pungent = 24 boss_required = "" boss = true -scores_id = -1 -times_id = -1 +has_scoreboard = false scene = ExtResource( 8 ) [sub_resource type="Resource" id=3] @@ -93,8 +89,7 @@ shards_required_spicy = 0 shards_required_pungent = 0 boss_required = "boss1" boss = false -scores_id = 13264 -times_id = 13271 +has_scoreboard = true scene = ExtResource( 14 ) [sub_resource type="Resource" id=10] @@ -109,8 +104,7 @@ shards_required_spicy = 0 shards_required_pungent = 0 boss_required = "boss1" boss = false -scores_id = 13265 -times_id = 13272 +has_scoreboard = true scene = ExtResource( 7 ) [sub_resource type="Resource" id=9] @@ -125,8 +119,7 @@ shards_required_spicy = 0 shards_required_pungent = 0 boss_required = "boss1" boss = false -scores_id = 13266 -times_id = 13273 +has_scoreboard = true scene = ExtResource( 11 ) [sub_resource type="Resource" id=12] @@ -141,8 +134,7 @@ shards_required_spicy = 32 shards_required_pungent = 40 boss_required = "" boss = true -scores_id = -1 -times_id = -1 +has_scoreboard = false scene = ExtResource( 13 ) [sub_resource type="Resource" id=8] @@ -157,8 +149,7 @@ shards_required_spicy = 0 shards_required_pungent = 0 boss_required = "boss2" boss = false -scores_id = 13267 -times_id = 13274 +has_scoreboard = true scene = ExtResource( 10 ) [sub_resource type="Resource" id=7] @@ -173,8 +164,7 @@ shards_required_spicy = 0 shards_required_pungent = 0 boss_required = "boss2" boss = false -scores_id = 13268 -times_id = 13275 +has_scoreboard = true scene = ExtResource( 9 ) [sub_resource type="Resource" id=11] @@ -189,8 +179,7 @@ shards_required_spicy = 0 shards_required_pungent = 0 boss_required = "boss2" boss = false -scores_id = 13269 -times_id = 13276 +has_scoreboard = true scene = ExtResource( 12 ) [sub_resource type="Resource" id=15] @@ -205,8 +194,7 @@ shards_required_spicy = 50 shards_required_pungent = 60 boss_required = "" boss = true -scores_id = -1 -times_id = -1 +has_scoreboard = false scene = ExtResource( 16 ) [sub_resource type="Resource" id=14] @@ -221,8 +209,7 @@ shards_required_spicy = 72 shards_required_pungent = 72 boss_required = "boss3" boss = false -scores_id = -1 -times_id = -1 +has_scoreboard = false scene = ExtResource( 4 ) [sub_resource type="Resource" id=13] @@ -237,8 +224,7 @@ shards_required_spicy = 0 shards_required_pungent = 0 boss_required = "" boss = false -scores_id = -1 -times_id = -1 +has_scoreboard = false scene = ExtResource( 15 ) [node name="LevelData" type="Node"] diff --git a/autoloads/options.gd b/autoloads/options.gd index 26ec300..215948a 100644 --- a/autoloads/options.gd +++ b/autoloads/options.gd @@ -18,6 +18,8 @@ const TRANS_SPEEDS := [0.8, 0.4, 0.2, 0.0000001] #Game var rumble: int = RumbleMode.FULL var gore: int = Gore.FULL +var scoreboard_name: String = "" setget _set_scoreboard_name +var scoreboard_id: int = -1 #Video var fullscreen: bool = false setget _set_fullscreen @@ -40,15 +42,19 @@ var last_file: int = 0 # default values var defaults = null +# text is being entered +var entry: bool = false + func _ready() -> void: pause_mode = PAUSE_MODE_PROCESS + # clone self into defaults before loading stored values if defaults == null: defaults = duplicate() load_options() func _unhandled_input(event: InputEvent) -> void: - if Debug.entry == false: + if not Debug.entry and not entry: if event.is_action_pressed("fullscreen"): OS.window_fullscreen = not OS.window_fullscreen @@ -58,6 +64,9 @@ func load_options() -> void: # game rumble = file.get_value("game", "rumble", defaults.rumble) gore = file.get_value("game", "gore", defaults.gore) + scoreboard_name = file.get_value("game", "scoreboard_name", "") + randomize() + scoreboard_id = file.get_value("game", "scoreboard_id", randi()) # video _set_fullscreen(file.get_value("video", "fullscreen", defaults.fullscreen)) _set_window_size(file.get_value("video", "window_size", defaults.window_size)) @@ -78,6 +87,8 @@ func load_defaults(section: int = Section.ALL) -> void: Section.GAME, Section.ALL: rumble = defaults.rumble gore = defaults.gore + scoreboard_name = defaults.scoreboard_name + scoreboard_id = randi() Section.VIDEO, Section.ALL: fullscreen = defaults.fullscreen window_size = defaults.window_size @@ -96,6 +107,8 @@ func save_options() -> void: #Game file.set_value("game", "rumble", rumble) file.set_value("game", "gore", gore) + file.set_value("game", "scoreboard_name", scoreboard_name) + file.set_value("game", "scoreboard_id", scoreboard_id) #Video file.set_value("video", "fullscreen", fullscreen) file.set_value("video", "window_size", window_size) @@ -115,6 +128,10 @@ func save_options() -> void: # Setters +# game setters +func _set_scoreboard_name(value: String) -> void: + scoreboard_name = value.substr(0, 10).to_lower() + # video setters func _set_fullscreen(value: bool) -> void: fullscreen = value diff --git a/autoloads/scoreboard.gd b/autoloads/scoreboard.gd new file mode 100644 index 0000000..17a043d --- /dev/null +++ b/autoloads/scoreboard.gd @@ -0,0 +1,123 @@ +extends Node + + +signal _response_received + + +const CHECK_INTERVAL: float = 60.0 +const POLL_INTERVAL: float = 0.5 + + +var server_host: String = "" +var http: HTTPRequest = null +## True if there is currently a request processing. +var waiting_for_response: bool = false +## True if the last request failed and the result is not valid. +var errored: bool = false + +var _response_code: int = -1 +var _response_body: String = "" + + +class ScoreEntry: + var score: int + var time: int + var difficulty: int + + func _init(score: int, time: int, difficulty: int) -> void: + self.score = score + self.time = time + self.difficulty = difficulty + + static func from_dict(dict: Dictionary) -> ScoreEntry: + return ScoreEntry.new(dict.score, dict.time, dict.difficulty) + + +func _ready() -> void: + var file = File.new() + file.open("res://scoreboard_host.txt", File.READ) + server_host = file.get_line() + file.close() + + http = HTTPRequest.new() + http.download_chunk_size = 4096 + http.timeout = 30.0 + http.use_threads = true + http.connect("request_completed", self, "_on_request_completed") + add_child(http) + +func _on_request_completed(result: int, response_code: int, headers: PoolStringArray, body: PoolByteArray) -> void: + if result != OK: + errored = true + else: + errored = false + _response_code = response_code + _response_body = body.get_string_from_utf8() + waiting_for_response = false + emit_signal("_response_received") + + +func is_name_free(player_name: String, id: int) -> bool: + if waiting_for_response: + yield(self, "_response_received") + var err = http.request(server_host + "/api/players/" + player_name) + if err != OK: + errored = true + return false + waiting_for_response = true + + yield(self, "_response_received") + if _response_code == HTTPClient.RESPONSE_NOT_FOUND or _response_body.to_int() == id: + return true + return false + + +func touch_name(player_name: String, id: int) -> void: + if waiting_for_response: + yield(self, "_response_received") + var err = http.request( + server_host + "/api/players/%s/%d" % [player_name, id], + [], true, HTTPClient.METHOD_POST + ) + if err != OK: + errored = true + return + waiting_for_response = true + + +func submit_score(level: String, entry: ScoreEntry) -> bool: + if waiting_for_response: + yield(self, "_response_received") + var err = http.request( + server_host + "/api/scores/%s/%s/%d/%d/%d" % [ + level, Options.scoreboard_name, + entry.score, entry.time, entry.difficulty + ], + [], true, HTTPClient.METHOD_POST + ) + if err != OK: + errored = true + return false + waiting_for_response = true + yield(self, "_response_received") + if errored or _response_code != HTTPClient.RESPONSE_OK: + return false + return true + + +func get_scores(level: String) -> Dictionary: + if waiting_for_response: + yield(self, "_response_received") + var err = http.request(server_host + "/api/scores/%s" % level) + if err != OK: + errored = true + return {} + waiting_for_response = true + yield(self, "_response_received") + if not errored and _response_code == HTTPClient.RESPONSE_OK: + var dict = parse_json(_response_body) + var scores = {} + for player in dict.keys(): + scores[player] = ScoreEntry.from_dict(dict[player]) + return scores + return {} diff --git a/export_presets.cfg b/export_presets.cfg index 7a3e24a..75f22d9 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -5,7 +5,7 @@ platform="Windows Desktop" runnable=true custom_features="" export_filter="all_resources" -include_filter="ngio.ini" +include_filter="scoreboard_host.txt" exclude_filter="" export_path="build/Revolution 2083.exe" script_export_mode=1 @@ -33,6 +33,7 @@ codesign/description="" codesign/custom_options=PoolStringArray( ) application/modify_resources=true application/icon="res://icon.ico" +application/icon_interpolation=4 application/file_version="" application/product_version="" application/company_name="Team SG" @@ -48,7 +49,7 @@ platform="Linux/X11" runnable=true custom_features="" export_filter="all_resources" -include_filter="ngio.ini" +include_filter="scoreboard_host.txt" exclude_filter="" export_path="build/linux/Revolution 2083.x86_64" script_export_mode=1 @@ -58,7 +59,7 @@ script_encryption_key="" custom_template/debug="" custom_template/release="" -binary_format/64_bits=true +binary_format/architecture="x86_64" binary_format/embed_pck=true texture_format/bptc=false texture_format/s3tc=true @@ -73,7 +74,7 @@ platform="HTML5" runnable=true custom_features="" export_filter="all_resources" -include_filter="ngio.ini" +include_filter="scoreboard_host.txt" exclude_filter="" export_path="build/html5/index.html" script_export_mode=1 @@ -108,7 +109,7 @@ platform="Android" runnable=true custom_features="" export_filter="all_resources" -include_filter="" +include_filter="scoreboard_host.txt" exclude_filter="" export_path="build/android/hero-mark-2.apk" script_export_mode=1 @@ -241,6 +242,7 @@ permissions/mount_format_filesystems=false permissions/mount_unmount_filesystems=false permissions/nfc=false permissions/persistent_activity=false +permissions/post_notifications=false permissions/process_outgoing_calls=false permissions/read_calendar=false permissions/read_call_log=false diff --git a/graphics/hud/arrow_down.png b/graphics/hud/arrow_down.png new file mode 100644 index 0000000..b077880 Binary files /dev/null and b/graphics/hud/arrow_down.png differ diff --git a/graphics/hud/arrow_down.png.import b/graphics/hud/arrow_down.png.import new file mode 100644 index 0000000..147e2b1 --- /dev/null +++ b/graphics/hud/arrow_down.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/arrow_down.png-476089e36c213673a0f11adb99cc0724.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://graphics/hud/arrow_down.png" +dest_files=[ "res://.import/arrow_down.png-476089e36c213673a0f11adb99cc0724.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/graphics/hud/arrow_up.png b/graphics/hud/arrow_up.png new file mode 100644 index 0000000..795cca0 Binary files /dev/null and b/graphics/hud/arrow_up.png differ diff --git a/graphics/hud/arrow_up.png.import b/graphics/hud/arrow_up.png.import new file mode 100644 index 0000000..b303c7a --- /dev/null +++ b/graphics/hud/arrow_up.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/arrow_up.png-afb605e867089f8aedd83a8cc3ba6369.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://graphics/hud/arrow_up.png" +dest_files=[ "res://.import/arrow_up.png-afb605e867089f8aedd83a8cc3ba6369.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/graphics/hud/high_score.png b/graphics/hud/high_score.png new file mode 100644 index 0000000..908a3d7 Binary files /dev/null and b/graphics/hud/high_score.png differ diff --git a/graphics/hud/high_score.png.import b/graphics/hud/high_score.png.import new file mode 100644 index 0000000..23b4081 --- /dev/null +++ b/graphics/hud/high_score.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/high_score.png-02ca81bb7439e75fa559a1c0a399afc3.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://graphics/hud/high_score.png" +dest_files=[ "res://.import/high_score.png-02ca81bb7439e75fa559a1c0a399afc3.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/graphics/hud/scores/pungent.png b/graphics/hud/scores/pungent.png new file mode 100644 index 0000000..7754646 Binary files /dev/null and b/graphics/hud/scores/pungent.png differ diff --git a/graphics/hud/scores/pungent.png.import b/graphics/hud/scores/pungent.png.import new file mode 100644 index 0000000..1265a85 --- /dev/null +++ b/graphics/hud/scores/pungent.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/pungent.png-e07e66e400d4d252772a81c6867bb967.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://graphics/hud/scores/pungent.png" +dest_files=[ "res://.import/pungent.png-e07e66e400d4d252772a81c6867bb967.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/graphics/hud/scores/salty.png b/graphics/hud/scores/salty.png new file mode 100644 index 0000000..af22ef1 Binary files /dev/null and b/graphics/hud/scores/salty.png differ diff --git a/graphics/hud/scores/salty.png.import b/graphics/hud/scores/salty.png.import new file mode 100644 index 0000000..06ae307 --- /dev/null +++ b/graphics/hud/scores/salty.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/salty.png-44a2905ee6e3795b4fc59059696696a8.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://graphics/hud/scores/salty.png" +dest_files=[ "res://.import/salty.png-44a2905ee6e3795b4fc59059696696a8.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/graphics/hud/scores/spicy.png b/graphics/hud/scores/spicy.png new file mode 100644 index 0000000..ddace82 Binary files /dev/null and b/graphics/hud/scores/spicy.png differ diff --git a/graphics/hud/scores/spicy.png.import b/graphics/hud/scores/spicy.png.import new file mode 100644 index 0000000..2e03a1a --- /dev/null +++ b/graphics/hud/scores/spicy.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/spicy.png-a2205eedcb443d8faf52477db79df90f.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://graphics/hud/scores/spicy.png" +dest_files=[ "res://.import/spicy.png-a2205eedcb443d8faf52477db79df90f.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/graphics/hud/scores/sweet.png b/graphics/hud/scores/sweet.png new file mode 100644 index 0000000..7dc896c Binary files /dev/null and b/graphics/hud/scores/sweet.png differ diff --git a/graphics/hud/scores/sweet.png.import b/graphics/hud/scores/sweet.png.import new file mode 100644 index 0000000..8ed72ac --- /dev/null +++ b/graphics/hud/scores/sweet.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/sweet.png-9fd594d4011ef7c51cf9c89d5c0132b0.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://graphics/hud/scores/sweet.png" +dest_files=[ "res://.import/sweet.png-9fd594d4011ef7c51cf9c89d5c0132b0.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menus/file_create.gd b/menus/file_create.gd index fd6f68a..6a91bf1 100644 --- a/menus/file_create.gd +++ b/menus/file_create.gd @@ -100,6 +100,8 @@ func _on_Exit_area_entered(area: Area2D) -> void: func _on_player_teleport_finished() -> void: if file.name.length() > 0: get_tree().paused = true + if Options.scoreboard_name.empty(): + Options.scoreboard_name = file.name file.save_to_file() Save.current_file = file Game.difficulty = file.difficulty diff --git a/menus/file_create.tscn b/menus/file_create.tscn index 1ca045b..7521d3b 100644 --- a/menus/file_create.tscn +++ b/menus/file_create.tscn @@ -1,23 +1,26 @@ -[gd_scene load_steps=29 format=2] +[gd_scene load_steps=32 format=2] [ext_resource path="res://shaders/ska_plane.gdshader" type="Shader" 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/sg_menu.png" type="Texture" id=4] [ext_resource path="res://graphics/hud/sg_tasting.png" type="Texture" id=5] -[ext_resource path="res://graphics/hud/pause_arrow.png" type="Texture" id=6] +[ext_resource path="res://graphics/hud/scores/salty.png" type="Texture" id=6] [ext_resource path="res://menus/file_create.gd" type="Script" id=7] [ext_resource path="res://ui/2ndpuberty_outline.tres" type="Material" id=8] [ext_resource path="res://tilesets/t_abstract.tres" type="TileSet" id=9] [ext_resource path="res://objects/player/player.tscn" type="PackedScene" id=10] [ext_resource path="res://objects/hud/letter_block.tscn" type="PackedScene" id=11] [ext_resource path="res://tilesets/t_ladders.tres" type="TileSet" id=12] +[ext_resource path="res://graphics/hud/scores/sweet.png" type="Texture" id=13] [ext_resource path="res://graphics/exit/exit.png" type="Texture" id=14] [ext_resource path="res://objects/environment/ladder/ladder.tscn" type="PackedScene" id=15] [ext_resource path="res://objects/hud/menu_sounds.tscn" type="PackedScene" id=16] [ext_resource path="res://shaders/can_stain.tres" type="Material" id=17] [ext_resource path="res://shaders/beam_of_sin.gdshader" type="Shader" id=18] [ext_resource path="res://graphics/exit/exit_back.png" type="Texture" id=19] +[ext_resource path="res://graphics/hud/scores/pungent.png" type="Texture" id=20] +[ext_resource path="res://graphics/hud/scores/spicy.png" type="Texture" id=21] [sub_resource type="ShaderMaterial" id=1] shader = ExtResource( 1 ) @@ -136,20 +139,20 @@ theme = ExtResource( 2 ) [node name="Sweet" type="TextureButton" parent="DifficultySelect/ButtonsPanel"] material = SubResource( 3 ) -margin_left = 8.0 -margin_top = 9.0 -margin_right = 16.0 -margin_bottom = 17.0 +margin_left = 5.0 +margin_top = 8.0 +margin_right = 17.0 +margin_bottom = 20.0 focus_neighbour_top = NodePath("../Pungent") focus_neighbour_bottom = NodePath("../Salty") -texture_focused = ExtResource( 6 ) +texture_focused = ExtResource( 13 ) [node name="Salty" type="TextureButton" parent="DifficultySelect/ButtonsPanel"] material = SubResource( 3 ) -margin_left = 8.0 -margin_top = 22.0 -margin_right = 16.0 -margin_bottom = 30.0 +margin_left = 5.0 +margin_top = 21.0 +margin_right = 17.0 +margin_bottom = 33.0 focus_neighbour_top = NodePath("../Sweet") focus_neighbour_bottom = NodePath("../Spicy") texture_focused = ExtResource( 6 ) @@ -157,29 +160,29 @@ texture_focused = ExtResource( 6 ) [node name="Spicy" type="TextureButton" parent="DifficultySelect/ButtonsPanel"] unique_name_in_owner = true material = SubResource( 3 ) -margin_left = 8.0 -margin_top = 35.0 -margin_right = 16.0 -margin_bottom = 43.0 +margin_left = 5.0 +margin_top = 34.0 +margin_right = 17.0 +margin_bottom = 46.0 focus_neighbour_top = NodePath("../Salty") focus_neighbour_bottom = NodePath("../Pungent") -texture_focused = ExtResource( 6 ) +texture_focused = ExtResource( 21 ) [node name="Pungent" type="TextureButton" parent="DifficultySelect/ButtonsPanel"] material = SubResource( 3 ) -margin_left = 8.0 -margin_top = 48.0 -margin_right = 16.0 -margin_bottom = 56.0 +margin_left = 5.0 +margin_top = 47.0 +margin_right = 17.0 +margin_bottom = 59.0 focus_neighbour_top = NodePath("../Spicy") focus_neighbour_bottom = NodePath("../Sweet") -texture_focused = ExtResource( 6 ) +texture_focused = ExtResource( 20 ) [node name="Body" type="Label" parent="DifficultySelect/ButtonsPanel"] material = SubResource( 2 ) -margin_left = 16.0 +margin_left = 18.0 margin_top = 8.0 -margin_right = 65.0 +margin_right = 67.0 margin_bottom = 57.0 text = "sweet salty diff --git a/menus/main_menu.gd b/menus/main_menu.gd index 3856a39..f91fb60 100644 --- a/menus/main_menu.gd +++ b/menus/main_menu.gd @@ -52,7 +52,7 @@ func _on_HighScores_button_down() -> void: Game.last_mm_button = @"Panel/HighScores" Fade.fade_out(Options.transition_speed_secs) yield(Fade, "fade_finished") - SceneManager.current_scene = load("res://menus/scoreboards.tscn").instance() + SceneManager.current_scene = load("res://menus/scoreboards_scholar.tscn").instance() func _on_Options_button_down() -> void: diff --git a/menus/results.gd b/menus/results.gd index d8c2d4c..9748925 100644 --- a/menus/results.gd +++ b/menus/results.gd @@ -1,7 +1,6 @@ extends Node const Text3D = preload("res://objects/hud/3d_text.tscn") -const SubmitScore = preload("res://menus/submit_score.tscn") const LevelSelect := preload("res://menus/level_select_scholar.tscn") onready var shards: Node2D = $ShardsAndBonuses/Shards @@ -29,6 +28,11 @@ func _notification(what: int) -> void: func _ready() -> void: var palette = load("res://graphics/player/palettes/%s.tex" % Game.current_palette) $"%ArrowBonus".material.set_shader_param("palette", palette) + # easy indicator + if Game.difficulty == Game.Difficulty.SWEET: + $EasyIndicator.visible = true + else: + $EasyIndicator.visible = false #preload final score text_3d = Text3D.instance() text_3d.anim = "final score" @@ -61,6 +65,9 @@ func show_final_score(): func _on_AnimationPlayer_animation_finished(anim_name): + if anim_name != "results": + return + if Game.marathon_mode: Game.current_level += 1 if Game.current_level > LevelData.marathon_end: @@ -70,9 +77,33 @@ func _on_AnimationPlayer_animation_finished(anim_name): else: Game.change_map(LevelData.levels[Game.current_level].scene) return + if Game.final_score > Game.old_high_score and not Debug.is_cheating: + animation_player.play("submit_score_popup") + else: + Fade.fade_out(Options.transition_speed_secs) + yield(Fade, "fade_finished") + SceneManager.change_scene(LevelSelect.instance()) + + +func _on_YesSubmit_button_down() -> void: + $"%YesSubmit".release_focus() + animation_player.play("submit") + + var save_id = LevelData.levels[Game.current_level].save_id + var entry = ScoreBoard.ScoreEntry.new(Game.final_score, int(Game.time * 1000.0), Game.difficulty) + var submitted = yield(ScoreBoard.submit_score(save_id, entry), "completed") + if ScoreBoard.errored or not submitted: + animation_player.play("try_again") + else: + animation_player.play("success") + + +func _on_NoSubmit_button_down() -> void: + $"%NoSubmit".release_focus() + _next_screen() + + +func _next_screen() -> void: Fade.fade_out(Options.transition_speed_secs) yield(Fade, "fade_finished") - if Debug.is_cheating == false: - SceneManager.change_scene(SubmitScore.instance()) - else: - SceneManager.change_scene(LevelSelect.instance()) + SceneManager.change_scene(LevelSelect.instance()) diff --git a/menus/results.tscn b/menus/results.tscn index b6d0d50..d5d1733 100644 --- a/menus/results.tscn +++ b/menus/results.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=21 format=2] +[gd_scene load_steps=35 format=2] [ext_resource path="res://shaders/wibble_wobble.gdshader" type="Shader" id=1] [ext_resource path="res://shaders/ska_plane.gdshader" type="Shader" id=2] @@ -14,6 +14,12 @@ [ext_resource path="res://graphics/player/palettes/default.tex" type="Texture" id=12] [ext_resource path="res://menus/results.gd" type="Script" id=13] [ext_resource path="res://menus/results_icon.tscn" type="PackedScene" id=14] +[ext_resource path="res://graphics/hud/high_score.png" type="Texture" id=15] +[ext_resource path="res://graphics/particles/shine.png" type="Texture" id=16] +[ext_resource path="res://scripts/randomize_particle_start.gd" type="Script" id=17] +[ext_resource path="res://graphics/hud/pause_arrow.png" type="Texture" id=18] +[ext_resource path="res://ui/2ndpuberty_scholar_outline.fnt" type="BitmapFont" id=19] +[ext_resource path="res://graphics/hud/scores/sweet.png" type="Texture" id=20] [sub_resource type="ShaderMaterial" id=5] shader = ExtResource( 2 ) @@ -36,6 +42,29 @@ shader = ExtResource( 3 ) shader_param/border_color = Color( 0, 0, 0, 1 ) shader_param/border_corners = false +[sub_resource type="Curve" id=11] +_data = [ Vector2( 0, 0 ), 0.0, 0.100639, 0, 0, Vector2( 0.158257, 1 ), 7.51724, -6.83592, 0, 0, Vector2( 0.31422, 0 ), 0.0, 0.0, 0, 0 ] + +[sub_resource type="Gradient" id=17] +interpolation_mode = 2 +offsets = PoolRealArray( 0, 0.734694, 1 ) +colors = PoolColorArray( 0.576471, 0.980392, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ) + +[sub_resource type="ShaderMaterial" id=14] +resource_local_to_scene = true +shader = ExtResource( 1 ) +shader_param/speed = Vector2( 4, 8 ) +shader_param/ammount = Vector2( 24, 12 ) +shader_param/offset = Vector2( 0, 0 ) +shader_param/delay = Vector2( 0, 0 ) + +[sub_resource type="ShaderMaterial" id=13] +shader = ExtResource( 1 ) +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=6] shader = ExtResource( 1 ) shader_param/speed = Vector2( 4, 8 ) @@ -117,6 +146,138 @@ tracks/5/keys = { "update": 1, "values": [ false ] } +tracks/6/type = "value" +tracks/6/path = NodePath("ShardsAndBonuses/FinalScore:visible") +tracks/6/interp = 1 +tracks/6/loop_wrap = true +tracks/6/imported = false +tracks/6/enabled = true +tracks/6/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 1, +"values": [ true ] +} +tracks/7/type = "value" +tracks/7/path = NodePath("ShardsAndBonuses/HighScore:visible") +tracks/7/interp = 1 +tracks/7/loop_wrap = true +tracks/7/imported = false +tracks/7/enabled = true +tracks/7/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 1, +"values": [ false ] +} +tracks/8/type = "value" +tracks/8/path = NodePath("ShardsAndBonuses/FinalScore:scale") +tracks/8/interp = 1 +tracks/8/loop_wrap = true +tracks/8/imported = false +tracks/8/enabled = true +tracks/8/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Vector2( 1, 1 ) ] +} +tracks/9/type = "value" +tracks/9/path = NodePath("ShardsAndBonuses/HighScore:scale") +tracks/9/interp = 1 +tracks/9/loop_wrap = true +tracks/9/imported = false +tracks/9/enabled = true +tracks/9/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Vector2( 1, 1 ) ] +} +tracks/10/type = "value" +tracks/10/path = NodePath("CenterContainer/SubmitScore:visible") +tracks/10/interp = 1 +tracks/10/loop_wrap = true +tracks/10/imported = false +tracks/10/enabled = true +tracks/10/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 1, +"values": [ false ] +} +tracks/11/type = "value" +tracks/11/path = NodePath("CenterContainer/SubmitScore:rect_scale") +tracks/11/interp = 1 +tracks/11/loop_wrap = true +tracks/11/imported = false +tracks/11/enabled = true +tracks/11/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Vector2( 1, 1 ) ] +} +tracks/12/type = "value" +tracks/12/path = NodePath("CenterContainer/LoadingGraphic:visible") +tracks/12/interp = 1 +tracks/12/loop_wrap = true +tracks/12/imported = false +tracks/12/enabled = true +tracks/12/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 1, +"values": [ false ] +} +tracks/13/type = "value" +tracks/13/path = NodePath("CenterContainer/LoadingGraphic:rect_scale") +tracks/13/interp = 1 +tracks/13/loop_wrap = true +tracks/13/imported = false +tracks/13/enabled = true +tracks/13/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Vector2( 1, 1 ) ] +} +tracks/14/type = "value" +tracks/14/path = NodePath("CenterContainer/LoadingGraphic:material:shader_param/ammount") +tracks/14/interp = 1 +tracks/14/loop_wrap = true +tracks/14/imported = false +tracks/14/enabled = true +tracks/14/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Vector2( 24, 12 ) ] +} +tracks/15/type = "value" +tracks/15/path = NodePath("CenterContainer/SubmitScore:modulate") +tracks/15/interp = 1 +tracks/15/loop_wrap = true +tracks/15/imported = false +tracks/15/enabled = true +tracks/15/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Color( 1, 1, 1, 1 ) ] +} +tracks/16/type = "value" +tracks/16/path = NodePath("CenterContainer/SubmitScore/Label:text") +tracks/16/interp = 1 +tracks/16/loop_wrap = true +tracks/16/imported = false +tracks/16/enabled = true +tracks/16/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 1, +"values": [ "submit score?" ] +} [sub_resource type="Animation" id=4] resource_name = "results" @@ -321,6 +482,340 @@ tracks/14/keys = { } ] } +[sub_resource type="Animation" id=15] +resource_name = "submit" +length = 0.3 +tracks/0/type = "value" +tracks/0/path = NodePath("CenterContainer/SubmitScore:rect_scale") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.3 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ Vector2( 1, 1 ), Vector2( 1e-05, 1 ) ] +} +tracks/1/type = "value" +tracks/1/path = NodePath("CenterContainer/SubmitScore:visible") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 1, +"values": [ true ] +} +tracks/2/type = "value" +tracks/2/path = NodePath("CenterContainer/LoadingGraphic:material:shader_param/ammount") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/keys = { +"times": PoolRealArray( 0, 0.2 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ Vector2( 0, 0 ), Vector2( 24, 12 ) ] +} +tracks/3/type = "value" +tracks/3/path = NodePath("CenterContainer/LoadingGraphic:visible") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 1, +"values": [ true ] +} + +[sub_resource type="Animation" id=12] +resource_name = "submit_score_popup" +length = 1.5 +tracks/0/type = "value" +tracks/0/path = NodePath("ShardsAndBonuses:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Vector2( -512, 0 ) ] +} +tracks/1/type = "value" +tracks/1/path = NodePath("ShardsAndBonuses/FinalScore:visible") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 1, +"values": [ true ] +} +tracks/2/type = "value" +tracks/2/path = NodePath("ShardsAndBonuses/HighScore:visible") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/keys = { +"times": PoolRealArray( 0, 0.3 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 1, +"values": [ false, true ] +} +tracks/3/type = "value" +tracks/3/path = NodePath("ShardsAndBonuses/FinalScore:scale") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/keys = { +"times": PoolRealArray( 0, 0.3 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ Vector2( 1, 1 ), Vector2( 1e-05, 1 ) ] +} +tracks/4/type = "value" +tracks/4/path = NodePath("ShardsAndBonuses/HighScore:scale") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/keys = { +"times": PoolRealArray( 0, 0.3, 0.6 ), +"transitions": PoolRealArray( 1, 1, 1 ), +"update": 0, +"values": [ Vector2( 1, 1 ), Vector2( 1e-05, 1 ), Vector2( 1, 1 ) ] +} +tracks/5/type = "value" +tracks/5/path = NodePath("CenterContainer/SubmitScore:visible") +tracks/5/interp = 1 +tracks/5/loop_wrap = true +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/keys = { +"times": PoolRealArray( 0, 1 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 1, +"values": [ false, true ] +} +tracks/6/type = "value" +tracks/6/path = NodePath("CenterContainer/SubmitScore:rect_scale") +tracks/6/interp = 1 +tracks/6/loop_wrap = true +tracks/6/imported = false +tracks/6/enabled = true +tracks/6/keys = { +"times": PoolRealArray( 0, 1, 1.3 ), +"transitions": PoolRealArray( 1, 1, 1 ), +"update": 0, +"values": [ Vector2( 1e-05, 1 ), Vector2( 1e-05, 1 ), Vector2( 1, 1 ) ] +} +tracks/7/type = "method" +tracks/7/path = NodePath("CenterContainer/SubmitScore/YesNoPrompt/HBoxContainer/YesSubmit") +tracks/7/interp = 1 +tracks/7/loop_wrap = true +tracks/7/imported = false +tracks/7/enabled = true +tracks/7/keys = { +"times": PoolRealArray( 1.5 ), +"transitions": PoolRealArray( 1 ), +"values": [ { +"args": [ ], +"method": "grab_focus" +} ] +} +tracks/8/type = "value" +tracks/8/path = NodePath("CenterContainer/SubmitScore:modulate") +tracks/8/interp = 1 +tracks/8/loop_wrap = true +tracks/8/imported = false +tracks/8/enabled = true +tracks/8/keys = { +"times": PoolRealArray( 1, 1.056 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 1, +"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ] +} +tracks/9/type = "value" +tracks/9/path = NodePath("CenterContainer/LoadingGraphic:visible") +tracks/9/interp = 1 +tracks/9/loop_wrap = true +tracks/9/imported = false +tracks/9/enabled = true +tracks/9/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 1, +"values": [ false ] +} +tracks/10/type = "value" +tracks/10/path = NodePath("CenterContainer/SubmitScore/Label:text") +tracks/10/interp = 1 +tracks/10/loop_wrap = true +tracks/10/imported = false +tracks/10/enabled = true +tracks/10/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 1, +"values": [ "submit score?" ] +} + +[sub_resource type="Animation" id=18] +resource_name = "success" +length = 1.5 +tracks/0/type = "value" +tracks/0/path = NodePath("CenterContainer/LoadingGraphic:material:shader_param/ammount") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.3 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ Vector2( 24, 12 ), Vector2( 0, 0 ) ] +} +tracks/1/type = "value" +tracks/1/path = NodePath("CenterContainer/CollectedParticles:emitting") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"times": PoolRealArray( 0.3 ), +"transitions": PoolRealArray( 1 ), +"update": 1, +"values": [ true ] +} +tracks/2/type = "value" +tracks/2/path = NodePath("CenterContainer/LoadingGraphic:visible") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/keys = { +"times": PoolRealArray( 0, 0.3 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 1, +"values": [ true, false ] +} +tracks/3/type = "value" +tracks/3/path = NodePath("CenterContainer/SubmitScore:visible") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 1, +"values": [ false ] +} +tracks/4/type = "method" +tracks/4/path = NodePath(".") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/keys = { +"times": PoolRealArray( 1.5 ), +"transitions": PoolRealArray( 1 ), +"values": [ { +"args": [ ], +"method": "_next_screen" +} ] +} + +[sub_resource type="Animation" id=16] +resource_name = "try_again" +length = 0.5 +tracks/0/type = "value" +tracks/0/path = NodePath("CenterContainer/SubmitScore:rect_scale") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.3 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ Vector2( 1e-05, 1 ), Vector2( 1, 1 ) ] +} +tracks/1/type = "value" +tracks/1/path = NodePath("CenterContainer/SubmitScore:visible") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 1, +"values": [ true ] +} +tracks/2/type = "value" +tracks/2/path = NodePath("CenterContainer/LoadingGraphic:material:shader_param/ammount") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/keys = { +"times": PoolRealArray( 0, 0.1, 0.3 ), +"transitions": PoolRealArray( 1, 1, 1 ), +"update": 0, +"values": [ Vector2( 24, 12 ), Vector2( 24, 12 ), Vector2( 0, 0 ) ] +} +tracks/3/type = "value" +tracks/3/path = NodePath("CenterContainer/LoadingGraphic:visible") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 1, +"values": [ true ] +} +tracks/4/type = "value" +tracks/4/path = NodePath("CenterContainer/SubmitScore/Label:text") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 1, +"values": [ "failed. try again?" ] +} +tracks/5/type = "method" +tracks/5/path = NodePath("CenterContainer/SubmitScore/YesNoPrompt/HBoxContainer/YesSubmit") +tracks/5/interp = 1 +tracks/5/loop_wrap = true +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/keys = { +"times": PoolRealArray( 0.5 ), +"transitions": PoolRealArray( 1 ), +"values": [ { +"args": [ ], +"method": "grab_focus" +} ] +} + [node name="Results" type="Node"] script = ExtResource( 13 ) @@ -529,6 +1024,28 @@ material = ExtResource( 7 ) position = Vector2( 640, 40 ) texture = ExtResource( 8 ) +[node name="HighScore" type="Sprite" parent="ShardsAndBonuses"] +visible = false +material = ExtResource( 7 ) +position = Vector2( 640, 40 ) +texture = ExtResource( 15 ) + +[node name="Sparkles" type="CPUParticles2D" parent="ShardsAndBonuses/HighScore"] +light_mask = 0 +amount = 4 +lifetime = 2.0 +texture = ExtResource( 16 ) +emission_shape = 2 +emission_rect_extents = Vector2( 48, 8 ) +gravity = Vector2( 0, 0 ) +angular_velocity = 720.0 +angular_velocity_random = 1.0 +angle = 720.0 +angle_random = 1.0 +scale_amount_curve = SubResource( 11 ) +color = Color( 0.72549, 0.956863, 1, 1 ) +script = ExtResource( 17 ) + [node name="Score" type="Label" parent="."] material = ExtResource( 9 ) margin_top = 8.0 @@ -538,6 +1055,13 @@ theme = ExtResource( 10 ) text = "Score: 0000000" align = 1 +[node name="EasyIndicator" type="TextureRect" parent="."] +margin_left = 61.0 +margin_top = 7.0 +margin_right = 73.0 +margin_bottom = 19.0 +texture = ExtResource( 20 ) + [node name="Time" type="Label" parent="."] material = ExtResource( 9 ) margin_top = 178.0 @@ -547,6 +1071,131 @@ theme = ExtResource( 10 ) text = "Time: " align = 1 +[node name="CenterContainer" type="CenterContainer" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_top = 77.0 +theme = ExtResource( 10 ) + +[node name="CollectedParticles" type="CPUParticles2D" parent="CenterContainer"] +pause_mode = 2 +position = Vector2( 127, 56 ) +emitting = false +amount = 64 +one_shot = true +explosiveness = 1.0 +local_coords = false +emission_shape = 2 +emission_rect_extents = Vector2( 4, 4 ) +direction = Vector2( 0, -1 ) +spread = 180.0 +gravity = Vector2( 0, 150 ) +initial_velocity = 250.0 +initial_velocity_random = 0.9 +damping = 2.0 +angle = 720.0 +angle_random = 1.0 +scale_amount_random = 1.0 +color_ramp = SubResource( 17 ) + +[node name="LoadingGraphic" type="Label" parent="CenterContainer"] +unique_name_in_owner = true +visible = false +material = SubResource( 14 ) +margin_left = 124.0 +margin_top = 52.0 +margin_right = 131.0 +margin_bottom = 62.0 +text = "§" +align = 1 +valign = 1 + +[node name="SubmitScore" type="VBoxContainer" parent="CenterContainer"] +unique_name_in_owner = true +visible = false +margin_left = 82.0 +margin_top = 47.0 +margin_right = 173.0 +margin_bottom = 67.0 +rect_pivot_offset = Vector2( 45.5, 18 ) +theme = ExtResource( 10 ) + +[node name="Label" type="Label" parent="CenterContainer/SubmitScore"] +margin_right = 91.0 +margin_bottom = 10.0 +custom_fonts/font = ExtResource( 19 ) +text = "submit score?" + +[node name="YesNoPrompt" type="PanelContainer" parent="CenterContainer/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/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="YesSubmit" type="TextureButton" parent="CenterContainer/SubmitScore/YesNoPrompt/HBoxContainer"] +unique_name_in_owner = true +material = SubResource( 13 ) +margin_top = 4.0 +margin_right = 12.0 +margin_bottom = 12.0 +rect_min_size = Vector2( 12, 8 ) +focus_neighbour_right = NodePath("../NoSubmit") +size_flags_vertical = 4 +texture_focused = ExtResource( 18 ) +expand = true +stretch_mode = 3 + +[node name="YesLabel" type="Label" parent="CenterContainer/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/SubmitScore/YesNoPrompt/HBoxContainer"] +margin_left = 33.0 +margin_right = 45.0 +margin_bottom = 16.0 +rect_min_size = Vector2( 12, 0 ) + +[node name="NoSubmit" type="TextureButton" parent="CenterContainer/SubmitScore/YesNoPrompt/HBoxContainer"] +unique_name_in_owner = true +material = SubResource( 13 ) +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("../YesSubmit") +size_flags_vertical = 4 +texture_focused = ExtResource( 18 ) +expand = true +stretch_mode = 3 + +[node name="NoLabel" type="Label" parent="CenterContainer/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/SubmitScore/YesNoPrompt/HBoxContainer"] +margin_left = 71.0 +margin_right = 83.0 +margin_bottom = 16.0 +rect_min_size = Vector2( 12, 0 ) + [node name="Results" type="Sprite" parent="."] material = SubResource( 6 ) position = Vector2( 232, 80 ) @@ -557,5 +1206,11 @@ autoplay = "results" playback_speed = 2.0 anims/RESET = SubResource( 10 ) anims/results = SubResource( 4 ) +anims/submit = SubResource( 15 ) +anims/submit_score_popup = SubResource( 12 ) +anims/success = SubResource( 18 ) +anims/try_again = SubResource( 16 ) +[connection signal="button_down" from="CenterContainer/SubmitScore/YesNoPrompt/HBoxContainer/YesSubmit" to="." method="_on_YesSubmit_button_down"] +[connection signal="button_down" from="CenterContainer/SubmitScore/YesNoPrompt/HBoxContainer/NoSubmit" to="." method="_on_NoSubmit_button_down"] [connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_AnimationPlayer_animation_finished"] diff --git a/menus/score_entry.gd b/menus/score_entry.gd index d59a2ce..89927e3 100644 --- a/menus/score_entry.gd +++ b/menus/score_entry.gd @@ -1,26 +1,47 @@ tool extends HBoxContainer +const DIFFICULTY_ICONS = [ + preload("res://graphics/hud/scores/sweet.png"), + preload("res://graphics/hud/scores/salty.png"), + preload("res://graphics/hud/scores/spicy.png"), + preload("res://graphics/hud/scores/pungent.png"), +] + export var place: int = 0 setget _set_place -export var user: String = "Username" setget _set_user -export var score: String = "00000" setget _set_score +export var player: String = "Username" setget _set_player +export var score: int = 0 setget _set_score +export var time: float = 0.0 setget _set_time +export(int, "Sweet", "Salty", "Spicy", "Pungent") var difficulty: int = 0 setget _set_difficulty func _ready() -> void: - $Place.text = " %01d " % place - $User.text = user - $Score.text = score + _set_place(place) + _set_player(player) + _set_score(score) + _set_time(time) + _set_difficulty(difficulty) func _set_place(value: int) -> void: place = value if is_inside_tree(): - $Place.text = " %01d " % place + $Place.text = "%d" % place -func _set_user(value: String) -> void: - user = value +func _set_player(value: String) -> void: + player = value.substr(0, 10) if is_inside_tree(): - $User.text = user + $Player.text = player -func _set_score(value: String) -> void: +func _set_score(value: int) -> void: score = value if is_inside_tree(): - $Score.text = score + $Score.text = "%05d" % score + +func _set_time(value: float) -> void: + time = value + if is_inside_tree(): + $Time.text = Game.format_time(time) + +func _set_difficulty(value: int) -> void: + difficulty = value + if is_inside_tree(): + $Difficulty.texture = DIFFICULTY_ICONS[difficulty] diff --git a/menus/score_entry.tscn b/menus/score_entry.tscn index 2eaac8c..26aaa66 100644 --- a/menus/score_entry.tscn +++ b/menus/score_entry.tscn @@ -1,32 +1,60 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://ui/theme.tres" type="Theme" id=1] [ext_resource path="res://menus/score_entry.gd" type="Script" id=2] +[ext_resource path="res://graphics/hud/scores/sweet.png" type="Texture" id=3] +[ext_resource path="res://ui/2ndpuberty_scholar_outline.fnt" type="BitmapFont" id=4] [node name="ScoreEntry" type="HBoxContainer"] -margin_right = 210.0 -margin_bottom = 10.0 +margin_right = 228.0 +margin_bottom = 12.0 +rect_min_size = Vector2( 0, 12 ) theme = ExtResource( 1 ) custom_constants/separation = 8 script = ExtResource( 2 ) -user = "--------" -score = "-----" +player = "coolplayer" [node name="Place" type="Label" parent="."] -margin_right = 21.0 -margin_bottom = 10.0 -text = " 0 " +margin_top = 1.0 +margin_right = 16.0 +margin_bottom = 11.0 +rect_min_size = Vector2( 16, 0 ) +custom_fonts/font = ExtResource( 4 ) +text = "0" +align = 1 -[node name="User" type="Label" parent="."] -margin_left = 29.0 -margin_right = 167.0 -margin_bottom = 10.0 -size_flags_horizontal = 3 -text = "--------" +[node name="Player" type="Label" parent="."] +margin_left = 24.0 +margin_top = 1.0 +margin_right = 94.0 +margin_bottom = 11.0 +rect_min_size = Vector2( 70, 0 ) +custom_fonts/font = ExtResource( 4 ) +text = "coolplayer" +align = 1 [node name="Score" type="Label" parent="."] -margin_left = 175.0 -margin_right = 210.0 -margin_bottom = 10.0 -text = "-----" +margin_left = 102.0 +margin_top = 1.0 +margin_right = 137.0 +margin_bottom = 11.0 +rect_min_size = Vector2( 35, 0 ) +custom_fonts/font = ExtResource( 4 ) +text = "00000" align = 2 + +[node name="Time" type="Label" parent="."] +margin_left = 145.0 +margin_top = 1.0 +margin_right = 201.0 +margin_bottom = 11.0 +rect_min_size = Vector2( 56, 0 ) +custom_fonts/font = ExtResource( 4 ) +text = "--:--.--" +align = 2 + +[node name="Difficulty" type="TextureRect" parent="."] +margin_left = 209.0 +margin_right = 221.0 +margin_bottom = 12.0 +texture = ExtResource( 3 ) diff --git a/menus/scoreboards_scholar.gd b/menus/scoreboards_scholar.gd new file mode 100644 index 0000000..10b3f05 --- /dev/null +++ b/menus/scoreboards_scholar.gd @@ -0,0 +1,108 @@ +extends Node + + +const PAGE_SIZE: int = 8 + + +var loaded_scores: Dictionary = {} +var selected_level: int = 0 +var _page: int = 0 + + +onready var scores: VBoxContainer = $"%Scores" +onready var level_title: Button = $"%LevelTitle" + + +func _ready() -> void: + yield(_refresh_scores(), "completed") + Fade.fade_in(Options.transition_speed_secs) + + +func _input(event: InputEvent) -> void: + if event.is_action_pressed("ui_right"): + selected_level = posmod(selected_level + 1, LevelData.levels.size()) + while not LevelData.levels[selected_level].has_scoreboard: + selected_level = posmod(selected_level + 1, LevelData.levels.size()) + _refresh_scores() + elif event.is_action_pressed("ui_left"): + selected_level = posmod(selected_level - 1, LevelData.levels.size()) + while not LevelData.levels[selected_level].has_scoreboard: + selected_level = posmod(selected_level - 1, LevelData.levels.size()) + _refresh_scores() + elif event.is_action_pressed("ui_down"): + _page += 1 + _refresh_scores() + elif event.is_action_pressed("ui_up"): + _page = int(max(_page - 1, 0)) + _refresh_scores() + elif event.is_action_pressed("ui_cancel"): + Fade.fade_out(Options.transition_speed_secs) + yield(Fade, "fade_finished") + SceneManager.current_scene = preload("res://menus/main_menu.tscn").instance() + + +func _refresh_scores() -> void: + level_title.text = LevelData.levels[selected_level].title + + var level = LevelData.levels[selected_level].save_id + if not level in loaded_scores: + yield(_load_scores(level), "completed") + + if ScoreBoard.errored: + push_error("Scoreboard could not be loaded.") + + var entries = loaded_scores.get(level, {}) + + while _page * PAGE_SIZE > entries.size(): + _page -= 1 + + var offset = _page * PAGE_SIZE + + $"%PrevScores".visible = _page > 0 + $"%NextScores".visible = entries.size() - offset > PAGE_SIZE + + for i in 8: + var entry_node = scores.get_node("ScoreEntry%d" % i) + if i >= entries.size() - offset: + entry_node.visible = false + else: + var player = entries.keys()[offset + i] + var entry = entries[player] + entry_node.visible = true + entry_node.place = offset + i + 1 + entry_node.player = player + entry_node.score = entry.score + entry_node.time = float(entry.time) * 0.001 # convert from ms + entry_node.difficulty = entry.difficulty + + +func _load_scores(level: String) -> void: + var result: Dictionary = yield(ScoreBoard.get_scores(level), "completed") + if ScoreBoard.errored: + #TODO: failure indication + return + + var players = result.keys().duplicate() + _sorting_dict = result + players.sort_custom(self, "_sort_scores") + + loaded_scores[level] = {} + for p in players: + loaded_scores[level][p] = result[p] + + +var _sorting_dict: Dictionary = {} +func _sort_scores(a, b) -> bool: + var score_a = _sorting_dict[a] + var score_b = _sorting_dict[b] + + if score_b.score < score_a.score: + return true + elif score_b.score == score_a.score: + if score_b.difficulty < score_a.difficulty: + return true + elif score_b.difficulty == score_a.difficulty: + if score_b.time > score_a.time: + return true + + return false diff --git a/menus/scoreboards_scholar.tscn b/menus/scoreboards_scholar.tscn new file mode 100644 index 0000000..ca8f960 --- /dev/null +++ b/menus/scoreboards_scholar.tscn @@ -0,0 +1,320 @@ +[gd_scene load_steps=16 format=2] + +[ext_resource path="res://shaders/ska_plane.gdshader" type="Shader" id=1] +[ext_resource path="res://menus/scoreboards_scholar.gd" type="Script" id=2] +[ext_resource path="res://graphics/hud/arrow_down.png" type="Texture" id=3] +[ext_resource path="res://shaders/wibble_wobble.gdshader" type="Shader" id=4] +[ext_resource path="res://ui/theme.tres" type="Theme" id=5] +[ext_resource path="res://graphics/hud/pause_arrow.png" type="Texture" id=6] +[ext_resource path="res://menus/score_entry.tscn" type="PackedScene" id=7] +[ext_resource path="res://ui/2ndpuberty_scholar_outline.fnt" type="BitmapFont" id=8] +[ext_resource path="res://graphics/hud/arrow_up.png" type="Texture" id=9] + +[sub_resource type="ShaderMaterial" id=1] +shader = ExtResource( 1 ) +shader_param/color_1 = Color( 0.615686, 0.670588, 0.984314, 1 ) +shader_param/color_2 = Color( 1, 0.709804, 0.984314, 1 ) +shader_param/checker_size = Vector2( 24, 12 ) +shader_param/pan_speed = Vector2( 0, 0 ) +shader_param/cycle_speed = Vector2( 8, -8 ) +shader_param/cycle_alternation = Vector2( 0, 1 ) +shader_param/uv_transform = Transform2D( 1, 0, 1, 1, 0, 0 ) + +[sub_resource type="ShaderMaterial" id=2] +shader = ExtResource( 4 ) +shader_param/speed = Vector2( 4, 0 ) +shader_param/ammount = Vector2( 2, 0 ) +shader_param/offset = Vector2( 0, 0 ) +shader_param/delay = Vector2( 0, 0 ) + +[sub_resource type="ShaderMaterial" id=3] +shader = ExtResource( 4 ) +shader_param/speed = Vector2( 4, 0 ) +shader_param/ammount = Vector2( 2, 0 ) +shader_param/offset = Vector2( 0, 0 ) +shader_param/delay = Vector2( 4, 0 ) + +[sub_resource type="ShaderMaterial" id=5] +shader = ExtResource( 4 ) +shader_param/speed = Vector2( 0, 4 ) +shader_param/ammount = Vector2( 0, 2 ) +shader_param/offset = Vector2( 0, 0 ) +shader_param/delay = Vector2( 0, 0 ) + +[sub_resource type="ShaderMaterial" id=6] +shader = ExtResource( 4 ) +shader_param/speed = Vector2( 0, 4 ) +shader_param/ammount = Vector2( 0, 2 ) +shader_param/offset = Vector2( 0, 0 ) +shader_param/delay = Vector2( 0, 4 ) + +[sub_resource type="ShaderMaterial" id=4] +shader = ExtResource( 4 ) +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="Scoreboards" type="Node"] +script = ExtResource( 2 ) + +[node name="Background" type="ColorRect" parent="."] +material = SubResource( 1 ) +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="BoardsScreen" type="VBoxContainer" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +theme = ExtResource( 5 ) +custom_constants/separation = 0 + +[node name="SelectLevel" type="HBoxContainer" parent="BoardsScreen"] +margin_right = 256.0 +margin_bottom = 16.0 +rect_min_size = Vector2( 0, 16 ) +alignment = 1 + +[node name="BackArrow" type="TextureRect" parent="BoardsScreen/SelectLevel"] +unique_name_in_owner = true +material = SubResource( 2 ) +margin_left = 72.0 +margin_top = 4.0 +margin_right = 78.0 +margin_bottom = 12.0 +size_flags_vertical = 4 +texture = ExtResource( 6 ) +flip_h = true + +[node name="LevelTitle" type="Button" parent="BoardsScreen/SelectLevel"] +unique_name_in_owner = true +margin_left = 82.0 +margin_top = 3.0 +margin_right = 173.0 +margin_bottom = 13.0 +size_flags_vertical = 4 +theme = ExtResource( 5 ) +custom_colors/font_color_focus = Color( 1, 0.968627, 0.709804, 1 ) +custom_colors/font_color = Color( 1, 1, 1, 1 ) +custom_fonts/font = ExtResource( 8 ) +text = "Verdant Hills" + +[node name="NextArrow" type="TextureRect" parent="BoardsScreen/SelectLevel"] +unique_name_in_owner = true +material = SubResource( 3 ) +margin_left = 177.0 +margin_top = 4.0 +margin_right = 183.0 +margin_bottom = 12.0 +size_flags_vertical = 4 +texture = ExtResource( 6 ) + +[node name="Scoreboard" type="HBoxContainer" parent="BoardsScreen"] +margin_top = 16.0 +margin_right = 256.0 +margin_bottom = 192.0 +focus_mode = 2 +size_flags_vertical = 3 +alignment = 1 + +[node name="PrevBoard" type="TextureRect" parent="BoardsScreen/Scoreboard"] +unique_name_in_owner = true +visible = false +material = SubResource( 2 ) +margin_top = 84.0 +margin_right = 6.0 +margin_bottom = 92.0 +size_flags_vertical = 4 +texture = ExtResource( 6 ) +flip_h = true + +[node name="MarginContainer" type="MarginContainer" parent="BoardsScreen/Scoreboard"] +margin_left = 10.0 +margin_right = 246.0 +margin_bottom = 176.0 +custom_constants/margin_right = 4 +custom_constants/margin_top = 4 +custom_constants/margin_left = 4 +custom_constants/margin_bottom = 4 + +[node name="VBoxContainer" type="VBoxContainer" parent="BoardsScreen/Scoreboard/MarginContainer"] +margin_left = 4.0 +margin_top = 4.0 +margin_right = 232.0 +margin_bottom = 172.0 + +[node name="Header" type="HBoxContainer" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer"] +margin_right = 228.0 +margin_bottom = 10.0 +rect_min_size = Vector2( 228, 10 ) +custom_constants/separation = 8 + +[node name="Place" type="Label" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer/Header"] +margin_right = 16.0 +margin_bottom = 10.0 +rect_min_size = Vector2( 16, 0 ) +custom_fonts/font = ExtResource( 8 ) +text = "#" +align = 1 + +[node name="Player" type="Label" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer/Header"] +margin_left = 24.0 +margin_right = 94.0 +margin_bottom = 10.0 +rect_min_size = Vector2( 70, 0 ) +custom_fonts/font = ExtResource( 8 ) +text = "Player" +align = 1 +clip_text = true + +[node name="Score" type="Label" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer/Header"] +margin_left = 102.0 +margin_right = 137.0 +margin_bottom = 10.0 +rect_min_size = Vector2( 35, 0 ) +custom_fonts/font = ExtResource( 8 ) +text = "score" +align = 2 + +[node name="Time" type="Label" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer/Header"] +margin_left = 145.0 +margin_right = 201.0 +margin_bottom = 10.0 +rect_min_size = Vector2( 56, 0 ) +custom_fonts/font = ExtResource( 8 ) +text = "time" +align = 1 + +[node name="Control" type="Control" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer/Header"] +margin_left = 209.0 +margin_right = 221.0 +margin_bottom = 10.0 +rect_min_size = Vector2( 12, 0 ) + +[node name="HSeparator" type="HSeparator" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer"] +margin_top = 14.0 +margin_right = 228.0 +margin_bottom = 15.0 +custom_constants/separation = 1 + +[node name="ScoreboardTabs" type="Control" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer"] +unique_name_in_owner = true +margin_top = 19.0 +margin_right = 228.0 +margin_bottom = 168.0 +size_flags_vertical = 3 + +[node name="Scores" type="VBoxContainer" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer/ScoreboardTabs"] +unique_name_in_owner = true +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="PrevScores" type="TextureRect" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer/ScoreboardTabs/Scores"] +unique_name_in_owner = true +visible = false +material = SubResource( 5 ) +margin_left = 110.0 +margin_right = 118.0 +margin_bottom = 8.0 +rect_pivot_offset = Vector2( 3, 4 ) +size_flags_horizontal = 4 +size_flags_vertical = 4 +texture = ExtResource( 9 ) + +[node name="ScoreEntry0" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer/ScoreboardTabs/Scores" instance=ExtResource( 7 )] +place = 1 + +[node name="ScoreEntry1" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer/ScoreboardTabs/Scores" instance=ExtResource( 7 )] +margin_top = 16.0 +margin_bottom = 28.0 +place = 2 + +[node name="ScoreEntry2" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer/ScoreboardTabs/Scores" instance=ExtResource( 7 )] +margin_top = 32.0 +margin_bottom = 44.0 +place = 3 + +[node name="ScoreEntry3" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer/ScoreboardTabs/Scores" instance=ExtResource( 7 )] +margin_top = 48.0 +margin_bottom = 60.0 +place = 4 + +[node name="ScoreEntry4" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer/ScoreboardTabs/Scores" instance=ExtResource( 7 )] +margin_top = 64.0 +margin_bottom = 76.0 +place = 5 + +[node name="ScoreEntry5" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer/ScoreboardTabs/Scores" instance=ExtResource( 7 )] +margin_top = 80.0 +margin_bottom = 92.0 +place = 6 + +[node name="ScoreEntry6" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer/ScoreboardTabs/Scores" instance=ExtResource( 7 )] +margin_top = 96.0 +margin_bottom = 108.0 +place = 7 + +[node name="ScoreEntry7" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer/ScoreboardTabs/Scores" instance=ExtResource( 7 )] +margin_top = 112.0 +margin_bottom = 124.0 +place = 8 + +[node name="NextScores" type="TextureRect" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer/ScoreboardTabs/Scores"] +unique_name_in_owner = true +visible = false +material = SubResource( 6 ) +margin_left = 110.0 +margin_top = 128.0 +margin_right = 118.0 +margin_bottom = 136.0 +rect_pivot_offset = Vector2( 3, 4 ) +size_flags_horizontal = 4 +size_flags_vertical = 4 +texture = ExtResource( 3 ) + +[node name="LoadingIndicator" type="CenterContainer" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer/ScoreboardTabs"] +visible = false +anchor_right = 1.0 +anchor_bottom = 1.0 +size_flags_vertical = 3 + +[node name="Label" type="Label" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer/ScoreboardTabs/LoadingIndicator"] +material = SubResource( 4 ) +margin_left = 110.0 +margin_top = 69.0 +margin_right = 117.0 +margin_bottom = 79.0 +text = "§" + +[node name="FailedIndicator" type="CenterContainer" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer/ScoreboardTabs"] +visible = false +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="Label" type="Label" parent="BoardsScreen/Scoreboard/MarginContainer/VBoxContainer/ScoreboardTabs/FailedIndicator"] +margin_left = 65.0 +margin_top = 69.0 +margin_right = 163.0 +margin_bottom = 79.0 +text = "Failed to load" + +[node name="PanelContainer" type="PanelContainer" parent="BoardsScreen/Scoreboard"] +visible = false +margin_left = 250.0 +margin_right = 474.0 +margin_bottom = 144.0 +rect_min_size = Vector2( 224, 144 ) +size_flags_horizontal = 4 +size_flags_vertical = 0 + +[node name="NextBoard" type="TextureRect" parent="BoardsScreen/Scoreboard"] +unique_name_in_owner = true +visible = false +material = SubResource( 3 ) +margin_left = 250.0 +margin_top = 84.0 +margin_right = 256.0 +margin_bottom = 92.0 +size_flags_horizontal = 0 +size_flags_vertical = 4 +texture = ExtResource( 6 ) diff --git a/objects/hud/options_screen_scholar.gd b/objects/hud/options_screen_scholar.gd index 4f8d11c..ffb07d0 100644 --- a/objects/hud/options_screen_scholar.gd +++ b/objects/hud/options_screen_scholar.gd @@ -39,7 +39,7 @@ func focus() -> void: func _unhandled_input(event: InputEvent) -> void: Options.save_options() - if can_exit and event.is_action_pressed("ui_cancel"): + if can_exit and event.is_action_pressed("ui_cancel") and not Options.entry: if visible == true: emit_signal("exit") diff --git a/objects/hud/options_screen_scholar.tscn b/objects/hud/options_screen_scholar.tscn index 3e1f343..13733a4 100644 --- a/objects/hud/options_screen_scholar.tscn +++ b/objects/hud/options_screen_scholar.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=16 format=2] +[gd_scene load_steps=19 format=2] [ext_resource path="res://objects/hud/options_screen_scholar.gd" type="Script" id=1] [ext_resource path="res://ui/theme.tres" type="Theme" id=2] @@ -11,6 +11,21 @@ [ext_resource path="res://objects/hud/set_gamepad_button.gd" type="Script" id=9] [ext_resource path="res://objects/hud/scroll_follow_focus.gd" type="Script" id=10] [ext_resource path="res://graphics/hud/levelselect_nexlevel.png" type="Texture" id=11] +[ext_resource path="res://objects/hud/player_name_input.gd" type="Script" id=12] + +[sub_resource type="StyleBoxFlat" id=5] +content_margin_left = 1.0 +content_margin_right = 1.0 +bg_color = Color( 0.14902, 0.0980392, 0.247059, 1 ) +corner_detail = 1 +anti_aliasing = false + +[sub_resource type="StyleBoxFlat" id=6] +content_margin_left = 1.0 +content_margin_right = 1.0 +bg_color = Color( 0.213124, 0.165611, 0.382812, 1 ) +corner_detail = 1 +anti_aliasing = false [sub_resource type="ShaderMaterial" id=1] shader = ExtResource( 4 ) @@ -100,7 +115,6 @@ size_flags_vertical = 3 tabs_visible = false [node name="Game" type="VBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs"] -visible = false anchor_right = 1.0 anchor_bottom = 1.0 focus_next = NodePath("Rumble/SelectRumble") @@ -146,11 +160,34 @@ margin_left = 39.0 margin_right = 218.0 margin_bottom = 12.0 focus_neighbour_top = NodePath("../../Rumble/SelectRumble") +focus_neighbour_bottom = NodePath("../../ScoreBoardName/PlayerNameInput") focus_mode = 2 size_flags_horizontal = 3 script = ExtResource( 3 ) options = [ "none", "no stains", "full" ] +[node name="ScoreBoardName" type="HBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game"] +margin_top = 32.0 +margin_right = 218.0 +margin_bottom = 42.0 + +[node name="Label" type="Label" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/ScoreBoardName"] +margin_right = 112.0 +margin_bottom = 10.0 +text = "Scoreboard name:" + +[node name="PlayerNameInput" type="TextEdit" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/ScoreBoardName"] +margin_left = 130.0 +margin_right = 203.0 +margin_bottom = 10.0 +rect_min_size = Vector2( 73, 0 ) +focus_neighbour_top = NodePath("../../Gore/SelectGore") +size_flags_horizontal = 6 +custom_constants/line_spacing = 0 +custom_styles/focus = SubResource( 5 ) +custom_styles/normal = SubResource( 6 ) +script = ExtResource( 12 ) + [node name="Video" type="VBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs"] visible = false anchor_right = 1.0 @@ -459,6 +496,7 @@ script = ExtResource( 3 ) options = [ "off", "on" ] [node name="Input" type="VBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs"] +visible = false anchor_right = 1.0 anchor_bottom = 1.0 focus_next = NodePath("ScrollContainer/ControlsVBox/Left/Keyboard") @@ -825,6 +863,10 @@ align = 1 [connection signal="selected" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/SelectTab" to="." method="_on_tab_selected"] [connection signal="selected" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/Rumble/SelectRumble" to="." method="_on_Rumble_selected"] [connection signal="selected" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/Gore/SelectGore" to="." method="_on_Gore_selected"] +[connection signal="focus_entered" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/ScoreBoardName/PlayerNameInput" to="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/ScoreBoardName/PlayerNameInput" method="_on_focus_entered"] +[connection signal="focus_exited" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/ScoreBoardName/PlayerNameInput" to="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/ScoreBoardName/PlayerNameInput" method="_on_focus_exited"] +[connection signal="gui_input" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/ScoreBoardName/PlayerNameInput" to="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/ScoreBoardName/PlayerNameInput" method="_on_gui_input"] +[connection signal="text_changed" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/ScoreBoardName/PlayerNameInput" to="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Game/ScoreBoardName/PlayerNameInput" method="_on_text_changed"] [connection signal="selected" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Video/Fullscreen/SelectFullscreen" to="." method="_on_Fullscreen_selected"] [connection signal="selected" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Video/WindowSize/SelectWindowSize" to="." method="_on_WindowSize_selected"] [connection signal="selected" from="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Video/Scaling/SelectScaling" to="." method="_on_Scaling_selected"] diff --git a/objects/hud/player_name_input.gd b/objects/hud/player_name_input.gd new file mode 100644 index 0000000..23edaf8 --- /dev/null +++ b/objects/hud/player_name_input.gd @@ -0,0 +1,29 @@ +extends TextEdit + + +func _ready() -> void: + text = Options.scoreboard_name + + +func _exit_tree() -> void: + Options.entry = false + + +func _on_text_changed() -> void: + text = text.substr(0, 10).to_lower().strip_escapes() + Options.scoreboard_name = text + cursor_set_column(text.length()) + + +func _on_focus_entered() -> void: + Options.entry = true + cursor_set_column(text.length()) + + +func _on_focus_exited() -> void: + Options.set_deferred("entry", false) + + +func _on_gui_input(event: InputEvent) -> void: + if event.is_action_pressed("text_enter"): + get_node(focus_neighbour_top).grab_focus() diff --git a/project.godot b/project.godot index ec768cd..6b26af2 100644 --- a/project.godot +++ b/project.godot @@ -109,7 +109,7 @@ SceneManager="*res://autoloads/scene_manager.tscn" Console="*res://autoloads/console.tscn" Fade="*res://autoloads/fade.tscn" StainLayer="*res://autoloads/stain_layer.tscn" -Ngio="*res://autoloads/ngio.gd" +ScoreBoard="*res://autoloads/scoreboard.gd" [debug] @@ -359,6 +359,12 @@ shield={ , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":5,"pressure":0.0,"pressed":false,"script":null) ] } +text_enter={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"physical_scancode":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"physical_scancode":0,"unicode":0,"echo":false,"script":null) + ] +} [input_devices] diff --git a/scripts/level_entry.gd b/scripts/level_entry.gd index 55024db..db1b37c 100644 --- a/scripts/level_entry.gd +++ b/scripts/level_entry.gd @@ -16,8 +16,7 @@ export var shards_required_spicy: int = 0 export var shards_required_pungent: int = 0 export var boss_required: String = "" export var boss: bool = false -export var scores_id: int = -1 -export var times_id: int = -1 +export var has_scoreboard: bool = false export var scene: PackedScene var shards_required: int = 0 setget , _get_shards_required