This commit is contained in:
2023-02-24 20:38:31 +01:00
parent c78d37b12a
commit 1d483479e5
9 changed files with 304 additions and 4 deletions

View File

@@ -31,9 +31,6 @@ margin_bottom = 1200.0
mouse_filter = 2 mouse_filter = 2
texture = ExtResource( 7 ) texture = ExtResource( 7 )
script = ExtResource( 2 ) script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="room_label" type="Label" parent="ESCBackground"] [node name="room_label" type="Label" parent="ESCBackground"]
margin_right = 82.0 margin_right = 82.0

View File

@@ -0,0 +1,212 @@
# A tooltip displaying <verb> <item1> [<item2>]
tool
extends Node2D
class_name ESCRichTooltip
# Maximum width of the label
const MAX_WIDTH = 200
# Minimum height of the label
const MIN_HEIGHT = 30
# Maximum height of the label
const MAX_HEIGHT = 500
# Height of one line in the label
const ONE_LINE_HEIGHT = 16
# Color of the label
export(Color) var color setget set_color
# Vector2 defining the offset from the cursor
export(Vector2) var offset_from_cursor = Vector2(10,0)
# Activates debug mode. If enabled, shows the label with a white background.
export(bool) var debug_mode = false setget set_debug_mode
# Infinitive verb
var current_action: String
# Target item/hotspot
var current_target: String setget set_target
# Preposition: on, with...
var current_prep: String = "with"
# Target 2 item/hotspot
var current_target2: String
# True if tooltip is waiting for a click on second target (use x with y)
var waiting_for_target2 = false
# Node containing the debug white background
var debug_texturerect_node: TextureRect
# Indicates whether the current room is loaded and ready
var _room_is_ready: bool = false
# Connect relevant functions
func _ready():
escoria.main.connect("room_ready", self, "_on_room_ready")
escoria.action_manager.connect("action_changed", self, "_on_action_selected")
# Set the color of the label
#
# ## Parameters
# - p_color: the color to set the label
func set_color(p_color: Color):
color = p_color
if _room_is_ready:
update_tooltip_text()
# Enable/disable debug mode of the label. If enabled, the label is displayed
# with a white background.
#
# ## Parameters
# - p_debug_mode: if true, enable debug mode. False to disable
func set_debug_mode(p_debug_mode: bool):
debug_mode = p_debug_mode
if debug_mode:
# Add a white TextureRect behind the RTL to see its actual size
debug_texturerect_node = TextureRect.new()
add_child(debug_texturerect_node)
debug_texturerect_node.texture = load("res://addons/escoria-core/game/assets/images/white.png")
debug_texturerect_node.expand = true
debug_texturerect_node.stretch_mode = TextureRect.STRETCH_TILE
#debug_texturerect_node.size_flags_horizontal = SIZE_EXPAND_FILL
debug_texturerect_node.size_flags_vertical = SIZE_EXPAND_FILL
debug_texturerect_node.show_behind_parent = true
debug_texturerect_node.anchor_right = 1.0
debug_texturerect_node.anchor_bottom = 1.0
debug_texturerect_node.mouse_filter = Control.MOUSE_FILTER_IGNORE
move_child(debug_texturerect_node, 2)
else:
if debug_texturerect_node:
remove_child(debug_texturerect_node)
debug_texturerect_node.queue_free()
# Set the first target of the label.
#
# ## Parameters
# - target: String the target to add to the label
# - needs_second_target: if true, the label will prepare for a second target
func set_target(target: String, needs_second_target: bool = false) -> void:
current_target = target
waiting_for_target2 = needs_second_target
if _room_is_ready:
update_tooltip_text()
# Set the second target of the label
#
# ## Parameters
# - target2: String the second target to add to the label
func set_target2(target2: String) -> void:
current_target2 = target2
if _room_is_ready:
update_tooltip_text()
# Update the tooltip text.
func update_tooltip_text():
"""
Overriden method. Should not be called directly.
"""
pass
# Update the tooltip size according to the text.
func update_size():
if not get_tree():
# We're not in the tree anymore. Return
return
rect_size = get_font("normal_font").get_string_size(current_target)
# Calculate the offset of the label depending on its position.
#
# ## Parameters
# - position: the position to test
#
# **Return**
# The calculated offset
func _offset(position: Vector2) -> Vector2:
var center_offset_x = rect_size.x / 2
var offset_y = 5
position.x -= center_offset_x
position.y += offset_y
return position
# Return the tooltip distance to top edge.
#
# ## Parameters
# - position: the position to test
#
# **Return**
# The distance to the edge.
func tooltip_distance_to_edge_top(position: Vector2):
return position.y
# Return the tooltip distance to bottom edge.
#
# ## Parameters
# - position: the position to test
#
# **Return**
# The distance to the edge.
func tooltip_distance_to_edge_bottom(position: Vector2):
return escoria.game_size.y - position.y
# Return the tooltip distance to left edge.
#
# ## Parameters
# - position: the position to test
#
# **Return**
# The distance to the edge.
func tooltip_distance_to_edge_left(position: Vector2):
return position.x
# Return the tooltip distance to right edge.
#
# ## Parameters
# - position: the position to test
#
# **Return**
# The distance to the edge.
func tooltip_distance_to_edge_right(position: Vector2):
return escoria.game_size.x - position.x
# Clear the tooltip targets texts
func clear():
waiting_for_target2 = false
set_target("")
set_target2("")
# Called when the room is loaded to setup the label.
func _on_room_ready():
escoria.main.current_scene.game.tooltip_node = self
_room_is_ready = true
# Called when an action is selected in Escoria
func _on_action_selected() -> void:
current_action = escoria.action_manager.current_action
if _room_is_ready:
update_tooltip_text()

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 MiB

View File

@@ -0,0 +1,18 @@
:setup
teleport player l_start_detras
# Set player look down
set_angle player 0
camera_set_target 0 player
stop
#> [eq ESC_LAST_SCENE trasera_cocina]
# teleport player l_start_detras
# Set player look down
# set_angle player 0
# camera_set_target 0 player
# stop
#> [eq ESC_LAST_SCENE room5]
# teleport player r_exit
# # Set player look left
# camera_set_target 0 player
# set_angle player 270
# stop

View File

@@ -0,0 +1,2 @@
:exit_scene
change_scene "res://gymkhana/rooms/trasera_cocina/trasera_cocina.tscn"

View File

@@ -0,0 +1,65 @@
[gd_scene load_steps=10 format=2]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_background.gd" type="Script" id=1]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_room.gd" type="Script" id=2]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_location.gd" type="Script" id=3]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_terrain.gd" type="Script" id=4]
[ext_resource path="res://gymkhana/rooms/interior_cocina/assets/cocina_interior_vista_completa-577h.png" type="Texture" id=5]
[ext_resource path="res://gymkhana/addons/escoria-ui-return-monkey-island/esc_item_with_tooltip.gd" type="Script" id=6]
[ext_resource path="res://gymkhana/characters/oier/oier.tscn" type="PackedScene" id=7]
[ext_resource path="res://gymkhana/rooms/interior_cocina/assets/cocina_interior_vista_completa-577h-depth.png" type="Texture" id=8]
[sub_resource type="NavigationPolygon" id=1]
vertices = PoolVector2Array( 2404, 380, 2407, 413, 2067, 355, 2040, 322, 1787, 387, 1788.8, 435.475, 1606, 453, 1634, 513, 1600, 512, 1792, 522, 1621, 576, 648, 564, 463, 561, 275, 549, 274, 516, 413, 417, 543, 411, 779, 404, 839, 576, 809, 667, 2745, 677, 1884, 577, 2553, 380, 2595, 485, 2369, 574, 2725, 472, 2745, 505, 1850, 544 )
polygons = [ PoolIntArray( 0, 1, 2, 3 ), PoolIntArray( 4, 3, 2, 5, 6 ), PoolIntArray( 7, 8, 6, 5 ), PoolIntArray( 7, 5, 9, 10 ), PoolIntArray( 11, 12, 13, 14, 15, 16, 17 ), PoolIntArray( 11, 17, 18, 19 ), PoolIntArray( 20, 19, 18, 10, 21 ), PoolIntArray( 0, 22, 23, 24 ), PoolIntArray( 23, 25, 26, 20, 24 ), PoolIntArray( 10, 9, 27, 21 ), PoolIntArray( 20, 21, 24 ) ]
outlines = [ PoolVector2Array( 2725, 472, 2745, 505, 2745, 677, 809, 667, 648, 564, 463, 561, 275, 549, 274, 516, 413, 417, 543, 411, 779, 404, 839, 576, 1621, 576, 1634, 513, 1600, 512, 1606, 453, 1787, 387, 2040, 322, 2408, 380, 2407, 413, 2067, 355, 1788.8, 435.475, 1792, 522, 1850, 544, 1884, 577, 2369, 574, 2404, 380, 2553, 380, 2595, 485 ) ]
[node name="ESCRoom" type="Node2D"]
script = ExtResource( 2 )
global_id = "interior_cocina"
player_scene = ExtResource( 7 )
[node name="ESCBackground" type="TextureRect" parent="."]
margin_left = -1650.0
margin_top = 3.0
margin_right = 5955.0
margin_bottom = 1503.0
mouse_filter = 2
texture = ExtResource( 5 )
script = ExtResource( 1 )
[node name="ESCTerrain" type="Navigation2D" parent="."]
position = Vector2( -1650, 3 )
script = ExtResource( 4 )
scales = ExtResource( 8 )
[node name="NavigationPolygonInstance" type="NavigationPolygonInstance" parent="ESCTerrain"]
navpoly = SubResource( 1 )
[node name="start_detras" type="Position2D" parent="."]
position = Vector2( 445, 353 )
script = ExtResource( 3 )
global_id = "l_start_detras"
is_start_location = true
[node name="start_delante" type="Position2D" parent="."]
position = Vector2( 1064, 506 )
script = ExtResource( 3 )
global_id = "l_start_delante"
[node name="salida_detras" type="Area2D" parent="."]
pause_mode = 1
position = Vector2( 440, 257 )
script = ExtResource( 6 )
global_id = "salida_detras"
esc_script = "res://gymkhana/rooms/interior_cocina/esc/salida_detras.esc"
combine_when_selected_action_is_in = [ ]
dialog_color = Color( 1, 1, 1, 1 )
animations = null
[node name="ESCLocation" type="Position2D" parent="salida_detras"]
position = Vector2( 59, 89 )
script = ExtResource( 3 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="salida_detras"]
polygon = PoolVector2Array( -12, 69, -47, 64, -48, -96, -11, -104, 44, -95, 51, 66 )

View File

@@ -16,4 +16,4 @@ say player "Parece que veo a Mikel"
:action2 :action2
#say player "Esta cerrada por dentro." #say player "Esta cerrada por dentro."
play_snd res://game/sfx/sounds/doorOpen_2.ogg play_snd res://game/sfx/sounds/doorOpen_2.ogg
change_scene "res://gymkhana/rooms/home/home.tscn" change_scene "res://gymkhana/rooms/interior_cocina/interior_cocina.tscn"

View File

@@ -395,6 +395,11 @@ _global_script_classes=[ {
"path": "res://gymkhana/addons/escoria-ui-return-monkey-island-dialog-simple/esc_dialog_simple.gd" "path": "res://gymkhana/addons/escoria-ui-return-monkey-island-dialog-simple/esc_dialog_simple.gd"
}, { }, {
"base": "Node2D", "base": "Node2D",
"class": "ESCRichTooltip",
"language": "GDScript",
"path": "res://gymkhana/addons/escoria-ui-return-monkey-island/esc_rich_tooltip.gd"
}, {
"base": "Node2D",
"class": "ESCRoom", "class": "ESCRoom",
"language": "GDScript", "language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc_room.gd" "path": "res://addons/escoria-core/game/core-scripts/esc_room.gd"
@@ -777,6 +782,7 @@ _global_script_class_icons={
"ESCResourceCache": "", "ESCResourceCache": "",
"ESCResourceDescriptor": "", "ESCResourceDescriptor": "",
"ESCReturnToMonekyIslandDialogs": "", "ESCReturnToMonekyIslandDialogs": "",
"ESCRichTooltip": "",
"ESCRoom": "res://addons/escoria-core/design/esc_room.svg", "ESCRoom": "res://addons/escoria-core/design/esc_room.svg",
"ESCRoomManager": "", "ESCRoomManager": "",
"ESCRoomObjects": "", "ESCRoomObjects": "",