From a6d137bf7a91e9dc61ab769aaca73420fbfce4e2 Mon Sep 17 00:00:00 2001 From: henry Date: Sun, 21 Jun 2026 11:31:44 +0100 Subject: [PATCH 1/6] Setup for adding Notification Component. --- scenes/world.tscn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scenes/world.tscn b/scenes/world.tscn index 9148110..ef39be3 100644 --- a/scenes/world.tscn +++ b/scenes/world.tscn @@ -6,9 +6,9 @@ [node name="World" type="Node2D" unique_id=1317852169] -[node name="Level" type="Node2D" parent="." unique_id=934289771] +[node name="UI" parent="." unique_id=480295610 instance=ExtResource("1_nnsk1")] -[node name="UI" parent="Level" unique_id=480295610 instance=ExtResource("1_nnsk1")] +[node name="Level" type="Node2D" parent="." unique_id=934289771] [node name="Background" type="Node2D" parent="Level" unique_id=485120278] z_index = -1 From 18dc548dd66f11f2d45488c5f43cfa94fcd47966 Mon Sep 17 00:00:00 2001 From: henry Date: Sun, 21 Jun 2026 17:55:47 +0100 Subject: [PATCH 2/6] Implemented basic notification system for weapons changing. --- graphics/stock.png | Bin 0 -> 256 bytes graphics/stock.png.import | 40 +++++++++ graphics/tri.png | Bin 0 -> 271 bytes graphics/tri.png.import | 40 +++++++++ graphics/vanguard.png | Bin 0 -> 254 bytes graphics/vanguard.png.import | 40 +++++++++ project.godot | 4 + resources/player_weapon_resources/stock.tres | 2 +- scenes/notification_display.tscn | 42 +++++++++ scenes/world.tscn | 6 ++ scripts/event_bus.gd | 3 +- scripts/notification_display.gd | 89 +++++++++++++++++++ scripts/notification_display.gd.uid | 1 + scripts/notification_manager.gd | 23 +++++ scripts/notification_manager.gd.uid | 1 + scripts/weapon_component.gd | 11 +++ 16 files changed, 300 insertions(+), 2 deletions(-) create mode 100644 graphics/stock.png create mode 100644 graphics/stock.png.import create mode 100644 graphics/tri.png create mode 100644 graphics/tri.png.import create mode 100644 graphics/vanguard.png create mode 100644 graphics/vanguard.png.import create mode 100644 scenes/notification_display.tscn create mode 100644 scripts/notification_display.gd create mode 100644 scripts/notification_display.gd.uid create mode 100644 scripts/notification_manager.gd create mode 100644 scripts/notification_manager.gd.uid diff --git a/graphics/stock.png b/graphics/stock.png new file mode 100644 index 0000000000000000000000000000000000000000..bec290680a0d9fac2b080caeb52c4df33eefac3a GIT binary patch literal 256 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1IggaDrqS0JsV zVB)G_lV)kyA7*{OQ0?Y|w0DPR{r+S&^JzfVJ_GY9dES}&LEb7xHkS7GB?bvi(RmM( zXaA2s`{eZPKmY&#pS^Z_OI>?rR#s$KP?=NL8Y82d;mOylclA&A>dH6xoxJBf&<=%? zAirP+plWIEF|}O-^uO=DES*;_52-P=t8~W0KR#gE|clOPKbtGU!Kh V9-Jajy&kBV!PC{xWt~$(696a0Z7u)+ literal 0 HcmV?d00001 diff --git a/graphics/stock.png.import b/graphics/stock.png.import new file mode 100644 index 0000000..0f7e7f0 --- /dev/null +++ b/graphics/stock.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dtggedl0127vk" +path="res://.godot/imported/stock.png-0cb798b4967b33f195d444f0ce113e61.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://graphics/stock.png" +dest_files=["res://.godot/imported/stock.png-0cb798b4967b33f195d444f0ce113e61.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/graphics/tri.png b/graphics/tri.png new file mode 100644 index 0000000000000000000000000000000000000000..a2464416cc665260e348c2c5510fd41e6c8dd1c7 GIT binary patch literal 271 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1IggaDrqS0JsV zVB)G_lV)kyA7*{OQ0?Y|w0DPR{r+S&^JzfVJ_GY9dES}&LEb7xHkS7GB?bvi(RmM( zXaA2s`{eZPKmY&#pS^Z_OI>?rR#s$KP?=NL8Y82d;mOylclA&A>dH6xoxJBf&<=%? zAirP+plW1n0W%CLPSCxLPXRKF-&aXXfR-I=~ZA0V|ZxA lrV{SVD)6t#N|u*_;bb;<;1}(u3xS#$JYD@<);T3K0RU-8a8v*Q literal 0 HcmV?d00001 diff --git a/graphics/tri.png.import b/graphics/tri.png.import new file mode 100644 index 0000000..75a75d6 --- /dev/null +++ b/graphics/tri.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cne450xyao5xl" +path="res://.godot/imported/tri.png-6a3868cfc07d960f5a88b231524dc08e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://graphics/tri.png" +dest_files=["res://.godot/imported/tri.png-6a3868cfc07d960f5a88b231524dc08e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/graphics/vanguard.png b/graphics/vanguard.png new file mode 100644 index 0000000000000000000000000000000000000000..610b89d5f641f77eb6493fa5956e50a22415a5e4 GIT binary patch literal 254 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1IggaDrqS0JsV zVB)G_lV)kyA7*{OQ0?Y|w0DPR{r+S&^JzfVJ_GY9dES}&LEb7xHkS7GB?bvi(RmM( zXaA2s`{eZPKmY&#pS^Z_OI>?rR#s$KP?=NL8Y82d;mOylclA&A>dH6xoxJBf&<=%? zAirP+plW void: + label.add_theme_font_size_override("font_size", 8) + label.text = weapon_name + + # Auto-load icon from graphics folder matching the weapon name + var icon_path = "res://graphics/" + weapon_name.to_lower() + ".png" + if ResourceLoader.exists(icon_path): + icon.texture = load(icon_path) + else: + icon.texture = null + + _player = player_node + _player.tree_exiting.connect(queue_free) + _sprite_size = player_sprite_size + _origin_offset = origin_offset + _follow_player = true + + # Wait one frame for layout to resolve shrink-to-fit widths + await get_tree().process_frame + + # Use container's natural width, but fix height at 16px + size = Vector2(_container.size.x, 16.0) + + # Position using origin offset for Y, to the right of player for X + _update_position() + modulate.a = 1.0 + + # Fade out and free + var tween = create_tween() + tween.tween_property(self, "modulate:a", 0.0, 2.0) + tween.tween_callback(_on_fade_complete) + + +func _process(_delta: float) -> void: + if _follow_player and _player: + _update_position() + + +func _update_position() -> void: + if _player == null: + return + + var player_pos = _player.position + + # Y position uses the weapon origin offset from player center + var notif_y = player_pos.y + _origin_offset - (size.y / 2.0) + + # X position is 10px to the right of player's sprite edge + var right_edge = player_pos.x + (_sprite_size.x / 2.0) + var notif_x = right_edge + 10.0 + + var is_flipped = false + + # Clamp to screen bounds — flip to left if it would go off-screen right + var viewport_size = get_viewport_rect().size + if notif_x + size.x > viewport_size.x: + is_flipped = true + var left_edge = player_pos.x - (_sprite_size.x / 2.0) + notif_x = left_edge - 10.0 - size.x + + # Swap icon/label order so the icon is always closest to the player + if is_flipped: + _container.move_child(label, 0) + _container.move_child(icon, 1) + else: + _container.move_child(icon, 0) + _container.move_child(label, 1) + + # Final clamp: ensure the entire notification is within screen bounds + notif_x = clamp(notif_x, 0, viewport_size.x - size.x) + notif_y = clamp(notif_y, 0, viewport_size.y - size.y) + + position = Vector2(notif_x, notif_y) + + +func _on_fade_complete() -> void: + _follow_player = false + queue_free() diff --git a/scripts/notification_display.gd.uid b/scripts/notification_display.gd.uid new file mode 100644 index 0000000..3dfcfa6 --- /dev/null +++ b/scripts/notification_display.gd.uid @@ -0,0 +1 @@ +uid://3a0cypjsx5cq diff --git a/scripts/notification_manager.gd b/scripts/notification_manager.gd new file mode 100644 index 0000000..eb8028e --- /dev/null +++ b/scripts/notification_manager.gd @@ -0,0 +1,23 @@ +class_name NotificationManager extends Node + +@export var notification_scene: PackedScene + +var _active_notification: NotificationDisplay = null + +func _ready() -> void: + EventBus.weapon_changed.connect(_on_weapon_changed) + + +func _on_weapon_changed(weapon_name: String, player_node: Node2D, player_sprite_size: Vector2, origin_offset: float) -> void: + if notification_scene == null: + return + + # Free any existing notification so the new one can fade in cleanly + if _active_notification: + _active_notification.queue_free() + _active_notification = null + + var notification = notification_scene.instantiate() + add_child(notification) + _active_notification = notification + notification.show_notification(weapon_name, player_node, player_sprite_size, origin_offset) diff --git a/scripts/notification_manager.gd.uid b/scripts/notification_manager.gd.uid new file mode 100644 index 0000000..9d13c9e --- /dev/null +++ b/scripts/notification_manager.gd.uid @@ -0,0 +1 @@ +uid://boce4kgerpff2 diff --git a/scripts/weapon_component.gd b/scripts/weapon_component.gd index 41ecc74..37dc306 100644 --- a/scripts/weapon_component.gd +++ b/scripts/weapon_component.gd @@ -15,6 +15,13 @@ func _ready() -> void: return +func _emit_weapon_changed() -> void: + var ship: Sprite2D = get_parent().get_node("Ship") + var sprite_size = ship.get_rect().size + var origin_offset = weapon_data.origin if weapon_data else 0.0 + EventBus.weapon_changed.emit(weapon_data.shot_name, get_parent(), sprite_size, origin_offset) + + func get_bullet_scene() -> PackedScene: return weapon_data.bullet_scene if weapon_data else null @@ -27,6 +34,8 @@ func select_weapon_by_name(name: String) -> bool: _current_weapon_index = i weapon_data = available_weapons[i] print("Switched to: ", name) + + _emit_weapon_changed() return true return false @@ -39,3 +48,5 @@ func cycle_weapon() -> void: # Used for testing weapon cycling _current_weapon_index = (_current_weapon_index + 1) % available_weapons.size() weapon_data = available_weapons[_current_weapon_index] print("Switched to: ", weapon_data.shot_name) + + _emit_weapon_changed() From 64d55572c209315899ab628fbc8247555628d2f6 Mon Sep 17 00:00:00 2001 From: henry Date: Mon, 22 Jun 2026 00:38:37 +0100 Subject: [PATCH 3/6] Slight visual updates. --- graphics/stock.png | Bin 256 -> 256 bytes graphics/tri.png | Bin 271 -> 271 bytes graphics/vanguard.png | Bin 254 -> 254 bytes scenes/notification_display.tscn | 5 +---- 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/graphics/stock.png b/graphics/stock.png index bec290680a0d9fac2b080caeb52c4df33eefac3a..2ffd2efc43a0998cf64f5c7858bfc01b677199cc 100644 GIT binary patch delta 54 zcmZo*YG9ghQGbF1GtUhc7gtx+2O`Wf7?Ye<9@J@gSi-cAm4V+yY~vfgucZt?;OXk; Jvd$@?2>|r05*Gjf delta 54 zcmZo*YG9ghQ9r?jndb(Ji>s^TLlNc~j7d%_59%~LEMeNm%Ag<3d2otA^?C*%@O1Ta JS?83{1OVnR5rhB$ diff --git a/graphics/tri.png b/graphics/tri.png index a2464416cc665260e348c2c5510fd41e6c8dd1c7..13ac5255d5424469a96182dc3c30867bc1945eaa 100644 GIT binary patch delta 33 ncmeBY>Svm8k!ga%#LF5YKP1IUZ(W(|%K!wPu6{1-oD!M<*J=zL delta 33 ncmeBY>Svm8ktxAt;$;nyliA#XU$mbtWB>wBS3j3^P6XbIMcoMw%se|-TwFbc1w>nwlvp3wa4ee6AjQBC#3=SW#$ula0}yz+`njxg HN@xNAuuTs$ delta 52 zcmeyz_>XbIMco7!W}Y1^F0P)!0-~)-N~{lTI2KK3kYZpc3gn1f%Cuu60}yz+`njxg HN@xNAu9^>V diff --git a/scenes/notification_display.tscn b/scenes/notification_display.tscn index 32ef4d6..982c58f 100644 --- a/scenes/notification_display.tscn +++ b/scenes/notification_display.tscn @@ -12,9 +12,6 @@ label = NodePath("HBoxContainer/Label") [node name="HBoxContainer" type="HBoxContainer" parent="." unique_id=228546504] layout_mode = 0 -separation = 4 -theme_override_constants/margin_left = 4 -theme_override_constants/margin_right = 4 [node name="Icon" type="TextureRect" parent="HBoxContainer" unique_id=3] custom_minimum_size = Vector2(16, 16) @@ -39,4 +36,4 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -color = Color(0.13333334, 0.1254902, 0.20392157, 1) +color = Color(0.4117647, 0.4117647, 0.41568628, 1) From f69862af8cb846d193e9b4611b6a68850b7b50c5 Mon Sep 17 00:00:00 2001 From: henry Date: Mon, 22 Jun 2026 01:19:49 +0100 Subject: [PATCH 4/6] Added animation to notification display. --- scripts/notification_display.gd | 45 +++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/scripts/notification_display.gd b/scripts/notification_display.gd index 17fa3ff..8e5a713 100644 --- a/scripts/notification_display.gd +++ b/scripts/notification_display.gd @@ -32,14 +32,42 @@ func show_notification(weapon_name: String, player_node: Node2D, player_sprite_s # Use container's natural width, but fix height at 16px size = Vector2(_container.size.x, 16.0) - # Position using origin offset for Y, to the right of player for X + # Calculate target position _update_position() - modulate.a = 1.0 + var target_pos = position - # Fade out and free - var tween = create_tween() - tween.tween_property(self, "modulate:a", 0.0, 2.0) - tween.tween_callback(_on_fade_complete) + # Start 10px above destination, fully transparent + position.y = target_pos.y - 10.0 + modulate.a = 0.0 + + # Pause following during fade-in so the tween isn't overridden by _process + _follow_player = false + + # Fade in and slide into position with overshoot + var tween = create_tween().set_parallel() + tween.tween_property(self, "modulate:a", 1.0, 0.3) + var move_tween = tween.tween_property(self, "position:y", target_pos.y, 0.3) + move_tween.set_trans(Tween.TRANS_ELASTIC).set_ease(Tween.EASE_OUT) + + # Wait for fade-in to finish, then resume following + await tween.finished + _follow_player = true + + # Stay fully visible for a moment before fading + await get_tree().create_timer(0.35).timeout + + # Record current position as the fade-out starting point + await get_tree().process_frame + var fade_start_y = position.y + + # Fade out and drift downward with steady acceleration + _follow_player = false + var fade_out = create_tween().set_parallel() + fade_out.tween_property(self, "modulate:a", 0.0, .35) + var drift = fade_out.tween_property(self, "position:y", fade_start_y + 7, .3) + drift.set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_IN) + await fade_out.finished + queue_free() func _process(_delta: float) -> void: @@ -82,8 +110,3 @@ func _update_position() -> void: notif_y = clamp(notif_y, 0, viewport_size.y - size.y) position = Vector2(notif_x, notif_y) - - -func _on_fade_complete() -> void: - _follow_player = false - queue_free() From 68d0cf95808ff67c4ef1216f35be7b9efb2c41b4 Mon Sep 17 00:00:00 2001 From: henry Date: Mon, 22 Jun 2026 01:24:56 +0100 Subject: [PATCH 5/6] Temporarily disabled notifications from following the player. --- scripts/notification_display.gd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/notification_display.gd b/scripts/notification_display.gd index 8e5a713..645601f 100644 --- a/scripts/notification_display.gd +++ b/scripts/notification_display.gd @@ -24,7 +24,7 @@ func show_notification(weapon_name: String, player_node: Node2D, player_sprite_s _player.tree_exiting.connect(queue_free) _sprite_size = player_sprite_size _origin_offset = origin_offset - _follow_player = true + _follow_player = false # Disable movement for testing # Wait one frame for layout to resolve shrink-to-fit widths await get_tree().process_frame @@ -51,10 +51,10 @@ func show_notification(weapon_name: String, player_node: Node2D, player_sprite_s # Wait for fade-in to finish, then resume following await tween.finished - _follow_player = true + # _follow_player = true # Stay fully visible for a moment before fading - await get_tree().create_timer(0.35).timeout + await get_tree().create_timer(0.25).timeout # Record current position as the fade-out starting point await get_tree().process_frame From ae34cb934adbb2e63211765862f7e892aa01c46f Mon Sep 17 00:00:00 2001 From: henry Date: Mon, 22 Jun 2026 12:58:25 +0100 Subject: [PATCH 6/6] Added segment lines to notification display. --- scripts/notification_display.gd | 50 +++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/scripts/notification_display.gd b/scripts/notification_display.gd index 645601f..e310866 100644 --- a/scripts/notification_display.gd +++ b/scripts/notification_display.gd @@ -9,6 +9,10 @@ var _sprite_size: Vector2 = Vector2.ZERO var _origin_offset: float = 0.0 var _follow_player: bool = false +var _connector_line: Line2D = null +var _connector_visible: bool = false + + func show_notification(weapon_name: String, player_node: Node2D, player_sprite_size: Vector2, origin_offset: float) -> void: label.add_theme_font_size_override("font_size", 8) label.text = weapon_name @@ -51,10 +55,17 @@ func show_notification(weapon_name: String, player_node: Node2D, player_sprite_s # Wait for fade-in to finish, then resume following await tween.finished - # _follow_player = true + _follow_player = true + + # Create connector line from notification to player origin + _connector_line = Line2D.new() + _connector_line.default_color = Color.WHITE + _connector_line.width = 1.0 + add_child(_connector_line) + _connector_visible = true # Stay fully visible for a moment before fading - await get_tree().create_timer(0.25).timeout + await get_tree().create_timer(0.5).timeout # Record current position as the fade-out starting point await get_tree().process_frame @@ -73,6 +84,8 @@ func show_notification(weapon_name: String, player_node: Node2D, player_sprite_s func _process(_delta: float) -> void: if _follow_player and _player: _update_position() + if _connector_visible and _player: + _update_connector() func _update_position() -> void: @@ -110,3 +123,36 @@ func _update_position() -> void: notif_y = clamp(notif_y, 0, viewport_size.y - size.y) position = Vector2(notif_x, notif_y) + + +func _update_connector() -> void: + if _connector_line == null or _player == null: + return + + # Icon position in the notification's local space + var icon_pos = _container.position + icon.position + var icon_mid_y = icon_pos.y + icon.size.y / 2.0 + + # Point 0: edge of the container closest to the icon, at icon's vertical midpoint + var point0: Vector2 + var direction: float + + if _container.get_child(0) == icon: + # Icon on the left (not flipped) — container's left edge, line goes left toward player + point0 = Vector2(_container.position.x, icon_mid_y) + direction = -1.0 + else: + # Icon on the right (flipped) — container's right edge, line goes right toward player + point0 = Vector2(_container.position.x + _container.size.x, icon_mid_y) + direction = 1.0 + + # Point 1: 8px straight from point 0 toward the player + const SEGMENT_ORIGIN: float = 8.0 # length of initial segment from origin + var point1 = Vector2(point0.x + SEGMENT_ORIGIN * direction, icon_mid_y) + + # Point 2: player's origin + ENDPOINT_OFFSET, converted to notification's local space + const ENDPOINT_OFFSET = Vector2(4, 7) # offset from player's origin to connector endpoint + var target = _player.position + Vector2(+ENDPOINT_OFFSET.x, _origin_offset + ENDPOINT_OFFSET.y) + var point2 = target - position + + _connector_line.points = PackedVector2Array([point0, point1, point2])