-
Notifications
You must be signed in to change notification settings - Fork 491
Show area name when moving between areas #2818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
28e745d
4577c68
87c17bc
d574e6c
299e3bf
af863b7
3a08106
7362531
da98b3d
ee87210
d2d0fde
9035f05
8f03895
fce350a
e355dff
3bea70e
2845897
b1c17ac
6e73bdf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
renato-sy marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # SPDX-FileCopyrightText: The Threadbare Authors | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
| extends Node2D | ||
|
|
||
| @export_multiline var zone_name: String | ||
|
|
||
| @export_range(1, 3) var time: int = 2 | ||
|
|
||
|
|
||
| func _on_detect_body_entered(body: Node2D) -> void: | ||
| if not body.is_in_group("player"): | ||
| return | ||
|
|
||
| if GameState.global.current_area_name == zone_name: | ||
| return | ||
|
|
||
| GameState.global.current_area_name = zone_name | ||
|
|
||
| GameState.global.set_unlock_area(zone_name) | ||
| GameState.save() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| uid://k6j0kcn8lb1d |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # SPDX-FileCopyrightText: The Threadbare Authors | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
| extends PanelContainer | ||
|
|
||
|
|
||
| func _is_player_at_bottom() -> bool: | ||
| var player := get_tree().get_first_node_in_group("player") as Node2D | ||
| if not player: | ||
| return false | ||
|
|
||
| var viewport := player.get_viewport() | ||
| var screen_pos: Vector2 = viewport.get_canvas_transform() * player.global_position | ||
| var viewport_size: Vector2 = viewport.get_visible_rect().size | ||
|
|
||
| return screen_pos.y > viewport_size.y * 3.0 / 4.0 | ||
|
|
||
| func animate_first_unlock(zona_name: String, time: int) -> void: | ||
| var label = $Label | ||
| label.text = zona_name | ||
|
|
||
| # Ensure the panel is visible | ||
| show() | ||
| modulate.a = 0.0 | ||
|
|
||
| # 1. Position based on the player | ||
| if _is_player_at_bottom(): | ||
| # Stuck to the TOP, centered | ||
| set_anchors_and_offsets_preset(Control.PRESET_CENTER_TOP) | ||
| grow_vertical = Control.GROW_DIRECTION_END | ||
| position.y = 20.0 | ||
| else: | ||
| # Stuck to the BOTTOM, centered (above the HUD) | ||
| set_anchors_and_offsets_preset(Control.PRESET_CENTER_BOTTOM) | ||
| grow_vertical = Control.GROW_DIRECTION_BEGIN | ||
| position.y = get_viewport_rect().size.y - size.y - 45.0 | ||
|
|
||
| # Wait 1 frame for the UI to calculate its new size based on the text | ||
| await get_tree().process_frame | ||
|
|
||
| # 2. Set the pivot at the center so it scales nicely | ||
| pivot_offset = size / 2.0 | ||
| scale = Vector2(0.6, 0.6) # Starts slightly smaller to scale up when appearing | ||
|
|
||
| # 3. FADE IN | ||
| var tween_in := create_tween().set_parallel(true) | ||
| tween_in.tween_property(self, "modulate:a", 1.0, 0.35)\ | ||
| .set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_OUT) | ||
| tween_in.tween_property(self, "scale", Vector2(1.0, 1.0), 0.35)\ | ||
| .set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_OUT) | ||
|
|
||
| await tween_in.finished | ||
|
|
||
| # 4. Keep visible for the requested time | ||
| await get_tree().create_timer(time).timeout | ||
|
|
||
| # 5. FADE OUT | ||
| var tween_out := create_tween().set_parallel(true) | ||
| tween_out.tween_property(self, "modulate:a", 0.0, 0.3)\ | ||
| .set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_IN) | ||
| tween_out.tween_property(self, "scale", Vector2(0.8, 0.8), 0.3)\ | ||
| .set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_IN) | ||
|
|
||
| await tween_out.finished | ||
| hide() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| uid://c1f8uqwm124qu |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # SPDX-FileCopyrightText: The Threadbare Authors | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
| extends PanelContainer | ||
|
|
||
| @export var slide_offset_y: float = 150.0 # Amount of pixels for the slide offset[cite: 5] | ||
|
|
||
| @onready var label: Label = $Label | ||
|
|
||
| var _base_target_y: float = 0.0 | ||
| var _is_target_saved: bool = false | ||
|
|
||
|
|
||
| func _ready() -> void: | ||
| modulate.a = 0.0 | ||
|
|
||
|
|
||
| func animate_re_entry(zona_name: String, time: int) -> void: | ||
| show() | ||
| label.text = zona_name | ||
|
|
||
| # Save base position if it hasn't been saved yet | ||
| if not _is_target_saved: | ||
| _base_target_y = position.y | ||
| _is_target_saved = true | ||
|
|
||
| var target_y: float = _base_target_y | ||
| var start_y: float = target_y - abs(slide_offset_y) | ||
|
|
||
| position.y = start_y | ||
| modulate.a = 0.0 | ||
|
|
||
| # ENTRY | ||
| var tween_in := create_tween().set_parallel(true) | ||
| tween_in.tween_property(self, "position:y", target_y, 0.35)\ | ||
| .set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_OUT) | ||
| tween_in.tween_property(self, "modulate:a", 1.0, 0.3)\ | ||
| .set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_OUT) | ||
|
|
||
| await get_tree().create_timer(time).timeout | ||
|
|
||
| # EXIT | ||
| var tween_out := create_tween().set_parallel(true) | ||
| tween_out.tween_property(self, "position:y", start_y, 0.35)\ | ||
| .set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_IN) | ||
| tween_out.tween_property(self, "modulate:a", 0.0, 0.3)\ | ||
| .set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_IN) | ||
|
|
||
| await tween_out.finished | ||
| position.y = target_y | ||
| hide() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| uid://qlfg2cvfb6ia |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like how this looks with the heavy drop shadow. Personally I think we could use the same presentation as the dialogue balloons.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I've applied the "Balloons" one. Take a look—how does the color look? Should I change it? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| [gd_scene format=3 uid="uid://ipgq27vmhsmc"] | ||
|
|
||
| [ext_resource type="Script" uid="uid://c1f8uqwm124qu" path="res://scenes/ui_elements/area_name/components/first_unlock.gd" id="2_1xhrb"] | ||
|
|
||
| [sub_resource type="StyleBoxTexture" id="StyleBoxTexture_si2rt"] | ||
| content_margin_left = 64.0 | ||
| content_margin_top = 48.0 | ||
| content_margin_right = 64.0 | ||
| content_margin_bottom = 64.0 | ||
| texture_margin_left = 64.0 | ||
| texture_margin_top = 64.0 | ||
| texture_margin_right = 64.0 | ||
| texture_margin_bottom = 64.0 | ||
| expand_margin_left = 16.0 | ||
| expand_margin_top = 16.0 | ||
| expand_margin_right = 16.0 | ||
| expand_margin_bottom = 16.0 | ||
| axis_stretch_horizontal = 1 | ||
| axis_stretch_vertical = 1 | ||
|
|
||
| [node name="FirstUnlock" type="PanelContainer" unique_id=1838469583] | ||
| anchors_preset = 8 | ||
| anchor_left = 0.5 | ||
| anchor_top = 0.5 | ||
| anchor_right = 0.5 | ||
| anchor_bottom = 0.5 | ||
| offset_left = -126.0 | ||
| offset_top = -268.0 | ||
| offset_right = 110.0 | ||
| offset_bottom = -129.0 | ||
| grow_horizontal = 2 | ||
| grow_vertical = 2 | ||
| theme_type_variation = &"NPCRibbon" | ||
| theme_override_styles/panel = SubResource("StyleBoxTexture_si2rt") | ||
| script = ExtResource("2_1xhrb") | ||
|
|
||
| [node name="Label" type="Label" parent="." unique_id=1726876452] | ||
| layout_mode = 2 | ||
| theme_override_colors/font_color = Color(0.8980392, 0.8784314, 0.8235294, 0.88235295) | ||
| theme_override_constants/shadow_offset_x = 12 | ||
| theme_override_constants/shadow_offset_y = 5 | ||
| theme_override_constants/shadow_outline_size = 10 | ||
| theme_override_font_sizes/font_size = 100 | ||
| text = "Name Zone" | ||
| horizontal_alignment = 1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| [gd_scene format=3 uid="uid://cps4im7j5unff"] | ||
|
|
||
| [ext_resource type="Script" uid="uid://qlfg2cvfb6ia" path="res://scenes/ui_elements/area_name/components/re_entry.gd" id="2_7rwir"] | ||
| [ext_resource type="Theme" uid="uid://cvitou84ni7qe" path="res://scenes/ui_elements/components/theme.tres" id="2_g8ohe"] | ||
|
|
||
| [sub_resource type="StyleBoxTexture" id="StyleBoxTexture_isa5i"] | ||
| content_margin_left = 64.0 | ||
| content_margin_top = 25.0 | ||
| content_margin_right = 64.0 | ||
| content_margin_bottom = 50.0 | ||
| texture_margin_left = 64.0 | ||
| texture_margin_top = 64.0 | ||
| texture_margin_right = 64.0 | ||
| texture_margin_bottom = 64.0 | ||
| expand_margin_left = 16.0 | ||
| expand_margin_top = 45.0 | ||
| expand_margin_right = 16.0 | ||
| axis_stretch_horizontal = 1 | ||
| axis_stretch_vertical = 1 | ||
|
|
||
| [node name="ReEntry" type="PanelContainer" unique_id=775249051] | ||
| theme_override_styles/panel = SubResource("StyleBoxTexture_isa5i") | ||
| script = ExtResource("2_7rwir") | ||
|
|
||
| [node name="Label" type="Label" parent="." unique_id=653377466] | ||
| layout_mode = 2 | ||
| theme = ExtResource("2_g8ohe") | ||
| theme_type_variation = &"HintLabel" | ||
| theme_override_colors/font_color = Color(0.8980392, 0.8784314, 0.8235294, 0.88235295) | ||
| theme_override_constants/shadow_offset_x = 4 | ||
| theme_override_constants/shadow_outline_size = 2 | ||
| text = "Name Zone" | ||
| horizontal_alignment = 1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| [gd_scene format=3 uid="uid://bjin4sdopq7rn"] | ||
|
|
||
| [ext_resource type="Script" uid="uid://k6j0kcn8lb1d" path="res://scenes/ui_elements/area_name/components/area_name.gd" id="1_j0vm2"] | ||
|
|
||
| [node name="TextNameArea" type="Node2D" unique_id=1184526213] | ||
| script = ExtResource("1_j0vm2") | ||
|
|
||
| [node name="detect" type="Area2D" parent="." unique_id=1821875710] | ||
|
|
||
| [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="detect" unique_id=1009866314] | ||
|
|
||
| [node name="Timer" type="Timer" parent="." unique_id=53937746] | ||
| one_shot = true | ||
|
|
||
| [connection signal="body_entered" from="detect" to="." method="_on_detect_body_entered"] | ||
| [connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"] |
Uh oh!
There was an error while loading. Please reload this page.