-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
80cf2e9
commit a391824
Showing
5 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# A notification that scales up to appear on the screen, | ||
# stays for a few instants, and fades out slowly. | ||
extends Control | ||
|
||
const DURATION_SCALE := 0.25 | ||
const DURATION_VISIBLE := 2.0 | ||
const DURATION_FADE_OUT := 2.0 | ||
|
||
onready var label: RichTextLabel = $RichTextLabel | ||
onready var tween: Tween = $Tween | ||
|
||
|
||
func _ready() -> void: | ||
rect_pivot_offset = rect_size | ||
rect_scale = Vector2.ZERO | ||
|
||
|
||
func setup(username: String, color := Color.white, disconnected := false) -> void: | ||
label.bbcode_text = ( | ||
"[color=#%s]%s[/color] %s" | ||
% [color.to_html(false), username, "left" if disconnected else "joined"] | ||
) | ||
# warning-ignore:return_value_discarded | ||
tween.interpolate_property( | ||
self, | ||
"rect_scale", | ||
Vector2.ZERO, | ||
Vector2.ONE, | ||
DURATION_SCALE, | ||
Tween.TRANS_LINEAR, | ||
Tween.EASE_OUT | ||
) | ||
# warning-ignore:return_value_discarded | ||
tween.interpolate_property( | ||
self, | ||
"modulate", | ||
Color.white, | ||
Color.transparent, | ||
DURATION_FADE_OUT, | ||
Tween.TRANS_LINEAR, | ||
Tween.EASE_IN_OUT, | ||
DURATION_SCALE + DURATION_VISIBLE | ||
) | ||
# warning-ignore:return_value_discarded | ||
tween.start() | ||
yield(tween, "tween_all_completed") | ||
queue_free() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[gd_scene load_steps=3 format=2] | ||
|
||
[ext_resource path="res://assets/theme/gdquest.theme" type="Theme" id=1] | ||
[ext_resource path="res://src/UI/Elements/Notification.gd" type="Script" id=2] | ||
|
||
[node name="Panel" type="Panel"] | ||
margin_right = 400.0 | ||
margin_bottom = 120.0 | ||
grow_horizontal = 2 | ||
rect_min_size = Vector2( 400, 120 ) | ||
rect_pivot_offset = Vector2( 400, 120 ) | ||
theme = ExtResource( 1 ) | ||
script = ExtResource( 2 ) | ||
__meta__ = { | ||
"_edit_use_anchors_": false, | ||
"_editor_description_": "" | ||
} | ||
|
||
[node name="RichTextLabel" type="RichTextLabel" parent="."] | ||
margin_left = 10.0 | ||
margin_top = 10.0 | ||
margin_right = 390.0 | ||
margin_bottom = 90.0 | ||
bbcode_enabled = true | ||
scroll_active = false | ||
__meta__ = { | ||
"_edit_use_anchors_": false | ||
} | ||
|
||
[node name="Tween" type="Tween" parent="."] |