65 lines
1.4 KiB
GDScript
65 lines
1.4 KiB
GDScript
tool
|
|
extends Node2D
|
|
|
|
|
|
export(String, DIR) var messages_dir: String setget _set_messages_dir
|
|
export var flip: bool = false setget _set_flip
|
|
#export
|
|
var message: String setget _set_message
|
|
|
|
|
|
func _ready() -> void:
|
|
if Engine.editor_hint:
|
|
return
|
|
|
|
scale.x = 0.0
|
|
$Message.texture = load("%s/%s.png" % [messages_dir, message])
|
|
|
|
|
|
func appear() -> void:
|
|
if Options.speccy_help:
|
|
$AnimationPlayer.play("fun")
|
|
|
|
|
|
func switch_action() -> void:
|
|
appear()
|
|
|
|
|
|
func _set_messages_dir(value: String) -> void:
|
|
messages_dir = value
|
|
property_list_changed_notify()
|
|
|
|
|
|
func _set_message(value: String) -> void:
|
|
message = value
|
|
if not Engine.editor_hint:
|
|
return
|
|
$Message.texture = load("%s/%s.png" % [messages_dir, message])
|
|
|
|
|
|
func _set_flip(value: bool) -> void:
|
|
flip = value
|
|
$Flipper.scale.x = -1.0 if flip else 1.0
|
|
|
|
|
|
func _get_property_list() -> Array:
|
|
var files: String = ""
|
|
var dir: Directory = Directory.new()
|
|
if dir.open(messages_dir) == OK:
|
|
dir.list_dir_begin(true, true)
|
|
var file_name: String = dir.get_next()
|
|
while file_name != "":
|
|
if not dir.current_is_dir() and file_name.ends_with(".png"):
|
|
files += "%s," % file_name.trim_suffix(".png")
|
|
file_name = dir.get_next()
|
|
files = files.trim_suffix(",")
|
|
else:
|
|
push_error("Failed to open dir: %s" % messages_dir)
|
|
return [
|
|
{
|
|
name = "message",
|
|
type = TYPE_STRING,
|
|
hint = PROPERTY_HINT_ENUM,
|
|
hint_string = files,
|
|
}
|
|
]
|