Deleted non-CC0 assets
Managed room7 camera pushes
This commit is contained in:
@@ -32,6 +32,7 @@ var commands = {
|
||||
"anim": { "min_args": 2, "types": [TYPE_STRING, TYPE_STRING, TYPE_BOOL, TYPE_BOOL, TYPE_BOOL] },
|
||||
"camera_push": { "min_args": 1, "types": [TYPE_STRING] },
|
||||
"camera_set_drag_margin_enabled": { "min_args": 2, "types": [TYPE_BOOL, TYPE_BOOL] },
|
||||
"camera_set_limits": { "min_args": 1, "types": [TYPE_INT]},
|
||||
"camera_set_pos": { "min_args": 3, "types": [TYPE_REAL, TYPE_INT, TYPE_INT] },
|
||||
"camera_set_target": { "min_args": 1, "types": [TYPE_REAL] },
|
||||
"camera_set_zoom": { "min_args": 1, "types": [TYPE_REAL] },
|
||||
|
||||
@@ -134,7 +134,11 @@ func camera_push(command_params : Array):
|
||||
var target = escoria.esc_runner.get_object(command_params[0])
|
||||
var time = command_params[1] if command_params.size() > 1 else 1
|
||||
var type = command_params[2] if command_params.size() > 2 else "QUAD"
|
||||
escoria.main.current_scene.game.get_node("camera").push(target, time, type)
|
||||
escoria.esc_runner.get_object("camera").push(target, time, type)
|
||||
|
||||
|
||||
func camera_set_limits(command_params : Array):
|
||||
escoria.main.set_camera_limits(command_params[0])
|
||||
|
||||
|
||||
"""
|
||||
@@ -163,8 +167,10 @@ This is the default behavior (default follow object is "player").
|
||||
If there's more than 1 object, the camera follows the average position of all
|
||||
the objects specified.
|
||||
"""
|
||||
func camera_set_target():
|
||||
pass
|
||||
func camera_set_target(command_params : Array):
|
||||
var speed = command_params[0]
|
||||
var target = escoria.esc_runner.get_object(command_params[1])
|
||||
escoria.esc_runner.get_object("camera").set_target(target, speed)
|
||||
|
||||
|
||||
"""
|
||||
@@ -180,7 +186,7 @@ func camera_set_zoom():
|
||||
|
||||
"""
|
||||
camera_set_zoom_height pixels [time]
|
||||
Similar to the command abo/ve, but uses pixel height instead of magnitude to zoom.
|
||||
Similar to the command above, but uses pixel height instead of magnitude to zoom.
|
||||
"""
|
||||
func camera_set_zoom_height():
|
||||
pass
|
||||
|
||||
@@ -60,6 +60,7 @@ func _enter_tree():
|
||||
add_child(area)
|
||||
|
||||
func _ready():
|
||||
# escoria.register_object(self)
|
||||
mouse_filter = MOUSE_FILTER_IGNORE
|
||||
area.connect("input_event", self, "manage_input")
|
||||
connect("gui_input", self, "manage_input_texturerect")
|
||||
@@ -71,6 +72,11 @@ func _ready():
|
||||
# connect("mouse_moved_on_bg", escoria.inputs_manager, "_on_mouse_moved_on_bg")
|
||||
|
||||
func manage_input(_viewport, event, _shape_idx):
|
||||
if 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:
|
||||
@@ -95,3 +101,21 @@ func manage_input_texturerect(event):
|
||||
emit_signal("right_click_on_bg", event.position)
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
func get_full_area_rect2() -> Rect2:
|
||||
var area_rect2 : Rect2 = Rect2()
|
||||
var pos = get_global_position()
|
||||
var size : Vector2
|
||||
if get_texture():
|
||||
size = get_texture().get_size()
|
||||
else:
|
||||
size = rect_size
|
||||
|
||||
if rect_scale.x != 1 or rect_scale.y != 1:
|
||||
size.x *= rect_scale.x
|
||||
size.y *= rect_scale.y
|
||||
|
||||
area_rect2 = area_rect2.expand(pos)
|
||||
area_rect2 = area_rect2.expand(pos + size)
|
||||
return area_rect2
|
||||
|
||||
@@ -245,6 +245,7 @@ func update_terrain(on_event_finished_name = null):
|
||||
return
|
||||
|
||||
var pos = position
|
||||
var gpos = global_position
|
||||
z_index = pos.y if pos.y <= VisualServer.CANVAS_ITEM_Z_MAX else VisualServer.CANVAS_ITEM_Z_MAX
|
||||
|
||||
var color
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
tool
|
||||
extends Node2D
|
||||
class_name ESCRoom
|
||||
|
||||
@@ -7,11 +8,33 @@ func get_class():
|
||||
export(String) var global_id = ""
|
||||
export(String, FILE, "*.esc") var esc_script = ""
|
||||
export(PackedScene) var player_scene
|
||||
export(Rect2) var camera_limits = Rect2()
|
||||
export(Array, Rect2) var camera_limits : Array = [Rect2()] setget set_camera_limits
|
||||
var player
|
||||
onready var game = $game
|
||||
|
||||
### EDITOR TOOLS ###
|
||||
enum EDITOR_ROOM_DEBUG_DISPLAY {
|
||||
NONE,
|
||||
CAMERA_LIMITS
|
||||
}
|
||||
export(EDITOR_ROOM_DEBUG_DISPLAY) var editor_debug_mode = EDITOR_ROOM_DEBUG_DISPLAY.NONE setget set_editor_debug_mode
|
||||
onready var camera_limits_colors : Array = [
|
||||
ColorN("red"), ColorN("blue"), ColorN("green")
|
||||
]
|
||||
### END EDITOR TOOLS ###
|
||||
|
||||
func _enter_tree():
|
||||
randomize()
|
||||
|
||||
|
||||
func _ready():
|
||||
if camera_limits.empty():
|
||||
camera_limits.push_back(Rect2())
|
||||
if camera_limits.size() == 1 and camera_limits[0].has_no_area():
|
||||
camera_limits[0] = Rect2(0, 0, $background.rect_size.x, $background.rect_size.y)
|
||||
|
||||
if Engine.is_editor_hint():
|
||||
return
|
||||
|
||||
if player_scene:
|
||||
player = player_scene.instance()
|
||||
@@ -25,3 +48,31 @@ func _ready():
|
||||
if global_id.empty():
|
||||
global_id = name
|
||||
|
||||
func _draw():
|
||||
if !Engine.is_editor_hint():
|
||||
return
|
||||
if editor_debug_mode == EDITOR_ROOM_DEBUG_DISPLAY.NONE:
|
||||
return
|
||||
|
||||
# If there are more camera limits than colors defined for them, add more.
|
||||
if camera_limits.size() > camera_limits_colors.size():
|
||||
for i in camera_limits.size() - camera_limits_colors.size():
|
||||
camera_limits_colors.push_back(Color(randf(), randf(), randf(), 1.0))
|
||||
|
||||
# Draw lines for camera limits
|
||||
for i in camera_limits.size():
|
||||
draw_rect(camera_limits[i], camera_limits_colors[i], false, 10.0)
|
||||
var default_font = Control.new().get_font("font")
|
||||
|
||||
draw_string(default_font, Vector2(camera_limits[i].position.x + 30,
|
||||
camera_limits[i].position.y + 30), str(i), camera_limits_colors[i])
|
||||
|
||||
return
|
||||
|
||||
func set_camera_limits(p_camera_limits : Array) -> void:
|
||||
camera_limits = p_camera_limits
|
||||
update()
|
||||
|
||||
func set_editor_debug_mode(p_editor_debug_mode : int) -> void:
|
||||
editor_debug_mode = p_editor_debug_mode
|
||||
update()
|
||||
|
||||
@@ -96,6 +96,9 @@ func register_object(object : Object):
|
||||
if object is ESCTerrain:
|
||||
room_terrain = object
|
||||
|
||||
# if object is ESCBackground:
|
||||
# $esc_runner.register_object(object_id, object, true)
|
||||
|
||||
if object is ESCCamera:
|
||||
$esc_runner.register_object(object_id, object, true)
|
||||
|
||||
|
||||
@@ -99,3 +99,9 @@ func _on_mouse_left_double_clicked_item(item_global_id : String, event : InputEv
|
||||
func _on_mouse_right_clicked_item(item_global_id : String, event : InputEvent) -> void:
|
||||
printt("Item right clicked", item_global_id, event)
|
||||
escoria.main.current_scene.game.right_click_on_item(item_global_id, event)
|
||||
|
||||
|
||||
##################################################################################
|
||||
|
||||
func _on_mousewheel_action(direction : int):
|
||||
escoria.main.current_scene.game.mousewheel_action(direction)
|
||||
|
||||
@@ -117,26 +117,14 @@ func _on_wait_finished():
|
||||
escoria.esc_level_runner.finished(wait_level)
|
||||
|
||||
|
||||
func set_camera_limits():
|
||||
func set_camera_limits(camera_limit_id : int = 0):
|
||||
var limits = {}
|
||||
var scene_camera_limits = current_scene.camera_limits
|
||||
var scene_camera_limits = current_scene.camera_limits[camera_limit_id]
|
||||
if scene_camera_limits.size.x == 0 and scene_camera_limits.size.y == 0:
|
||||
var area = Rect2()
|
||||
for child in current_scene.get_children():
|
||||
if child is ESCBackground:
|
||||
var pos = child.get_global_position()
|
||||
var size : Vector2
|
||||
if child.get_texture():
|
||||
size = child.get_texture().get_size()
|
||||
else:
|
||||
size = child.rect_size
|
||||
|
||||
if child.rect_scale.x != 1 or child.rect_scale.y != 1:
|
||||
size.x *= child.rect_scale.x
|
||||
size.y *= child.rect_scale.y
|
||||
|
||||
area = area.expand(pos)
|
||||
area = area.expand(pos + size)
|
||||
area = child.get_full_area_rect2()
|
||||
break
|
||||
|
||||
# if the background is smaller than the viewport, we want the camera to stick centered on the background
|
||||
|
||||
@@ -15,6 +15,16 @@ var zoom_target
|
||||
# This is needed to adjust dialog positions and such, see dialog_instance.gd
|
||||
var zoom_transform
|
||||
|
||||
"""
|
||||
Sets camera limits so it doesn't go out of the scene. If kwargs is null, default
|
||||
limits are used. See Camera2D limits for more details.
|
||||
- kwargs Dictionary (can be null) Limits to set.
|
||||
- limit_left int Left limit.
|
||||
- limit_right int Right limit.
|
||||
- limit_top int Top limit.
|
||||
- limit_bottom int Bottom limit.
|
||||
- set_default bool (Facultative) If true, the given limits are save as default limits.
|
||||
"""
|
||||
func set_limits(kwargs=null):
|
||||
if not kwargs:
|
||||
kwargs = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://game/characters/guybrush/guybrush.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://game/characters/mark/mark.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://addons/escoria-core/testing/player_angles_finder.gd" type="Script" id=2]
|
||||
|
||||
[node name="player_angles_finder" type="Node2D"]
|
||||
@@ -59,8 +59,8 @@ width = 2.0
|
||||
default_color = Color( 1, 1, 1, 1 )
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
margin_right = 370.0
|
||||
margin_bottom = 170.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
@@ -91,7 +91,7 @@ __meta__ = {
|
||||
}
|
||||
|
||||
[node name="angle_x" type="HBoxContainer" parent="VBoxContainer"]
|
||||
margin_right = 235.0
|
||||
margin_right = 370.0
|
||||
margin_bottom = 24.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
@@ -116,7 +116,7 @@ __meta__ = {
|
||||
|
||||
[node name="angle_y" type="HBoxContainer" parent="VBoxContainer"]
|
||||
margin_top = 28.0
|
||||
margin_right = 235.0
|
||||
margin_right = 370.0
|
||||
margin_bottom = 52.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
@@ -141,7 +141,7 @@ __meta__ = {
|
||||
|
||||
[node name="angle_diag" type="HBoxContainer" parent="VBoxContainer"]
|
||||
margin_top = 56.0
|
||||
margin_right = 235.0
|
||||
margin_right = 370.0
|
||||
margin_bottom = 80.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
@@ -166,42 +166,42 @@ __meta__ = {
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer"]
|
||||
margin_top = 84.0
|
||||
margin_right = 235.0
|
||||
margin_right = 370.0
|
||||
margin_bottom = 88.0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer"]
|
||||
margin_top = 92.0
|
||||
margin_right = 235.0
|
||||
margin_bottom = 116.0
|
||||
margin_right = 370.0
|
||||
margin_bottom = 170.0
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_editor_description_": ""
|
||||
}
|
||||
|
||||
[node name="angles" type="HBoxContainer" parent="VBoxContainer/VBoxContainer"]
|
||||
margin_right = 235.0
|
||||
margin_bottom = 24.0
|
||||
margin_right = 370.0
|
||||
margin_bottom = 78.0
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/VBoxContainer/angles"]
|
||||
margin_top = 5.0
|
||||
margin_top = 32.0
|
||||
margin_right = 78.0
|
||||
margin_bottom = 19.0
|
||||
margin_bottom = 46.0
|
||||
text = "Angles array"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="angle_array" type="LineEdit" parent="VBoxContainer/VBoxContainer/angles"]
|
||||
[node name="angle_array" type="TextEdit" parent="VBoxContainer/VBoxContainer/angles"]
|
||||
margin_left = 82.0
|
||||
margin_right = 235.0
|
||||
margin_bottom = 24.0
|
||||
margin_right = 370.0
|
||||
margin_bottom = 78.0
|
||||
size_flags_horizontal = 3
|
||||
editable = false
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
size_flags_vertical = 3
|
||||
wrap_enabled = true
|
||||
|
||||
[node name="player_animations" type="OptionButton" parent="."]
|
||||
visible = false
|
||||
@@ -212,6 +212,7 @@ margin_bottom = 33.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[connection signal="text_changed" from="VBoxContainer/HBoxContainer/number_of_directions" to="." method="_on_number_of_directions_text_changed"]
|
||||
[connection signal="text_changed" from="VBoxContainer/angle_x/angle_horiz" to="." method="_on_angle_horiz_text_changed"]
|
||||
[connection signal="text_changed" from="VBoxContainer/angle_y/angle_vert" to="." method="_on_angle_vert_text_changed"]
|
||||
|
||||
Reference in New Issue
Block a user