First commit 🎉
|
@ -0,0 +1,144 @@
|
|||
class_name PopochiuDialogMenu
|
||||
extends Control
|
||||
@warning_ignore("return_value_discarded")
|
||||
@warning_ignore("unused_signal")
|
||||
|
||||
signal shown
|
||||
|
||||
@export var option_scene: PackedScene
|
||||
## Max height of the menu in pixels. If visible options make the menu to exceed this value, it will
|
||||
## enable a vertical scroll bar.
|
||||
@export var max_height := 49
|
||||
@export_category("Option buttons")
|
||||
@export var normal_font_color: Color = Color("706deb")
|
||||
@export var normal_used_font_color: Color = Color("2e2c9b")
|
||||
@export var hover_font_color: Color = Color("ffffff")
|
||||
@export var hover_used_font_color: Color = Color("b2b2b2")
|
||||
@export var pressed_font_color: Color = Color("a9ff9f")
|
||||
@export var pressed_used_font_color: Color = Color("56ac4d")
|
||||
|
||||
var current_options := []
|
||||
|
||||
@onready var panel_container: PanelContainer = $PanelContainer
|
||||
@onready var dialog_options_container: VBoxContainer = %DialogOptionsContainer
|
||||
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _ready() -> void:
|
||||
for child in dialog_options_container.get_children():
|
||||
child.queue_free()
|
||||
|
||||
panel_container.custom_minimum_size = Vector2.ZERO
|
||||
|
||||
# Connect to own signals
|
||||
gui_input.connect(_clicked)
|
||||
|
||||
# Connect to autoloads signals
|
||||
PopochiuUtils.d.dialog_options_requested.connect(_create_options.bind(true))
|
||||
PopochiuUtils.d.inline_dialog_requested.connect(_create_inline_options)
|
||||
PopochiuUtils.d.dialog_finished.connect(remove_options)
|
||||
|
||||
hide()
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private ####################################################################################
|
||||
func _clicked(event: InputEvent) -> void:
|
||||
if PopochiuUtils.get_click_or_touch_index(event) == MOUSE_BUTTON_LEFT:
|
||||
accept_event()
|
||||
|
||||
|
||||
# Creates an Array of PopochiuDialogOption to show dialog tree options created
|
||||
# during execution, (those that are created after calling D.show_inline_dialog)
|
||||
func _create_inline_options(opts: Array) -> void:
|
||||
var tmp_opts := []
|
||||
for idx in opts.size():
|
||||
var new_opt: PopochiuDialogOption = PopochiuDialogOption.new()
|
||||
|
||||
new_opt.id = str(idx)
|
||||
new_opt.text = opts[idx]
|
||||
|
||||
tmp_opts.append(new_opt)
|
||||
|
||||
_create_options(tmp_opts, true)
|
||||
|
||||
|
||||
func _create_options(options := [], autoshow := false) -> void:
|
||||
remove_options()
|
||||
|
||||
if options.is_empty():
|
||||
if not current_options.is_empty():
|
||||
show_options()
|
||||
return
|
||||
|
||||
current_options = options.duplicate(true)
|
||||
|
||||
for dialog_option: PopochiuDialogOption in options:
|
||||
var dialog_menu_option := option_scene.instantiate()
|
||||
dialog_menu_option.normal_color = normal_font_color
|
||||
dialog_menu_option.normal_used_color = normal_used_font_color
|
||||
dialog_menu_option.hover_color = hover_font_color
|
||||
dialog_menu_option.hover_used_color = hover_used_font_color
|
||||
dialog_menu_option.pressed_color = pressed_font_color
|
||||
dialog_menu_option.pressed_used_color = pressed_used_font_color
|
||||
dialog_options_container.add_child(dialog_menu_option)
|
||||
|
||||
dialog_menu_option.option = dialog_option
|
||||
dialog_menu_option.pressed.connect(_on_option_clicked)
|
||||
|
||||
if dialog_option.disabled or not dialog_option.visible:
|
||||
dialog_menu_option.hide()
|
||||
else:
|
||||
dialog_menu_option.show()
|
||||
|
||||
if autoshow: show_options()
|
||||
await get_tree().create_timer(0.1).timeout
|
||||
|
||||
# Fix: Height and position of the dialog menu was wrong when changing the amount of options to
|
||||
# show.
|
||||
var options_height := 0
|
||||
var visible_options := 0
|
||||
for opt in dialog_options_container.get_children():
|
||||
if not opt.visible: continue
|
||||
|
||||
options_height += opt.size.y
|
||||
visible_options += 1
|
||||
|
||||
options_height += (
|
||||
dialog_options_container.get_theme_constant("separation") * (visible_options - 1)
|
||||
)
|
||||
|
||||
panel_container.size.y = min(options_height, max_height)
|
||||
panel_container.position.y = PopochiuUtils.e.height - panel_container.size.y
|
||||
|
||||
|
||||
func remove_options(_dialog: PopochiuDialog = null) -> void:
|
||||
if not current_options.is_empty():
|
||||
current_options.clear()
|
||||
|
||||
for btn in dialog_options_container.get_children():
|
||||
btn.queue_free()
|
||||
|
||||
await get_tree().process_frame
|
||||
|
||||
size.y = 0
|
||||
dialog_options_container.size.y = 0
|
||||
|
||||
|
||||
func show_options() -> void:
|
||||
PopochiuUtils.g.block()
|
||||
PopochiuUtils.g.dialog_options_shown.emit()
|
||||
|
||||
show()
|
||||
shown.emit()
|
||||
|
||||
|
||||
func _on_option_clicked(opt: PopochiuDialogOption) -> void:
|
||||
PopochiuUtils.g.unblock()
|
||||
|
||||
hide()
|
||||
PopochiuUtils.d.option_selected.emit(opt)
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://c6el34etfenet
|
|
@ -0,0 +1,39 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://dhsfl8ot4j5fj"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/dialog_menu/dialog_menu.gd" id="1_3dp72"]
|
||||
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="1_cvsnu"]
|
||||
[ext_resource type="PackedScene" uid="uid://dcta4urojglil" path="res://addons/popochiu/engine/objects/gui/components/dialog_menu/dialog_menu_option/dialog_menu_option.tscn" id="3_0jfsm"]
|
||||
|
||||
[node name="DialogMenu" 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_cvsnu")
|
||||
script = ExtResource("1_3dp72")
|
||||
option_scene = ExtResource("3_0jfsm")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||
custom_minimum_size = Vector2(0, 53)
|
||||
layout_mode = 1
|
||||
anchors_preset = 12
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -53.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="PanelContainer"]
|
||||
layout_mode = 2
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="DialogOptionsContainer" type="VBoxContainer" parent="PanelContainer/ScrollContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 8
|
||||
theme_override_constants/separation = 1
|
|
@ -0,0 +1,92 @@
|
|||
class_name PopochiuDialogMenuOption
|
||||
extends PanelContainer
|
||||
|
||||
signal pressed(node: PopochiuDialogOption)
|
||||
|
||||
var option: PopochiuDialogOption : set = set_dialog_option
|
||||
var text := "" : set = set_text
|
||||
var used := false : set = set_used
|
||||
var normal_color := Color.WHITE
|
||||
var normal_used_color := normal_color
|
||||
var hover_color := Color.WHITE
|
||||
var hover_used_color := hover_color
|
||||
var pressed_color := Color.WHITE
|
||||
var pressed_used_color := pressed_color
|
||||
|
||||
var _state := "normal" : set = set_state
|
||||
|
||||
@onready var rich_text_label: RichTextLabel = %RichTextLabel
|
||||
@onready var handler: Button = %Handler
|
||||
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _ready() -> void:
|
||||
handler.pressed.connect(_on_pressed)
|
||||
handler.mouse_entered.connect(_on_mouse_entered)
|
||||
handler.mouse_exited.connect(_on_mouse_exited)
|
||||
handler.button_down.connect(_on_button_down)
|
||||
handler.button_up.connect(_on_button_up)
|
||||
|
||||
_update_font_color()
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetGet #####################################################################################
|
||||
func set_dialog_option(value: PopochiuDialogOption) -> void:
|
||||
option = value
|
||||
if PopochiuConfig.should_dialog_options_be_gibberish():
|
||||
text = PopochiuUtils.d.create_gibberish(option.text)
|
||||
else:
|
||||
text = option.text
|
||||
|
||||
used = option.used and not option.always_on
|
||||
|
||||
|
||||
func set_text(value: String) -> void:
|
||||
text = value
|
||||
rich_text_label.text = value
|
||||
|
||||
|
||||
func set_used(value: bool) -> void:
|
||||
used = value
|
||||
_update_font_color()
|
||||
|
||||
|
||||
func set_state(value: String) -> void:
|
||||
_state = value
|
||||
_update_font_color()
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private ####################################################################################
|
||||
func _on_pressed() -> void:
|
||||
_state = "pressed"
|
||||
pressed.emit(option)
|
||||
|
||||
|
||||
func _on_mouse_entered() -> void:
|
||||
_state = "hover"
|
||||
|
||||
|
||||
func _on_mouse_exited() -> void:
|
||||
_state = "normal"
|
||||
|
||||
|
||||
func _on_button_down() -> void:
|
||||
_state = "pressed"
|
||||
|
||||
|
||||
func _on_button_up() -> void:
|
||||
_state = "hover" if handler.is_hovered() else "normal"
|
||||
|
||||
|
||||
func _update_font_color() -> void:
|
||||
rich_text_label.add_theme_color_override(
|
||||
"default_color",
|
||||
get("%s_color" % (_state + ("_used" if used else "")))
|
||||
)
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://blkbqigv64y7w
|
|
@ -0,0 +1,40 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://dcta4urojglil"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="1_y0k4l"]
|
||||
[ext_resource type="FontFile" uid="uid://dixh1egf7k2fb" path="res://addons/popochiu/engine/objects/gui/fonts/monkeyisland_1991.ttf" id="2_5iw2f"]
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/dialog_menu/dialog_menu_option/dialog_menu_option.gd" id="2_nywcv"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_un1pr"]
|
||||
content_margin_left = 2.0
|
||||
content_margin_right = 2.0
|
||||
content_margin_bottom = 2.0
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_we03b"]
|
||||
|
||||
[node name="DialogMenuOption" type="PanelContainer"]
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
offset_bottom = 24.0
|
||||
grow_horizontal = 2
|
||||
mouse_filter = 2
|
||||
theme = ExtResource("1_y0k4l")
|
||||
theme_override_styles/panel = SubResource("StyleBoxEmpty_un1pr")
|
||||
script = ExtResource("2_nywcv")
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
bbcode_enabled = true
|
||||
text = "A [wave]veeeeeeeeeeeeeery[/wave] long line option that should wrap so devs can have long options......"
|
||||
fit_content = true
|
||||
scroll_active = false
|
||||
|
||||
[node name="Handler" type="Button" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_fonts/font = ExtResource("2_5iw2f")
|
||||
theme_override_font_sizes/font_size = 12
|
||||
theme_override_styles/focus = SubResource("StyleBoxEmpty_we03b")
|
||||
flat = true
|
||||
alignment = 0
|
||||
text_overrun_behavior = 4
|
|
@ -0,0 +1,17 @@
|
|||
extends PopochiuDialogText
|
||||
|
||||
|
||||
#region Private ####################################################################################
|
||||
func _modify_size(msg: String, _target_position: Vector2) -> void:
|
||||
var _size := await _calculate_size(msg)
|
||||
|
||||
# Define size and position (before calculating overflow)
|
||||
rich_text_label.size.y = _size.y
|
||||
rich_text_label.position.y = get_meta(DFLT_POSITION).y - (_size.y - get_meta(DFLT_SIZE).y)
|
||||
|
||||
|
||||
func _append_text(msg: String, props: Dictionary) -> void:
|
||||
rich_text_label.text = "[center][color=%s]%s[/color][/center]" % [props.color.to_html(), msg]
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://mnqgd41iws6y
|
|
@ -0,0 +1,58 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://bpl3qjbxonfpb"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/dialog_text/dialog_caption/dialog_caption.gd" id="1_17s2p"]
|
||||
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="1_xoamn"]
|
||||
[ext_resource type="Texture2D" uid="uid://h156lkhxk5tl" path="res://addons/popochiu/engine/objects/gui/components/dialog_text/images/ico_continue.png" id="3_etbl2"]
|
||||
|
||||
[node name="DialogCaption" 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_xoamn")
|
||||
script = ExtResource("1_17s2p")
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="."]
|
||||
unique_name_in_owner = true
|
||||
clip_contents = false
|
||||
custom_minimum_size = Vector2(16, 16)
|
||||
layout_mode = 1
|
||||
anchors_preset = 12
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 20.0
|
||||
offset_top = -20.0
|
||||
offset_right = -20.0
|
||||
offset_bottom = -4.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
size_flags_horizontal = 0
|
||||
mouse_filter = 2
|
||||
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
|
||||
theme_override_constants/outline_size = 4
|
||||
bbcode_enabled = true
|
||||
text = "[center]A [shake]caption[/shake] dialog text[/center]"
|
||||
fit_content = true
|
||||
scroll_active = false
|
||||
meta_underlined = false
|
||||
|
||||
[node name="ContinueIcon" type="TextureProgressBar" parent="RichTextLabel"]
|
||||
unique_name_in_owner = true
|
||||
texture_filter = 1
|
||||
layout_mode = 1
|
||||
anchors_preset = 3
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -16.0
|
||||
offset_right = 16.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
value = 100.0
|
||||
fill_mode = 2
|
||||
texture_progress = ExtResource("3_etbl2")
|
|
@ -0,0 +1,47 @@
|
|||
extends PopochiuDialogText
|
||||
|
||||
|
||||
#region Private ####################################################################################
|
||||
func _modify_size(msg: String, target_position: Vector2) -> void:
|
||||
var _size := await _calculate_size(msg)
|
||||
|
||||
# Define size and position (before calculating overflow)
|
||||
rich_text_label.size = _size
|
||||
rich_text_label.position = target_position - rich_text_label.size / 2.0
|
||||
rich_text_label.position.y -= rich_text_label.size.y / 2.0
|
||||
# Calculate overflow and reposition
|
||||
if rich_text_label.position.x < 0.0:
|
||||
rich_text_label.position.x = limit_margin
|
||||
elif rich_text_label.position.x + rich_text_label.size.x + continue_icon_size.x > _x_limit:
|
||||
rich_text_label.position.x = (
|
||||
_x_limit - limit_margin - rich_text_label.size.x - continue_icon_size.x
|
||||
)
|
||||
if rich_text_label.position.y < 0.0:
|
||||
rich_text_label.position.y = limit_margin
|
||||
elif rich_text_label.position.y + rich_text_label.size.y > _y_limit:
|
||||
rich_text_label.position.y = _y_limit - limit_margin - rich_text_label.size.y
|
||||
|
||||
|
||||
func _set_default_label_size(lbl: Label) -> void:
|
||||
lbl.size.y = get_meta(DFLT_SIZE).y
|
||||
|
||||
|
||||
func _append_text(msg: String, props: Dictionary) -> void:
|
||||
var center: float = floor(rich_text_label.position.x + (rich_text_label.size.x / 2))
|
||||
if center == props.position.x:
|
||||
rich_text_label.text = "[center]%s[/center]" % msg
|
||||
elif center < props.position.x:
|
||||
rich_text_label.text = "[right]%s[/right]" % msg
|
||||
else:
|
||||
rich_text_label.text = msg
|
||||
|
||||
|
||||
func _get_icon_from_position() -> float:
|
||||
return rich_text_label.size.y / 2.0 - 1.0
|
||||
|
||||
|
||||
func _get_icon_to_position() -> float:
|
||||
return rich_text_label.size.y / 2.0 + 3.0
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://cp4khma0rcc33
|
|
@ -0,0 +1,47 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://bn7o13nv11ka1"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/dialog_text/dialog_overhead/dialog_overhead.gd" id="1_a5mdx"]
|
||||
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="2_t336a"]
|
||||
[ext_resource type="Texture2D" uid="uid://h156lkhxk5tl" path="res://addons/popochiu/engine/objects/gui/components/dialog_text/images/ico_continue.png" id="3_67j10"]
|
||||
|
||||
[node name="DialogOverhead" 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("2_t336a")
|
||||
script = ExtResource("1_a5mdx")
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="."]
|
||||
unique_name_in_owner = true
|
||||
clip_contents = false
|
||||
custom_minimum_size = Vector2(16, 16)
|
||||
layout_mode = 0
|
||||
offset_right = 153.0
|
||||
offset_bottom = 16.0
|
||||
size_flags_horizontal = 0
|
||||
mouse_filter = 2
|
||||
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
|
||||
theme_override_constants/outline_size = 4
|
||||
bbcode_enabled = true
|
||||
text = "An [shake]overhead[/shake] dialog text"
|
||||
fit_content = true
|
||||
scroll_active = false
|
||||
meta_underlined = false
|
||||
|
||||
[node name="ContinueIcon" type="TextureProgressBar" parent="RichTextLabel"]
|
||||
unique_name_in_owner = true
|
||||
texture_filter = 1
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_right = 16.0
|
||||
offset_bottom = 16.0
|
||||
grow_horizontal = 0
|
||||
value = 100.0
|
||||
fill_mode = 2
|
||||
texture_progress = ExtResource("3_67j10")
|
|
@ -0,0 +1,45 @@
|
|||
extends PopochiuDialogText
|
||||
|
||||
@onready var left_avatar_container: PanelContainer = %LeftAvatarContainer
|
||||
@onready var left_avatar: TextureRect = %LeftAvatar
|
||||
@onready var right_avatar_container: PanelContainer = %RightAvatarContainer
|
||||
@onready var right_avatar: TextureRect = %RightAvatar
|
||||
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _ready() -> void:
|
||||
super()
|
||||
|
||||
# Connect to singletons signals
|
||||
PopochiuUtils.c.character_spoke.connect(_update_avatar)
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private ####################################################################################
|
||||
func _update_avatar(chr: PopochiuCharacter, _msg := '') -> void:
|
||||
if not rich_text_label.visible:
|
||||
return
|
||||
|
||||
left_avatar_container.modulate.a = 0.0
|
||||
left_avatar.texture = null
|
||||
right_avatar_container.modulate.a = 0.0
|
||||
right_avatar.texture = null
|
||||
|
||||
var char_pos: Vector2 = PopochiuUtils.get_screen_coords_for(chr).floor() / (
|
||||
PopochiuUtils.e.scale if PopochiuUtils.e.settings.scale_gui else Vector2.ONE
|
||||
)
|
||||
|
||||
if char_pos.x <= PopochiuUtils.e.half_width:
|
||||
left_avatar_container.modulate.a = 1.0
|
||||
left_avatar.texture = chr.get_avatar_for_emotion(chr.emotion)
|
||||
else:
|
||||
right_avatar_container.modulate.a = 1.0
|
||||
right_avatar.texture = chr.get_avatar_for_emotion(chr.emotion)
|
||||
|
||||
|
||||
func _set_default_size() -> void:
|
||||
pass
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://bad80j2xrbimk
|
|
@ -0,0 +1,106 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://33wmak2jumqm"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/dialog_text/dialog_portrait/dialog_portrait.gd" id="1_ejue5"]
|
||||
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="1_x1xka"]
|
||||
[ext_resource type="Texture2D" uid="uid://h156lkhxk5tl" path="res://addons/popochiu/engine/objects/gui/components/dialog_text/images/ico_continue.png" id="4_lqu2o"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_8fbbc"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_mjjs7"]
|
||||
content_margin_left = 4.0
|
||||
content_margin_top = 2.0
|
||||
content_margin_right = 4.0
|
||||
content_margin_bottom = 2.0
|
||||
bg_color = Color(0, 0, 0, 0.705882)
|
||||
|
||||
[node name="DialogPortrait" 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_x1xka")
|
||||
script = ExtResource("1_ejue5")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 12
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -48.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
mouse_filter = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxEmpty_8fbbc")
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer"]
|
||||
layout_mode = 2
|
||||
mouse_filter = 2
|
||||
theme_override_constants/separation = 2
|
||||
|
||||
[node name="LeftAvatarContainer" type="PanelContainer" parent="PanelContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="LeftAvatar" type="TextureRect" parent="PanelContainer/HBoxContainer/LeftAvatarContainer"]
|
||||
unique_name_in_owner = true
|
||||
texture_filter = 1
|
||||
custom_minimum_size = Vector2(48, 48)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
mouse_filter = 2
|
||||
stretch_mode = 3
|
||||
|
||||
[node name="TextContainer" type="PanelContainer" parent="PanelContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
mouse_filter = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_mjjs7")
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="PanelContainer/HBoxContainer/TextContainer"]
|
||||
unique_name_in_owner = true
|
||||
clip_contents = false
|
||||
custom_minimum_size = Vector2(16, 16)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
mouse_filter = 2
|
||||
bbcode_enabled = true
|
||||
text = "A [shake]portrait[/shake] dialog text."
|
||||
scroll_active = false
|
||||
meta_underlined = false
|
||||
|
||||
[node name="ContinueIcon" type="TextureProgressBar" parent="PanelContainer/HBoxContainer/TextContainer/RichTextLabel"]
|
||||
unique_name_in_owner = true
|
||||
texture_filter = 1
|
||||
layout_mode = 1
|
||||
anchors_preset = 3
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -16.0
|
||||
offset_top = -16.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
mouse_filter = 2
|
||||
value = 100.0
|
||||
fill_mode = 2
|
||||
texture_progress = ExtResource("4_lqu2o")
|
||||
|
||||
[node name="RightAvatarContainer" type="PanelContainer" parent="PanelContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="RightAvatar" type="TextureRect" parent="PanelContainer/HBoxContainer/RightAvatarContainer"]
|
||||
unique_name_in_owner = true
|
||||
texture_filter = 1
|
||||
custom_minimum_size = Vector2(48, 48)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
mouse_filter = 2
|
||||
stretch_mode = 3
|
|
@ -0,0 +1,301 @@
|
|||
class_name PopochiuDialogText
|
||||
extends Control
|
||||
## Show dialogue texts char by char using a [RichTextLabel].
|
||||
##
|
||||
## An invisible [Label] is used to calculate the width of the [RichTextLabel] node.
|
||||
|
||||
signal animation_finished
|
||||
signal text_show_started
|
||||
signal text_show_finished
|
||||
|
||||
const DFLT_SIZE := "dflt_size"
|
||||
const DFLT_POSITION := "dflt_position"
|
||||
|
||||
@export var wrap_width := 200.0
|
||||
@export var limit_margin := 4.0
|
||||
|
||||
var tween: Tween = null
|
||||
var continue_icon_tween: Tween = null
|
||||
|
||||
var _secs_per_character := 1.0
|
||||
var _is_waiting_input := false
|
||||
var _auto_continue := false
|
||||
var _dialog_pos := Vector2.ZERO
|
||||
var _x_limit := 0.0
|
||||
var _y_limit := 0.0
|
||||
|
||||
@onready var rich_text_label: RichTextLabel = %RichTextLabel
|
||||
@onready var continue_icon: TextureProgressBar = %ContinueIcon
|
||||
@onready var continue_icon_size := continue_icon.texture_progress.get_size()
|
||||
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _ready() -> void:
|
||||
# Set the default values
|
||||
rich_text_label.text = ""
|
||||
|
||||
set_meta(DFLT_SIZE, rich_text_label.size)
|
||||
set_meta(DFLT_POSITION, rich_text_label.position)
|
||||
|
||||
modulate.a = 0.0
|
||||
_secs_per_character = PopochiuUtils.e.text_speed
|
||||
_x_limit = PopochiuUtils.e.width / (
|
||||
PopochiuUtils.e.scale.x if PopochiuUtils.e.settings.scale_gui else 1.0
|
||||
)
|
||||
_y_limit = PopochiuUtils.e.height / (
|
||||
PopochiuUtils.e.scale.y if PopochiuUtils.e.settings.scale_gui else 1.0
|
||||
)
|
||||
|
||||
# Connect to singletons events
|
||||
PopochiuUtils.e.text_speed_changed.connect(change_speed)
|
||||
PopochiuUtils.c.character_spoke.connect(_show_dialogue)
|
||||
|
||||
continue_icon.hide()
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if (
|
||||
not PopochiuUtils.get_click_or_touch_index(event) in [MOUSE_BUTTON_LEFT, MOUSE_BUTTON_RIGHT]
|
||||
or modulate.a == 0.0
|
||||
):
|
||||
return
|
||||
|
||||
accept_event()
|
||||
if rich_text_label.visible_ratio == 1.0:
|
||||
disappear()
|
||||
else:
|
||||
stop()
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public #####################################################################################
|
||||
func play_text(props: Dictionary) -> void:
|
||||
var msg: String = PopochiuUtils.e.get_text(props.text)
|
||||
_is_waiting_input = false
|
||||
_dialog_pos = props.position
|
||||
|
||||
if PopochiuConfig.should_talk_gibberish():
|
||||
msg = PopochiuUtils.d.create_gibberish(msg)
|
||||
|
||||
# Call the virtual method that modifies the size of the RichTextLabel in case the dialog style
|
||||
# requires it.
|
||||
await _modify_size(msg, props.position)
|
||||
|
||||
# Assign the text and align mode
|
||||
msg = "[color=%s]%s[/color]" % [props.color.to_html(), msg]
|
||||
_append_text(msg, props)
|
||||
|
||||
if _secs_per_character > 0.0:
|
||||
# The text will appear with an animation
|
||||
if is_instance_valid(tween) and tween.is_running():
|
||||
tween.kill()
|
||||
|
||||
tween = create_tween()
|
||||
tween.tween_property(
|
||||
rich_text_label, "visible_ratio",
|
||||
1,
|
||||
_secs_per_character * rich_text_label.get_total_character_count()
|
||||
).from(0.0)
|
||||
tween.finished.connect(_wait_input)
|
||||
else:
|
||||
_wait_input()
|
||||
|
||||
modulate.a = 1.0
|
||||
|
||||
|
||||
func stop() ->void:
|
||||
if modulate.a == 0.0:
|
||||
return
|
||||
|
||||
if _is_waiting_input:
|
||||
_notify_completion()
|
||||
else:
|
||||
# Skip tweens
|
||||
if is_instance_valid(tween) and tween.is_running():
|
||||
tween.kill()
|
||||
|
||||
rich_text_label.visible_ratio = 1.0
|
||||
_wait_input()
|
||||
|
||||
|
||||
func disappear() -> void:
|
||||
if modulate.a == 0.0: return
|
||||
|
||||
_auto_continue = false
|
||||
modulate.a = 0.0
|
||||
_is_waiting_input = false
|
||||
|
||||
if is_instance_valid(tween) and tween.is_running():
|
||||
tween.kill()
|
||||
|
||||
rich_text_label.clear()
|
||||
rich_text_label.text = ""
|
||||
_set_default_size()
|
||||
|
||||
continue_icon.hide()
|
||||
continue_icon.modulate.a = 1.0
|
||||
|
||||
if is_instance_valid(continue_icon_tween) and continue_icon_tween.is_running():
|
||||
continue_icon_tween.kill()
|
||||
|
||||
set_process_input(false)
|
||||
text_show_finished.emit()
|
||||
PopochiuUtils.g.dialog_line_finished.emit()
|
||||
|
||||
|
||||
func change_speed() -> void:
|
||||
_secs_per_character = PopochiuUtils.e.text_speed
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private ####################################################################################
|
||||
func _show_dialogue(chr: PopochiuCharacter, msg := "") -> void:
|
||||
if not visible: return
|
||||
|
||||
play_text({
|
||||
text = msg,
|
||||
color = chr.text_color,
|
||||
position = PopochiuUtils.get_screen_coords_for(chr, chr.dialog_pos).floor() / (
|
||||
PopochiuUtils.e.scale if PopochiuUtils.e.settings.scale_gui else Vector2.ONE
|
||||
),
|
||||
})
|
||||
|
||||
PopochiuUtils.g.dialog_line_started.emit()
|
||||
|
||||
set_process_input(true)
|
||||
text_show_started.emit()
|
||||
|
||||
|
||||
func _modify_size(_msg: String, _target_position: Vector2) -> void:
|
||||
await get_tree().process_frame
|
||||
|
||||
|
||||
## Creates a RichTextLabel to calculate the resulting size of this node once the whole text is shown.
|
||||
func _calculate_size(msg: String) -> Vector2:
|
||||
var rt := RichTextLabel.new()
|
||||
rt.add_theme_font_override("normal_font", get_theme_font("normal_font"))
|
||||
rt.bbcode_enabled = true
|
||||
rt.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
rt.text = msg
|
||||
rt.size = get_meta(DFLT_SIZE)
|
||||
rich_text_label.add_child(rt)
|
||||
|
||||
# Create a Label to check if the text exceeds the wrap_width
|
||||
var lbl := Label.new()
|
||||
lbl.add_theme_font_override("normal_font", get_theme_font("normal_font"))
|
||||
|
||||
_set_default_label_size(lbl)
|
||||
|
||||
lbl.text = rt.get_parsed_text()
|
||||
rich_text_label.add_child(lbl)
|
||||
|
||||
rt.clear()
|
||||
rt.text = ""
|
||||
|
||||
await get_tree().process_frame
|
||||
|
||||
var _size := lbl.size
|
||||
|
||||
if _size.x > wrap_width:
|
||||
# This node will have the width of the wrap_width
|
||||
_size.x = wrap_width
|
||||
rt.fit_content = true
|
||||
rt.size.x = _size.x
|
||||
rt.text = msg
|
||||
|
||||
await get_tree().process_frame
|
||||
|
||||
_size = rt.size
|
||||
else:
|
||||
# This node will have the width of the text
|
||||
_size.y = get_meta(DFLT_SIZE).y
|
||||
|
||||
var characters_count := lbl.get_total_character_count()
|
||||
|
||||
lbl.free()
|
||||
rt.free()
|
||||
|
||||
return _size
|
||||
|
||||
|
||||
func _set_default_label_size(lbl: Label) -> void:
|
||||
lbl.size = get_meta(DFLT_SIZE)
|
||||
|
||||
|
||||
func _append_text(msg: String, _props: Dictionary) -> void:
|
||||
rich_text_label.append_text(msg)
|
||||
|
||||
|
||||
func _wait_input() -> void:
|
||||
_is_waiting_input = true
|
||||
|
||||
if is_instance_valid(tween) and tween.finished.is_connected(_wait_input):
|
||||
tween.finished.disconnect(_wait_input)
|
||||
|
||||
if PopochiuUtils.e.auto_continue_after >= 0.0:
|
||||
_auto_continue = true
|
||||
await get_tree().create_timer(PopochiuUtils.e.auto_continue_after + 0.2).timeout
|
||||
|
||||
if _auto_continue:
|
||||
_continue(true)
|
||||
else:
|
||||
_show_icon()
|
||||
|
||||
|
||||
func _show_icon() -> void:
|
||||
if is_instance_valid(continue_icon_tween) and continue_icon_tween.is_running():
|
||||
continue_icon_tween.kill()
|
||||
|
||||
continue_icon_tween = create_tween()
|
||||
|
||||
if not PopochiuUtils.e.settings.auto_continue_text:
|
||||
# For manual continuation: make the icon jump
|
||||
continue_icon.value = 100.0
|
||||
continue_icon_tween.tween_property(
|
||||
continue_icon, "position:y", _get_icon_to_position(), 0.8
|
||||
).from(_get_icon_from_position()).set_trans(Tween.TRANS_BOUNCE).set_ease(Tween.EASE_OUT)
|
||||
continue_icon_tween.set_loops()
|
||||
else:
|
||||
# For automatic continuation: Make the icon appear as a progress bar indicating the time
|
||||
# players have to read before auto-continuing.
|
||||
continue_icon.value = 0.0
|
||||
continue_icon.position.y = size.y / 2.0
|
||||
|
||||
continue_icon_tween.tween_property(
|
||||
continue_icon, "value",
|
||||
100.0, 3.0,
|
||||
).from_current().set_ease(Tween.EASE_OUT)
|
||||
continue_icon_tween.finished.connect(_continue)
|
||||
|
||||
continue_icon_tween.pause()
|
||||
await get_tree().create_timer(0.2).timeout
|
||||
|
||||
continue_icon_tween.play()
|
||||
continue_icon.show()
|
||||
|
||||
|
||||
func _get_icon_from_position() -> float:
|
||||
return rich_text_label.size.y - continue_icon.size.y + 2.0
|
||||
|
||||
|
||||
func _get_icon_to_position() -> float:
|
||||
return rich_text_label.size.y - continue_icon.size.y - 1.0
|
||||
|
||||
|
||||
func _notify_completion() -> void:
|
||||
disappear()
|
||||
animation_finished.emit()
|
||||
|
||||
|
||||
func _continue(forced_continue := false) -> void:
|
||||
if PopochiuUtils.e.settings.auto_continue_text or forced_continue:
|
||||
disappear()
|
||||
|
||||
|
||||
func _set_default_size() -> void:
|
||||
rich_text_label.size = get_meta(DFLT_SIZE)
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://1kyr8r56atd8
|
|
@ -0,0 +1,38 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://cymfte4xe3tnw"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="1_mrmwc"]
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/dialog_text/dialog_text.gd" id="2_adpg7"]
|
||||
[ext_resource type="Texture2D" uid="uid://h156lkhxk5tl" path="res://addons/popochiu/engine/objects/gui/components/dialog_text/images/ico_continue.png" id="3_fqlmr"]
|
||||
|
||||
[node name="DialogText" 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_mrmwc")
|
||||
script = ExtResource("2_adpg7")
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 0
|
||||
offset_right = 74.0
|
||||
offset_bottom = 12.0
|
||||
text = "Dialog text"
|
||||
fit_content = true
|
||||
|
||||
[node name="ContinueIcon" type="TextureProgressBar" parent="RichTextLabel"]
|
||||
unique_name_in_owner = true
|
||||
texture_filter = 1
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_right = 16.0
|
||||
offset_bottom = 16.0
|
||||
grow_horizontal = 0
|
||||
value = 100.0
|
||||
fill_mode = 2
|
||||
texture_progress = ExtResource("3_fqlmr")
|
After Width: | Height: | Size: 173 B |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://h156lkhxk5tl"
|
||||
path="res://.godot/imported/ico_continue.png-1c56d7b39fdf03dafd5aacca996d24e0.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/popochiu/engine/objects/gui/components/dialog_text/images/ico_continue.png"
|
||||
dest_files=["res://.godot/imported/ico_continue.png-1c56d7b39fdf03dafd5aacca996d24e0.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
|
@ -0,0 +1,39 @@
|
|||
extends Control
|
||||
class_name PopochiuHoverText
|
||||
|
||||
@export var hide_during_dialogs := false
|
||||
|
||||
@onready var label: RichTextLabel = $RichTextLabel
|
||||
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _ready() -> void:
|
||||
label.text = ""
|
||||
|
||||
# Connect to autoloads' signals
|
||||
PopochiuUtils.g.hover_text_shown.connect(_show_text)
|
||||
PopochiuUtils.g.dialog_line_started.connect(_on_dialog_line_started)
|
||||
PopochiuUtils.g.dialog_line_finished.connect(_on_dialog_line_finished)
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Virtual ####################################################################################
|
||||
func _show_text(txt := "") -> void:
|
||||
label.text = "[center]%s[/center]" % txt
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private ####################################################################################
|
||||
func _on_dialog_line_started() -> void:
|
||||
if hide_during_dialogs:
|
||||
hide()
|
||||
|
||||
|
||||
func _on_dialog_line_finished() -> void:
|
||||
if hide_during_dialogs:
|
||||
show()
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://cb8ngs7ei1rao
|
|
@ -0,0 +1,29 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://esorelppu4hw"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="1_s7kd8"]
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/hover_text/hover_text.gd" id="2_r2ckj"]
|
||||
|
||||
[node name="HoverText" 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_s7kd8")
|
||||
script = ExtResource("2_r2ckj")
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
offset_bottom = 12.0
|
||||
grow_horizontal = 2
|
||||
mouse_filter = 2
|
||||
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
|
||||
theme_override_constants/outline_size = 4
|
||||
bbcode_enabled = true
|
||||
text = "[center]text for hovered objects[/center]"
|
||||
fit_content = true
|
||||
scroll_active = false
|
|
@ -0,0 +1,183 @@
|
|||
extends Control
|
||||
|
||||
@export var always_visible := false
|
||||
@export var hide_when_gui_is_blocked := false
|
||||
## Defines the height in pixels of the zone where moving the mouse in the top of the screen will
|
||||
## make the bar to show. Note: This value will be affected by the Experimental Scale GUI checkbox
|
||||
## in Project Settings > Popochiu > GUI.
|
||||
@export var input_zone_height := 4
|
||||
|
||||
var is_disabled := false
|
||||
var tween: Tween = null
|
||||
|
||||
var _is_hidden := true
|
||||
|
||||
@onready var panel_container: PanelContainer = %PanelContainer
|
||||
@onready var box: Container = %Box
|
||||
@onready var hidden_y := panel_container.position.y - panel_container.size.y
|
||||
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _ready():
|
||||
if not always_visible:
|
||||
panel_container.position.y = hidden_y
|
||||
|
||||
# Connect to singletons signals
|
||||
PopochiuUtils.g.blocked.connect(_on_gui_blocked)
|
||||
PopochiuUtils.g.unblocked.connect(_on_gui_unblocked)
|
||||
PopochiuUtils.i.item_added.connect(_add_item)
|
||||
PopochiuUtils.i.item_removed.connect(_remove_item)
|
||||
PopochiuUtils.i.item_replaced.connect(_replace_item)
|
||||
PopochiuUtils.i.inventory_show_requested.connect(_show_and_hide)
|
||||
PopochiuUtils.i.inventory_hide_requested.connect(_close)
|
||||
|
||||
# Check if there are already items in the inventory (set manually in the scene)
|
||||
for ii in box.get_children():
|
||||
if ii is PopochiuInventoryItem:
|
||||
ii.in_inventory = true
|
||||
ii.selected.connect(_change_cursor)
|
||||
|
||||
set_process_input(not always_visible)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if not event is InputEventMouseMotion: return
|
||||
|
||||
var rect := panel_container.get_rect()
|
||||
rect.size += Vector2(0.0, input_zone_height)
|
||||
if PopochiuUtils.e.settings.scale_gui:
|
||||
rect = Rect2(
|
||||
panel_container.get_rect().position * PopochiuUtils.e.scale,
|
||||
panel_container.get_rect().size * PopochiuUtils.e.scale
|
||||
)
|
||||
|
||||
if _is_hidden and rect.has_point(get_global_mouse_position()):
|
||||
_open()
|
||||
elif not _is_hidden and not rect.has_point(get_global_mouse_position()):
|
||||
_close()
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private ####################################################################################
|
||||
func _open() -> void:
|
||||
if always_visible: return
|
||||
if not is_disabled and panel_container.position.y != hidden_y: return
|
||||
|
||||
if is_instance_valid(tween) and tween.is_running():
|
||||
tween.kill()
|
||||
|
||||
tween = create_tween().set_trans(Tween.TRANS_EXPO).set_ease(Tween.EASE_OUT)
|
||||
tween.tween_property(
|
||||
panel_container, "position:y", 0.0, 0.5
|
||||
).from(hidden_y if not is_disabled else panel_container.position.y)
|
||||
|
||||
_is_hidden = false
|
||||
|
||||
|
||||
func _close() -> void:
|
||||
if always_visible: return
|
||||
await get_tree().process_frame
|
||||
|
||||
if is_instance_valid(tween) and tween.is_running():
|
||||
tween.kill()
|
||||
|
||||
tween = create_tween()
|
||||
tween.tween_property(
|
||||
panel_container, "position:y",
|
||||
hidden_y if not is_disabled else hidden_y - 3.5,
|
||||
0.2
|
||||
).from(0.0).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN)
|
||||
|
||||
_is_hidden = true
|
||||
|
||||
|
||||
func _on_tween_finished() -> void:
|
||||
_is_hidden = panel_container.position.y == hidden_y
|
||||
|
||||
|
||||
func _change_cursor(item: PopochiuInventoryItem) -> void:
|
||||
PopochiuUtils.i.set_active_item(item)
|
||||
|
||||
|
||||
func _on_gui_blocked() -> void:
|
||||
set_process_input(false)
|
||||
|
||||
if hide_when_gui_is_blocked:
|
||||
hide()
|
||||
|
||||
|
||||
func _on_gui_unblocked() -> void:
|
||||
set_process_input(true)
|
||||
|
||||
if hide_when_gui_is_blocked:
|
||||
show()
|
||||
|
||||
|
||||
func _add_item(item: PopochiuInventoryItem, animate := true) -> void:
|
||||
box.add_child(item)
|
||||
|
||||
item.expand_mode = TextureRect.EXPAND_FIT_WIDTH
|
||||
item.custom_minimum_size.y = box.size.y
|
||||
|
||||
item.selected.connect(_change_cursor)
|
||||
|
||||
if not always_visible and animate:
|
||||
# Show the inventory for a while and hide after a couple of seconds so players can see the
|
||||
# item being added to the inventory
|
||||
set_process_input(false)
|
||||
|
||||
_open()
|
||||
await get_tree().create_timer(2.0).timeout
|
||||
|
||||
# The mouse not being on the inventory can close the inventory prior to the 2 seconds
|
||||
# expiring. This check fixes this. Bug 350.
|
||||
if not _is_hidden:
|
||||
_close()
|
||||
await get_tree().create_timer(0.5).timeout
|
||||
|
||||
set_process_input(true)
|
||||
else:
|
||||
await get_tree().process_frame
|
||||
|
||||
PopochiuUtils.i.item_add_done.emit(item)
|
||||
|
||||
|
||||
func _remove_item(item: PopochiuInventoryItem, animate := true) -> void:
|
||||
item.selected.disconnect(_change_cursor)
|
||||
box.remove_child(item)
|
||||
|
||||
if not always_visible:
|
||||
PopochiuUtils.cursor.show_cursor()
|
||||
PopochiuUtils.g.show_hover_text()
|
||||
|
||||
if animate:
|
||||
_close()
|
||||
await get_tree().create_timer(1.0).timeout
|
||||
|
||||
await get_tree().process_frame
|
||||
|
||||
PopochiuUtils.i.item_remove_done.emit(item)
|
||||
|
||||
|
||||
func _replace_item(item: PopochiuInventoryItem, new_item: PopochiuInventoryItem) -> void:
|
||||
item.replace_by(new_item)
|
||||
await get_tree().process_frame
|
||||
|
||||
PopochiuUtils.i.item_replace_done.emit()
|
||||
|
||||
|
||||
func _show_and_hide(time := 1.0) -> void:
|
||||
set_process_input(false)
|
||||
_open()
|
||||
await tween.finished
|
||||
await PopochiuUtils.e.wait(time)
|
||||
|
||||
_close()
|
||||
await tween.finished
|
||||
|
||||
set_process_input(true)
|
||||
PopochiuUtils.i.inventory_shown.emit()
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://cnso60yytp7ot
|
|
@ -0,0 +1,27 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://ciar5j7qm85bc"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/inventory_bar/inventory_bar.gd" id="1"]
|
||||
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="1_aynoo"]
|
||||
|
||||
[node name="InventoryBar" 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_aynoo")
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
texture_filter = 1
|
||||
layout_mode = 0
|
||||
offset_right = 36.0
|
||||
offset_bottom = 24.0
|
||||
|
||||
[node name="Box" type="HBoxContainer" parent="PanelContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
mouse_filter = 2
|
After Width: | Height: | Size: 249 B |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://s4phlorab5ds"
|
||||
path="res://.godot/imported/inventory_grid_down_button.png-ffac1afa54860747ab14c6a1f8220bae.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/popochiu/engine/objects/gui/components/inventory_grid/images/inventory_grid_down_button.png"
|
||||
dest_files=["res://.godot/imported/inventory_grid_down_button.png-ffac1afa54860747ab14c6a1f8220bae.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
After Width: | Height: | Size: 246 B |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dfa511cxg31g5"
|
||||
path="res://.godot/imported/inventory_grid_up_button.png-dd40c7fcb22a7dfc4741c7c1c2d05d54.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/popochiu/engine/objects/gui/components/inventory_grid/images/inventory_grid_up_button.png"
|
||||
dest_files=["res://.godot/imported/inventory_grid_up_button.png-dd40c7fcb22a7dfc4741c7c1c2d05d54.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
|
@ -0,0 +1,226 @@
|
|||
@tool
|
||||
class_name PopochiuInventoryGrid
|
||||
extends HBoxContainer
|
||||
|
||||
const EMPTY_SLOT := "[Empty Slot]00"
|
||||
|
||||
@export var slot_scene: PackedScene = null : set = set_slot_scene
|
||||
@export var columns := 4 : set = set_columns
|
||||
@export var visible_rows := 2 : set = set_visible_rows
|
||||
@export var number_of_slots := 16 : set = set_number_of_slots
|
||||
@export var h_separation := 0 : set = set_h_separation
|
||||
@export var v_separation := 0 : set = set_v_separation
|
||||
@export var show_arrows := true : set = set_show_arrows
|
||||
@export var scroll_with_mouse_wheel := true
|
||||
|
||||
var rows := 0
|
||||
var max_scroll := 0.0
|
||||
|
||||
var slot_size: float = 0.0
|
||||
|
||||
@onready var scroll_container: ScrollContainer = $ScrollContainer
|
||||
@onready var box: GridContainer = %Box
|
||||
@onready var scroll_buttons: VBoxContainer = $ScrollButtons
|
||||
@onready var up: TextureButton = %Up
|
||||
@onready var down: TextureButton = %Down
|
||||
@onready var gap_size: int = box.get_theme_constant("v_separation")
|
||||
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _ready():
|
||||
if Engine.is_editor_hint():
|
||||
_update_box()
|
||||
return
|
||||
|
||||
scroll_container.mouse_filter = (
|
||||
Control.MOUSE_FILTER_PASS if scroll_with_mouse_wheel else Control.MOUSE_FILTER_IGNORE
|
||||
)
|
||||
|
||||
_update_box()
|
||||
_calculate_rows_and_scroll()
|
||||
# _check_starting_items()
|
||||
|
||||
# Connect to child signals
|
||||
up.pressed.connect(_on_up_pressed)
|
||||
down.pressed.connect(_on_down_pressed)
|
||||
scroll_container.get_v_scroll_bar().value_changed.connect(_on_scroll)
|
||||
|
||||
# Connect to singletons signals
|
||||
PopochiuUtils.i.item_added.connect(_add_item)
|
||||
PopochiuUtils.i.item_removed.connect(_remove_item)
|
||||
PopochiuUtils.i.item_replaced.connect(_replace_item)
|
||||
|
||||
_check_scroll_buttons()
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetGet #####################################################################################
|
||||
func set_visible_rows(value: int) -> void:
|
||||
visible_rows = value
|
||||
_update_box()
|
||||
|
||||
|
||||
func set_columns(value: int) -> void:
|
||||
columns = value
|
||||
_update_box()
|
||||
|
||||
|
||||
func set_slot_scene(value: PackedScene) -> void:
|
||||
slot_scene = value
|
||||
_update_box()
|
||||
|
||||
|
||||
func set_number_of_slots(value: int) -> void:
|
||||
number_of_slots = value
|
||||
_update_box()
|
||||
|
||||
|
||||
func set_h_separation(value: int) -> void:
|
||||
h_separation = value
|
||||
_update_box()
|
||||
|
||||
|
||||
func set_v_separation(value: int) -> void:
|
||||
v_separation = value
|
||||
_update_box()
|
||||
|
||||
|
||||
func set_show_arrows(value: bool) -> void:
|
||||
show_arrows = value
|
||||
|
||||
if is_instance_valid(scroll_buttons):
|
||||
scroll_buttons.visible = value
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private ####################################################################################
|
||||
func _update_box() -> void:
|
||||
if not is_instance_valid(box): return
|
||||
|
||||
box.columns = columns
|
||||
box.add_theme_constant_override("h_separation", h_separation)
|
||||
box.add_theme_constant_override("v_separation", v_separation)
|
||||
|
||||
# Fix: remove the child immediately (instead of calling queue_free()), and do not await for
|
||||
# a process frame cause it can cause an issue when adding items marked as "Start with it".
|
||||
for child in box.get_children():
|
||||
child.free()
|
||||
|
||||
for idx in number_of_slots:
|
||||
var slot := slot_scene.instantiate()
|
||||
box.add_child(slot)
|
||||
|
||||
slot.name = EMPTY_SLOT
|
||||
slot_size = slot.size.y
|
||||
|
||||
scroll_container.custom_minimum_size = Vector2(
|
||||
(columns * (slot_size + h_separation)) - h_separation,
|
||||
(visible_rows * (slot_size + v_separation)) - v_separation
|
||||
)
|
||||
|
||||
|
||||
## Calculate the number of rows in the box and the max scroll
|
||||
func _calculate_rows_and_scroll() -> void:
|
||||
var visible_slots := 0
|
||||
for slot in box.get_children():
|
||||
if slot.visible:
|
||||
visible_slots += 1
|
||||
@warning_ignore("integer_division")
|
||||
rows = visible_slots / box.columns
|
||||
max_scroll = ((slot_size + gap_size) * int(rows / 2))
|
||||
|
||||
|
||||
## Check if there are inventory items in the scene tree and add them to the
|
||||
## Inventory interface class (I).
|
||||
func _check_starting_items() -> void:
|
||||
for slot in box.get_children():
|
||||
if (slot.get_child_count() > 0
|
||||
and slot.get_child(0) is PopochiuInventoryItem
|
||||
):
|
||||
PopochiuUtils.i.items.append(slot.get_child(0).script_name)
|
||||
slot.name = slot.get_child(0).script_name
|
||||
else:
|
||||
slot.name = EMPTY_SLOT
|
||||
|
||||
|
||||
func _on_up_pressed() -> void:
|
||||
scroll_container.scroll_vertical -= (slot_size + gap_size) + 1
|
||||
_check_scroll_buttons()
|
||||
|
||||
|
||||
func _on_down_pressed() -> void:
|
||||
scroll_container.scroll_vertical += (slot_size + gap_size) + 1
|
||||
_check_scroll_buttons()
|
||||
|
||||
|
||||
func _add_item(item: PopochiuInventoryItem, _animate := true) -> void:
|
||||
var slot := box.get_child(PopochiuUtils.i.items.size() - 1)
|
||||
slot.name = "[%s]" % item.script_name
|
||||
slot.add_child(item)
|
||||
|
||||
item.expand_mode = TextureRect.EXPAND_FIT_WIDTH
|
||||
|
||||
if slot.has_method("get_content_height"):
|
||||
item.custom_minimum_size.y = slot.get_content_height()
|
||||
else:
|
||||
item.custom_minimum_size.y = slot.size.y
|
||||
|
||||
box.set_meta(item.script_name, slot)
|
||||
|
||||
item.selected.connect(_change_cursor)
|
||||
_check_scroll_buttons()
|
||||
|
||||
# Common call to all inventories. Should be in the class from where inventory panels will
|
||||
# inherit from
|
||||
await get_tree().process_frame
|
||||
|
||||
PopochiuUtils.i.item_add_done.emit(item)
|
||||
|
||||
|
||||
func _remove_item(item: PopochiuInventoryItem, _animate := true) -> void:
|
||||
item.selected.disconnect(_change_cursor)
|
||||
|
||||
box.get_meta(item.script_name).remove_child(item)
|
||||
box.get_meta(item.script_name).name = EMPTY_SLOT
|
||||
|
||||
_check_scroll_buttons()
|
||||
|
||||
await get_tree().process_frame
|
||||
|
||||
PopochiuUtils.i.item_remove_done.emit(item)
|
||||
|
||||
|
||||
func _replace_item(
|
||||
item: PopochiuInventoryItem, new_item: PopochiuInventoryItem
|
||||
) -> void:
|
||||
item.replace_by(new_item)
|
||||
box.remove_meta(item.script_name)
|
||||
box.set_meta(new_item.script_name, new_item.get_parent())
|
||||
|
||||
_check_scroll_buttons()
|
||||
|
||||
await get_tree().process_frame
|
||||
|
||||
PopochiuUtils.i.item_replace_done.emit()
|
||||
|
||||
|
||||
func _change_cursor(item: PopochiuInventoryItem) -> void:
|
||||
PopochiuUtils.i.set_active_item(item)
|
||||
|
||||
|
||||
## Checks if the UP and DOWN buttons should be enabled
|
||||
func _check_scroll_buttons() -> void:
|
||||
up.disabled = scroll_container.scroll_vertical == 0
|
||||
down.disabled = (
|
||||
scroll_container.scroll_vertical >= max_scroll
|
||||
or not (PopochiuUtils.i.items.size() > box.columns * visible_rows)
|
||||
)
|
||||
|
||||
|
||||
func _on_scroll(_value: float) -> void:
|
||||
_check_scroll_buttons()
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://5iimjg0vmeqf
|
|
@ -0,0 +1,91 @@
|
|||
[gd_scene load_steps=14 format=3 uid="uid://cn2b5v8k1lseo"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/inventory_grid/inventory_grid.gd" id="1_0y5i1"]
|
||||
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="1_kaq1v"]
|
||||
[ext_resource type="Texture2D" uid="uid://dfa511cxg31g5" path="res://addons/popochiu/engine/objects/gui/components/inventory_grid/images/inventory_grid_up_button.png" id="2_6y3so"]
|
||||
[ext_resource type="PackedScene" uid="uid://db6csk6i4f3un" path="res://addons/popochiu/engine/objects/gui/components/inventory_grid/inventory_grid_slot.tscn" id="3_ma7vn"]
|
||||
[ext_resource type="Texture2D" uid="uid://s4phlorab5ds" path="res://addons/popochiu/engine/objects/gui/components/inventory_grid/images/inventory_grid_down_button.png" id="3_yoinj"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_7tbkh"]
|
||||
atlas = ExtResource("2_6y3so")
|
||||
region = Rect2(0, 0, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_yafup"]
|
||||
atlas = ExtResource("2_6y3so")
|
||||
region = Rect2(32, 0, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_8r5xk"]
|
||||
atlas = ExtResource("2_6y3so")
|
||||
region = Rect2(16, 0, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_73nr4"]
|
||||
atlas = ExtResource("2_6y3so")
|
||||
region = Rect2(48, 0, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_mcgs4"]
|
||||
atlas = ExtResource("3_yoinj")
|
||||
region = Rect2(0, 0, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kw4h2"]
|
||||
atlas = ExtResource("3_yoinj")
|
||||
region = Rect2(32, 0, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_pi25e"]
|
||||
atlas = ExtResource("3_yoinj")
|
||||
region = Rect2(16, 0, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_pejpn"]
|
||||
atlas = ExtResource("3_yoinj")
|
||||
region = Rect2(48, 0, 16, 16)
|
||||
|
||||
[node name="InventoryGrid" type="HBoxContainer" groups=["popochiu_gui_component"]]
|
||||
offset_right = 152.0
|
||||
offset_bottom = 50.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
mouse_filter = 0
|
||||
theme = ExtResource("1_kaq1v")
|
||||
script = ExtResource("1_0y5i1")
|
||||
slot_scene = ExtResource("3_ma7vn")
|
||||
|
||||
[node name="ScrollButtons" type="VBoxContainer" parent="."]
|
||||
custom_minimum_size = Vector2(24, 0)
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="Up" type="TextureButton" parent="ScrollButtons"]
|
||||
texture_filter = 1
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
texture_normal = SubResource("AtlasTexture_7tbkh")
|
||||
texture_pressed = SubResource("AtlasTexture_yafup")
|
||||
texture_hover = SubResource("AtlasTexture_8r5xk")
|
||||
texture_disabled = SubResource("AtlasTexture_73nr4")
|
||||
stretch_mode = 3
|
||||
|
||||
[node name="Down" type="TextureButton" parent="ScrollButtons"]
|
||||
texture_filter = 1
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
texture_normal = SubResource("AtlasTexture_mcgs4")
|
||||
texture_pressed = SubResource("AtlasTexture_kw4h2")
|
||||
texture_hover = SubResource("AtlasTexture_pi25e")
|
||||
texture_disabled = SubResource("AtlasTexture_pejpn")
|
||||
stretch_mode = 3
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="."]
|
||||
custom_minimum_size = Vector2(100, 50)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
scroll_vertical_custom_step = 27.0
|
||||
horizontal_scroll_mode = 3
|
||||
vertical_scroll_mode = 3
|
||||
|
||||
[node name="Box" type="GridContainer" parent="ScrollContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/h_separation = 0
|
||||
theme_override_constants/v_separation = 0
|
||||
columns = 4
|
|
@ -0,0 +1,17 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://db6csk6i4f3un"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_fjc4l"]
|
||||
content_margin_left = 2.0
|
||||
content_margin_top = 2.0
|
||||
content_margin_right = 2.0
|
||||
content_margin_bottom = 2.0
|
||||
bg_color = Color(0.180392, 0.172549, 0.607843, 1)
|
||||
border_width_left = 1
|
||||
border_width_top = 1
|
||||
border_width_right = 1
|
||||
border_width_bottom = 1
|
||||
border_color = Color(1, 1, 1, 1)
|
||||
|
||||
[node name="Slot" type="PanelContainer"]
|
||||
custom_minimum_size = Vector2(31, 25)
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_fjc4l")
|
|
@ -0,0 +1,25 @@
|
|||
extends "../popochiu_popup.gd"
|
||||
|
||||
|
||||
#region Virtual ####################################################################################
|
||||
## Called when the popup is opened. At this point it is not visible yet.
|
||||
func _open() -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when the popup is closed. The node hides after calling this method.
|
||||
func _close() -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when OK is pressed.
|
||||
func _on_ok() -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when CANCEL or X (top-right corner) are pressed.
|
||||
func _on_cancel() -> void:
|
||||
pass
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://bed7ao6h80o80
|
|
@ -0,0 +1,82 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://d06okn5i6id2g"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="1_ck2qk"]
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/popups/confirmation_popup/confirmation_popup.gd" id="2_2ngwd"]
|
||||
[ext_resource type="StyleBox" uid="uid://dbajakvkltfaj" path="res://addons/popochiu/engine/objects/gui/components/popups/popochiu_popup_panel_container.tres" id="3_jqrxu"]
|
||||
[ext_resource type="Texture2D" uid="uid://cmxrewai8t2lm" path="res://addons/popochiu/engine/objects/gui/resources/images/close.png" id="3_n4smw"]
|
||||
[ext_resource type="Texture2D" uid="uid://p32i25numi5e" path="res://addons/popochiu/engine/objects/gui/resources/images/close_highlight.png" id="4_4phlw"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_x73gy"]
|
||||
|
||||
[node name="ConfirmationPopup" type="Control" groups=["popochiu_gui_popup"]]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("1_ck2qk")
|
||||
script = ExtResource("2_2ngwd")
|
||||
script_name = &"ConfirmationPopup"
|
||||
title = "Confirmation"
|
||||
|
||||
[node name="Overlay" type="PanelContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxEmpty_x73gy")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="Overlay"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
theme_override_styles/panel = ExtResource("3_jqrxu")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Overlay/PanelContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HeaderContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Title" type="Label" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Confirmation"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Close" type="TextureButton" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
|
||||
unique_name_in_owner = true
|
||||
texture_filter = 1
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
texture_normal = ExtResource("3_n4smw")
|
||||
texture_pressed = ExtResource("4_4phlw")
|
||||
texture_hover = ExtResource("4_4phlw")
|
||||
|
||||
[node name="Question" type="Label" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Yes or No?"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
autowrap_mode = 3
|
||||
|
||||
[node name="FooterContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 10
|
||||
alignment = 1
|
||||
|
||||
[node name="Ok" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "ok"
|
||||
|
||||
[node name="Cancel" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "cancel"
|
|
@ -0,0 +1,13 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://b6dm3xvvr7dvi"]
|
||||
|
||||
[ext_resource type="FontFile" uid="uid://dixh1egf7k2fb" path="res://addons/popochiu/engine/objects/gui/fonts/monkeyisland_1991.ttf" id="1_o6vvl"]
|
||||
|
||||
[node name="DialogLine" type="RichTextLabel"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
theme_override_fonts/normal_font = ExtResource("1_o6vvl")
|
||||
bbcode_enabled = true
|
||||
text = "Popochiu: Hi!"
|
||||
fit_content = true
|
|
@ -0,0 +1,13 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://2mnjw3qsi8hc"]
|
||||
|
||||
[ext_resource type="FontFile" uid="uid://dixh1egf7k2fb" path="res://addons/popochiu/engine/objects/gui/fonts/monkeyisland_1991.ttf" id="1_i1qxr"]
|
||||
|
||||
[node name="InteractionLine" type="RichTextLabel"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
theme_override_fonts/normal_font = ExtResource("1_i1qxr")
|
||||
bbcode_enabled = true
|
||||
text = "Player [color=edf171]click[/color] Toy car"
|
||||
fit_content = true
|
|
@ -0,0 +1,57 @@
|
|||
@tool
|
||||
extends PopochiuPopup
|
||||
|
||||
@export var dialog_line: PackedScene = null
|
||||
@export var interaction_line: PackedScene = null
|
||||
|
||||
@onready var lines_list: VBoxContainer = find_child("LinesList")
|
||||
@onready var empty: Label = %Empty
|
||||
@onready var lines_scroll: ScrollContainer = %LinesScroll
|
||||
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _ready() -> void:
|
||||
super()
|
||||
|
||||
if Engine.is_editor_hint(): return
|
||||
|
||||
for c in lines_list.get_children():
|
||||
(c as Control).queue_free()
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Virtual ####################################################################################
|
||||
func _open() -> void:
|
||||
if PopochiuUtils.e.history.is_empty():
|
||||
empty.show()
|
||||
lines_scroll.hide()
|
||||
else:
|
||||
empty.hide()
|
||||
lines_scroll.show()
|
||||
|
||||
for data in PopochiuUtils.e.history:
|
||||
var lbl: RichTextLabel
|
||||
|
||||
if data.has("character"):
|
||||
lbl = dialog_line.instantiate()
|
||||
lbl.text = "[color=%s]%s:[/color] %s" % [
|
||||
(data.character as PopochiuCharacter).text_color.to_html(false),
|
||||
(data.character as PopochiuCharacter).description,
|
||||
data.text
|
||||
]
|
||||
else:
|
||||
lbl = interaction_line.instantiate()
|
||||
lbl.text = "[color=edf171]%s[/color] [color=a9ff9f]%s[/color]" % [
|
||||
data.action, data.target
|
||||
]
|
||||
|
||||
lines_list.add_child(lbl)
|
||||
|
||||
|
||||
func _close() -> void:
|
||||
for c in lines_list.get_children():
|
||||
(c as Control).queue_free()
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://beng6nsf3gmgy
|
|
@ -0,0 +1,115 @@
|
|||
[gd_scene load_steps=12 format=3 uid="uid://dfrsiyyqncspo"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="1_ktant"]
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/popups/history_popup/history_popup.gd" id="2_bdgcw"]
|
||||
[ext_resource type="Texture2D" uid="uid://cmxrewai8t2lm" path="res://addons/popochiu/engine/objects/gui/resources/images/close.png" id="3_6f0nr"]
|
||||
[ext_resource type="PackedScene" uid="uid://b6dm3xvvr7dvi" path="res://addons/popochiu/engine/objects/gui/components/popups/history_popup/components/dialog_line.tscn" id="3_8deqt"]
|
||||
[ext_resource type="Texture2D" uid="uid://p32i25numi5e" path="res://addons/popochiu/engine/objects/gui/resources/images/close_highlight.png" id="4_e8jii"]
|
||||
[ext_resource type="PackedScene" uid="uid://2mnjw3qsi8hc" path="res://addons/popochiu/engine/objects/gui/components/popups/history_popup/components/interaction_line.tscn" id="4_ndekf"]
|
||||
[ext_resource type="StyleBox" uid="uid://dbajakvkltfaj" path="res://addons/popochiu/engine/objects/gui/components/popups/popochiu_popup_panel_container.tres" id="5_odsj4"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_xipc1"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_pm06l"]
|
||||
bg_color = Color(1, 1, 1, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_gr6a3"]
|
||||
bg_color = Color(0.768627, 0.423529, 0.443137, 1)
|
||||
border_width_left = 8
|
||||
border_color = Color(0.388235, 0.607843, 1, 1)
|
||||
|
||||
[sub_resource type="Theme" id="Theme_cqgnt"]
|
||||
VScrollBar/styles/grabber = SubResource("StyleBoxFlat_pm06l")
|
||||
VScrollBar/styles/grabber_highlight = SubResource("StyleBoxFlat_pm06l")
|
||||
VScrollBar/styles/grabber_pressed = SubResource("StyleBoxFlat_pm06l")
|
||||
VScrollBar/styles/scroll = SubResource("StyleBoxFlat_gr6a3")
|
||||
VScrollBar/styles/scroll_focus = SubResource("StyleBoxFlat_gr6a3")
|
||||
|
||||
[node name="HistoryPopup" type="Control" groups=["popochiu_gui_popup"]]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("1_ktant")
|
||||
script = ExtResource("2_bdgcw")
|
||||
dialog_line = ExtResource("3_8deqt")
|
||||
interaction_line = ExtResource("4_ndekf")
|
||||
script_name = &"HistoryPopup"
|
||||
title = "History"
|
||||
|
||||
[node name="Overlay" type="PanelContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxEmpty_xipc1")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="Overlay"]
|
||||
custom_minimum_size = Vector2(256, 144)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
theme_override_styles/panel = ExtResource("5_odsj4")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Overlay/PanelContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HeaderContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Title" type="Label" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "History"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Close" type="TextureButton" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
|
||||
unique_name_in_owner = true
|
||||
texture_filter = 1
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
texture_normal = ExtResource("3_6f0nr")
|
||||
texture_pressed = ExtResource("4_e8jii")
|
||||
texture_hover = ExtResource("4_e8jii")
|
||||
|
||||
[node name="Empty" type="Label" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
text = "Nothing to show yet"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="LinesScroll" type="ScrollContainer" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme = SubResource("Theme_cqgnt")
|
||||
|
||||
[node name="LinesList" type="VBoxContainer" parent="Overlay/PanelContainer/VBoxContainer/LinesScroll"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="FooterContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 10
|
||||
alignment = 1
|
||||
|
||||
[node name="Ok" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "ok"
|
||||
|
||||
[node name="Cancel" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "cancel"
|
|
@ -0,0 +1,139 @@
|
|||
@tool
|
||||
class_name PopochiuPopup
|
||||
extends Control
|
||||
## The base popup node used by Popochiu GUIs.
|
||||
|
||||
@export var closes_by_clicking_out := true
|
||||
@export var script_name: StringName = ""
|
||||
@export var title := "" : set = set_title
|
||||
|
||||
@onready var lbl_title: Label = %Title
|
||||
@onready var btn_ok: Button = %Ok
|
||||
@onready var btn_cancel: Button = %Cancel
|
||||
@onready var btn_close: TextureButton = %Close
|
||||
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _ready() -> void:
|
||||
if not title.is_empty():
|
||||
lbl_title.text = title
|
||||
|
||||
if Engine.is_editor_hint(): return
|
||||
|
||||
# Connect to own signals
|
||||
$Overlay.gui_input.connect(_check_click)
|
||||
|
||||
# Connect to child signals
|
||||
btn_ok.pressed.connect(on_ok_pressed)
|
||||
btn_cancel.pressed.connect(on_cancel_pressed)
|
||||
btn_close.pressed.connect(on_cancel_pressed)
|
||||
|
||||
# Connect to singleton signals
|
||||
PopochiuUtils.g.popup_requested.connect(_on_popup_requested)
|
||||
|
||||
close()
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Virtual ####################################################################################
|
||||
## Called when the popup is opened. At this point it is not visible yet.
|
||||
func _open() -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when the popup is closed. The node hides after calling this method.
|
||||
func _close() -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when OK is pressed.
|
||||
func _on_ok() -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when CANCEL or X (top-right corner) are pressed.
|
||||
func _on_cancel() -> void:
|
||||
pass
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public #####################################################################################
|
||||
## Shows the popup scaling it and blocking interactions with the graphic interface.
|
||||
func open() -> void:
|
||||
_open()
|
||||
|
||||
PopochiuUtils.g.block()
|
||||
PopochiuUtils.cursor.show_cursor("gui", true)
|
||||
# Never open a popup on top of another
|
||||
if not PopochiuUtils.e.gui.popups_stack.is_empty():
|
||||
PopochiuUtils.e.gui.popups_stack.back().hide()
|
||||
PopochiuUtils.e.gui.popups_stack.append(self)
|
||||
|
||||
show()
|
||||
|
||||
|
||||
## Closes the popup unlocking interactions with the graphic interface.
|
||||
func close() -> void:
|
||||
PopochiuUtils.e.gui.popups_stack.erase(self)
|
||||
hide()
|
||||
|
||||
if PopochiuUtils.e.gui.popups_stack.is_empty():
|
||||
PopochiuUtils.g.unblock()
|
||||
PopochiuUtils.cursor.unblock()
|
||||
else:
|
||||
# Idempotent call, no need to check the mode
|
||||
PopochiuUtils.e.gui.popups_stack.back().show()
|
||||
|
||||
_close()
|
||||
|
||||
|
||||
## Called when the OK button is pressed. It closes the popup afterwards.
|
||||
func on_ok_pressed() -> void:
|
||||
_on_ok()
|
||||
close()
|
||||
|
||||
|
||||
## Called when the CANCEL button is pressed. It closes the popup afterwards.
|
||||
func on_cancel_pressed() -> void:
|
||||
_on_cancel()
|
||||
close()
|
||||
|
||||
|
||||
## Called when the X (top-right corner) button is pressed. It closes the popup
|
||||
## afterwards.
|
||||
func on_close_pressed() -> void:
|
||||
_on_cancel()
|
||||
close()
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetGet #####################################################################################
|
||||
func set_title(value: String) -> void:
|
||||
title = value
|
||||
|
||||
if is_instance_valid(lbl_title):
|
||||
lbl_title.text = title
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private ####################################################################################
|
||||
## Checks if the overlay area of the popup was clicked in order to close it.
|
||||
func _check_click(event: InputEvent) -> void:
|
||||
if (
|
||||
PopochiuUtils.get_click_or_touch_index(event) == MOUSE_BUTTON_LEFT
|
||||
and closes_by_clicking_out
|
||||
):
|
||||
_on_cancel()
|
||||
close()
|
||||
|
||||
|
||||
func _on_popup_requested(popup_script_name: StringName) -> void:
|
||||
if popup_script_name == script_name:
|
||||
open()
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://bmlrdxcv748wb
|
|
@ -0,0 +1,69 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://c51xplyeuk787"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="1_4hfpy"]
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/popups/popochiu_popup.gd" id="2_yuv82"]
|
||||
[ext_resource type="Texture2D" uid="uid://cmxrewai8t2lm" path="res://addons/popochiu/engine/objects/gui/resources/images/close.png" id="3_5rk5h"]
|
||||
[ext_resource type="StyleBox" uid="uid://dbajakvkltfaj" path="res://addons/popochiu/engine/objects/gui/components/popups/popochiu_popup_panel_container.tres" id="3_co4j2"]
|
||||
[ext_resource type="Texture2D" uid="uid://p32i25numi5e" path="res://addons/popochiu/engine/objects/gui/resources/images/close_highlight.png" id="4_4odj8"]
|
||||
|
||||
[node name="PopochiuPopup" type="Control" groups=["popochiu_gui_popup"]]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("1_4hfpy")
|
||||
script = ExtResource("2_yuv82")
|
||||
|
||||
[node name="Overlay" type="PanelContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="Overlay"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
theme_override_styles/panel = ExtResource("3_co4j2")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Overlay/PanelContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HeaderContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Title" type="Label" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Title"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Close" type="TextureButton" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
|
||||
unique_name_in_owner = true
|
||||
texture_filter = 1
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
texture_normal = ExtResource("3_5rk5h")
|
||||
texture_pressed = ExtResource("4_4odj8")
|
||||
texture_hover = ExtResource("4_4odj8")
|
||||
|
||||
[node name="FooterContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 10
|
||||
alignment = 1
|
||||
|
||||
[node name="Ok" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "ok"
|
||||
|
||||
[node name="Cancel" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "cancel"
|
|
@ -0,0 +1,12 @@
|
|||
[gd_resource type="StyleBoxFlat" format=3 uid="uid://dbajakvkltfaj"]
|
||||
|
||||
[resource]
|
||||
content_margin_left = 4.0
|
||||
content_margin_top = 2.0
|
||||
content_margin_right = 4.0
|
||||
content_margin_bottom = 2.0
|
||||
bg_color = Color(0, 0, 0, 0.705882)
|
||||
expand_margin_left = 2.0
|
||||
expand_margin_top = 2.0
|
||||
expand_margin_right = 2.0
|
||||
expand_margin_bottom = 2.0
|
|
@ -0,0 +1,26 @@
|
|||
@tool
|
||||
extends PopochiuPopup
|
||||
|
||||
|
||||
#region Virtual ####################################################################################
|
||||
## Called when the popup is opened. At this point it is not visible yet.
|
||||
func _open() -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when the popup is closed. The node hides after calling this method.
|
||||
func _close() -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when OK is pressed.
|
||||
func _on_ok() -> void:
|
||||
get_tree().quit()
|
||||
|
||||
|
||||
## Called when CANCEL or X (top-right corner) are pressed.
|
||||
func _on_cancel() -> void:
|
||||
pass
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://bqvdywnh28ces
|
|
@ -0,0 +1,84 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://bnjo044fkdcq7"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="1_3nwvu"]
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/popups/quit_popup/quit_popup.gd" id="2_nkwwk"]
|
||||
[ext_resource type="StyleBox" uid="uid://dbajakvkltfaj" path="res://addons/popochiu/engine/objects/gui/components/popups/popochiu_popup_panel_container.tres" id="3_828u5"]
|
||||
[ext_resource type="Texture2D" uid="uid://cmxrewai8t2lm" path="res://addons/popochiu/engine/objects/gui/resources/images/close.png" id="3_r2fp8"]
|
||||
[ext_resource type="Texture2D" uid="uid://p32i25numi5e" path="res://addons/popochiu/engine/objects/gui/resources/images/close_highlight.png" id="4_mra7q"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_il3mr"]
|
||||
|
||||
[node name="QuitPopup" type="Control" groups=["popochiu_gui_popup"]]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("1_3nwvu")
|
||||
script = ExtResource("2_nkwwk")
|
||||
script_name = &"QuitPopup"
|
||||
title = "Quit game"
|
||||
|
||||
[node name="Overlay" type="PanelContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxEmpty_il3mr")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="Overlay"]
|
||||
custom_minimum_size = Vector2(256, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
theme_override_styles/panel = ExtResource("3_828u5")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Overlay/PanelContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HeaderContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Title" type="Label" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Quit game"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Close" type="TextureButton" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
|
||||
unique_name_in_owner = true
|
||||
texture_filter = 1
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
texture_normal = ExtResource("3_r2fp8")
|
||||
texture_pressed = ExtResource("4_mra7q")
|
||||
texture_hover = ExtResource("4_mra7q")
|
||||
|
||||
[node name="Question" type="Label" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Are you sure you want to quit?"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
autowrap_mode = 3
|
||||
|
||||
[node name="FooterContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 10
|
||||
alignment = 1
|
||||
|
||||
[node name="Ok" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "OK"
|
||||
|
||||
[node name="Cancel" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Cancel
|
||||
"
|
|
@ -0,0 +1,134 @@
|
|||
@tool
|
||||
extends PopochiuPopup
|
||||
|
||||
signal slot_selected
|
||||
|
||||
const SELECTION_COLOR := Color("edf171")
|
||||
const OVERWRITE_COLOR := Color("c46c71")
|
||||
|
||||
var _current_slot: Button = null
|
||||
var _slot_name := ""
|
||||
var _prev_text := ""
|
||||
var _slot := 0
|
||||
|
||||
@onready var slots: VBoxContainer = %Slots
|
||||
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _ready() -> void:
|
||||
super()
|
||||
|
||||
if Engine.is_editor_hint(): return
|
||||
|
||||
btn_ok.disabled = true
|
||||
|
||||
var saves: Dictionary = PopochiuUtils.e.get_saves_descriptions()
|
||||
|
||||
for btn: Button in slots.get_children():
|
||||
btn.set_meta("has_save", false)
|
||||
|
||||
if saves.has(btn.get_index() + 1):
|
||||
btn.text = saves[btn.get_index() + 1]
|
||||
btn.set_meta("has_save", true)
|
||||
else:
|
||||
btn.disabled = true
|
||||
|
||||
btn.pressed.connect(_select_slot.bind(btn))
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Virtual ####################################################################################
|
||||
func _open() -> void:
|
||||
btn_ok.disabled = true
|
||||
_slot = 0
|
||||
|
||||
if _current_slot:
|
||||
_current_slot.text = _prev_text
|
||||
_current_slot.button_pressed = false
|
||||
|
||||
_current_slot = null
|
||||
_prev_text = ""
|
||||
|
||||
|
||||
func _close() -> void:
|
||||
if not _slot: return
|
||||
|
||||
slot_selected.emit()
|
||||
|
||||
if _slot_name:
|
||||
PopochiuUtils.e.save_game(_slot, _slot_name)
|
||||
else:
|
||||
PopochiuUtils.e.load_game(_slot)
|
||||
|
||||
|
||||
func _on_ok() -> void:
|
||||
_slot = _current_slot.get_index() + 1
|
||||
|
||||
if _slot_name:
|
||||
_prev_text = _current_slot.text
|
||||
_current_slot.set_meta("has_save", true)
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public #####################################################################################
|
||||
func open_save() -> void:
|
||||
_show_save()
|
||||
|
||||
|
||||
func open_load() -> void:
|
||||
_show_load()
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private ####################################################################################
|
||||
func _show_save(slot_text := "") -> void:
|
||||
lbl_title.text = "Choose a slot to save the game"
|
||||
_slot_name = slot_text
|
||||
|
||||
if _slot_name.is_empty():
|
||||
_slot_name = _format_date(Time.get_datetime_dict_from_system())
|
||||
|
||||
for btn in slots.get_children():
|
||||
btn.disabled = false
|
||||
|
||||
open()
|
||||
|
||||
|
||||
func _show_load() -> void:
|
||||
lbl_title.text = "Choose the slot to load"
|
||||
_slot_name = ""
|
||||
|
||||
for btn in slots.get_children():
|
||||
btn.disabled = !(btn as Button).get_meta("has_save")
|
||||
|
||||
open()
|
||||
|
||||
|
||||
func _select_slot(btn: Button) -> void:
|
||||
if _slot_name:
|
||||
if _current_slot:
|
||||
_current_slot.text = _prev_text
|
||||
_current_slot.button_pressed = false
|
||||
|
||||
_current_slot = btn
|
||||
_prev_text = _current_slot.text
|
||||
_current_slot.text = _slot_name
|
||||
else:
|
||||
if _current_slot:
|
||||
_current_slot.button_pressed = false
|
||||
|
||||
_current_slot = btn
|
||||
_prev_text = _current_slot.text
|
||||
|
||||
btn_ok.disabled = false
|
||||
|
||||
|
||||
func _format_date(date: Dictionary) -> String:
|
||||
return "%d/%02d/%02d %02d:%02d:%02d" % [
|
||||
date.year, date.month, date.day, date.hour, date.minute, date.second
|
||||
]
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://bmwrmsc6w6ss6
|
|
@ -0,0 +1,100 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://cndputybyj57n"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="1_llqb8"]
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/popups/save_and_load_popup/save_and_load_popup.gd" id="2_m1ot6"]
|
||||
[ext_resource type="StyleBox" uid="uid://dbajakvkltfaj" path="res://addons/popochiu/engine/objects/gui/components/popups/popochiu_popup_panel_container.tres" id="3_inruf"]
|
||||
[ext_resource type="Texture2D" uid="uid://cmxrewai8t2lm" path="res://addons/popochiu/engine/objects/gui/resources/images/close.png" id="3_n4oyj"]
|
||||
[ext_resource type="Texture2D" uid="uid://p32i25numi5e" path="res://addons/popochiu/engine/objects/gui/resources/images/close_highlight.png" id="4_jqolx"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_yg86r"]
|
||||
|
||||
[node name="SaveAndLoadPopup" type="Control" groups=["popochiu_gui_popup"]]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("1_llqb8")
|
||||
script = ExtResource("2_m1ot6")
|
||||
script_name = &"SaveAndLoadPopup"
|
||||
|
||||
[node name="Overlay" type="PanelContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxEmpty_yg86r")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="Overlay"]
|
||||
custom_minimum_size = Vector2(192, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
theme_override_styles/panel = ExtResource("3_inruf")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Overlay/PanelContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HeaderContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Title" type="Label" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Choose a slot to..."
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Close" type="TextureButton" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
|
||||
unique_name_in_owner = true
|
||||
texture_filter = 1
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
texture_normal = ExtResource("3_n4oyj")
|
||||
texture_pressed = ExtResource("4_jqolx")
|
||||
texture_hover = ExtResource("4_jqolx")
|
||||
|
||||
[node name="Slots" type="VBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
alignment = 1
|
||||
|
||||
[node name="BtnSlot1" type="Button" parent="Overlay/PanelContainer/VBoxContainer/Slots"]
|
||||
layout_mode = 2
|
||||
toggle_mode = true
|
||||
text = "slot 1"
|
||||
|
||||
[node name="BtnSlot2" type="Button" parent="Overlay/PanelContainer/VBoxContainer/Slots"]
|
||||
layout_mode = 2
|
||||
toggle_mode = true
|
||||
text = "slot 2"
|
||||
|
||||
[node name="BtnSlot3" type="Button" parent="Overlay/PanelContainer/VBoxContainer/Slots"]
|
||||
layout_mode = 2
|
||||
toggle_mode = true
|
||||
text = "slot 3"
|
||||
|
||||
[node name="BtnSlot4" type="Button" parent="Overlay/PanelContainer/VBoxContainer/Slots"]
|
||||
layout_mode = 2
|
||||
toggle_mode = true
|
||||
text = "slot 4"
|
||||
|
||||
[node name="FooterContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 10
|
||||
alignment = 1
|
||||
|
||||
[node name="Ok" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "OK"
|
||||
|
||||
[node name="Cancel" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Cancel"
|
|
@ -0,0 +1,16 @@
|
|||
@tool
|
||||
extends PopochiuPopup
|
||||
|
||||
@onready var sound_volumes: GridContainer = %SoundVolumes
|
||||
|
||||
|
||||
#region Virtual ####################################################################################
|
||||
func _open() -> void:
|
||||
sound_volumes.update_sliders()
|
||||
|
||||
|
||||
func _on_cancel() -> void:
|
||||
sound_volumes.restore_last_volumes()
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://chx7nkjk6cwvt
|
|
@ -0,0 +1,80 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://dwxm2p1iyhpx6"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="1_rwmoe"]
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/popups/sound_settings_popup/sound_settings_popup.gd" id="2_qt85i"]
|
||||
[ext_resource type="Texture2D" uid="uid://cmxrewai8t2lm" path="res://addons/popochiu/engine/objects/gui/resources/images/close.png" id="3_knqsp"]
|
||||
[ext_resource type="StyleBox" uid="uid://dbajakvkltfaj" path="res://addons/popochiu/engine/objects/gui/components/popups/popochiu_popup_panel_container.tres" id="3_nqnfj"]
|
||||
[ext_resource type="Texture2D" uid="uid://p32i25numi5e" path="res://addons/popochiu/engine/objects/gui/resources/images/close_highlight.png" id="4_v7y6x"]
|
||||
[ext_resource type="PackedScene" uid="uid://drx0r8w00ivck" path="res://addons/popochiu/engine/objects/gui/components/sound_volumes/sound_volumes.tscn" id="5_lh576"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_6mo8y"]
|
||||
|
||||
[node name="SoundSettingsPopup" type="Control" groups=["popochiu_gui_popup"]]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("1_rwmoe")
|
||||
script = ExtResource("2_qt85i")
|
||||
script_name = &"SoundSettingsPopup"
|
||||
title = "Sound Settings"
|
||||
|
||||
[node name="Overlay" type="PanelContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxEmpty_6mo8y")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="Overlay"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
theme_override_styles/panel = ExtResource("3_nqnfj")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Overlay/PanelContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HeaderContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Title" type="Label" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Sound Settings"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Close" type="TextureButton" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
texture_filter = 1
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
texture_normal = ExtResource("3_knqsp")
|
||||
texture_pressed = ExtResource("4_v7y6x")
|
||||
texture_hover = ExtResource("4_v7y6x")
|
||||
|
||||
[node name="SoundVolumes" parent="Overlay/PanelContainer/VBoxContainer" instance=ExtResource("5_lh576")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="FooterContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 10
|
||||
alignment = 1
|
||||
|
||||
[node name="Ok" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "ok"
|
||||
|
||||
[node name="Cancel" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "cancel"
|
|
@ -0,0 +1,40 @@
|
|||
@tool
|
||||
extends PopochiuPopup
|
||||
|
||||
@onready var text_speed: HSlider = %TextSpeed
|
||||
@onready var dialog_style: OptionButton = %DialogStyle
|
||||
@onready var continue_mode: CheckButton = %ContinueMode
|
||||
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _ready() -> void:
|
||||
super()
|
||||
|
||||
if Engine.is_editor_hint(): return
|
||||
|
||||
text_speed.value = 0.1 - PopochiuUtils.e.text_speed
|
||||
dialog_style.selected = PopochiuUtils.e.settings.dialog_style
|
||||
continue_mode.button_pressed = PopochiuUtils.e.settings.auto_continue_text
|
||||
|
||||
# Connect to child signals
|
||||
text_speed.value_changed.connect(_on_text_speed_changed)
|
||||
dialog_style.item_selected.connect(_on_dialog_style_selected)
|
||||
continue_mode.toggled.connect(_on_continue_mode_toggled)
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private ####################################################################################
|
||||
func _on_text_speed_changed(value: float) -> void:
|
||||
PopochiuUtils.e.text_speed = 0.1 - value
|
||||
|
||||
|
||||
func _on_dialog_style_selected(idx: int) -> void:
|
||||
PopochiuUtils.e.current_dialog_style = dialog_style.get_item_id(idx)
|
||||
|
||||
|
||||
func _on_continue_mode_toggled(toggled_on: bool) -> void:
|
||||
PopochiuUtils.e.settings.auto_continue_text = toggled_on
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://s6343c1jdmgy
|
|
@ -0,0 +1,151 @@
|
|||
[gd_scene load_steps=13 format=3 uid="uid://de68lx1xqv7fb"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="1_7sq5d"]
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/popups/text_settings_popup/text_settings_popup.gd" id="2_nmcxa"]
|
||||
[ext_resource type="StyleBox" uid="uid://dbajakvkltfaj" path="res://addons/popochiu/engine/objects/gui/components/popups/popochiu_popup_panel_container.tres" id="3_coq7y"]
|
||||
[ext_resource type="Texture2D" uid="uid://cmxrewai8t2lm" path="res://addons/popochiu/engine/objects/gui/resources/images/close.png" id="3_rckox"]
|
||||
[ext_resource type="Texture2D" uid="uid://p32i25numi5e" path="res://addons/popochiu/engine/objects/gui/resources/images/close_highlight.png" id="4_gfs8i"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_bh5os"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_b5jxw"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_rinqp"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_vprmd"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_372y7"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_t5skw"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_5015x"]
|
||||
|
||||
[node name="TextSettingsPopup" type="Control" groups=["popochiu_gui_popup"]]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("1_7sq5d")
|
||||
script = ExtResource("2_nmcxa")
|
||||
script_name = &"SierraTextPopup"
|
||||
title = "Text options"
|
||||
|
||||
[node name="Overlay" type="PanelContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxEmpty_bh5os")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="Overlay"]
|
||||
custom_minimum_size = Vector2(160, 140)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
theme_override_styles/panel = ExtResource("3_coq7y")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Overlay/PanelContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HeaderContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Title" type="Label" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Text options"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Close" type="TextureButton" parent="Overlay/PanelContainer/VBoxContainer/HeaderContainer"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
texture_filter = 1
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
texture_normal = ExtResource("3_rckox")
|
||||
texture_pressed = ExtResource("4_gfs8i")
|
||||
texture_hover = ExtResource("4_gfs8i")
|
||||
|
||||
[node name="BodyContainer" type="VBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TextSpeedContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/TextSpeedContainer"]
|
||||
layout_mode = 2
|
||||
text = "Typing speed"
|
||||
|
||||
[node name="TextSpeed" type="HSlider" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/TextSpeedContainer"]
|
||||
unique_name_in_owner = true
|
||||
texture_filter = 1
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
max_value = 0.1
|
||||
step = 0.01
|
||||
|
||||
[node name="DialogStyleContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/DialogStyleContainer"]
|
||||
layout_mode = 2
|
||||
text = "Style"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="DialogStyle" type="OptionButton" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/DialogStyleContainer"]
|
||||
unique_name_in_owner = true
|
||||
texture_filter = 1
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
selected = 0
|
||||
item_count = 3
|
||||
popup/item_0/text = "Above character"
|
||||
popup/item_1/text = "Portrait"
|
||||
popup/item_1/id = 1
|
||||
popup/item_2/text = "Caption"
|
||||
popup/item_2/id = 2
|
||||
|
||||
[node name="ContinueModeContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/ContinueModeContainer"]
|
||||
layout_mode = 2
|
||||
text = "Autoadvance"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="ContinueMode" type="CheckButton" parent="Overlay/PanelContainer/VBoxContainer/BodyContainer/ContinueModeContainer"]
|
||||
unique_name_in_owner = true
|
||||
texture_filter = 1
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 10
|
||||
size_flags_vertical = 0
|
||||
theme_override_styles/focus = SubResource("StyleBoxEmpty_b5jxw")
|
||||
theme_override_styles/disabled = SubResource("StyleBoxEmpty_rinqp")
|
||||
theme_override_styles/hover_pressed = SubResource("StyleBoxEmpty_vprmd")
|
||||
theme_override_styles/hover = SubResource("StyleBoxEmpty_372y7")
|
||||
theme_override_styles/pressed = SubResource("StyleBoxEmpty_t5skw")
|
||||
theme_override_styles/normal = SubResource("StyleBoxEmpty_5015x")
|
||||
icon_alignment = 2
|
||||
|
||||
[node name="FooterContainer" type="HBoxContainer" parent="Overlay/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 10
|
||||
alignment = 1
|
||||
|
||||
[node name="Ok" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
text = "OK"
|
||||
|
||||
[node name="Cancel" type="Button" parent="Overlay/PanelContainer/VBoxContainer/FooterContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Back"
|
|
@ -0,0 +1,15 @@
|
|||
extends PopochiuSettingsBarButton
|
||||
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _ready() -> void:
|
||||
super()
|
||||
PopochiuUtils.e.game_saved.connect(show)
|
||||
|
||||
if PopochiuUtils.e.has_save():
|
||||
show()
|
||||
else:
|
||||
hide()
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://p0vkry54t2lc
|
|
@ -0,0 +1,11 @@
|
|||
extends PopochiuSettingsBarButton
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _ready() -> void:
|
||||
super()
|
||||
|
||||
if OS.has_feature("web"):
|
||||
hide()
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://7tvb4u0a2cgs
|
|
@ -0,0 +1,32 @@
|
|||
class_name PopochiuSettingsBarButton
|
||||
extends TextureButton
|
||||
|
||||
@export var description := "" : get = get_description
|
||||
@export var script_name := ""
|
||||
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _ready() -> void:
|
||||
mouse_entered.connect(_on_mouse_entered)
|
||||
mouse_exited.connect(_on_mouse_exited)
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetGet #####################################################################################
|
||||
func get_description() -> String:
|
||||
return description
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private ####################################################################################
|
||||
func _on_mouse_entered() -> void:
|
||||
PopochiuUtils.g.show_hover_text(self.description)
|
||||
|
||||
|
||||
func _on_mouse_exited() -> void:
|
||||
PopochiuUtils.g.show_hover_text()
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://d2d5leid2mkh4
|
After Width: | Height: | Size: 259 B |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cyvd8h2ouw8rg"
|
||||
path="res://.godot/imported/btn_audio.png-0e4052f1dae1f1f9c4ac0c708f040b4f.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/popochiu/engine/objects/gui/components/settings_bar/images/btn_audio.png"
|
||||
dest_files=["res://.godot/imported/btn_audio.png-0e4052f1dae1f1f9c4ac0c708f040b4f.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
After Width: | Height: | Size: 247 B |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bg1txcy1ofatq"
|
||||
path="res://.godot/imported/btn_dialog_history.png-5e6b81c2188724ad496fcf8877a9452a.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/popochiu/engine/objects/gui/components/settings_bar/images/btn_dialog_history.png"
|
||||
dest_files=["res://.godot/imported/btn_dialog_history.png-5e6b81c2188724ad496fcf8877a9452a.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
After Width: | Height: | Size: 250 B |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bns33w6nl2qkb"
|
||||
path="res://.godot/imported/btn_load.png-ecbfe8ff6b76c734e44ba7e7e6bdcc9b.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/popochiu/engine/objects/gui/components/settings_bar/images/btn_load.png"
|
||||
dest_files=["res://.godot/imported/btn_load.png-ecbfe8ff6b76c734e44ba7e7e6bdcc9b.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
After Width: | Height: | Size: 314 B |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cxpcw7xvcjcfy"
|
||||
path="res://.godot/imported/btn_quit.png-38ab2b1afef2a5dae796f87d983b4a23.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/popochiu/engine/objects/gui/components/settings_bar/images/btn_quit.png"
|
||||
dest_files=["res://.godot/imported/btn_quit.png-38ab2b1afef2a5dae796f87d983b4a23.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
After Width: | Height: | Size: 256 B |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bexxkrmqdiemq"
|
||||
path="res://.godot/imported/btn_save.png-885612922cd34c7a3774c5fde51c9c48.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/popochiu/engine/objects/gui/components/settings_bar/images/btn_save.png"
|
||||
dest_files=["res://.godot/imported/btn_save.png-885612922cd34c7a3774c5fde51c9c48.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
After Width: | Height: | Size: 406 B |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://hjol4hvanbt5"
|
||||
path="res://.godot/imported/btn_text.png-55ab59a0b65de9503101bf16f8b64b3f.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/popochiu/engine/objects/gui/components/settings_bar/images/btn_text.png"
|
||||
dest_files=["res://.godot/imported/btn_text.png-55ab59a0b65de9503101bf16f8b64b3f.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
|
@ -0,0 +1,5 @@
|
|||
extends Resource
|
||||
|
||||
@export var icon: Texture2D = null
|
||||
@export var description := ""
|
||||
@export var speed := 0.0
|
|
@ -0,0 +1 @@
|
|||
uid://crd2tr7gtr80d
|
|
@ -0,0 +1,143 @@
|
|||
class_name PopochiuSettingsBar
|
||||
extends Control
|
||||
|
||||
signal option_selected(option_name: String)
|
||||
|
||||
@export var used_in_game := true
|
||||
@export var always_visible := false
|
||||
@export var hide_when_gui_is_blocked := false
|
||||
## Defines the height in pixels of the zone where moving the mouse in the top of the screen will
|
||||
## make the bar to show. Note: This value will be affected by the Experimental Scale GUI checkbox
|
||||
## in Project Settings > Popochiu > GUI.
|
||||
@export var input_zone_height := 4
|
||||
|
||||
var is_disabled := false
|
||||
var tween: Tween = null
|
||||
|
||||
var _can_hide := true
|
||||
var _is_hidden := true
|
||||
var _is_mouse_hover := false
|
||||
|
||||
@onready var panel_container: PanelContainer = $PanelContainer
|
||||
@onready var box: BoxContainer = %Box
|
||||
@onready var hidden_y := panel_container.position.y - panel_container.size.y
|
||||
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _ready() -> void:
|
||||
if not always_visible:
|
||||
panel_container.position.y = hidden_y
|
||||
|
||||
# Connect to child signals
|
||||
for button: TextureButton in box.get_children():
|
||||
button.mouse_entered.connect(_disable_hide)
|
||||
button.mouse_exited.connect(_enable_hide)
|
||||
button.pressed.connect(_on_button_clicked.bind(button))
|
||||
|
||||
# Connect to singletons signals
|
||||
if hide_when_gui_is_blocked:
|
||||
PopochiuUtils.g.blocked.connect(_on_gui_blocked)
|
||||
PopochiuUtils.g.unblocked.connect(_on_gui_unblocked)
|
||||
|
||||
if not used_in_game:
|
||||
hide()
|
||||
|
||||
set_process_input(not always_visible)
|
||||
|
||||
panel_container.size.x = box.size.x
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if not event is InputEventMouseMotion: return
|
||||
|
||||
var rect := panel_container.get_rect()
|
||||
rect.size += Vector2(0.0, input_zone_height)
|
||||
if PopochiuUtils.e.settings.scale_gui:
|
||||
rect = Rect2(
|
||||
panel_container.get_rect().position * PopochiuUtils.e.scale,
|
||||
panel_container.get_rect().size * PopochiuUtils.e.scale
|
||||
)
|
||||
|
||||
if rect.has_point(get_global_mouse_position()):
|
||||
_is_mouse_hover = true
|
||||
PopochiuUtils.cursor.show_cursor("gui")
|
||||
elif _is_mouse_hover:
|
||||
_is_mouse_hover = false
|
||||
|
||||
if PopochiuUtils.d.current_dialog:
|
||||
PopochiuUtils.cursor.show_cursor("gui")
|
||||
elif PopochiuUtils.g.gui.is_showing_dialog_line:
|
||||
PopochiuUtils.cursor.show_cursor("wait")
|
||||
else:
|
||||
PopochiuUtils.cursor.show_cursor("normal")
|
||||
|
||||
if _is_hidden and rect.has_point(get_global_mouse_position()):
|
||||
_open()
|
||||
elif not _is_hidden and not rect.has_point(get_global_mouse_position()):
|
||||
_close()
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public #####################################################################################
|
||||
func is_open() -> bool:
|
||||
return _is_hidden == false
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private ####################################################################################
|
||||
func _open() -> void:
|
||||
if always_visible: return
|
||||
if not is_disabled and panel_container.position.y != hidden_y: return
|
||||
|
||||
if is_instance_valid(tween) and tween.is_running():
|
||||
tween.kill()
|
||||
|
||||
tween = create_tween().set_trans(Tween.TRANS_EXPO).set_ease(Tween.EASE_OUT)
|
||||
tween.tween_property(panel_container, "position:y", 0.0, 0.5).from(
|
||||
hidden_y if not is_disabled else panel_container.position.y
|
||||
)
|
||||
_is_hidden = false
|
||||
|
||||
|
||||
func _close() -> void:
|
||||
if always_visible: return
|
||||
|
||||
await get_tree().process_frame
|
||||
|
||||
if not _can_hide: return
|
||||
|
||||
if is_instance_valid(tween) and tween.is_running():
|
||||
tween.kill()
|
||||
|
||||
tween = create_tween().set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN)
|
||||
tween.tween_property(
|
||||
panel_container, "position:y", hidden_y if not is_disabled else hidden_y - 3.5, 0.2
|
||||
).from(0.0)
|
||||
_is_hidden = true
|
||||
|
||||
|
||||
func _disable_hide() -> void:
|
||||
_can_hide = false
|
||||
|
||||
|
||||
func _enable_hide() -> void:
|
||||
_can_hide = true
|
||||
|
||||
|
||||
func _on_gui_blocked() -> void:
|
||||
set_process_input(false)
|
||||
hide()
|
||||
|
||||
|
||||
func _on_gui_unblocked() -> void:
|
||||
set_process_input(true)
|
||||
show()
|
||||
|
||||
|
||||
func _on_button_clicked(button: TextureButton) -> void:
|
||||
option_selected.emit(button.script_name)
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://b677h1crcx6gm
|
|
@ -0,0 +1,168 @@
|
|||
[gd_scene load_steps=30 format=3 uid="uid://0cqerawlxb3o"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="1_457q0"]
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/settings_bar/settings_bar.gd" id="2_hk0vm"]
|
||||
[ext_resource type="Texture2D" uid="uid://bexxkrmqdiemq" path="res://addons/popochiu/engine/objects/gui/components/settings_bar/images/btn_save.png" id="3_b0ddg"]
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/settings_bar/buttons/settings_bar_button.gd" id="4_lqi16"]
|
||||
[ext_resource type="Texture2D" uid="uid://bns33w6nl2qkb" path="res://addons/popochiu/engine/objects/gui/components/settings_bar/images/btn_load.png" id="5_8xdf1"]
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/settings_bar/buttons/btn_load.gd" id="6_dfxoh"]
|
||||
[ext_resource type="Texture2D" uid="uid://cyvd8h2ouw8rg" path="res://addons/popochiu/engine/objects/gui/components/settings_bar/images/btn_audio.png" id="11_id5s2"]
|
||||
[ext_resource type="Texture2D" uid="uid://hjol4hvanbt5" path="res://addons/popochiu/engine/objects/gui/components/settings_bar/images/btn_text.png" id="12_y7pwl"]
|
||||
[ext_resource type="Texture2D" uid="uid://bg1txcy1ofatq" path="res://addons/popochiu/engine/objects/gui/components/settings_bar/images/btn_dialog_history.png" id="16_7j34k"]
|
||||
[ext_resource type="Texture2D" uid="uid://cxpcw7xvcjcfy" path="res://addons/popochiu/engine/objects/gui/components/settings_bar/images/btn_quit.png" id="18_64yvb"]
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/settings_bar/buttons/btn_quit.gd" id="19_5u3hw"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_mnuax"]
|
||||
atlas = ExtResource("3_b0ddg")
|
||||
region = Rect2(0, 0, 0, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_gcwc6"]
|
||||
atlas = ExtResource("3_b0ddg")
|
||||
region = Rect2(0, 16, 0, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_yci17"]
|
||||
atlas = ExtResource("3_b0ddg")
|
||||
region = Rect2(0, 32, 0, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_8ii6v"]
|
||||
atlas = ExtResource("5_8xdf1")
|
||||
region = Rect2(0, 0, 0, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_c5e8t"]
|
||||
atlas = ExtResource("5_8xdf1")
|
||||
region = Rect2(0, 16, 0, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_dtnbp"]
|
||||
atlas = ExtResource("5_8xdf1")
|
||||
region = Rect2(0, 32, 0, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_2vddc"]
|
||||
atlas = ExtResource("12_y7pwl")
|
||||
region = Rect2(0, 0, 0, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_38kcs"]
|
||||
atlas = ExtResource("12_y7pwl")
|
||||
region = Rect2(0, 16, 0, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ckg43"]
|
||||
atlas = ExtResource("12_y7pwl")
|
||||
region = Rect2(0, 32, 0, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_unaqu"]
|
||||
atlas = ExtResource("11_id5s2")
|
||||
region = Rect2(0, 0, 0, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_i8n60"]
|
||||
atlas = ExtResource("11_id5s2")
|
||||
region = Rect2(0, 16, 0, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kl1ek"]
|
||||
atlas = ExtResource("11_id5s2")
|
||||
region = Rect2(0, 32, 0, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_vqe4x"]
|
||||
atlas = ExtResource("16_7j34k")
|
||||
region = Rect2(0, 0, 0, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_h0y2i"]
|
||||
atlas = ExtResource("16_7j34k")
|
||||
region = Rect2(0, 16, 0, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_myrqy"]
|
||||
atlas = ExtResource("16_7j34k")
|
||||
region = Rect2(0, 32, 0, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_1sqfr"]
|
||||
atlas = ExtResource("18_64yvb")
|
||||
region = Rect2(0, 0, 0, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_blkpg"]
|
||||
atlas = ExtResource("18_64yvb")
|
||||
region = Rect2(0, 16, 0, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_834us"]
|
||||
atlas = ExtResource("18_64yvb")
|
||||
region = Rect2(0, 32, 0, 16)
|
||||
|
||||
[node name="SettingsBar" 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_457q0")
|
||||
script = ExtResource("2_hk0vm")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||
texture_filter = 1
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -96.0
|
||||
offset_bottom = 24.0
|
||||
grow_horizontal = 0
|
||||
|
||||
[node name="Box" type="HBoxContainer" parent="PanelContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
mouse_filter = 2
|
||||
alignment = 2
|
||||
|
||||
[node name="BtnSave" type="TextureButton" parent="PanelContainer/Box"]
|
||||
layout_mode = 2
|
||||
texture_normal = SubResource("AtlasTexture_mnuax")
|
||||
texture_pressed = SubResource("AtlasTexture_gcwc6")
|
||||
texture_hover = SubResource("AtlasTexture_yci17")
|
||||
script = ExtResource("4_lqi16")
|
||||
description = "Save game"
|
||||
script_name = "save"
|
||||
|
||||
[node name="BtnLoad" type="TextureButton" parent="PanelContainer/Box"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
texture_normal = SubResource("AtlasTexture_8ii6v")
|
||||
texture_pressed = SubResource("AtlasTexture_c5e8t")
|
||||
texture_hover = SubResource("AtlasTexture_dtnbp")
|
||||
script = ExtResource("6_dfxoh")
|
||||
description = "Load game"
|
||||
script_name = "load"
|
||||
|
||||
[node name="BtnTextSettings" type="TextureButton" parent="PanelContainer/Box"]
|
||||
layout_mode = 2
|
||||
texture_normal = SubResource("AtlasTexture_2vddc")
|
||||
texture_pressed = SubResource("AtlasTexture_38kcs")
|
||||
texture_hover = SubResource("AtlasTexture_ckg43")
|
||||
script = ExtResource("4_lqi16")
|
||||
description = "Text settings"
|
||||
script_name = "text_settings"
|
||||
|
||||
[node name="BtnSoundSettings" type="TextureButton" parent="PanelContainer/Box"]
|
||||
layout_mode = 2
|
||||
texture_normal = SubResource("AtlasTexture_unaqu")
|
||||
texture_pressed = SubResource("AtlasTexture_i8n60")
|
||||
texture_hover = SubResource("AtlasTexture_kl1ek")
|
||||
script = ExtResource("4_lqi16")
|
||||
description = "Sound settings"
|
||||
script_name = "sound_settings"
|
||||
|
||||
[node name="BtnHistory" type="TextureButton" parent="PanelContainer/Box"]
|
||||
layout_mode = 2
|
||||
texture_normal = SubResource("AtlasTexture_vqe4x")
|
||||
texture_pressed = SubResource("AtlasTexture_h0y2i")
|
||||
texture_hover = SubResource("AtlasTexture_myrqy")
|
||||
script = ExtResource("4_lqi16")
|
||||
description = "History"
|
||||
script_name = "history"
|
||||
|
||||
[node name="BtnQuit" type="TextureButton" parent="PanelContainer/Box"]
|
||||
layout_mode = 2
|
||||
texture_normal = SubResource("AtlasTexture_1sqfr")
|
||||
texture_pressed = SubResource("AtlasTexture_blkpg")
|
||||
texture_hover = SubResource("AtlasTexture_834us")
|
||||
script = ExtResource("19_5u3hw")
|
||||
description = "Quit"
|
||||
script_name = "quit"
|
|
@ -0,0 +1,73 @@
|
|||
extends GridContainer
|
||||
|
||||
const MIN_VOLUME := -30
|
||||
const MUTE_VOLUME := -70
|
||||
|
||||
var dflt_volumes := {}
|
||||
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _ready() -> void:
|
||||
# Connect to AudioManager ready signal
|
||||
PopochiuUtils.e.am.ready.connect(_on_audio_manager_ready)
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public #####################################################################################
|
||||
func update_sliders() -> void:
|
||||
for slider in $SlidersContainer.get_children():
|
||||
if not slider.has_meta("bus_name"): continue
|
||||
|
||||
var bus_name: String = slider.get_meta("bus_name")
|
||||
|
||||
slider.value = PopochiuUtils.e.am.volume_settings[bus_name]
|
||||
dflt_volumes[bus_name] = slider.value
|
||||
|
||||
|
||||
func restore_last_volumes() -> void:
|
||||
for slider in $SlidersContainer.get_children():
|
||||
if not slider.has_meta("bus_name"): continue
|
||||
|
||||
var bus_name: String = slider.get_meta("bus_name")
|
||||
PopochiuUtils.e.am.set_bus_volume_db(bus_name, dflt_volumes[bus_name])
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private ####################################################################################
|
||||
func _on_audio_manager_ready() -> void:
|
||||
PopochiuUtils.e.am.load_sound_settings()
|
||||
|
||||
# Build sound settings UI
|
||||
for bus_idx in range(AudioServer.get_bus_count()):
|
||||
var bus_name := AudioServer.get_bus_name(bus_idx)
|
||||
# Create the label for the slider
|
||||
var label := Label.new()
|
||||
label.text = bus_name
|
||||
$ChannelsContainer.add_child(label)
|
||||
|
||||
# Create the node that will allow players to modify buses volumes
|
||||
var slider = HSlider.new()
|
||||
slider.min_value = MIN_VOLUME
|
||||
slider.max_value = 0
|
||||
slider.value = PopochiuUtils.e.am.volume_settings[bus_name]
|
||||
slider.texture_filter = CanvasItem.TEXTURE_FILTER_NEAREST
|
||||
slider.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
slider.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
slider.custom_minimum_size.x = 120.0
|
||||
slider.set_meta("bus_name", bus_name)
|
||||
slider.value_changed.connect(_on_volume_slider_changed.bind(bus_name))
|
||||
$SlidersContainer.add_child(slider)
|
||||
|
||||
|
||||
# Called when a volume slider changes. It will update the volume of the [param bus_name_param] bus
|
||||
# to [param value]. If the volume is set below or equal to the minimum volume, it will mute the bus.
|
||||
func _on_volume_slider_changed(value: float, bus_name_param: String) -> void:
|
||||
if value > MIN_VOLUME:
|
||||
PopochiuUtils.e.am.set_bus_volume_db(bus_name_param, value)
|
||||
else:
|
||||
PopochiuUtils.e.am.set_bus_volume_db(bus_name_param, MUTE_VOLUME)
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://blyjwnmbu8c7u
|
|
@ -0,0 +1,19 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://drx0r8w00ivck"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="1_37u4o"]
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/components/sound_volumes/sound_volumes.gd" id="1_360xl"]
|
||||
|
||||
[node name="SoundVolumes" type="GridContainer" groups=["popochiu_gui_component"]]
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme = ExtResource("1_37u4o")
|
||||
columns = 2
|
||||
script = ExtResource("1_360xl")
|
||||
|
||||
[node name="ChannelsContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="SlidersContainer" type="VBoxContainer" parent="."]
|
||||
custom_minimum_size = Vector2(120, 0)
|
||||
layout_mode = 2
|
|
@ -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
|
BIN
addons/popochiu/engine/objects/gui/fonts/minecraftia-regular.ttf
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="font_data_dynamic"
|
||||
type="FontFile"
|
||||
uid="uid://dm6h44ck2nm2b"
|
||||
path="res://.godot/imported/minecraftia-regular.ttf-aa9f24486e1e8f742a673dd5ce961da5.fontdata"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/popochiu/engine/objects/gui/fonts/minecraftia-regular.ttf"
|
||||
dest_files=["res://.godot/imported/minecraftia-regular.ttf-aa9f24486e1e8f742a673dd5ce961da5.fontdata"]
|
||||
|
||||
[params]
|
||||
|
||||
Rendering=null
|
||||
antialiasing=1
|
||||
generate_mipmaps=false
|
||||
disable_embedded_bitmaps=true
|
||||
multichannel_signed_distance_field=false
|
||||
msdf_pixel_range=8
|
||||
msdf_size=48
|
||||
allow_system_fallback=true
|
||||
force_autohinter=false
|
||||
hinting=1
|
||||
subpixel_positioning=1
|
||||
oversampling=0.0
|
||||
Fallbacks=null
|
||||
fallbacks=[]
|
||||
Compress=null
|
||||
compress=true
|
||||
preload=[]
|
||||
language_support={}
|
||||
script_support={}
|
||||
opentype_features={}
|
BIN
addons/popochiu/engine/objects/gui/fonts/monkeyisland_1991.ttf
Normal file
|
@ -0,0 +1,40 @@
|
|||
[remap]
|
||||
|
||||
importer="font_data_dynamic"
|
||||
type="FontFile"
|
||||
uid="uid://dixh1egf7k2fb"
|
||||
path="res://.godot/imported/monkeyisland_1991.ttf-48b761f2bda7eabd2ec4c88e22b30ed5.fontdata"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/popochiu/engine/objects/gui/fonts/monkeyisland_1991.ttf"
|
||||
dest_files=["res://.godot/imported/monkeyisland_1991.ttf-48b761f2bda7eabd2ec4c88e22b30ed5.fontdata"]
|
||||
|
||||
[params]
|
||||
|
||||
Rendering=null
|
||||
antialiasing=0
|
||||
generate_mipmaps=true
|
||||
disable_embedded_bitmaps=true
|
||||
multichannel_signed_distance_field=false
|
||||
msdf_pixel_range=8
|
||||
msdf_size=48
|
||||
allow_system_fallback=true
|
||||
force_autohinter=false
|
||||
hinting=1
|
||||
subpixel_positioning=1
|
||||
oversampling=0.0
|
||||
Fallbacks=null
|
||||
fallbacks=[]
|
||||
Compress=null
|
||||
compress=true
|
||||
preload=[{
|
||||
"chars": [],
|
||||
"glyphs": [],
|
||||
"name": "New Configuration",
|
||||
"size": Vector2i(16, 0),
|
||||
"variation_embolden": 0.0
|
||||
}]
|
||||
language_support={}
|
||||
script_support={}
|
||||
opentype_features={}
|
25
addons/popochiu/engine/objects/gui/popochiu_commands.gd
Normal file
|
@ -0,0 +1,25 @@
|
|||
class_name PopochiuCommands
|
||||
extends RefCounted
|
||||
## Defines the commands that can be used by players to interact with the objects in the game.
|
||||
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _init() -> void:
|
||||
PopochiuUtils.e.register_command(-1, "", fallback)
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public #####################################################################################
|
||||
## Should return the name of this class, or the identifier you want to use in scripts to know the
|
||||
## type of the current GUI commands.
|
||||
static func get_script_name() -> String:
|
||||
return "PopochiuCommands"
|
||||
|
||||
|
||||
## Called by [Popochiu] when a command doesn't have an associated [Callable].
|
||||
func fallback() -> void:
|
||||
PopochiuUtils.print_normal("[rainbow]The default Popochiu command fallback[/rainbow]")
|
||||
|
||||
|
||||
#endregion
|
|
@ -0,0 +1 @@
|
|||
uid://ciipu5ylfyi6c
|
202
addons/popochiu/engine/objects/gui/popochiu_gui.gd
Normal file
|
@ -0,0 +1,202 @@
|
|||
class_name PopochiuGraphicInterface
|
||||
extends Control
|
||||
## Handles the in-game Graphic Interface.
|
||||
##
|
||||
## You can extend this class to create your own GUI, or use one of the built-in templates for:
|
||||
## 2-click context-sensitive, 9 verbs and Sierra style.
|
||||
|
||||
## Stack of opened popups.
|
||||
var popups_stack := []
|
||||
## Whether a dialog line is being displayed.
|
||||
var is_showing_dialog_line := false
|
||||
|
||||
var _components_map := {}
|
||||
|
||||
|
||||
#region Godot ######################################################################################
|
||||
func _ready():
|
||||
for node: Control in (
|
||||
get_tree().get_nodes_in_group("popochiu_gui_component")
|
||||
+ get_tree().get_nodes_in_group("popochiu_gui_popup")
|
||||
):
|
||||
_components_map[node.name] = node
|
||||
|
||||
# Connect to singleton signals
|
||||
PopochiuUtils.g.blocked.connect(_on_blocked)
|
||||
PopochiuUtils.g.unblocked.connect(_on_unblocked)
|
||||
PopochiuUtils.g.hidden.connect(on_hidden)
|
||||
PopochiuUtils.g.shown.connect(on_shown)
|
||||
PopochiuUtils.g.system_text_shown.connect(_on_system_text_shown)
|
||||
PopochiuUtils.g.system_text_hidden.connect(_on_system_text_hidden)
|
||||
PopochiuUtils.g.mouse_entered_clickable.connect(_on_mouse_entered_clickable)
|
||||
PopochiuUtils.g.mouse_exited_clickable.connect(_on_mouse_exited_clickable)
|
||||
PopochiuUtils.g.mouse_entered_inventory_item.connect(_on_mouse_entered_inventory_item)
|
||||
PopochiuUtils.g.mouse_exited_inventory_item.connect(_on_mouse_exited_inventory_item)
|
||||
PopochiuUtils.g.dialog_line_started.connect(_on_dialog_line_started)
|
||||
PopochiuUtils.g.dialog_line_finished.connect(_on_dialog_line_finished)
|
||||
PopochiuUtils.d.dialog_started.connect(_on_dialog_started)
|
||||
PopochiuUtils.g.dialog_options_shown.connect(_on_dialog_options_shown)
|
||||
PopochiuUtils.d.dialog_finished.connect(_on_dialog_finished)
|
||||
PopochiuUtils.i.item_selected.connect(_on_inventory_item_selected)
|
||||
PopochiuUtils.e.game_saved.connect(_on_game_saved)
|
||||
PopochiuUtils.e.game_loaded.connect(_on_game_loaded)
|
||||
|
||||
if PopochiuUtils.e.settings.is_pixel_art_game:
|
||||
# Apply this filter so the font doesn't blur
|
||||
texture_filter = CanvasItem.TEXTURE_FILTER_NEAREST
|
||||
|
||||
if PopochiuUtils.e.settings.scale_gui:
|
||||
size = get_viewport_rect().size / PopochiuUtils.e.scale
|
||||
scale = PopochiuUtils.e.scale
|
||||
|
||||
# Adjust nodes with a "text" property that is a String in order to try to prevent glitches
|
||||
# when rendering its font
|
||||
_adjust_nodes_text(get_children())
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Virtual ####################################################################################
|
||||
## Called when the GUI is blocked and not intended to handle input events.
|
||||
func _on_blocked(props := { blocking = true }) -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when the GUI is unblocked and can handle input events again.
|
||||
func _on_unblocked() -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when the GUI is hidden.
|
||||
func _on_hidden() -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when the GUI is shown.
|
||||
func _on_shown() -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when [method G.show_system_text] is executed. Shows [param msg] in the [SystemText]
|
||||
## component.
|
||||
func _on_system_text_shown(msg: String) -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called once the player closes the [SystemText] component by default when clicking anywhere on the
|
||||
## screen.
|
||||
func _on_system_text_hidden() -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when the mouse enters (hovers) [param clickable].
|
||||
func _on_mouse_entered_clickable(clickable: PopochiuClickable) -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when the mouse exits [param clickable].
|
||||
func _on_mouse_exited_clickable(clickable: PopochiuClickable) -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when the mouse enters (hovers) [param inventory_item].
|
||||
func _on_mouse_entered_inventory_item(inventory_item: PopochiuInventoryItem) -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when the mouse exits [param inventory_item].
|
||||
func _on_mouse_exited_inventory_item(inventory_item: PopochiuInventoryItem) -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when a dialog line is said by a [PopochiuCharacter] (this is when
|
||||
## [method PopochiuCharacter.say] is called.
|
||||
func _on_dialog_line_started() -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when a dialog line said by a [PopochiuCharacter] finishes (this is after players click the
|
||||
## screen anywhere to make the dialog line disappear).
|
||||
func _on_dialog_line_finished() -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when [param dialog] starts (this is after calling [method PopochiuDialog.start]).
|
||||
func _on_dialog_started(dialog: PopochiuDialog) -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when the running [PopochiuDialog] shows its options on screen.
|
||||
func _on_dialog_options_shown() -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when [param dialog] finishes (this is afet calling [method PopochiuDialog.stop]).
|
||||
func _on_dialog_finished(dialog: PopochiuDialog) -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when [param item] is selected in the inventory (i.e. by clicking it).
|
||||
func _on_inventory_item_selected(item: PopochiuInventoryItem) -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when the game is saved. By default, it shows [code]Game saved[/code] in the SystemText
|
||||
## component.
|
||||
func _on_game_saved() -> void:
|
||||
pass
|
||||
|
||||
|
||||
## Called when a game is loaded. [param loaded_game] has the loaded data. By default, this emits
|
||||
## the [signal G.load_feedback_finished] signal.
|
||||
func _on_game_loaded(loaded_game: Dictionary) -> void:
|
||||
PopochiuUtils.g.load_feedback_finished.emit()
|
||||
|
||||
|
||||
## Called by [b]cursor.gd[/b] to get the name of the cursor texture to show.
|
||||
func _get_cursor_name() -> String:
|
||||
return ""
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public #####################################################################################
|
||||
## Returns the GUI component which [member Node.name] matches [param component_name].
|
||||
## GUI components are those nodes that are in any of this groups:
|
||||
## [code]popochiu_gui_component[/code] and [code]popochiu_gui_popup[/code].
|
||||
func get_component(component_name: String) -> Control:
|
||||
if _components_map.has(component_name):
|
||||
return _components_map[component_name]
|
||||
else:
|
||||
PopochiuUtils.print_warning("No GUI component with name %s" % component_name)
|
||||
|
||||
return null
|
||||
|
||||
|
||||
## Returns the name of the cursor texture to show. [code]"normal"[/code] is returned by default.
|
||||
func get_cursor_name() -> String:
|
||||
return "normal" if _get_cursor_name().is_empty() else _get_cursor_name()
|
||||
|
||||
|
||||
func on_hidden() -> void:
|
||||
hide()
|
||||
_on_hidden()
|
||||
|
||||
|
||||
func on_shown() -> void:
|
||||
show()
|
||||
_on_shown()
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private ####################################################################################
|
||||
func _adjust_nodes_text(nodes_array: Array) -> void:
|
||||
for node: Node in nodes_array:
|
||||
_adjust_nodes_text(node.get_children())
|
||||
if not node.get("text") or not typeof(node.get("text")) == TYPE_STRING: continue
|
||||
if node.text.length() % 2 != 0:
|
||||
node.text += " "
|
||||
|
||||
|
||||
#endregion
|
1
addons/popochiu/engine/objects/gui/popochiu_gui.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://dvtw5lqfyk7e
|
15
addons/popochiu/engine/objects/gui/popochiu_gui.tscn
Normal file
|
@ -0,0 +1,15 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://k35rpa45ngms"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/popochiu_gui.gd" id="1"]
|
||||
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="1_lylgs"]
|
||||
|
||||
[node name="GraphicInterface" type="Control"]
|
||||
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_lylgs")
|
||||
script = ExtResource("1")
|
|
@ -0,0 +1,88 @@
|
|||
[gd_resource type="Theme" load_steps=20 format=3 uid="uid://dpequqav4rjaf"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://pl1ch71kfj72" path="res://addons/popochiu/engine/objects/gui/resources/images/check_button_checked.png" id="2_ldprq"]
|
||||
[ext_resource type="Texture2D" uid="uid://dukr75slqli45" path="res://addons/popochiu/engine/objects/gui/resources/images/check_button_unchecked.png" id="3_3rprc"]
|
||||
[ext_resource type="Texture2D" uid="uid://cqxqfxobqltga" path="res://addons/popochiu/engine/objects/gui/resources/images/grabber.png" id="4_4x0ix"]
|
||||
[ext_resource type="Texture2D" uid="uid://d1ywqbehmtuv" path="res://addons/popochiu/engine/objects/gui/resources/images/down_arrow.png" id="5_jwcnu"]
|
||||
[ext_resource type="FontFile" uid="uid://dm6h44ck2nm2b" path="res://addons/popochiu/engine/objects/gui/fonts/minecraftia-regular.ttf" id="6_gx6k1"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jar7r"]
|
||||
content_margin_left = 2.0
|
||||
content_margin_top = 0.0
|
||||
content_margin_right = 2.0
|
||||
content_margin_bottom = 0.0
|
||||
bg_color = Color(0, 0, 0, 0.705882)
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_jts3x"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_d2wsf"]
|
||||
content_margin_left = 2.0
|
||||
content_margin_top = 0.0
|
||||
content_margin_right = 2.0
|
||||
content_margin_bottom = 0.0
|
||||
bg_color = Color(0, 0, 0, 0.705882)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="7"]
|
||||
content_margin_left = 2.0
|
||||
content_margin_top = 0.0
|
||||
content_margin_right = 2.0
|
||||
content_margin_bottom = 0.0
|
||||
bg_color = Color(0, 0, 0, 0.705882)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3mrlf"]
|
||||
content_margin_left = 2.0
|
||||
content_margin_top = 0.0
|
||||
content_margin_right = 2.0
|
||||
content_margin_bottom = 0.0
|
||||
bg_color = Color(0, 0, 0, 0.705882)
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_aa7jm"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_tv3kj"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_0prrl"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_3tq14"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_l3jvo"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_pr0tq"]
|
||||
bg_color = Color(0.698039, 0.698039, 0.698039, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_mp7ca"]
|
||||
bg_color = Color(1, 1, 1, 1)
|
||||
|
||||
[sub_resource type="StyleBoxLine" id="StyleBoxLine_1vxxo"]
|
||||
thickness = 4
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_d8gde"]
|
||||
bg_color = Color(0, 0, 0, 0.705882)
|
||||
|
||||
[resource]
|
||||
default_font = ExtResource("6_gx6k1")
|
||||
default_font_size = 8
|
||||
Button/colors/font_color = Color(1, 1, 1, 1)
|
||||
Button/colors/font_disabled_color = Color(0.482353, 0.482353, 0.482353, 1)
|
||||
Button/colors/font_focus_color = Color(0.305882, 0.305882, 0.862745, 1)
|
||||
Button/colors/font_hover_color = Color(0.952941, 0.952941, 0.0627451, 1)
|
||||
Button/colors/font_hover_pressed_color = Color(0.901961, 0.337255, 0.901961, 1)
|
||||
Button/colors/font_pressed_color = Color(0.305882, 0.952941, 0.952941, 1)
|
||||
Button/styles/disabled = SubResource("StyleBoxFlat_jar7r")
|
||||
Button/styles/focus = SubResource("StyleBoxEmpty_jts3x")
|
||||
Button/styles/hover = SubResource("StyleBoxFlat_d2wsf")
|
||||
Button/styles/normal = SubResource("7")
|
||||
Button/styles/pressed = SubResource("StyleBoxFlat_3mrlf")
|
||||
CheckButton/icons/checked = ExtResource("2_ldprq")
|
||||
CheckButton/icons/unchecked = ExtResource("3_3rprc")
|
||||
CheckButton/styles/disabled = SubResource("StyleBoxEmpty_aa7jm")
|
||||
CheckButton/styles/hover = SubResource("StyleBoxEmpty_tv3kj")
|
||||
CheckButton/styles/hover_pressed = SubResource("StyleBoxEmpty_0prrl")
|
||||
CheckButton/styles/normal = SubResource("StyleBoxEmpty_3tq14")
|
||||
CheckButton/styles/pressed = SubResource("StyleBoxEmpty_l3jvo")
|
||||
HSlider/icons/grabber = ExtResource("4_4x0ix")
|
||||
HSlider/icons/grabber_highlight = ExtResource("4_4x0ix")
|
||||
HSlider/styles/grabber_area = SubResource("StyleBoxFlat_pr0tq")
|
||||
HSlider/styles/grabber_area_highlight = SubResource("StyleBoxFlat_mp7ca")
|
||||
HSlider/styles/slider = SubResource("StyleBoxLine_1vxxo")
|
||||
OptionButton/icons/arrow = ExtResource("5_jwcnu")
|
||||
PanelContainer/styles/panel = SubResource("StyleBoxFlat_d8gde")
|
After Width: | Height: | Size: 169 B |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://pl1ch71kfj72"
|
||||
path="res://.godot/imported/check_button_checked.png-b1eb37ae4557b8c54cf724d6ab85b490.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/popochiu/engine/objects/gui/resources/images/check_button_checked.png"
|
||||
dest_files=["res://.godot/imported/check_button_checked.png-b1eb37ae4557b8c54cf724d6ab85b490.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
After Width: | Height: | Size: 126 B |