fix: Huge cleanup (#420)

Co-authored-by: Dennis Ploeger <develop@dieploegers.de>
This commit is contained in:
Dennis Ploeger
2021-10-25 08:59:07 +02:00
committed by GitHub
parent 3de06adcf9
commit 94d86d24d5
101 changed files with 1091 additions and 67952 deletions

View File

@@ -0,0 +1,111 @@
# A dialog GUI showing a dialog box and character portraits
extends Popup
# Signal emitted when a dialog line has started
signal dialog_line_started
# Signal emitted when a dialog line has finished
signal dialog_line_finished
# The currently speaking character
export(String) var current_character setget set_current_character
# The text speed per character for normal display
export(float, 0.0, 0.3) var text_speed_per_character = 0.1
# The text speed per character if the dialog line is skipped
export(float) var fast_text_speed_per_character = 0.25
# The time to wait before the dialog is finished
export(float) var max_time_to_text_disappear = 1.0
# The node holding the avatar
onready var avatar_node = $Panel/MarginContainer/HSplitContainer/VBoxContainer\
/avatar
# The node holding the player name
onready var name_node = $Panel/MarginContainer/HSplitContainer/VBoxContainer\
/name
# The node showing the text
onready var text_node = $Panel/MarginContainer/HSplitContainer/text
# The tween node for text animations
onready var tween = text_node.get_node("Tween")
# Build up the UI
func _ready():
var centered_position_on_screen = Vector2(
ProjectSettings.get_setting("display/window/size/width") / 2,
ProjectSettings.get_setting("display/window/size/height") / 2
) - rect_size / 2
rect_position = centered_position_on_screen
text_node.bbcode_enabled = true
$Panel/MarginContainer/HSplitContainer/text/Tween.connect(
"tween_completed",
self,
"_on_dialog_line_typed"
)
# Switch the current character
#
# #### Parameters
# - name: The name of the current character
func set_current_character(name: String):
# TODO: Make this configurable in #47
var avatar = "res://game/dialog_avatars/%s.tres" % name
if ResourceLoader.exists(avatar):
$Panel/MarginContainer/HSplitContainer/VBoxContainer/avatar.texture = \
ResourceLoader.load(avatar)
current_character = name
# Make a character say something
#
# #### Parameters
# - character: The global id of the character speaking
# - line: Line to say
func say(character: String, line: String) :
popup_centered()
emit_signal("dialog_line_started")
set_current_character(character)
text_node.bbcode_text = tr(line)
text_node.percent_visible = 0.0
var time_show_full_text = text_speed_per_character * len(line)
tween.interpolate_property(text_node, "percent_visible",
0.0, 1.0, time_show_full_text,
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.start()
# Called by the dialog player when the
func finish_fast():
tween.stop(text_node)
tween.interpolate_property(text_node, "percent_visible",
text_node.percent_visible, 1.0, fast_text_speed_per_character,
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.start()
# The dialog line was printed, start the waiting time and then finish
# the dialog
func _on_dialog_line_typed(object, key):
text_node.visible_characters = -1
$Timer.start(max_time_to_text_disappear)
$Timer.connect("timeout", self, "_on_dialog_finished")
# Ending the dialog
func _on_dialog_finished():
emit_signal("dialog_line_finished")
queue_free()

View File

@@ -0,0 +1,74 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/escoria-core/ui_library/dialogs/avatar_dialog_player.gd" type="Script" id=1]
[node name="dialog_box" type="Popup"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_right = -782.0
margin_bottom = -734.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Timer" type="Timer" parent="."]
[node name="Panel" type="Panel" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MarginContainer" type="MarginContainer" parent="Panel"]
anchor_right = 1.0
anchor_bottom = 1.0
custom_constants/margin_right = 20
custom_constants/margin_top = 20
custom_constants/margin_left = 20
custom_constants/margin_bottom = 20
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HSplitContainer" type="HSplitContainer" parent="Panel/MarginContainer"]
margin_left = 20.0
margin_top = 20.0
margin_right = 478.0
margin_bottom = 146.0
custom_constants/separation = 35
dragger_visibility = 1
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/MarginContainer/HSplitContainer"]
margin_right = 88.0
margin_bottom = 126.0
size_flags_horizontal = 3
size_flags_stretch_ratio = 0.3
[node name="avatar" type="TextureRect" parent="Panel/MarginContainer/HSplitContainer/VBoxContainer"]
margin_right = 88.0
margin_bottom = 108.0
size_flags_horizontal = 3
size_flags_vertical = 3
expand = true
[node name="name" type="Label" parent="Panel/MarginContainer/HSplitContainer/VBoxContainer"]
margin_top = 112.0
margin_right = 88.0
margin_bottom = 126.0
valign = 1
[node name="text" type="RichTextLabel" parent="Panel/MarginContainer/HSplitContainer"]
margin_left = 123.0
margin_right = 458.0
margin_bottom = 126.0
size_flags_horizontal = 3
bbcode_enabled = true
bbcode_text = "Here be some text"
text = "Here be some text"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Tween" type="Tween" parent="Panel/MarginContainer/HSplitContainer/text"]

View File

@@ -0,0 +1,94 @@
# A dialog UI using a label above the head of the character
extends RichTextLabel
# Signal emitted when a dialog line has started
signal dialog_line_started
# Signal emitted when a dialog line has finished
signal dialog_line_finished
# The text speed per character for normal display
export(float, 0.0, 0.3) var text_speed_per_character = 0.1
# The text speed per character if the dialog line is skipped
export(float) var fast_text_speed_per_character = 0.25
# The time to wait before the dialog is finished
export(float) var max_time_to_text_disappear = 2.0
# Current character speaking, to keep track of reference for animation purposes
var current_character
# Tween node for text animation
onready var tween = $Tween
# The node showing the text
onready var text_node = self
# Enable bbcode and catch the signal when a tween completed
func _ready():
bbcode_enabled = true
$Tween.connect("tween_completed", self, "_on_dialog_line_typed")
# Make a character say something
#
# #### Parameters
# - character: The global id of the character speaking
# - line: Line to say
func say(character: String, line: String) :
show()
emit_signal("dialog_line_started")
# Position the RichTextLabel on the character's dialog position, if any.
current_character = escoria.object_manager.get_object(character).node
rect_position = current_character.get_node("dialog_position").get_global_transform_with_canvas().origin
rect_position.x -= rect_size.x / 2
current_character.start_talking()
# Set text color to color set in the actor
var text_color = current_character.dialog_color
var text_color_html = text_color.to_html(false)
text_node.bbcode_text = "[center][color=#" + text_color_html + "]" \
.format([text_color_html]) + tr(line) + "[/color][center]"
text_node.percent_visible = 0.0
var time_show_full_text = text_speed_per_character * len(line)
tween.interpolate_property(text_node, "percent_visible",
0.0, 1.0, time_show_full_text,
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.start()
# Called by the dialog player when the
func finish_fast():
tween.stop(text_node)
tween.interpolate_property(text_node, "percent_visible",
text_node.percent_visible, 1.0, fast_text_speed_per_character,
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.start()
# The dialog line was printed, start the waiting time and then finish
# the dialog
func _on_dialog_line_typed(object, key):
text_node.visible_characters = -1
$Timer.start(max_time_to_text_disappear)
$Timer.connect("timeout", self, "_on_dialog_finished")
# Ending the dialog
func _on_dialog_finished():
current_character.stop_talking()
emit_signal("dialog_line_finished")
escoria.dialog_player.is_speaking = false
queue_free()

View File

@@ -0,0 +1,20 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/escoria-core/ui_library/dialogs/floating_dialog_player.gd" type="Script" id=2]
[node name="dialog_label" type="RichTextLabel"]
margin_right = 643.0
margin_bottom = 60.0
bbcode_enabled = true
bbcode_text = "[center]Here be some text.[/center]"
text = "Here be some text."
fit_content_height = true
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
text_speed_per_character = 0.0
[node name="Tween" type="Tween" parent="."]
[node name="Timer" type="Timer" parent="."]

View File

@@ -0,0 +1,83 @@
# A simple dialog chooser that shows selectable lines of text
# Supports timeout and avatar display
extends ESCDialogOptionsChooser
export(Color, RGB) var color_normal = Color(1.0,1.0,1.0,1.0)
export(Color, RGB) var color_hover = Color(165.0,42.0,42.0, 1.0)
export(Font) var font
# Hide the chooser at the start just to be safe
func _ready() -> void:
hide_chooser()
# Process the timeout display
func _process(delta: float) -> void:
if $MarginContainer.visible and self.dialog and self.dialog.timeout > 0:
$TimerProgress.value = (
self.dialog.timeout - $Timer.time_left
) / self.dialog.timeout * 100
# Show the chooser
func show_chooser():
var _vbox = $MarginContainer/ScrollContainer/VBoxContainer
for option_node in _vbox.get_children():
_vbox.remove_child(option_node)
_remove_avatar()
for option in self.dialog.options:
var _option_node = Button.new()
_option_node.text = (option as ESCDialogOption).option
_option_node.flat = true
_option_node.add_color_override("font_color", color_normal)
_option_node.add_color_override("font_color_hover", color_hover)
_option_node.add_font_override("font", font)
_vbox.add_child(_option_node)
_option_node.connect("pressed", self, "_on_answer_selected", [option])
if self.dialog.avatar != "-":
$AvatarContainer.add_child(
ResourceLoader.load(self.dialog.avatar).instance()
)
$MarginContainer.show()
if self.dialog.timeout > 0:
$Timer.start(self.dialog.timeout)
# Hide the chooser
func hide_chooser():
$MarginContainer.hide()
# An option was choosen, emit the option
#
# #### Parameters
# - option: Option that was chosen
func _option_chosen(option: ESCDialogOption):
_remove_avatar()
$TimerProgress.value = 0
emit_signal("option_chosen", option)
# An option was chosen directly from the list
#
# #### Parameters
# - option: Option that was chosen
func _on_answer_selected(option: ESCDialogOption):
_option_chosen(option)
# The timeout came and a option was selected
func _on_Timer_timeout() -> void:
_option_chosen(self.dialog.options[self.dialog.timeout_option - 1])
# Remove the avatar
func _remove_avatar():
if $AvatarContainer.get_child_count() > 0:
$AvatarContainer.remove_child($AvatarContainer.get_child(0))

View File

@@ -0,0 +1,61 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://addons/escoria-core/ui_library/dialogs/text_dialog_chooser.gd" type="Script" id=1]
[sub_resource type="Gradient" id=1]
colors = PoolColorArray( 1, 0, 0, 1, 1, 0, 0, 1 )
[sub_resource type="GradientTexture" id=2]
gradient = SubResource( 1 )
[node name="text_dialog_choice" type="Node"]
script = ExtResource( 1 )
[node name="MarginContainer" type="MarginContainer" parent="."]
margin_left = 20.0
margin_top = 20.0
margin_right = 1280.0
margin_bottom = 900.0
mouse_filter = 2
custom_constants/margin_top = 20
custom_constants/margin_left = 20
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer"]
margin_left = 20.0
margin_top = 20.0
margin_right = 1260.0
margin_bottom = 880.0
scroll_horizontal_enabled = false
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/ScrollContainer"]
margin_right = 1240.0
margin_bottom = 860.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_constants/separation = 20
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Timer" type="Timer" parent="."]
one_shot = true
[node name="TimerProgress" type="TextureProgress" parent="."]
anchor_right = 1.0
rect_min_size = Vector2( 0, 20 )
texture_progress = SubResource( 2 )
nine_patch_stretch = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="AvatarContainer" type="Node2D" parent="."]
position = Vector2( 29.1458, 120.012 )
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]

View File

@@ -0,0 +1,107 @@
# The inventory representation of an ESC item if pickable (only used by
# the inventory components)
extends TextureButton
class_name ESCInventoryButton
# Signal emitted when the item was left clicked
#
# #### Parameters
#
# - item_id: Global ID of the clicked item
signal mouse_left_inventory_item(item_id)
# Signal emitted when the item was right clicked
#
# #### Parameters
#
# - item_id: Global ID of the clicked item
signal mouse_right_inventory_item(item_id)
# Signal emitted when the item was double clicked
#
# #### Parameters
#
# - item_id: Global ID of the clicked item
signal mouse_double_left_inventory_item(item_id)
# Signal emitted when the item was focused
#
# #### Parameters
#
# - item_id: Global ID of the clicked item
signal inventory_item_focused(item_id)
# Signal emitted when the item is not focused anymore
signal inventory_item_unfocused()
# Global ID of the ESCItem that uses this ESCInventoryItem
var global_id: String = ""
func _init(p_item: ESCInventoryItem) -> void:
global_id = p_item.global_id
texture_normal = p_item.texture
expand = true
stretch_mode = TextureButton.STRETCH_KEEP_ASPECT
func _process(_delta: float) -> void:
rect_size = ProjectSettings.get_setting("escoria/ui/inventory_item_size")
rect_min_size = ProjectSettings.get_setting(
"escoria/ui/inventory_item_size"
)
# Connect input handlers
func _ready():
connect("gui_input", self, "_on_inventory_item_gui_input")
connect("mouse_entered", self, "_on_inventory_item_mouse_enter")
connect("mouse_exited", self, "_on_inventory_item_mouse_exit")
# Handle the gui input and emit the respective signals
#
# #### Parameters
#
# - event: The event received
func _on_inventory_item_gui_input(event: InputEvent):
if InputMap.has_action("switch_action_verb") \
and event.is_action_pressed("switch_action_verb"):
if event.button_index == BUTTON_WHEEL_UP:
escoria.inputs_manager._on_mousewheel_action(-1)
elif event.button_index == BUTTON_WHEEL_DOWN:
escoria.inputs_manager._on_mousewheel_action(1)
if event is InputEventMouseButton:
# var p = get_global_mouse_position()
if event.doubleclick:
if event.button_index == BUTTON_LEFT:
emit_signal(
"mouse_double_left_inventory_item",
global_id,
event
)
else:
if event.is_pressed():
if event.button_index == BUTTON_LEFT:
emit_signal(
"mouse_left_inventory_item",
global_id,
event
)
if event.button_index == BUTTON_RIGHT:
emit_signal(
"mouse_right_inventory_item",
global_id,
event
)
# Handle mouse entering the item and send the respecitve signal
func _on_inventory_item_mouse_enter():
emit_signal("inventory_item_focused", global_id)
# Handle mouse leaving the item and send the respecitve signal
func _on_inventory_item_mouse_exit():
emit_signal("inventory_item_unfocused")

View File

@@ -0,0 +1,31 @@
# Inventory container handler that acts as a base for UIs inventory containers
extends Control
class_name ESCInventoryContainer
# Get wether the inventory container currently is empty
# **Returns** Wether the container is empty or not
func is_empty() -> bool:
return get_child_count() > 0
# Add a new item into the container and return the control generated for it
# so its events can be handled by the inputs manager
#
# #### Parameters
# - inventory_item: Item to add
# **Returns** The button generated for the item
func add_item(inventory_item: ESCInventoryItem) -> ESCInventoryButton:
var button = ESCInventoryButton.new(inventory_item)
add_child(button)
return button
# Remove an item from the container
#
# #### Parameters
# - inventory_item: Item to remove
func remove_item(inventory_item: ESCInventoryItem):
for c in get_children():
if c is ESCInventoryButton and c.global_id == inventory_item.global_id:
remove_child(c)
c.queue_free()

View File

@@ -0,0 +1,44 @@
# A container for loading from a save slot
extends Control
# Emitted when the back button is pressed
signal back_button_pressed
# The scene to display a slot
export(PackedScene) var slot_ui_scene
# Load the savegames when loaded
func _ready():
refresh_savegames()
# A slot was pressed. Load the game
#
# #### Parameters
# - slot_id: The slot that was pressed
func _on_slot_pressed(slot_id: int) -> void:
escoria.save_manager.load_game(slot_id)
# The back button was pressed
func _on_back_pressed():
emit_signal("back_button_pressed")
# Create the slots from the list of savegames
func refresh_savegames():
for slot in $VBoxContainer/ScrollContainer/slots.get_children():
$VBoxContainer/ScrollContainer/slots.remove_child(slot)
var saves_list = escoria.save_manager.get_saves_list()
for i in saves_list.size():
var save_data = saves_list[i+1]
var new_slot = slot_ui_scene.instance()
$VBoxContainer/ScrollContainer/slots.add_child(
new_slot
)
new_slot.set_slot_name_date(save_data["name"], save_data["date"])
new_slot.connect("pressed", self, "_on_slot_pressed", [i+1])

View File

@@ -0,0 +1,53 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/load_save_slot/load_save_slot.tscn" type="PackedScene" id=2]
[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/load/load_game.gd" type="Script" id=3]
[node name="load_game" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
slot_ui_scene = ExtResource( 2 )
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchor_left = 0.3
anchor_top = 0.3
anchor_right = 0.7
anchor_bottom = 0.7
margin_left = -55.5
margin_right = 55.5
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer"]
margin_right = 623.0
margin_bottom = 336.0
size_flags_vertical = 3
scroll_horizontal_enabled = false
__meta__ = {
"_edit_use_anchors_": false
}
[node name="slots" type="VBoxContainer" parent="VBoxContainer/ScrollContainer"]
margin_right = 623.0
margin_bottom = 336.0
size_flags_horizontal = 3
size_flags_vertical = 3
__meta__ = {
"_edit_use_anchors_": false
}
[node name="back" type="Button" parent="VBoxContainer"]
margin_top = 340.0
margin_right = 623.0
margin_bottom = 360.0
text = "OPTIONS_BACK"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="VBoxContainer/back" to="." method="_on_back_pressed"]

View File

@@ -0,0 +1,7 @@
extends Button
func set_slot_name_date(p_name: String, p_date: String):
$VBoxContainer/slot_name.text = p_name
$VBoxContainer/date.text = p_date

View File

@@ -0,0 +1,35 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/load_save_slot/load_save_slot.gd" type="Script" id=2]
[node name="slot" type="Button"]
margin_right = 665.0
margin_bottom = 86.0
rect_min_size = Vector2( 0, 100 )
size_flags_horizontal = 3
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="slot_name" type="Label" parent="VBoxContainer"]
margin_top = 34.0
margin_right = 665.0
margin_bottom = 48.0
text = "slot_name"
align = 1
[node name="date" type="Label" parent="VBoxContainer"]
margin_top = 52.0
margin_right = 665.0
margin_bottom = 66.0
text = "date"
align = 1

View File

@@ -0,0 +1,12 @@
extends PopupDialog
signal confirm_yes
func _on_no_pressed():
hide()
func _on_yes_pressed():
emit_signal("confirm_yes")
hide()

View File

@@ -0,0 +1,67 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/save/overwrite_confirm_popup.gd" type="Script" id=2]
[node name="overwrite_confirm_popup" type="PopupDialog"]
visible = true
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MarginContainer" type="MarginContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
custom_constants/margin_right = 30
custom_constants/margin_top = 30
custom_constants/margin_left = 30
custom_constants/margin_bottom = 30
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
margin_left = 30.0
margin_top = 423.0
margin_right = 1250.0
margin_bottom = 477.0
size_flags_vertical = 4
custom_constants/separation = 20
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer"]
margin_right = 1220.0
margin_bottom = 14.0
text = "CONFIRM_OVERWRITE"
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
margin_top = 34.0
margin_right = 1220.0
margin_bottom = 54.0
custom_constants/separation = 10
alignment = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="yes" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
margin_left = 1144.0
margin_right = 1177.0
margin_bottom = 20.0
text = "YES"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="no" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
margin_left = 1187.0
margin_right = 1220.0
margin_bottom = 20.0
text = "NO"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/yes" to="." method="_on_yes_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/no" to="." method="_on_no_pressed"]

View File

@@ -0,0 +1,75 @@
# A container for saving to a save slot
extends Control
# Emitted when the back button is pressed
signal back_button_pressed
# The scene to display a slot
export(PackedScene) var slot_ui_scene
# The slot that was pressed
var _slot_pressed = null
# Load the savegames when loaded
func _ready():
refresh_savegames()
# A slot was pressed, save the game
func _on_slot_pressed(p_slot_n: int):
_slot_pressed = p_slot_n
if escoria.save_manager.save_game_exists(p_slot_n):
$overwrite_confirm_popup.popup_centered_ratio(.3)
else:
$save_name_popup.popup_centered_ratio(.3)
# Create the slots from the list of savegames
func refresh_savegames():
var _slots = $VBoxContainer/ScrollContainer/slots
for slot in _slots.get_children():
_slots.remove_child(slot)
var saves_list = escoria.save_manager.get_saves_list()
for i in saves_list.size():
var save_data = saves_list[i+1]
var new_slot = slot_ui_scene.instance()
_slots.add_child(new_slot)
new_slot.set_slot_name_date(save_data["name"], save_data["date"])
new_slot.connect("pressed", self, "_on_slot_pressed", [i+1])
var datetime = OS.get_datetime()
var datetime_string = "%02d/%02d/%02d %02d:%02d" % [
datetime["day"],
datetime["month"],
datetime["year"],
datetime["hour"],
datetime["minute"],
]
var new_slot = slot_ui_scene.instance()
_slots.add_child(new_slot)
new_slot.set_slot_name_date(tr("New save"), datetime_string)
new_slot.connect("pressed", self, "_on_slot_pressed", [saves_list.size()+1])
# The back button was pressed
func _on_back_pressed():
emit_signal("back_button_pressed")
# The name for the save game was given, save the game.
#
# #### Parameters
# - p_savename: The name of the savegame entered
func _on_save_name_popup_savegame_name_ok(p_savename: String):
escoria.save_manager.save_game(_slot_pressed, p_savename)
refresh_savegames()
_slot_pressed = null
# Overwriting the savegame was confirmed, show the save name popup
func _on_overwrite_confirm_popup_confirm_yes():
$save_name_popup.popup_centered_ratio(.3)

View File

@@ -0,0 +1,63 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/load_save_slot/load_save_slot.tscn" type="PackedScene" id=1]
[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/save/save_game.gd" type="Script" id=2]
[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/save/save_name_popup.tscn" type="PackedScene" id=4]
[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/save/overwrite_confirm_popup.tscn" type="PackedScene" id=5]
[node name="save_game" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
slot_ui_scene = ExtResource( 1 )
[node name="save_name_popup" parent="." instance=ExtResource( 4 )]
visible = false
[node name="overwrite_confirm_popup" parent="." instance=ExtResource( 5 )]
visible = false
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchor_left = 0.3
anchor_top = 0.3
anchor_right = 0.7
anchor_bottom = 0.7
margin_left = -55.5
margin_right = 55.5
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer"]
margin_right = 623.0
margin_bottom = 336.0
size_flags_vertical = 3
scroll_horizontal_enabled = false
__meta__ = {
"_edit_use_anchors_": false
}
[node name="slots" type="VBoxContainer" parent="VBoxContainer/ScrollContainer"]
margin_right = 623.0
margin_bottom = 336.0
size_flags_horizontal = 3
size_flags_vertical = 3
__meta__ = {
"_edit_use_anchors_": false
}
[node name="back" type="Button" parent="VBoxContainer"]
margin_top = 340.0
margin_right = 623.0
margin_bottom = 360.0
text = "OPTIONS_BACK"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="savegame_name_ok" from="save_name_popup" to="." method="_on_save_name_popup_savegame_name_ok"]
[connection signal="confirm_yes" from="overwrite_confirm_popup" to="." method="_on_overwrite_confirm_popup_confirm_yes"]
[connection signal="pressed" from="VBoxContainer/back" to="." method="_on_back_pressed"]

View File

@@ -0,0 +1,14 @@
extends PopupDialog
signal savegame_name_ok(savegame_name)
signal savegame_cancel
func _on_cancel_pressed():
emit_signal("savegame_cancel")
hide()
func _on_ok_pressed():
if not $MarginContainer/VBoxContainer/LineEdit.text.empty():
emit_signal("savegame_name_ok", $MarginContainer/VBoxContainer/LineEdit.text)
$MarginContainer/VBoxContainer/LineEdit.clear()
hide()

View File

@@ -0,0 +1,72 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/save/save_name_popup.gd" type="Script" id=2]
[node name="save_name_popup" type="PopupDialog"]
visible = true
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MarginContainer" type="MarginContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
custom_constants/margin_right = 30
custom_constants/margin_top = 30
custom_constants/margin_left = 30
custom_constants/margin_bottom = 30
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
margin_left = 30.0
margin_top = 401.0
margin_right = 1250.0
margin_bottom = 499.0
size_flags_vertical = 4
custom_constants/separation = 20
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer"]
margin_right = 1220.0
margin_bottom = 14.0
text = "ENTER_SAVE_NAME"
[node name="LineEdit" type="LineEdit" parent="MarginContainer/VBoxContainer"]
margin_top = 34.0
margin_right = 1220.0
margin_bottom = 58.0
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
margin_top = 78.0
margin_right = 1220.0
margin_bottom = 98.0
custom_constants/separation = 10
alignment = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="cancel" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
margin_left = 1118.0
margin_right = 1179.0
margin_bottom = 20.0
text = "CANCEL"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ok" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
margin_left = 1189.0
margin_right = 1220.0
margin_bottom = 20.0
text = "OK"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/cancel" to="." method="_on_cancel_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/ok" to="." method="_on_ok_pressed"]

View File

@@ -0,0 +1,37 @@
# A simple main menu
extends Control
# Start the game
func _on_new_game_pressed():
escoria.new_game()
# Show the load slots
func _on_load_game_pressed():
$main.hide()
$load_game.refresh_savegames()
$load_game.show()
# Show the options panel
func _on_options_pressed():
$main.hide()
$options.show()
# Quit the game
func _on_quit_pressed():
get_tree().quit()
# Hide the options panel again
func _on_options_back_button_pressed():
$options.hide()
$main.show()
# Hide the load panel
func _on_load_game_back_button_pressed():
$load_game.hide()
$main.show()

View File

@@ -0,0 +1,103 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://addons/escoria-core/ui_library/menus/main_menu/main_menu.gd" type="Script" id=1]
[ext_resource path="res://addons/escoria-core/design/escoria-logo-small.png" type="Texture" id=3]
[ext_resource path="res://addons/escoria-core/ui_library/menus/options/options.tscn" type="PackedScene" id=4]
[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/load/load_game.tscn" type="PackedScene" id=5]
[node name="main_menu" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="load_game" parent="." instance=ExtResource( 5 )]
visible = false
[node name="options" parent="." instance=ExtResource( 4 )]
visible = false
[node name="main" type="Control" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
[node name="Panel" type="Panel" parent="main"]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false,
"_editor_description_": ""
}
[node name="main" type="VBoxContainer" parent="main"]
anchor_left = 0.5
anchor_right = 0.5
anchor_bottom = 1.0
margin_left = -308.0
margin_right = 308.0
custom_constants/separation = 100
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TextureRect" type="TextureRect" parent="main/main"]
margin_top = 162.0
margin_right = 616.0
margin_bottom = 398.0
texture = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="buttons" type="VBoxContainer" parent="main/main"]
margin_top = 498.0
margin_right = 616.0
margin_bottom = 738.0
custom_constants/separation = 10
__meta__ = {
"_edit_use_anchors_": false
}
[node name="new_game" type="Button" parent="main/main/buttons"]
margin_right = 616.0
margin_bottom = 150.0
rect_min_size = Vector2( 0, 150 )
size_flags_vertical = 3
text = "NEW_GAME"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="load_game" type="Button" parent="main/main/buttons"]
margin_top = 160.0
margin_right = 616.0
margin_bottom = 180.0
text = "LOAD_GAME"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="options" type="Button" parent="main/main/buttons"]
margin_top = 190.0
margin_right = 616.0
margin_bottom = 210.0
text = "OPTIONS"
[node name="quit" type="Button" parent="main/main/buttons"]
margin_top = 220.0
margin_right = 616.0
margin_bottom = 240.0
text = "QUIT"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="back_button_pressed" from="load_game" to="." method="_on_load_game_back_button_pressed"]
[connection signal="back_button_pressed" from="options" to="." method="_on_options_back_button_pressed"]
[connection signal="pressed" from="main/main/buttons/new_game" to="." method="_on_new_game_pressed"]
[connection signal="pressed" from="main/main/buttons/load_game" to="." method="_on_load_game_pressed"]
[connection signal="pressed" from="main/main/buttons/options" to="." method="_on_options_pressed"]
[connection signal="pressed" from="main/main/buttons/quit" to="." method="_on_quit_pressed"]

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -0,0 +1,124 @@
# An options menu
extends Control
# The back button was pressed
signal back_button_pressed
# The current settings
var backup_settings
# A list of languages already added to the language selection
var _loaded_languages: Array = []
# The settings changed
onready var settings_changed = false
# Initialize the flags
func _ready() -> void:
var _flags_container: HBoxContainer = \
$VBoxContainer/MarginContainer/options/flags
for child in _flags_container.get_children():
_flags_container.remove_child(child)
_loaded_languages = []
for lang in TranslationServer.get_loaded_locales():
if not lang in _loaded_languages:
_loaded_languages.append(lang)
var _lang = TextureRect.new()
_lang.texture = load(
"res://addons/escoria-core/ui_library" + \
"/menus/options/flags/%s.png" % lang
)
_flags_container.add_child(_lang)
_lang.connect("gui_input", self, "_on_language_input", [lang])
# Show the options
func show():
backup_settings = escoria.settings.duplicate()
initialize_options(escoria.settings)
visible = true
# Set the sliders to the values of the settings
#
# #### Parameters
# - p_settings: The settings to use
func initialize_options(p_settings):
var _options = $VBoxContainer/MarginContainer/options
_options.get_node("general_volume").value = p_settings["master_volume"]
_options.get_node("sound_volume").value = p_settings["sfx_volume"]
_options.get_node("music_volume").value = p_settings["music_volume"]
_options.get_node("speech_volume").value = p_settings["speech_volume"]
# The language was changed
#
# #### Parameters
# - event: The input event from the flag
# - language: The language to set
func _on_language_input(event: InputEvent, language: String):
if event.is_pressed():
TranslationServer.set_locale(language)
escoria.settings["text_lang"] = language
settings_changed = true
# Sound volume was changed
#
# #### Parameters
# - value: The new volume level
func _on_sound_volume_changed(value):
escoria.settings["sfx_volume"] = value
escoria._on_settings_loaded(escoria.settings)
settings_changed = true
# Music volume was changed
#
# #### Parameters
# - value: The new volume level
func _on_music_volume_changed(value):
escoria.settings["music_volume"] = value
escoria._on_settings_loaded(escoria.settings)
settings_changed = true
# General volume was changed
#
# #### Parameters
# - value: The new volume level
func _on_general_volume_changed(value):
escoria.settings["master_volume"] = value
escoria._on_settings_loaded(escoria.settings)
settings_changed = true
# Speech volume was changed
#
# #### Parameters
# - value: The new volume level
func _on_speech_volume_value_changed(value: float) -> void:
escoria.settings["speech_volume"] = value
escoria._on_settings_loaded(escoria.settings)
settings_changed = true
# Save the settings
func _on_apply_pressed():
escoria.save_manager.save_settings()
settings_changed = false
emit_signal("back_button_pressed")
# The back button was pressed
func _on_back_pressed():
escoria.settings = backup_settings
escoria._on_settings_loaded(escoria.settings)
emit_signal("back_button_pressed")

View File

@@ -0,0 +1,168 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://addons/escoria-core/ui_library/menus/options/flags/de.png" type="Texture" id=1]
[ext_resource path="res://addons/escoria-core/ui_library/menus/options/options.gd" type="Script" id=4]
[node name="options" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 4 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer"]
margin_left = 391.0
margin_top = 340.0
margin_right = 888.0
margin_bottom = 535.0
size_flags_horizontal = 6
custom_constants/margin_right = 20
custom_constants/margin_top = 20
custom_constants/margin_left = 20
custom_constants/margin_bottom = 20
[node name="options" type="GridContainer" parent="VBoxContainer/MarginContainer"]
margin_left = 20.0
margin_top = 20.0
margin_right = 477.0
margin_bottom = 175.0
size_flags_vertical = 6
custom_constants/hseparation = 40
columns = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="label" type="Label" parent="VBoxContainer/MarginContainer/options"]
margin_top = 30.0
margin_right = 137.0
margin_bottom = 44.0
text = "OPTIONS_LANGUAGE"
[node name="flags" type="HBoxContainer" parent="VBoxContainer/MarginContainer/options"]
margin_left = 177.0
margin_right = 457.0
margin_bottom = 75.0
size_flags_vertical = 3
custom_constants/separation = 30
alignment = 1
[node name="TextureRect2" type="TextureRect" parent="VBoxContainer/MarginContainer/options/flags"]
margin_right = 125.0
margin_bottom = 75.0
texture = ExtResource( 1 )
[node name="TextureRect3" type="TextureRect" parent="VBoxContainer/MarginContainer/options/flags"]
margin_left = 155.0
margin_right = 280.0
margin_bottom = 75.0
texture = ExtResource( 1 )
[node name="label2" type="Label" parent="VBoxContainer/MarginContainer/options"]
margin_top = 80.0
margin_right = 137.0
margin_bottom = 94.0
text = "GENERAL_VOLUME"
[node name="general_volume" type="HSlider" parent="VBoxContainer/MarginContainer/options"]
margin_left = 177.0
margin_top = 79.0
margin_right = 457.0
margin_bottom = 95.0
size_flags_horizontal = 3
min_value = 0.001
max_value = 1.0
step = 0.001
value = 0.001
[node name="label3" type="Label" parent="VBoxContainer/MarginContainer/options"]
margin_top = 100.0
margin_right = 137.0
margin_bottom = 114.0
text = "SOUND_VOLUME"
[node name="sound_volume" type="HSlider" parent="VBoxContainer/MarginContainer/options"]
margin_left = 177.0
margin_top = 99.0
margin_right = 457.0
margin_bottom = 115.0
size_flags_horizontal = 3
min_value = 0.001
max_value = 1.0
step = 0.001
value = 0.001
[node name="label4" type="Label" parent="VBoxContainer/MarginContainer/options"]
margin_top = 120.0
margin_right = 137.0
margin_bottom = 134.0
text = "MUSIC_VOLUME"
[node name="music_volume" type="HSlider" parent="VBoxContainer/MarginContainer/options"]
margin_left = 177.0
margin_top = 119.0
margin_right = 457.0
margin_bottom = 135.0
size_flags_horizontal = 3
min_value = 0.001
max_value = 1.0
step = 0.001
value = 0.001
[node name="label5" type="Label" parent="VBoxContainer/MarginContainer/options"]
margin_top = 140.0
margin_right = 137.0
margin_bottom = 154.0
text = "SPEECH_VOLUME"
[node name="speech_volume" type="HSlider" parent="VBoxContainer/MarginContainer/options"]
margin_left = 177.0
margin_top = 139.0
margin_right = 457.0
margin_bottom = 155.0
size_flags_horizontal = 3
min_value = 0.001
max_value = 1.0
step = 0.001
value = 0.001
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 539.0
margin_right = 1280.0
margin_bottom = 559.0
custom_constants/separation = 20
alignment = 1
[node name="back" type="Button" parent="VBoxContainer/HBoxContainer"]
margin_left = 549.0
margin_right = 660.0
margin_bottom = 20.0
text = "OPTIONS_BACK"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="apply" type="Button" parent="VBoxContainer/HBoxContainer"]
margin_left = 680.0
margin_right = 731.0
margin_bottom = 20.0
text = "APPLY"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="value_changed" from="VBoxContainer/MarginContainer/options/general_volume" to="." method="_on_general_volume_changed"]
[connection signal="value_changed" from="VBoxContainer/MarginContainer/options/sound_volume" to="." method="_on_sound_volume_changed"]
[connection signal="value_changed" from="VBoxContainer/MarginContainer/options/music_volume" to="." method="_on_music_volume_changed"]
[connection signal="value_changed" from="VBoxContainer/MarginContainer/options/speech_volume" to="." method="_on_speech_volume_value_changed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/back" to="." method="_on_back_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/apply" to="." method="_on_apply_pressed"]

View File

@@ -0,0 +1,51 @@
# A menu shown in game
extends Control
# Make the pause menu process in pause mode and hide it just to be sure
func _ready():
self.pause_mode = Node.PAUSE_MODE_PROCESS
hide()
# Continue the game
func _on_continue_pressed():
escoria.main.current_scene.game.pause_game()
# Show the save slots
func _on_save_game_pressed():
$VBoxContainer.hide()
$save_game.show()
# Show the load slots
func _on_load_game_pressed():
$VBoxContainer.hide()
$load_game.refresh_savegames()
$load_game.show()
# Quit the game
func _on_quit_pressed():
get_tree().quit()
# Hide the save slots again
func _on_save_game_back_button_pressed():
$VBoxContainer.show()
$save_game.hide()
# Hide the load slots again
func _on_load_game_back_button_pressed():
$VBoxContainer.show()
$load_game.hide()
# Set wether saving is enabled currently
#
# #### Parameters
# - p_enabled: Enable or disable saving
func set_save_enabled(p_enabled: bool):
$VBoxContainer/menuitems/save_game.disabled = !p_enabled

View File

@@ -0,0 +1,104 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://addons/escoria-core/ui_library/menus/pause_menu/pause_menu.gd" type="Script" id=1]
[ext_resource path="res://addons/escoria-core/design/escoria-logo-small.png" type="Texture" id=3]
[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/save/save_game.tscn" type="PackedScene" id=4]
[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/load/load_game.tscn" type="PackedScene" id=5]
[node name="pause_menu" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Panel" type="Panel" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="save_game" parent="." instance=ExtResource( 4 )]
visible = false
[node name="load_game" parent="." instance=ExtResource( 5 )]
visible = false
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchor_left = 0.5
anchor_right = 0.5
anchor_bottom = 1.0
margin_left = -308.0
margin_right = 308.0
custom_constants/separation = 100
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TextureRect" type="TextureRect" parent="VBoxContainer"]
margin_top = 162.0
margin_right = 616.0
margin_bottom = 398.0
texture = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="menuitems" type="VBoxContainer" parent="VBoxContainer"]
margin_top = 498.0
margin_right = 616.0
margin_bottom = 738.0
custom_constants/separation = 10
__meta__ = {
"_edit_use_anchors_": false
}
[node name="continue" type="Button" parent="VBoxContainer/menuitems"]
margin_right = 616.0
margin_bottom = 150.0
rect_min_size = Vector2( 0, 150 )
size_flags_vertical = 3
text = "CONTINUE_GAME"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="save_game" type="Button" parent="VBoxContainer/menuitems"]
margin_top = 160.0
margin_right = 616.0
margin_bottom = 180.0
size_flags_vertical = 3
text = "SAVE_GAME"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="load_game" type="Button" parent="VBoxContainer/menuitems"]
margin_top = 190.0
margin_right = 616.0
margin_bottom = 210.0
size_flags_vertical = 3
text = "LOAD_GAME"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="quit" type="Button" parent="VBoxContainer/menuitems"]
margin_top = 220.0
margin_right = 616.0
margin_bottom = 240.0
size_flags_vertical = 3
text = "QUIT"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="back_button_pressed" from="save_game" to="." method="_on_save_game_back_button_pressed"]
[connection signal="back_button_pressed" from="load_game" to="." method="_on_load_game_back_button_pressed"]
[connection signal="pressed" from="VBoxContainer/menuitems/continue" to="." method="_on_continue_pressed"]
[connection signal="pressed" from="VBoxContainer/menuitems/save_game" to="." method="_on_save_game_pressed"]
[connection signal="pressed" from="VBoxContainer/menuitems/load_game" to="." method="_on_load_game_pressed"]
[connection signal="pressed" from="VBoxContainer/menuitems/quit" to="." method="_on_quit_pressed"]

View File

@@ -0,0 +1,64 @@
# A small utility to quickly switch to a room while developing
extends OptionButton
# The selected option
var _selected_id = 0
# The path to available rooms
var _options_paths = []
# Build up the list of rooms
func _ready():
var rooms_folder = ProjectSettings.get_setting(
"escoria/debug/room_selector_room_dir"
)
if rooms_folder == "" or \
not ProjectSettings.get_setting("escoria/debug/enable_room_selector"):
return
var dir = Directory.new()
var rooms_list: Array = []
var path = ProjectSettings.globalize_path(rooms_folder)
if not OS.has_feature("editor"):
path = OS.get_executable_path().get_base_dir().plus_file(path)
var tmp = dir.open(path)
if tmp == OK:
dir.list_dir_begin(true)
var file_name = dir.get_next()
while file_name != "":
if dir.current_is_dir():
rooms_list.push_back(file_name)
file_name = dir.get_next()
rooms_list.sort()
for room in rooms_list:
add_item(room)
_options_paths.push_back("%s/%s/%s.tscn" %[
rooms_folder,
room,
room
])
else:
escoria.logger.report_warnings("room_select.gd:_ready()",
["A problem occurred while opening rooms folder."])
# Switch to the selected room
func _on_button_pressed():
var script = escoria.esc_compiler.compile([
":debug",
"change_scene %s" % _options_paths[_selected_id]
])
escoria.event_manager.interrupt_running_event()
escoria.event_manager.queue_event(script.events['debug'])
# A room was selected, store the selection
#
# #### Parameters
# - index: The index of the selected room in the paths list
func _on_option_item_selected(index):
_selected_id = index

View File

@@ -0,0 +1,25 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/escoria-core/ui_library/tools/room_select/room_select.gd" type="Script" id=1]
[node name="room_select" type="HBoxContainer"]
margin_right = 63.0
margin_bottom = 40.0005
__meta__ = {
"_edit_use_anchors_": false
}
[node name="option" type="OptionButton" parent="."]
margin_right = 29.0
margin_bottom = 40.0
size_flags_horizontal = 3
script = ExtResource( 1 )
[node name="button" type="Button" parent="."]
margin_left = 33.0
margin_right = 63.0
margin_bottom = 40.0
text = "Go"
[connection signal="item_selected" from="option" to="option" method="_on_option_item_selected"]
[connection signal="pressed" from="button" to="option" method="_on_button_pressed"]