Added hover stack to manage overlapping Area2Ds

Added room selector in demo scenes
Modified dialogues in room 1, fixed bug in room 8 and 9
This commit is contained in:
Julian Murgia
2021-02-03 17:26:12 +01:00
parent b789490f63
commit bd3ef71c80
33 changed files with 253 additions and 202 deletions

View File

@@ -0,0 +1,36 @@
extends OptionButton
var selected_id = 0
var options_paths = []
func _ready():
var rooms_folder = "res://game/rooms/"
var dir = Directory.new()
var i = 1
if dir.open(rooms_folder) == OK:
dir.list_dir_begin(true)
var file_name = dir.get_next()
while file_name != "":
if dir.current_is_dir():
add_item(file_name)
options_paths.push_back("res://game/rooms/" + file_name + "/" + file_name + ".tscn")
i += 1
file_name = dir.get_next()
else:
escoria.report_errors("room_select.gd:_ready()",
["A problem occurred while opening rooms folder."])
func _on_button_pressed():
var actual_command = ":debug\nchange_scene " + options_paths[selected_id] + "\n"
var errors = []
var events = escoria.esc_compiler.compile_str(actual_command, errors)
if errors.empty():
#past_actions.text += str(events)
var ret = escoria.esc_runner.run_event(events["debug"])
func _on_option_item_selected(index):
selected_id = index

View File

@@ -0,0 +1,24 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://game/ui/commons/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
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"]

View File

@@ -24,10 +24,14 @@ Implement methods to react to inputs.
- mousewheel_action(direction : int)
- hide_ui()
- show_ui()
- _on_event_done(event_name: String)
"""
signal element_focused(element_global_id)
func _ready():
escoria.esc_runner.connect("event_done", self, "_on_event_done")
func _input(event):
@@ -42,29 +46,27 @@ func _input(event):
func left_click_on_bg(position : Vector2) -> void:
escoria.do("walk", ["player", position])
escoria.esc_runner.clear_current_action()
$ui/verbs_layer/verbs_menu.unselect_actions()
func right_click_on_bg(position : Vector2) -> void:
escoria.do("walk", ["player", position])
escoria.esc_runner.clear_current_action()
$ui/verbs_layer/verbs_menu.unselect_actions()
func left_double_click_on_bg(position : Vector2) -> void:
escoria.do("walk", ["player", position, true])
escoria.esc_runner.clear_current_action()
$ui/verbs_layer/verbs_menu.unselect_actions()
## ITEM FOCUS ##
func element_focused(element_id : String) -> void:
#emit_signal("element_focused", element_id)
# var target_obj = escoria.esc_runner.get_object(element_id)
# if escoria.esc_runner.current_action != "use" && escoria.esc_runner.current_tool == null:
# if target_obj is ESCItem or target_obj is ESCHotspot:
# $ui/verbs_layer/verbs_menu.set_by_name(target_obj.default_action)
pass
$ui/tooltip_layer/tooltip.set_target(escoria.esc_runner.get_object(element_id).tooltip_name)
func element_unfocused() -> void:
#emit_signal("element_focused", "")
#$ui/verbs_layer/verbs_menu.set_by_name("walk")
pass
$ui/tooltip_layer/tooltip.set_target("")
## ITEMS ##
@@ -97,10 +99,10 @@ func left_double_click_on_inventory_item(inventory_item_global_id : String, even
pass
func inventory_item_focused(inventory_item_global_id : String) -> void:
emit_signal("element_focused", inventory_item_global_id)
$ui/tooltip_layer/tooltip.set_target(escoria.esc_runner.get_object(inventory_item_global_id).tooltip_name)
func inventory_item_unfocused() -> void:
emit_signal("element_focused", "")
$ui/tooltip_layer/tooltip.set_target("")
func open_inventory():
@@ -124,3 +126,7 @@ func show_ui():
$ui/verbs_layer/verbs_menu.show()
$ui/inventory_layer/inventory_ui.show()
$ui/tooltip_layer/tooltip.show()
func _on_event_done(event_name: String):
escoria.esc_runner.clear_current_action()
$ui/verbs_layer/verbs_menu.unselect_actions()

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=9 format=2]
[ext_resource path="res://addons/escoria-core/template_scenes/label/action_target_tooltip.tscn" type="PackedScene" id=1]
[ext_resource path="res://game/ui/ui_9verbs/inventory/inventory_ui.tscn" type="PackedScene" id=2]
@@ -6,6 +6,7 @@
[ext_resource path="res://addons/escoria-core/game/scenes/dialogs/dialog_player.tscn" type="PackedScene" id=4]
[ext_resource path="res://game/ui/ui_9verbs/game.gd" type="Script" id=5]
[ext_resource path="res://addons/escoria-core/game/scenes/camera_player/camera.tscn" type="PackedScene" id=6]
[ext_resource path="res://game/ui/commons/room_select.tscn" type="PackedScene" id=7]
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0.6, 0.6, 0.6, 0.5 )
@@ -34,6 +35,12 @@ margin_top = 615.331
margin_right = 21.097
margin_bottom = 615.331
[node name="room_select" parent="ui/verbs_layer" instance=ExtResource( 7 )]
margin_left = 394.817
margin_top = 756.336
margin_right = 423.817
margin_bottom = 776.336
[node name="inventory_layer" type="CanvasLayer" parent="ui"]
layer = 2
@@ -61,4 +68,13 @@ layer = 3
[node name="dialog_player" parent="ui/dialog_layer" instance=ExtResource( 4 )]
[node name="hover_stack" type="Label" parent="ui"]
margin_left = 1085.0
margin_top = 2.81912
margin_right = 1283.0
margin_bottom = 107.819
__meta__ = {
"_edit_use_anchors_": false
}
[node name="camera" parent="." instance=ExtResource( 6 )]

View File

@@ -17,3 +17,6 @@ func _on_action_selected(action : String):
for but in $actions.get_children():
but.set_pressed(but.get_name() == action)
func unselect_actions():
for but in $actions.get_children():
but.set_pressed(false)

View File

@@ -2,7 +2,6 @@
[ext_resource path="res://game/ui/ui_9verbs/verbs_menu.gd" type="Script" id=1]
[node name="verbs_menu" type="Control"]
margin_left = 1.0
margin_right = 1.0