Added Notice_msg for notices

This commit is contained in:
Noah 2022-10-28 15:16:00 -05:00
parent 8c0cbb1512
commit f02ab01606
4 changed files with 111 additions and 0 deletions

View File

@ -7,6 +7,15 @@ var local_version # The version installed on this computer
var os_name # The simplified name of the OS (linux, or windows)
var suffix #
var Notice_msg = load("res://Notice_msg.tscn")
func notice(msg, type):
var notice = Notice_msg.instance()
notice.message = msg
notice.type = type
notice.set_position(Vector2(20, $Notices.get_child_count()*30))
$Notices.add_child(notice)
# Every _process tick
func _process(_delta):
# If the newest_version variable exists,
@ -31,6 +40,7 @@ func _process(_delta):
# When everything is loaded,
func _ready():
# Determine the os_name
if OS.get_name() == "X11": # X11 is linuxy-based
os_name = "linux"

View File

@ -71,4 +71,9 @@ rect_scale = Vector2( 0.962016, 0.91427 )
custom_fonts/font = SubResource( 5 )
text = "play"
[node name="Notices" type="VBoxContainer" parent="."]
margin_top = 80.0
margin_right = 192.0
margin_bottom = 272.0
[connection signal="pressed" from="Panel/Play_button" to="." method="_on_Play_button_pressed"]

19
Notice_msg.gd Normal file
View File

@ -0,0 +1,19 @@
extends Node2D
var message
var type
func _ready():
if type == "warning":
$Label.add_color_override("font_color", Color(255, 69, 0))
if type == "alert":
$Label.add_color_override("font_color", Color(255, 0, 0))
func _process(delta):
$Label.text = message
func _on_TTL_timeout():
$AnimationPlayer.play("move_off_screen")
func _on_AnimationPlayer_animation_finished(anim_name):
queue_free()

77
Notice_msg.tscn Normal file
View File

@ -0,0 +1,77 @@
[gd_scene load_steps=6 format=2]
[ext_resource path="res://fonts/Retro Gaming.ttf" type="DynamicFontData" id=1]
[ext_resource path="res://Notice_msg.gd" type="Script" id=2]
[sub_resource type="DynamicFont" id=1]
size = 24
extra_spacing_char = 4
font_data = ExtResource( 1 )
[sub_resource type="Animation" id=2]
length = 0.001
tracks/0/type = "value"
tracks/0/path = NodePath(".:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Vector2( 0, 0 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("Label:rect_position")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Vector2( 0, 0 ) ]
}
[sub_resource type="Animation" id=3]
resource_name = "move_off_screen"
length = 0.3
tracks/0/type = "value"
tracks/0/path = NodePath("Label:rect_position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.3 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Vector2( 0, 0 ), Vector2( -200, 0 ) ]
}
[node name="Notice_msg" type="Node2D"]
script = ExtResource( 2 )
__meta__ = {
"_edit_group_": true
}
[node name="TTL" type="Timer" parent="."]
wait_time = 3.0
one_shot = true
autostart = true
[node name="Label" type="Label" parent="."]
margin_right = 200.0
margin_bottom = 41.0
custom_fonts/font = SubResource( 1 )
text = "Test"
valign = 1
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/RESET = SubResource( 2 )
anims/move_off_screen = SubResource( 3 )
[connection signal="timeout" from="TTL" to="." method="_on_TTL_timeout"]
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_AnimationPlayer_animation_finished"]