First commit 🎉
This commit is contained in:
commit
43ea213f9b
728 changed files with 37080 additions and 0 deletions
|
@ -0,0 +1,81 @@
|
|||
extends Control
|
||||
## Show a text in the form of GUI. Can be used to show game (or narrator)
|
||||
## messages.
|
||||
|
||||
const DFLT_SIZE := "dflt_size"
|
||||
|
||||
# Used to fix a warning shown by Godot related to the anchors of the node and changing its size
|
||||
# during a _ready() execution
|
||||
var _can_change_size := false
|
||||
|
||||
@onready var rich_text_label: RichTextLabel = %RichTextLabel
|
||||
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _ready() -> void:
|
||||
set_meta(DFLT_SIZE, rich_text_label.size)
|
||||
|
||||
# Connect to singletons signals
|
||||
PopochiuUtils.g.system_text_shown.connect(_show_text)
|
||||
PopochiuUtils.e.ready.connect(set.bind("_can_change_size", true))
|
||||
|
||||
close()
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
rich_text_label.position = get_parent().size / 2.0 - (rich_text_label.size / 2.0)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_released("popochiu-skip"):
|
||||
close.call_deferred()
|
||||
|
||||
if not PopochiuUtils.is_click_or_touch_pressed(event) or not visible:
|
||||
return
|
||||
|
||||
accept_event()
|
||||
if PopochiuUtils.get_click_or_touch_index(event) == MOUSE_BUTTON_LEFT:
|
||||
close()
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public #####################################################################################
|
||||
func appear() -> void:
|
||||
show()
|
||||
set_process_input(true)
|
||||
|
||||
|
||||
func close() -> void:
|
||||
set_process_input(false)
|
||||
|
||||
rich_text_label.clear()
|
||||
rich_text_label.text = ""
|
||||
|
||||
if _can_change_size:
|
||||
rich_text_label.size = get_meta(DFLT_SIZE)
|
||||
|
||||
hide()
|
||||
PopochiuUtils.g.system_text_hidden.emit()
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private ####################################################################################
|
||||
func _show_text(msg := "") -> void:
|
||||
if PopochiuUtils.e.cutscene_skipped:
|
||||
close.call_deferred()
|
||||
return
|
||||
|
||||
rich_text_label.clear()
|
||||
rich_text_label.text = ""
|
||||
rich_text_label.size = get_meta(DFLT_SIZE)
|
||||
rich_text_label.append_text("[center]%s[/center]" % msg)
|
||||
|
||||
if msg:
|
||||
appear()
|
||||
else:
|
||||
close()
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://cu5huf6n0l2tf
|
|
@ -0,0 +1,43 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://bdgs3xsbq3gdd"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="1_7ydn8"]
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/system_text/system_text.gd" id="2"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_4eue6"]
|
||||
content_margin_left = 8.0
|
||||
content_margin_top = 6.0
|
||||
content_margin_right = 8.0
|
||||
content_margin_bottom = 6.0
|
||||
bg_color = Color(0, 0, 0, 0.705882)
|
||||
corner_detail = 4
|
||||
anti_aliasing = false
|
||||
|
||||
[node name="SystemText" type="Control" groups=["popochiu_gui_component"]]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
theme = ExtResource("1_7ydn8")
|
||||
script = ExtResource("2")
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 14
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
offset_left = 33.0
|
||||
offset_top = -9.0
|
||||
offset_right = -33.0
|
||||
offset_bottom = 9.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/normal = SubResource("StyleBoxFlat_4eue6")
|
||||
bbcode_enabled = true
|
||||
text = "[center]Text from the game itself[/center]"
|
||||
fit_content = true
|
||||
scroll_active = false
|
Loading…
Add table
Add a link
Reference in a new issue