bug fixes

This commit is contained in:
dingo
2026-01-20 18:37:23 -05:00
parent a39f4a0a98
commit 5aa92abce8
3 changed files with 42 additions and 14 deletions
+11 -4
View File
@@ -490,7 +490,11 @@ func _apply_tint(tint_hex: String):
fallback_sprite.modulate = tint_color fallback_sprite.modulate = tint_color
func play_hurt_effect(): func play_hurt_effect():
"""Flash mob red briefly to show damage""" """Play hurt animation and flash mob red briefly to show damage"""
# Try to play hurt animation if available
if _animated_sprite and _animated_sprite.sprite_frames:
_play_animation("hurt", _facing_direction)
var sprite_to_flash = _animated_sprite if _animated_sprite and _animated_sprite.visible else fallback_sprite var sprite_to_flash = _animated_sprite if _animated_sprite and _animated_sprite.visible else fallback_sprite
if not sprite_to_flash: if not sprite_to_flash:
@@ -512,15 +516,17 @@ func play_death_animation():
_current_state = "dead" _current_state = "dead"
if _animated_sprite and _animated_sprite.sprite_frames: if _animated_sprite and _animated_sprite.sprite_frames:
# Try to play death animation # Try to play death animation using the standard animation search
var frames = _animated_sprite.sprite_frames var frames = _animated_sprite.sprite_frames
var death_anim_name = "" var death_anim_name = ""
# Try different death animation names # Try different death animation names with direction
var names_to_try = [ var names_to_try = [
"dead_%s" % _facing_direction, "dead_%s" % _facing_direction,
"dead", "dead_%s" % _alt_direction(_facing_direction),
"death_%s" % _facing_direction, "death_%s" % _facing_direction,
"death_%s" % _alt_direction(_facing_direction),
"dead",
"death" "death"
] ]
@@ -531,6 +537,7 @@ func play_death_animation():
if death_anim_name != "": if death_anim_name != "":
# Play the death animation # Play the death animation
_last_animation = death_anim_name
_animated_sprite.play(death_anim_name) _animated_sprite.play(death_anim_name)
# Wait for animation to finish # Wait for animation to finish
+18 -1
View File
@@ -14,12 +14,15 @@ var current_direction: String = "down" # down, up, left, right
func _ready(): func _ready():
# Sprite sheet will be loaded from CDN path: textures/player/Warrior-Blue.png # Sprite sheet will be loaded from CDN path: textures/player/Warrior-Blue.png
if UpdateManager: if UpdateManager:
# Try to load immediately (may already be cached)
var texture = UpdateManager.load_texture("textures/player/Warrior-Blue.png") var texture = UpdateManager.load_texture("textures/player/Warrior-Blue.png")
if texture: if texture:
print("[Player] Loaded sprite sheet texture") print("[Player] Loaded sprite sheet texture")
_setup_sprite_frames(texture) _setup_sprite_frames(texture)
else: else:
print("[Player] Failed to load sprite sheet texture") print("[Player] Failed to load sprite sheet texture, waiting for download...")
# Connect to file_downloaded signal to retry when file downloads
UpdateManager.file_downloaded.connect(_on_file_downloaded)
# Setup aim line (will be hidden once sprites load) # Setup aim line (will be hidden once sprites load)
if aim_line: if aim_line:
@@ -38,6 +41,20 @@ func _ready():
if aim_line: if aim_line:
aim_line.visible = true aim_line.visible = true
func _on_file_downloaded(file_path: String):
# Check if the player sprite was downloaded
if file_path == "textures/player/Warrior-Blue.png" and UpdateManager:
var texture = UpdateManager.load_texture("textures/player/Warrior-Blue.png")
if texture:
print("[Player] Loaded sprite sheet texture after download")
_setup_sprite_frames(texture)
# Start playing walk animation
if animated_sprite and animated_sprite.sprite_frames:
animated_sprite.play("walk_down")
# Hide aim line since we have sprites
if aim_line:
aim_line.visible = false
func _setup_sprite_frames(texture: Texture2D): func _setup_sprite_frames(texture: Texture2D):
""" """
Setup sprite frames from the Warrior-Blue sprite sheet Setup sprite frames from the Warrior-Blue sprite sheet
+13 -9
View File
@@ -123,9 +123,11 @@ func _toggle_char_sheet():
char_sheet_ui.visible = not char_sheet_ui.visible char_sheet_ui.visible = not char_sheet_ui.visible
func _create_settings_panel(): func _create_settings_panel():
# Create settings button (top right corner, 1/3 original size) # Create settings button (top right corner, small size)
settings_btn = TextureButton.new() settings_btn = TextureButton.new()
settings_btn.custom_minimum_size = Vector2(16, 16) settings_btn.custom_minimum_size = Vector2(32, 32)
settings_btn.ignore_texture_size = true
settings_btn.stretch_mode = TextureButton.STRETCH_KEEP_ASPECT_CENTERED
# Load settings icon from CDN # Load settings icon from CDN
var texture_loaded = false var texture_loaded = false
@@ -133,7 +135,6 @@ func _create_settings_panel():
var settings_texture = UpdateManager.load_texture("textures/ui/buttons/settings.png") var settings_texture = UpdateManager.load_texture("textures/ui/buttons/settings.png")
if settings_texture: if settings_texture:
settings_btn.texture_normal = settings_texture settings_btn.texture_normal = settings_texture
settings_btn.scale = Vector2(.17,.17) # 1/3 of 0.5 = 0.167
texture_loaded = true texture_loaded = true
# Fallback: add a visible background if texture doesn't load # Fallback: add a visible background if texture doesn't load
@@ -145,11 +146,10 @@ func _create_settings_panel():
fallback_style.set_corner_radius_all(8) fallback_style.set_corner_radius_all(8)
settings_btn.add_theme_stylebox_override("normal", fallback_style) settings_btn.add_theme_stylebox_override("normal", fallback_style)
# Add a label to show "⚙" gear icon # Add a label to show "⚙" gear icon
var label = Label.new() var label = Label.new()
label.text = "⚙" label.text = "⚙"
label.add_theme_font_size_override("font_size", 6) # Smaller for 1/3 size label.add_theme_font_size_override("font_size", 20)
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
label.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) label.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
@@ -158,12 +158,12 @@ func _create_settings_panel():
settings_btn.pressed.connect(_toggle_settings_panel) settings_btn.pressed.connect(_toggle_settings_panel)
add_child(settings_btn) add_child(settings_btn)
# Position top right corner (moved further left and down) # Position top right corner
settings_btn.set_anchors_and_offsets_preset(Control.PRESET_TOP_RIGHT) settings_btn.set_anchors_and_offsets_preset(Control.PRESET_TOP_RIGHT)
settings_btn.offset_left = -50 settings_btn.offset_left = -42 # 32 + 10 margin
settings_btn.offset_top = 10 settings_btn.offset_top = 10
settings_btn.offset_right = -56 settings_btn.offset_right = -10
settings_btn.offset_bottom = 24 settings_btn.offset_bottom = 42
# Create settings panel (initially hidden) # Create settings panel (initially hidden)
settings_panel = Panel.new() settings_panel = Panel.new()
@@ -294,6 +294,8 @@ func _on_settings_file_downloaded(file_path: String):
var settings_texture = UpdateManager.load_texture("textures/ui/buttons/settings.png") var settings_texture = UpdateManager.load_texture("textures/ui/buttons/settings.png")
if settings_texture: if settings_texture:
settings_btn.texture_normal = settings_texture settings_btn.texture_normal = settings_texture
settings_btn.ignore_texture_size = true
settings_btn.stretch_mode = TextureButton.STRETCH_KEEP_ASPECT_CENTERED
# Remove fallback styling if it was applied # Remove fallback styling if it was applied
if settings_btn.get_child_count() > 0: if settings_btn.get_child_count() > 0:
for child in settings_btn.get_children(): for child in settings_btn.get_children():
@@ -305,6 +307,8 @@ func _on_update_completed(_count: int):
var settings_texture = UpdateManager.load_texture("textures/ui/buttons/settings.png") var settings_texture = UpdateManager.load_texture("textures/ui/buttons/settings.png")
if settings_texture: if settings_texture:
settings_btn.texture_normal = settings_texture settings_btn.texture_normal = settings_texture
settings_btn.ignore_texture_size = true
settings_btn.stretch_mode = TextureButton.STRETCH_KEEP_ASPECT_CENTERED
# Remove fallback styling if it was applied # Remove fallback styling if it was applied
if settings_btn.get_child_count() > 0: if settings_btn.get_child_count() > 0:
for child in settings_btn.get_children(): for child in settings_btn.get_children():