From acd8d65b9572ac15f0c89756edf194e6495b5ca9 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 15 May 2026 10:52:26 +0200 Subject: [PATCH] #29 Small fixes --- .../godot-gdscript-style-guide/Skill.md | 48 +++++++++++++++++++ MusicPlayer.gd | 10 ++-- 2 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 .vibe/skills/godot-gdscript-style-guide/Skill.md diff --git a/.vibe/skills/godot-gdscript-style-guide/Skill.md b/.vibe/skills/godot-gdscript-style-guide/Skill.md new file mode 100644 index 0000000..d1cadb1 --- /dev/null +++ b/.vibe/skills/godot-gdscript-style-guide/Skill.md @@ -0,0 +1,48 @@ +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/MusicPlayer.gd b/MusicPlayer.gd index 603a338..66a1527 100644 --- a/MusicPlayer.gd +++ b/MusicPlayer.gd @@ -55,10 +55,6 @@ func _ready() -> void: func _process(_delta: float) -> void: if audio_player.has_stream_playback() && !is_changing && !audio_player.stream_paused: - print("Settings.hide_beginning: ", Settings.hide_beginning) - print("audio_player.get_playback_position(): ", audio_player.get_playback_position()) - print("audio_player.get_playback_position() >= 5.0: ", audio_player.get_playback_position() >= 5.0) - print("(!Settings.hide_beginning && audio_player.get_playback_position() >= 5.0): ", (!Settings.hide_beginning && audio_player.get_playback_position() >= 5.0)) if (!Settings.hide_beginning || audio_player.get_playback_position() >= 5.0): progress_slider.value = audio_player.get_playback_position() if stream != null: @@ -72,8 +68,12 @@ func format_time(time: float) -> String: return mins + ":" + sec func format_text(part: float, total: float) -> String: - if Settings.hide_length: + if (Settings.hide_beginning && part <= 5.0) && Settings.hide_length: + return "??:?? / ??:??" + elif Settings.hide_length: return format_time(part) + " / ??:??" + elif Settings.hide_beginning && part <= 5.0: + return "??:?? / " + format_time(total) else: return format_time(part) + " / " + format_time(total)