venus/assets/uielements/splash.gd
2024-05-15 21:08:58 +02:00

47 lines
1.5 KiB
GDScript

# STAROPENSOURCE CORE MODULES SOURCE FILE
# Copyright (c) 2024 The StarOpenSource Project & Contributors
# Licensed under the GNU Affero General Public License v3
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
@tool
extends SuiBaseClass
@export_category("Base configuration")
## From which category to pull splashes from.
@export var splash_category: String = "default"
var splash: CoreBaseModule
var splash_text: String = "Hmm... something went wrong."
# +++ initialization +++
func _ready() -> void:
super()
splash = core.get_custom_module("splashes")
update_splash()
# +++ update methods +++
func update_element() -> void:
# Update text
if in_editor(): $Text.text = "[center]Imagine that you see some splash text here"
else: $Text.text = "[center]" + splash_text
# Update sizes
$Text.size = size
$Switcher.size = size
func update_splash() -> void:
splash_text = await splash.get_random_splash(splash_category)