diff --git a/.vibe/skills/godot-gdscript-style-guide/Skill.md b/.vibe/skills/godot-gdscript-style-guide/Skill.md deleted file mode 100644 index d1cadb1..0000000 --- a/.vibe/skills/godot-gdscript-style-guide/Skill.md +++ /dev/null @@ -1,48 +0,0 @@ -When writing or reviewing GDScript code, strictly follow the official Godot Engine GDScript style guide and file naming conventions: - ---- - -### **Code Formatting** -1. **Indentation**: Use **4 spaces** (no tabs). -2. **Line Length**: Keep lines under **100 characters** where possible. -3. **Naming Conventions**: - - **Variables/functions**: `snake_case` (e.g., `player_health`, `calculate_damage()`). - - **Constants**: `UPPER_SNAKE_CASE` (e.g., `MAX_SPEED = 100`). - - **Class Names**: `PascalCase` (e.g., `class_name Player.gd`). - - **Signals**: `snake_case` (e.g., `signal player_died`). -4. **Spacing**: - - Add spaces around operators (`x = y + z`, not `x=y+z`). - - No space after `(` or before `)` in function calls (e.g., `func(a, b)`). -5. **Braces**: Open braces on the same line for `if`, `for`, `func`, etc.: - ```gdscript - if x > 0: - print("Positive") - ``` -6. **Docstrings**: Use **Godot’s built-in docstring format** for functions: - ```gdscript - ## Calculates the player's speed based on input. - ## @param delta: Time since last frame (float). - ## @return: The adjusted speed (float). - func calculate_speed(delta: float) -> float: - return base_speed * delta - ``` -7. **Type Hints**: Always include type hints for parameters and return values (Godot 4+). -8. **Avoid Redundancy**: Omit redundant `self.` unless required for clarity. - ---- -### **File Naming Conventions** -1. **Script Files**: - - Use **`snake_case`** for `.gd` files (e.g., `player.gd`, `enemy_ai.gd`). - - Match the filename to the **class name** (if the script defines a class). - Example: If the class is `Player`, the file should be `player.gd`. -2. **Scene Files**: - - Use **`PascalCase`** for `.tscn` files (e.g., `Player.tscn`, `MainMenu.tscn`). - - Match the filename to the **root node** of the scene. -3. **Resource Files**: - - Use **`snake_case`** for `.tres` or `.res` files (e.g., `player_stats.tres`). -4. **Folders**: - - Use **`snake_case`** for directories (e.g., `scripts/`, `assets/sprites/`). - - Group related files logically (e.g., `player/` for `player.gd`, `player.tscn`). - ---- -**Reference**: [Godot GDScript Style Guide](https://docs.godotengine.org/en/stable/getting_started/scripting/gdscript/gdscript_styleguide.html). diff --git a/AboutWindow.gd b/AboutWindow.gd index ce8a0d0..7a65c90 100644 --- a/AboutWindow.gd +++ b/AboutWindow.gd @@ -13,6 +13,9 @@ var whats_new_label: Label = %WhatsNewLabel # Changelog as Dictionary with version as key and description as value const WHATS_NEW: Dictionary = { + "1.8.5": "#9: New winner screen with positions of all players + #32: New setting for how long to hide the beginning + #33: Fixed bug with hiding beginning when song restarts", "1.8.0": "#14: Updated About page #15: Create new keymap page #20: The winner song can now be stopped diff --git a/MainWindow.gd b/MainWindow.gd index 0899d71..fcc7216 100644 --- a/MainWindow.gd +++ b/MainWindow.gd @@ -67,6 +67,9 @@ var shortcuts_window: Control = %ShortcutsWindow @onready var qr_window: Control = %QRWindow +@onready +var winner_window: Control = %WinnerWindow + @onready var qr_button: Button = $QRButton @@ -115,15 +118,6 @@ var search_button: Button = $SearchButton @onready var search_view: Control= $Search -@onready -var winner_popup: PopupPanel = $WinnerPopupPanel - -@onready -var winner_label: Label = %WinnerLabel - -@onready -var winner_picture: TextureRect = %WinnerPicture - @onready var auto_repeat_song_button: CheckButton = $RepeatSongCheckButton @@ -131,7 +125,7 @@ var auto_repeat_song_button: CheckButton = $RepeatSongCheckButton var music_player_container: PanelContainer = $MusicPlayer @onready -var log: Control = %Log +var log_window: Control = %Log @onready var debug_label: Label = $DebugLabel @@ -217,7 +211,7 @@ func _input(event: InputEvent) -> void: if event.alt_pressed && event.keycode == KEY_K: shortcuts_window.visible = !shortcuts_window.visible if event.alt_pressed && event.keycode == KEY_L: - log.visible = !log.visible + log_window.visible = !log_window.visible func server_updated() -> void: print("server_updated") @@ -456,7 +450,7 @@ func load_players() -> void: func _on_point_given(player_given_point: int) -> void: print("_on_point_given") - log.add_log_row(Settings.player_array[player_given_point].player_name + " got a point") + log_window.add_log_row(Settings.player_array[player_given_point].player_name + " got a point") if Playlist.currently_playing_song >= 0: Playlist.add_point(player_given_point) update_song_list() @@ -466,7 +460,7 @@ func _on_make_point_given_sound() -> void: func _on_point_taken(player_taken_point: int) -> void: print("_on_point_taken") - log.add_log_row(Settings.player_array[player_taken_point].player_name + " lost a point") + log_window.add_log_row(Settings.player_array[player_taken_point].player_name + " lost a point") music_player_container.play_sound_effect(preload("res://sounds/itemequip.wav")) if Playlist.currently_playing_song >= 0: Playlist.remove_point(player_taken_point) @@ -474,12 +468,7 @@ func _on_point_taken(player_taken_point: int) -> void: func _on_player_won(winning_player_id: int) -> void: print("_on_player_won") - winner_popup.visible = true - winner_label.text = Settings.player_array[winning_player_id].player_name + " won!!" - winner_picture.custom_minimum_size = Vector2(692, 300) - winner_picture.expand_mode = TextureRect.EXPAND_FIT_WIDTH_PROPORTIONAL - winner_picture.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED - winner_picture.texture = Settings.player_array[winning_player_id].character + winner_window.show_winner(winning_player_id) music_player_container.play_song(preload("res://sounds/winning.mp3")) Settings.add_to_stats = false diff --git a/MainWindow.tscn b/MainWindow.tscn index 7ccf2fc..9256b90 100644 --- a/MainWindow.tscn +++ b/MainWindow.tscn @@ -11,12 +11,12 @@ [ext_resource type="Theme" uid="uid://rxexo3ur85as" path="res://LightGrayTheme.tres" id="7_wxbv6"] [ext_resource type="PackedScene" uid="uid://bxydgil1yifps" path="res://SearchWindow.tscn" id="9_5ijvr"] [ext_resource type="PackedScene" uid="uid://dpdem7pdxweb5" path="res://SyncWindow.tscn" id="10_yxw0b"] -[ext_resource type="Texture2D" uid="uid://r4as0nmtoa7p" path="res://noCharacter.png" id="11_1qef0"] [ext_resource type="PackedScene" uid="uid://dldpeo5y3l5hq" path="res://SettingsWindow.tscn" id="11_k62u5"] [ext_resource type="PackedScene" uid="uid://bd1by80q1v27e" path="res://shortcutsWindow.tscn" id="13_8eebo"] [ext_resource type="PackedScene" uid="uid://bijh5h5yrivm3" path="res://Log.tscn" id="14_26rwn"] [ext_resource type="PackedScene" uid="uid://btupbowehiyyu" path="res://QRWindow.tscn" id="15_qr_window"] [ext_resource type="PackedScene" uid="uid://cp54idaudb8dp" path="res://AboutWindow.tscn" id="16_about_window"] +[ext_resource type="PackedScene" uid="uid://cxlsmxnrp0agh" path="res://WinnerWindow.tscn" id="17_winner_window"] [sub_resource type="LabelSettings" id="LabelSettings_ychxr"] font_size = 25 @@ -68,9 +68,6 @@ keycode = 83 [sub_resource type="Shortcut" id="Shortcut_fbju4"] events = [SubResource("InputEventKey_ujjlu")] -[sub_resource type="LabelSettings" id="LabelSettings_hr75l"] -font_size = 35 - [node name="Control" type="Control" unique_id=407149696] layout_mode = 3 anchors_preset = 0 @@ -477,44 +474,14 @@ offset_top = 153.0 offset_right = 720.0 offset_bottom = 153.0 -[node name="WinnerPopupPanel" type="PopupPanel" parent="." unique_id=938181211] -oversampling_override = 1.0 -initial_position = 2 -size = Vector2i(700, 350) - -[node name="Panel" type="Panel" parent="WinnerPopupPanel" unique_id=89212869] -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = 4.0 -offset_top = 4.0 -offset_right = 696.0 -offset_bottom = 346.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="VBoxContainer" type="VBoxContainer" parent="WinnerPopupPanel/Panel" unique_id=471159349] -layout_mode = 0 -offset_right = 692.0 -offset_bottom = 342.0 -alignment = 1 - -[node name="WinnerPicture" type="TextureRect" parent="WinnerPopupPanel/Panel/VBoxContainer" unique_id=1543774067] +[node name="WinnerWindow" parent="." unique_id=999999999 instance=ExtResource("17_winner_window")] unique_name_in_owner = true -custom_minimum_size = Vector2(692, 300) -layout_mode = 2 -texture = ExtResource("11_1qef0") -expand_mode = 3 -stretch_mode = 5 - -[node name="WinnerLabel" type="Label" parent="WinnerPopupPanel/Panel/VBoxContainer" unique_id=1437597286] -unique_name_in_owner = true -texture_filter = 1 -layout_mode = 2 -text = "Sansan won!!" -label_settings = SubResource("LabelSettings_hr75l") -horizontal_alignment = 1 -vertical_alignment = 2 +visible = false +layout_mode = 1 +offset_left = 720.0 +offset_top = 153.0 +offset_right = 720.0 +offset_bottom = 153.0 [node name="RepeatSongCheckButton" type="CheckButton" parent="." unique_id=776835053] layout_mode = 0 diff --git a/MusicPlayer.gd b/MusicPlayer.gd index 66a1527..16062ef 100644 --- a/MusicPlayer.gd +++ b/MusicPlayer.gd @@ -55,12 +55,12 @@ func _ready() -> void: func _process(_delta: float) -> void: if audio_player.has_stream_playback() && !is_changing && !audio_player.stream_paused: - if (!Settings.hide_beginning || audio_player.get_playback_position() >= 5.0): + if (!Settings.hide_beginning || audio_player.get_playback_position() > Settings.hide_for_seconds): progress_slider.value = audio_player.get_playback_position() - if stream != null: - music_time_label.text = format_text(progress_slider.value, stream.get_length()) - else: - music_time_label.text = format_text(progress_slider.value, 0.0) + if stream != null: + music_time_label.text = format_text(progress_slider.value, stream.get_length()) + else: + music_time_label.text = format_text(progress_slider.value, 0.0) func format_time(time: float) -> String: var mins: String = "%02d" % floor(time / 60) @@ -68,11 +68,11 @@ func format_time(time: float) -> String: return mins + ":" + sec func format_text(part: float, total: float) -> String: - if (Settings.hide_beginning && part <= 5.0) && Settings.hide_length: + if (Settings.hide_beginning && part <= Settings.hide_for_seconds) && Settings.hide_length: return "??:?? / ??:??" elif Settings.hide_length: return format_time(part) + " / ??:??" - elif Settings.hide_beginning && part <= 5.0: + elif Settings.hide_beginning && part < Settings.hide_for_seconds: return "??:?? / " + format_time(total) else: return format_time(part) + " / " + format_time(total) diff --git a/QRWindow.tscn b/QRWindow.tscn index 46af271..34ff866 100644 --- a/QRWindow.tscn +++ b/QRWindow.tscn @@ -18,15 +18,6 @@ layout_mode = 0 offset_right = 450.0 offset_bottom = 520.0 -[node name="TitleLabel" type="Label" parent="QRPanel" unique_id=1647138599] -layout_mode = 0 -offset_left = 20.0 -offset_right = 430.0 -offset_bottom = 20.0 -text = "Varsågod Peter!" -horizontal_alignment = 1 -vertical_alignment = 1 - [node name="QRCodeRect" type="TextureRect" parent="QRPanel" unique_id=1054378438] layout_mode = 0 offset_left = 20.0 diff --git a/Settings.gd b/Settings.gd index 66a41b6..08f125a 100644 --- a/Settings.gd +++ b/Settings.gd @@ -10,7 +10,7 @@ var is_local: bool = false var is_debug: bool = false var stop_after_current: bool = true -var auto_repeat_song: bool = false +var auto_repeat_song: bool = true var hide_next_track: bool = true var add_to_stats: bool = true var use_low_played_mode: bool = false @@ -18,6 +18,7 @@ var winning_score: int = 20 var fullscreen: bool = false var play_local: bool = false var inspiration_list_speed: int = 1 +var hide_for_seconds: float = 5.0 var hide_beginning: bool = false var hide_length: bool = false var hide_ticks: bool = false @@ -27,7 +28,7 @@ var edit_players: bool = false var currently_syncing: bool = false var character_select_open: bool = false -var version: String = "1.8.0" +var version: String = "1.8.5" func make_request2(address: String, func_name: Callable, expect_data: bool) -> void: var error_handling: Callable = func(_result: int, response_code: int, _headers: PackedStringArray, body: PackedByteArray) -> void: diff --git a/SettingsWindow.gd b/SettingsWindow.gd index bca060f..6cf69f7 100644 --- a/SettingsWindow.gd +++ b/SettingsWindow.gd @@ -51,6 +51,15 @@ var lower_inspiration_speed_button: Button = %LowerInspirationSpeedButton @onready var increase_inspiration_speed_button: Button = %IncreaseInspirationSpeedButton +@onready +var hide_for_seconds_label: Label = %HideForSecondsLabel + +@onready +var lower_hide_for_seconds_button: Button = %LowerHideForSecondsButton + +@onready +var increase_hide_for_seconds_button: Button = %IncreaseHideForSecondsButton + @onready var select_server_button: OptionButton = %SelectServerButton @@ -80,6 +89,8 @@ func _ready() -> void: increase_cache_button.pressed.connect(increase_cache) lower_inspiration_speed_button.pressed.connect(lower_inspiration_speed) increase_inspiration_speed_button.pressed.connect(increase_inspiration_speed) + lower_hide_for_seconds_button.pressed.connect(lower_hide_for_seconds) + increase_hide_for_seconds_button.pressed.connect(increase_hide_for_seconds) fullscreen_button.pressed.connect(fullscreen) local_button.pressed.connect(local_play) @@ -93,7 +104,9 @@ func _ready() -> void: score_label.text = str(Settings.winning_score) cache_label.text = str(Playlist.number_of_tracks_to_preload) inspiration_speed_label.text = str(Settings.inspiration_list_speed) + hide_for_seconds_label.text = str(Settings.hide_for_seconds) fullscreen_button.button_pressed = Settings.fullscreen + update_hide_for_seconds_enabled() select_server_button.select(Settings.selected_server) select_server_button.item_selected.connect(select_server) @@ -128,6 +141,11 @@ func low_played() -> void: func hide_beginning() -> void: Settings.hide_beginning = !Settings.hide_beginning + update_hide_for_seconds_enabled() + +func update_hide_for_seconds_enabled() -> void: + var enabled: bool = Settings.hide_beginning + %HideForSecondsHBoxContainer.visible = enabled func hide_length() -> void: Settings.hide_length = !Settings.hide_length @@ -167,6 +185,18 @@ func increase_inspiration_speed() -> void: Settings.inspiration_list_speed += 1 inspiration_speed_label.text = str(Settings.inspiration_list_speed ) +func lower_hide_for_seconds() -> void: + Settings.hide_for_seconds -= 1.0 + if Settings.hide_for_seconds < 0: + Settings.hide_for_seconds = 0 + hide_for_seconds_label.text = str(Settings.hide_for_seconds) + +func increase_hide_for_seconds() -> void: + Settings.hide_for_seconds += 1.0 + if Settings.hide_for_seconds > 10.0: + Settings.hide_for_seconds = 10.0 + hide_for_seconds_label.text = str(Settings.hide_for_seconds) + func select_server(new_server: int) -> void: print("select_server") Settings.default_path = select_server_button.get_item_text(new_server) diff --git a/SettingsWindow.tscn b/SettingsWindow.tscn index ca66d60..8271407 100644 --- a/SettingsWindow.tscn +++ b/SettingsWindow.tscn @@ -1,11 +1,11 @@ -[gd_scene load_steps=3 format=3 uid="uid://dldpeo5y3l5hq"] +[gd_scene format=3 uid="uid://dldpeo5y3l5hq"] [ext_resource type="Script" uid="uid://dukqyjoduf1af" path="res://SettingsWindow.gd" id="1_bt55j"] [sub_resource type="LabelSettings" id="LabelSettings_3xrlm"] font_size = 25 -[node name="SettingsControl" type="Control"] +[node name="SettingsControl" type="Control" unique_id=1298840328] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -14,30 +14,30 @@ grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_bt55j") -[node name="SettingsPanel" type="Panel" parent="."] +[node name="SettingsPanel" type="Panel" parent="." unique_id=45537159] unique_name_in_owner = true layout_mode = 0 offset_right = 500.0 offset_bottom = 640.0 -[node name="ScrollContainer" type="ScrollContainer" parent="SettingsPanel"] +[node name="ScrollContainer" type="ScrollContainer" parent="SettingsPanel" unique_id=1325795358] layout_mode = 0 offset_right = 500.0 offset_bottom = 640.0 -[node name="VBoxContainer" type="VBoxContainer" parent="SettingsPanel/ScrollContainer"] +[node name="VBoxContainer" type="VBoxContainer" parent="SettingsPanel/ScrollContainer" unique_id=1796635163] clip_contents = true layout_mode = 2 size_flags_horizontal = 3 -[node name="Label" type="Label" parent="SettingsPanel/ScrollContainer/VBoxContainer"] +[node name="Label" type="Label" parent="SettingsPanel/ScrollContainer/VBoxContainer" unique_id=1111531402] layout_mode = 2 size_flags_vertical = 0 text = "Settings" label_settings = SubResource("LabelSettings_3xrlm") horizontal_alignment = 1 -[node name="StopAfterCurrentCheckButton" type="CheckButton" parent="SettingsPanel/ScrollContainer/VBoxContainer"] +[node name="StopAfterCurrentCheckButton" type="CheckButton" parent="SettingsPanel/ScrollContainer/VBoxContainer" unique_id=508305575] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 0 @@ -45,7 +45,7 @@ button_pressed = true action_mode = 0 text = "Stop after current" -[node name="HideNextTrackCheckButton" type="CheckButton" parent="SettingsPanel/ScrollContainer/VBoxContainer"] +[node name="HideNextTrackCheckButton" type="CheckButton" parent="SettingsPanel/ScrollContainer/VBoxContainer" unique_id=1568244599] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 0 @@ -53,54 +53,84 @@ button_pressed = true action_mode = 0 text = "Hide next track" -[node name="AddToDatabaseCheckButton" type="CheckButton" parent="SettingsPanel/ScrollContainer/VBoxContainer"] +[node name="AddToDatabaseCheckButton" type="CheckButton" parent="SettingsPanel/ScrollContainer/VBoxContainer" unique_id=1673750542] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 0 action_mode = 0 text = "Turn on played to database" -[node name="LowPlayedCheckButton" type="CheckButton" parent="SettingsPanel/ScrollContainer/VBoxContainer"] +[node name="LowPlayedCheckButton" type="CheckButton" parent="SettingsPanel/ScrollContainer/VBoxContainer" unique_id=1672657048] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 0 action_mode = 0 text = "Use low played mode" -[node name="HideBeginningCheckButton" type="CheckButton" parent="SettingsPanel/ScrollContainer/VBoxContainer"] +[node name="HideBeginningCheckButton" type="CheckButton" parent="SettingsPanel/ScrollContainer/VBoxContainer" unique_id=1370617867] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 0 action_mode = 0 text = "Hide beginning of songs" -[node name="HideLengthCheckButton" type="CheckButton" parent="SettingsPanel/ScrollContainer/VBoxContainer"] +[node name="HideForSecondsHBoxContainer" type="HBoxContainer" parent="SettingsPanel/ScrollContainer/VBoxContainer" unique_id=1368485120] +unique_name_in_owner = true +layout_mode = 2 + +[node name="HideForSecondsTitle" type="Label" parent="SettingsPanel/ScrollContainer/VBoxContainer/HideForSecondsHBoxContainer" unique_id=1822369383] +unique_name_in_owner = true +layout_mode = 2 +text = "Hide Start Seconds: " + +[node name="HideForSecondsLabel" type="Label" parent="SettingsPanel/ScrollContainer/VBoxContainer/HideForSecondsHBoxContainer" unique_id=1580108945] +unique_name_in_owner = true +layout_mode = 2 +text = "5.0" + +[node name="LowerHideForSecondsButton" type="Button" parent="SettingsPanel/ScrollContainer/VBoxContainer/HideForSecondsHBoxContainer" unique_id=180643442] +unique_name_in_owner = true +custom_minimum_size = Vector2(30, 2.08165e-12) +layout_mode = 2 +focus_mode = 0 +action_mode = 0 +text = "-1" + +[node name="IncreaseHideForSecondsButton" type="Button" parent="SettingsPanel/ScrollContainer/VBoxContainer/HideForSecondsHBoxContainer" unique_id=340681770] +unique_name_in_owner = true +custom_minimum_size = Vector2(30, 2.08165e-12) +layout_mode = 2 +focus_mode = 0 +action_mode = 0 +text = "+1" + +[node name="HideLengthCheckButton" type="CheckButton" parent="SettingsPanel/ScrollContainer/VBoxContainer" unique_id=67806372] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 0 action_mode = 0 text = "Hide length of songs" -[node name="HideTicksCheckButton" type="CheckButton" parent="SettingsPanel/ScrollContainer/VBoxContainer"] +[node name="HideTicksCheckButton" type="CheckButton" parent="SettingsPanel/ScrollContainer/VBoxContainer" unique_id=706322752] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 0 action_mode = 0 text = "Hide ticks in playbar" -[node name="HBoxContainer" type="HBoxContainer" parent="SettingsPanel/ScrollContainer/VBoxContainer"] +[node name="HBoxContainer" type="HBoxContainer" parent="SettingsPanel/ScrollContainer/VBoxContainer" unique_id=2140610992] layout_mode = 2 -[node name="Label2" type="Label" parent="SettingsPanel/ScrollContainer/VBoxContainer/HBoxContainer"] +[node name="Label2" type="Label" parent="SettingsPanel/ScrollContainer/VBoxContainer/HBoxContainer" unique_id=1892907487] layout_mode = 2 text = "Winning Score: " -[node name="ScoreLabel" type="Label" parent="SettingsPanel/ScrollContainer/VBoxContainer/HBoxContainer"] +[node name="ScoreLabel" type="Label" parent="SettingsPanel/ScrollContainer/VBoxContainer/HBoxContainer" unique_id=444542662] unique_name_in_owner = true layout_mode = 2 text = "20" -[node name="LowerButton" type="Button" parent="SettingsPanel/ScrollContainer/VBoxContainer/HBoxContainer"] +[node name="LowerButton" type="Button" parent="SettingsPanel/ScrollContainer/VBoxContainer/HBoxContainer" unique_id=614806355] unique_name_in_owner = true custom_minimum_size = Vector2(30, 2.08165e-12) layout_mode = 2 @@ -108,7 +138,7 @@ focus_mode = 0 action_mode = 0 text = "-1" -[node name="IncreaseButton" type="Button" parent="SettingsPanel/ScrollContainer/VBoxContainer/HBoxContainer"] +[node name="IncreaseButton" type="Button" parent="SettingsPanel/ScrollContainer/VBoxContainer/HBoxContainer" unique_id=1837169457] unique_name_in_owner = true custom_minimum_size = Vector2(30, 2.08165e-12) layout_mode = 2 @@ -116,19 +146,19 @@ focus_mode = 0 action_mode = 0 text = "+1" -[node name="CacheHBoxContainer" type="HBoxContainer" parent="SettingsPanel/ScrollContainer/VBoxContainer"] +[node name="CacheHBoxContainer" type="HBoxContainer" parent="SettingsPanel/ScrollContainer/VBoxContainer" unique_id=658210492] layout_mode = 2 -[node name="CacheTitleLabel" type="Label" parent="SettingsPanel/ScrollContainer/VBoxContainer/CacheHBoxContainer"] +[node name="CacheTitleLabel" type="Label" parent="SettingsPanel/ScrollContainer/VBoxContainer/CacheHBoxContainer" unique_id=365012193] layout_mode = 2 text = "Predownload songs: " -[node name="CacheLabel" type="Label" parent="SettingsPanel/ScrollContainer/VBoxContainer/CacheHBoxContainer"] +[node name="CacheLabel" type="Label" parent="SettingsPanel/ScrollContainer/VBoxContainer/CacheHBoxContainer" unique_id=1558370172] unique_name_in_owner = true layout_mode = 2 text = "1" -[node name="LowerCacheButton" type="Button" parent="SettingsPanel/ScrollContainer/VBoxContainer/CacheHBoxContainer"] +[node name="LowerCacheButton" type="Button" parent="SettingsPanel/ScrollContainer/VBoxContainer/CacheHBoxContainer" unique_id=1990385038] unique_name_in_owner = true custom_minimum_size = Vector2(30, 2.08165e-12) layout_mode = 2 @@ -136,7 +166,7 @@ focus_mode = 0 action_mode = 0 text = "-1" -[node name="IncreaseCacheButton" type="Button" parent="SettingsPanel/ScrollContainer/VBoxContainer/CacheHBoxContainer"] +[node name="IncreaseCacheButton" type="Button" parent="SettingsPanel/ScrollContainer/VBoxContainer/CacheHBoxContainer" unique_id=1806295533] unique_name_in_owner = true custom_minimum_size = Vector2(30, 2.08165e-12) layout_mode = 2 @@ -144,19 +174,19 @@ focus_mode = 0 action_mode = 0 text = "+1" -[node name="InspirationHBoxContainer" type="HBoxContainer" parent="SettingsPanel/ScrollContainer/VBoxContainer"] +[node name="InspirationHBoxContainer" type="HBoxContainer" parent="SettingsPanel/ScrollContainer/VBoxContainer" unique_id=1686756540] layout_mode = 2 -[node name="InspirationListSpeedTitle" type="Label" parent="SettingsPanel/ScrollContainer/VBoxContainer/InspirationHBoxContainer"] +[node name="InspirationListSpeedTitle" type="Label" parent="SettingsPanel/ScrollContainer/VBoxContainer/InspirationHBoxContainer" unique_id=1397861506] layout_mode = 2 text = "Inspiration List Speed: " -[node name="InspirationListSpeedLabel" type="Label" parent="SettingsPanel/ScrollContainer/VBoxContainer/InspirationHBoxContainer"] +[node name="InspirationListSpeedLabel" type="Label" parent="SettingsPanel/ScrollContainer/VBoxContainer/InspirationHBoxContainer" unique_id=867387668] unique_name_in_owner = true layout_mode = 2 text = "1" -[node name="LowerInspirationSpeedButton" type="Button" parent="SettingsPanel/ScrollContainer/VBoxContainer/InspirationHBoxContainer"] +[node name="LowerInspirationSpeedButton" type="Button" parent="SettingsPanel/ScrollContainer/VBoxContainer/InspirationHBoxContainer" unique_id=845209534] unique_name_in_owner = true custom_minimum_size = Vector2(30, 2.08165e-12) layout_mode = 2 @@ -164,7 +194,7 @@ focus_mode = 0 action_mode = 0 text = "-1" -[node name="IncreaseInspirationSpeedButton" type="Button" parent="SettingsPanel/ScrollContainer/VBoxContainer/InspirationHBoxContainer"] +[node name="IncreaseInspirationSpeedButton" type="Button" parent="SettingsPanel/ScrollContainer/VBoxContainer/InspirationHBoxContainer" unique_id=1122701153] unique_name_in_owner = true custom_minimum_size = Vector2(30, 2.08165e-12) layout_mode = 2 @@ -172,7 +202,7 @@ focus_mode = 0 action_mode = 0 text = "+1" -[node name="SelectServerButton" type="OptionButton" parent="SettingsPanel/ScrollContainer/VBoxContainer"] +[node name="SelectServerButton" type="OptionButton" parent="SettingsPanel/ScrollContainer/VBoxContainer" unique_id=434350694] unique_name_in_owner = true layout_mode = 2 selected = 0 @@ -188,13 +218,13 @@ popup/item_3/id = 4 popup/item_4/text = "http://localhost:8080" popup/item_4/id = 5 -[node name="FullscreenButton" type="CheckButton" parent="SettingsPanel/ScrollContainer/VBoxContainer"] +[node name="FullscreenButton" type="CheckButton" parent="SettingsPanel/ScrollContainer/VBoxContainer" unique_id=400304684] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 0 text = "Fullscreen" -[node name="QuickSyncButton" type="CheckButton" parent="SettingsPanel/ScrollContainer/VBoxContainer"] +[node name="QuickSyncButton" type="CheckButton" parent="SettingsPanel/ScrollContainer/VBoxContainer" unique_id=49497448] visible = false layout_mode = 2 size_flags_horizontal = 0 @@ -202,7 +232,7 @@ button_pressed = true action_mode = 0 text = "Quick sync" -[node name="LocalButton" type="CheckButton" parent="SettingsPanel/ScrollContainer/VBoxContainer"] +[node name="LocalButton" type="CheckButton" parent="SettingsPanel/ScrollContainer/VBoxContainer" unique_id=905844805] unique_name_in_owner = true visible = false layout_mode = 2 diff --git a/WinnerWindow.tscn b/WinnerWindow.tscn new file mode 100644 index 0000000..c7a9415 --- /dev/null +++ b/WinnerWindow.tscn @@ -0,0 +1,54 @@ +[gd_scene format=3 uid="uid://cxlsmxnrp0agh"] + +[ext_resource type="Script" uid="uid://dxpb22xbwf3t1" path="res://winner_window.gd" id="1_winner_script"] +[ext_resource type="Texture2D" uid="uid://r4as0nmtoa7p" path="res://noCharacter.png" id="2_no_character"] + +[sub_resource type="LabelSettings" id="LabelSettings_hr75l"] +font_size = 35 + +[node name="WinnerControl" type="Control" unique_id=1111111111] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_winner_script") + +[node name="WinnerPanel" type="Panel" parent="." unique_id=89212869] +unique_name_in_owner = true +layout_mode = 0 +offset_right = 500.0 +offset_bottom = 600.0 + +[node name="VBoxContainer" type="VBoxContainer" parent="WinnerPanel" unique_id=471159349] +layout_mode = 0 +offset_top = 25.0 +offset_right = 500.0 +offset_bottom = 282.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +alignment = 1 + +[node name="WinnerPicture" type="TextureRect" parent="WinnerPanel/VBoxContainer" unique_id=1543774067] +unique_name_in_owner = true +custom_minimum_size = Vector2(480, 200) +layout_mode = 2 +texture = ExtResource("2_no_character") +expand_mode = 3 +stretch_mode = 5 + +[node name="WinnerLabel" type="Label" parent="WinnerPanel/VBoxContainer" unique_id=1437597286] +unique_name_in_owner = true +texture_filter = 1 +layout_mode = 2 +text = "Winner!" +label_settings = SubResource("LabelSettings_hr75l") +horizontal_alignment = 1 +vertical_alignment = 2 + +[node name="PlayersList" type="VBoxContainer" parent="WinnerPanel/VBoxContainer" unique_id=471159350] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 diff --git a/winner_window.gd b/winner_window.gd new file mode 100644 index 0000000..029c3e8 --- /dev/null +++ b/winner_window.gd @@ -0,0 +1,63 @@ +extends Control + +@onready +var winner_panel: Panel = %WinnerPanel + +@onready +var winner_picture: TextureRect = %WinnerPicture + +@onready +var winner_label: Label = %WinnerLabel + +@onready +var players_list: VBoxContainer = %PlayersList + + +func _ready() -> void: + visible = false + + +func show_winner(winning_player_id: int) -> void: + visible = true + # Set winner info + var winner: PlayerObject = Settings.player_array[winning_player_id] + winner_label.text = winner.player_name + " won with " + str(winner.player_score) + \ + " points!!" + winner_picture.texture = winner.character + winner_picture.custom_minimum_size = Vector2(480, 200) + winner_picture.expand_mode = TextureRect.EXPAND_FIT_WIDTH_PROPORTIONAL + winner_picture.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED + + # Clear previous player list entries + for child: Node in players_list.get_children(): + child.queue_free() + + # Sort players by score (descending) and add to list + var sorted_players: Array = Settings.player_array.duplicate() + sorted_players.sort_custom( + func(a: PlayerObject, b: PlayerObject) -> bool: + return a.player_score > b.player_score + ) + + var placing: int = 2 + for player: PlayerObject in sorted_players: + if player.id == winning_player_id: + continue # Skip the winner, already shown above + var label: Label = Label.new() + label.text = str(placing) + ". " + player.player_name + " - " + \ + str(player.player_score) + " points" + label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER + players_list.add_child(label) + placing += 1 + + +func hide_window() -> void: + visible = false + + +func _input(event: InputEvent) -> void: + if visible: + if event is InputEventMouseButton and event.is_pressed(): + var ev_local: InputEvent = make_input_local(event) + if !Rect2(Vector2(0, 0), winner_panel.size).has_point(ev_local.position): + visible = false diff --git a/winner_window.gd.uid b/winner_window.gd.uid new file mode 100644 index 0000000..faff4e7 --- /dev/null +++ b/winner_window.gd.uid @@ -0,0 +1 @@ +uid://dxpb22xbwf3t1