moving on
This commit is contained in:
parent
79c8abc6e7
commit
2e52c8d0c1
|
|
@ -3,169 +3,169 @@ extends MeshInstance3D
|
|||
class_name LineRenderer3D
|
||||
|
||||
@export var points: Array[Vector3] = [Vector3(0,0,0),Vector3(0,5,0)]:
|
||||
set(new_points): points = new_points
|
||||
set(new_points): points = new_points
|
||||
@export var start_thickness:float = 0.1:
|
||||
set(new_start_thickness): start_thickness = new_start_thickness
|
||||
set(new_start_thickness): start_thickness = new_start_thickness
|
||||
@export var end_thickness:float = 0.1:
|
||||
set(new_end_thickness): end_thickness = new_end_thickness
|
||||
set(new_end_thickness): end_thickness = new_end_thickness
|
||||
@export var corner_resolution:int = 5:
|
||||
set(new_corner_resolution): corner_resolution = new_corner_resolution
|
||||
set(new_corner_resolution): corner_resolution = new_corner_resolution
|
||||
@export var cap_resolution:int = 5:
|
||||
set(new_cap_resolution): cap_resolution = new_cap_resolution
|
||||
set(new_cap_resolution): cap_resolution = new_cap_resolution
|
||||
@export var draw_caps:bool = true:
|
||||
set(new_draw_caps): draw_caps = new_draw_caps
|
||||
set(new_draw_caps): draw_caps = new_draw_caps
|
||||
@export var draw_crners:bool = true:
|
||||
set(new_draw_crners): draw_crners = new_draw_crners
|
||||
set(new_draw_crners): draw_crners = new_draw_crners
|
||||
@export var use_global_coords:bool = true:
|
||||
set(new_use_global_coords): use_global_coords = new_use_global_coords
|
||||
set(new_use_global_coords): use_global_coords = new_use_global_coords
|
||||
@export var tile_texture:bool = true:
|
||||
set(new_tile_texture): tile_texture = new_tile_texture
|
||||
set(new_tile_texture): tile_texture = new_tile_texture
|
||||
|
||||
var camera : Camera3D
|
||||
var cameraOrigin : Vector3
|
||||
|
||||
func _enter_tree():
|
||||
mesh = ImmediateMesh.new()
|
||||
mesh = ImmediateMesh.new()
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
pass
|
||||
|
||||
func _process(_delta):
|
||||
if points.size() < 2:
|
||||
return
|
||||
if points.size() < 2:
|
||||
return
|
||||
|
||||
camera = get_viewport().get_camera_3d()
|
||||
if camera == null:
|
||||
return
|
||||
cameraOrigin = to_local(camera.get_global_transform().origin)
|
||||
camera = get_viewport().get_camera_3d()
|
||||
if camera == null:
|
||||
return
|
||||
cameraOrigin = to_local(camera.get_global_transform().origin)
|
||||
|
||||
var progressStep:float = 1.0 / points.size();
|
||||
var progress:float = 0;
|
||||
var thickness:float = lerp(start_thickness, end_thickness, progress);
|
||||
var nextThickness:float = lerp(start_thickness, end_thickness, progress + progressStep);
|
||||
var progressStep:float = 1.0 / points.size();
|
||||
var progress:float = 0;
|
||||
var thickness:float = lerp(start_thickness, end_thickness, progress);
|
||||
var nextThickness:float = lerp(start_thickness, end_thickness, progress + progressStep);
|
||||
|
||||
var surface:SurfaceTool = SurfaceTool.new()
|
||||
surface.begin(Mesh.PRIMITIVE_TRIANGLES)
|
||||
var surface:SurfaceTool = SurfaceTool.new()
|
||||
surface.begin(Mesh.PRIMITIVE_TRIANGLES)
|
||||
|
||||
for i in range(points.size() - 1):
|
||||
var A:Vector3 = points[i]
|
||||
var B:Vector3 = points[i+1]
|
||||
for i in range(points.size() - 1):
|
||||
var A:Vector3 = points[i]
|
||||
var B:Vector3 = points[i+1]
|
||||
|
||||
if use_global_coords:
|
||||
A = to_local(A)
|
||||
B = to_local(B)
|
||||
if use_global_coords:
|
||||
A = to_local(A)
|
||||
B = to_local(B)
|
||||
|
||||
var AB:Vector3 = B - A;
|
||||
var orthogonalABStart:Vector3 = (cameraOrigin - ((A + B) / 2)).cross(AB).normalized() * thickness;
|
||||
var orthogonalABEnd:Vector3 = (cameraOrigin - ((A + B) / 2)).cross(AB).normalized() * nextThickness;
|
||||
var AB:Vector3 = B - A;
|
||||
var orthogonalABStart:Vector3 = (cameraOrigin - ((A + B) / 2)).cross(AB).normalized() * thickness;
|
||||
var orthogonalABEnd:Vector3 = (cameraOrigin - ((A + B) / 2)).cross(AB).normalized() * nextThickness;
|
||||
|
||||
var AtoABStart:Vector3 = A + orthogonalABStart
|
||||
var AfromABStart:Vector3 = A - orthogonalABStart
|
||||
var BtoABEnd:Vector3 = B + orthogonalABEnd
|
||||
var BfromABEnd:Vector3 = B - orthogonalABEnd
|
||||
var AtoABStart:Vector3 = A + orthogonalABStart
|
||||
var AfromABStart:Vector3 = A - orthogonalABStart
|
||||
var BtoABEnd:Vector3 = B + orthogonalABEnd
|
||||
var BfromABEnd:Vector3 = B - orthogonalABEnd
|
||||
|
||||
if i == 0:
|
||||
if draw_caps:
|
||||
cap(surface, A, B, thickness, cap_resolution)
|
||||
if i == 0:
|
||||
if draw_caps:
|
||||
cap(surface, A, B, thickness, cap_resolution)
|
||||
|
||||
if tile_texture:
|
||||
var ABLen = AB.length()
|
||||
var ABFloor = floor(ABLen)
|
||||
var ABFrac = ABLen - ABFloor
|
||||
if tile_texture:
|
||||
var ABLen = AB.length()
|
||||
var ABFloor = floor(ABLen)
|
||||
var ABFrac = ABLen - ABFloor
|
||||
|
||||
surface.set_uv(Vector2(ABFloor, 0))
|
||||
surface.add_vertex(AtoABStart)
|
||||
surface.set_uv(Vector2(-ABFrac, 0))
|
||||
surface.add_vertex(BtoABEnd)
|
||||
surface.set_uv(Vector2(ABFloor, 1))
|
||||
surface.add_vertex(AfromABStart)
|
||||
surface.set_uv(Vector2(-ABFrac, 0))
|
||||
surface.add_vertex(BtoABEnd)
|
||||
surface.set_uv(Vector2(-ABFrac, 1))
|
||||
surface.add_vertex(BfromABEnd)
|
||||
surface.set_uv(Vector2(ABFloor, 1))
|
||||
surface.add_vertex(AfromABStart)
|
||||
else:
|
||||
surface.set_uv(Vector2(1, 0))
|
||||
surface.add_vertex(AtoABStart)
|
||||
surface.set_uv(Vector2(0, 0))
|
||||
surface.add_vertex(BtoABEnd)
|
||||
surface.set_uv(Vector2(1, 1))
|
||||
surface.add_vertex(AfromABStart)
|
||||
surface.set_uv(Vector2(0, 0))
|
||||
surface.add_vertex(BtoABEnd)
|
||||
surface.set_uv(Vector2(0, 1))
|
||||
surface.add_vertex(BfromABEnd)
|
||||
surface.set_uv(Vector2(1, 1))
|
||||
surface.add_vertex(AfromABStart)
|
||||
surface.set_uv(Vector2(ABFloor, 0))
|
||||
surface.add_vertex(AtoABStart)
|
||||
surface.set_uv(Vector2(-ABFrac, 0))
|
||||
surface.add_vertex(BtoABEnd)
|
||||
surface.set_uv(Vector2(ABFloor, 1))
|
||||
surface.add_vertex(AfromABStart)
|
||||
surface.set_uv(Vector2(-ABFrac, 0))
|
||||
surface.add_vertex(BtoABEnd)
|
||||
surface.set_uv(Vector2(-ABFrac, 1))
|
||||
surface.add_vertex(BfromABEnd)
|
||||
surface.set_uv(Vector2(ABFloor, 1))
|
||||
surface.add_vertex(AfromABStart)
|
||||
else:
|
||||
surface.set_uv(Vector2(1, 0))
|
||||
surface.add_vertex(AtoABStart)
|
||||
surface.set_uv(Vector2(0, 0))
|
||||
surface.add_vertex(BtoABEnd)
|
||||
surface.set_uv(Vector2(1, 1))
|
||||
surface.add_vertex(AfromABStart)
|
||||
surface.set_uv(Vector2(0, 0))
|
||||
surface.add_vertex(BtoABEnd)
|
||||
surface.set_uv(Vector2(0, 1))
|
||||
surface.add_vertex(BfromABEnd)
|
||||
surface.set_uv(Vector2(1, 1))
|
||||
surface.add_vertex(AfromABStart)
|
||||
|
||||
if i == points.size() - 2:
|
||||
if draw_caps:
|
||||
cap(surface, B, A, nextThickness, cap_resolution)
|
||||
else:
|
||||
if draw_crners:
|
||||
var C = points[i+2]
|
||||
if use_global_coords:
|
||||
C = to_local(C)
|
||||
if i == points.size() - 2:
|
||||
if draw_caps:
|
||||
cap(surface, B, A, nextThickness, cap_resolution)
|
||||
else:
|
||||
if draw_crners:
|
||||
var C = points[i+2]
|
||||
if use_global_coords:
|
||||
C = to_local(C)
|
||||
|
||||
var BC = C - B;
|
||||
var orthogonalBCStart = (cameraOrigin - ((B + C) / 2)).cross(BC).normalized() * nextThickness;
|
||||
var BC = C - B;
|
||||
var orthogonalBCStart = (cameraOrigin - ((B + C) / 2)).cross(BC).normalized() * nextThickness;
|
||||
|
||||
var angleDot = AB.dot(orthogonalBCStart)
|
||||
var angleDot = AB.dot(orthogonalBCStart)
|
||||
|
||||
if angleDot > 0 and not angleDot == 1:
|
||||
corner(surface, B, BtoABEnd, B + orthogonalBCStart, corner_resolution)
|
||||
elif angleDot < 0 and not angleDot == -1:
|
||||
corner(surface, B, B - orthogonalBCStart, BfromABEnd, corner_resolution)
|
||||
if angleDot > 0 and not angleDot == 1:
|
||||
corner(surface, B, BtoABEnd, B + orthogonalBCStart, corner_resolution)
|
||||
elif angleDot < 0 and not angleDot == -1:
|
||||
corner(surface, B, B - orthogonalBCStart, BfromABEnd, corner_resolution)
|
||||
|
||||
progress += progressStep;
|
||||
thickness = lerp(start_thickness, end_thickness, progress);
|
||||
nextThickness = lerp(start_thickness, end_thickness, progress + progressStep);
|
||||
progress += progressStep;
|
||||
thickness = lerp(start_thickness, end_thickness, progress);
|
||||
nextThickness = lerp(start_thickness, end_thickness, progress + progressStep);
|
||||
|
||||
surface.generate_normals()
|
||||
surface.generate_tangents()
|
||||
mesh = surface.commit()
|
||||
surface.generate_normals()
|
||||
surface.generate_tangents()
|
||||
mesh = surface.commit()
|
||||
|
||||
func cap(surface: SurfaceTool, center:Vector3, pivot:Vector3, thickness:float, cap_resolution:int):
|
||||
var orthogonal:Vector3 = (cameraOrigin - center).cross(center - pivot).normalized() * thickness;
|
||||
var axis:Vector3 = (center - cameraOrigin).normalized();
|
||||
var orthogonal:Vector3 = (cameraOrigin - center).cross(center - pivot).normalized() * thickness;
|
||||
var axis:Vector3 = (center - cameraOrigin).normalized();
|
||||
|
||||
var vertex_array:Array = []
|
||||
for i in range(cap_resolution + 1):
|
||||
vertex_array.append(Vector3(0,0,0))
|
||||
vertex_array[0] = center + orthogonal;
|
||||
vertex_array[cap_resolution] = center - orthogonal;
|
||||
var vertex_array:Array = []
|
||||
for i in range(cap_resolution + 1):
|
||||
vertex_array.append(Vector3(0,0,0))
|
||||
vertex_array[0] = center + orthogonal;
|
||||
vertex_array[cap_resolution] = center - orthogonal;
|
||||
|
||||
for i in range(1, cap_resolution):
|
||||
vertex_array[i] = center + (orthogonal.rotated(axis, lerp(0.0, PI, float(i) / cap_resolution)));
|
||||
for i in range(1, cap_resolution):
|
||||
vertex_array[i] = center + (orthogonal.rotated(axis, lerp(0.0, PI, float(i) / cap_resolution)));
|
||||
|
||||
for i in range(1, cap_resolution + 1):
|
||||
surface.set_uv(Vector2(0, (i - 1) / cap_resolution))
|
||||
surface.add_vertex(vertex_array[i - 1]);
|
||||
surface.set_uv(Vector2(0, (i - 1) / cap_resolution))
|
||||
surface.add_vertex(vertex_array[i]);
|
||||
surface.set_uv(Vector2(0.5, 0.5))
|
||||
surface.add_vertex(center);
|
||||
for i in range(1, cap_resolution + 1):
|
||||
surface.set_uv(Vector2(0, (i - 1) / cap_resolution))
|
||||
surface.add_vertex(vertex_array[i - 1]);
|
||||
surface.set_uv(Vector2(0, (i - 1) / cap_resolution))
|
||||
surface.add_vertex(vertex_array[i]);
|
||||
surface.set_uv(Vector2(0.5, 0.5))
|
||||
surface.add_vertex(center);
|
||||
|
||||
func corner(surface: SurfaceTool, center:Vector3, start:Vector3, end:Vector3, cap_resolution:int):
|
||||
var vertex_array:Array = []
|
||||
for i in range(cap_resolution + 1):
|
||||
vertex_array.append(Vector3(0,0,0))
|
||||
vertex_array[0] = start;
|
||||
vertex_array[cap_resolution] = end;
|
||||
var vertex_array:Array = []
|
||||
for i in range(cap_resolution + 1):
|
||||
vertex_array.append(Vector3(0,0,0))
|
||||
vertex_array[0] = start;
|
||||
vertex_array[cap_resolution] = end;
|
||||
|
||||
var axis:Vector3 = start.cross(end).normalized()
|
||||
var offset:Vector3 = start - center
|
||||
var angle:float = offset.angle_to(end - center)
|
||||
var axis:Vector3 = start.cross(end).normalized()
|
||||
var offset:Vector3 = start - center
|
||||
var angle:float = offset.angle_to(end - center)
|
||||
|
||||
for i in range(1, cap_resolution):
|
||||
vertex_array[i] = center + offset.rotated(axis, lerp(0.0, angle, float(i) / cap_resolution));
|
||||
for i in range(1, cap_resolution):
|
||||
vertex_array[i] = center + offset.rotated(axis, lerp(0.0, angle, float(i) / cap_resolution));
|
||||
|
||||
for i in range(1, cap_resolution + 1):
|
||||
surface.set_uv(Vector2(0, (i - 1) / cap_resolution))
|
||||
surface.add_vertex(vertex_array[i - 1]);
|
||||
surface.set_uv(Vector2(0, (i - 1) / cap_resolution))
|
||||
surface.add_vertex(vertex_array[i]);
|
||||
surface.set_uv(Vector2(0.5, 0.5))
|
||||
surface.add_vertex(center);
|
||||
for i in range(1, cap_resolution + 1):
|
||||
surface.set_uv(Vector2(0, (i - 1) / cap_resolution))
|
||||
surface.add_vertex(vertex_array[i - 1]);
|
||||
surface.set_uv(Vector2(0, (i - 1) / cap_resolution))
|
||||
surface.add_vertex(vertex_array[i]);
|
||||
surface.set_uv(Vector2(0.5, 0.5))
|
||||
surface.add_vertex(center);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,40 +5,40 @@ extends Area3D
|
|||
@onready var ui = $UiWrapper/UiSprite/SubViewport.get_child(0)
|
||||
|
||||
var revealed: bool = false:
|
||||
set(reveal):
|
||||
revealed = reveal
|
||||
if reveal:
|
||||
wrapper.show()
|
||||
ui.show()
|
||||
else:
|
||||
ui.hide()
|
||||
await get_tree().create_timer(1).timeout
|
||||
wrapper.hide()
|
||||
set(reveal):
|
||||
revealed = reveal
|
||||
if reveal:
|
||||
wrapper.show()
|
||||
ui.show()
|
||||
else:
|
||||
ui.hide()
|
||||
await get_tree().create_timer(1).timeout
|
||||
wrapper.hide()
|
||||
|
||||
var has_mouse: bool = false
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
connect("mouse_entered", Callable(self, "_on_mouse_entered"))
|
||||
connect("mouse_entered", Callable(self, "_on_mouse_entered"))
|
||||
|
||||
func _on_mouse_entered():
|
||||
if not State.focus_locked:
|
||||
input_ray_pickable = false
|
||||
ui.collapsed = false
|
||||
has_mouse = true
|
||||
if not State.focus_locked:
|
||||
input_ray_pickable = false
|
||||
ui.collapsed = false
|
||||
has_mouse = true
|
||||
|
||||
func _on_mouse_exited():
|
||||
print("mouse_exited")
|
||||
input_ray_pickable = true
|
||||
ui.collapsed = true
|
||||
has_mouse = false
|
||||
print("mouse_exited")
|
||||
input_ray_pickable = true
|
||||
ui.collapsed = true
|
||||
has_mouse = false
|
||||
|
||||
func reveal():
|
||||
revealed = true
|
||||
await get_tree().create_timer(5).timeout
|
||||
if not has_mouse:
|
||||
revealed = false
|
||||
revealed = true
|
||||
await get_tree().create_timer(5).timeout
|
||||
if not has_mouse:
|
||||
revealed = false
|
||||
|
||||
func collapse():
|
||||
_on_mouse_exited()
|
||||
revealed = false
|
||||
_on_mouse_exited()
|
||||
revealed = false
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ extends Node3D
|
|||
|
||||
# Referencing the current State of the Scene.
|
||||
enum Modes {
|
||||
FREEZE,
|
||||
WALKING,
|
||||
COLLECTING,
|
||||
LISTENING,
|
||||
SORTING
|
||||
FREEZE,
|
||||
WALKING,
|
||||
COLLECTING,
|
||||
LISTENING,
|
||||
SORTING
|
||||
}
|
||||
|
||||
signal freeze
|
||||
|
|
@ -15,35 +15,35 @@ signal ini_room
|
|||
signal resume_room
|
||||
|
||||
var current_mode: int = Modes.FREEZE:
|
||||
set(new_mode):
|
||||
if not current_mode == new_mode:
|
||||
current_mode = _update_scene(new_mode)
|
||||
set(new_mode):
|
||||
if not current_mode == new_mode:
|
||||
current_mode = _update_scene(new_mode)
|
||||
|
||||
func start():
|
||||
$logic/PlayerController.process_mode = Node.PROCESS_MODE_INHERIT
|
||||
emit_signal("ini_room")
|
||||
current_mode = Modes.WALKING
|
||||
$logic/PlayerController.process_mode = Node.PROCESS_MODE_INHERIT
|
||||
emit_signal("ini_room")
|
||||
current_mode = Modes.WALKING
|
||||
|
||||
func _update_scene(new_mode) -> int:
|
||||
if current_mode == Modes.FREEZE:
|
||||
emit_signal("freeze")
|
||||
elif new_mode == Modes.FREEZE:
|
||||
emit_signal("freeze")
|
||||
if current_mode == Modes.FREEZE:
|
||||
emit_signal("freeze")
|
||||
elif new_mode == Modes.FREEZE:
|
||||
emit_signal("freeze")
|
||||
|
||||
return new_mode
|
||||
return new_mode
|
||||
|
||||
func is_self(node: Node) -> bool:
|
||||
return self == node
|
||||
return self == node
|
||||
|
||||
func get_ready():
|
||||
self.show()
|
||||
$sfx/distant_rain.play()
|
||||
$"sfx/rain on window".play()
|
||||
await get_tree().create_timer(0.1).timeout
|
||||
$logic/UI/board.hide()
|
||||
self.show()
|
||||
$sfx/distant_rain.play()
|
||||
$"sfx/rain on window".play()
|
||||
await get_tree().create_timer(0.1).timeout
|
||||
$logic/UI/board.hide()
|
||||
|
||||
func _ready():
|
||||
if get_parent() == get_tree().root:
|
||||
get_ready()
|
||||
start()
|
||||
if get_parent() == get_tree().root:
|
||||
get_ready()
|
||||
start()
|
||||
|
||||
|
|
|
|||
|
|
@ -3,107 +3,107 @@ extends CenterContainer
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
$cards/card_1/AnimationPlayer.play("select")
|
||||
await $cards/card_1/AnimationPlayer.animation_finished
|
||||
$cards/card_1/AnimationPlayer.play("deselect")
|
||||
$cards/card_2/AnimationPlayer.play("select")
|
||||
await $cards/card_1/AnimationPlayer.animation_finished
|
||||
$cards/card_2/AnimationPlayer.play("deselect")
|
||||
$cards/card_3/AnimationPlayer.play("select")
|
||||
await $cards/card_2/AnimationPlayer.animation_finished
|
||||
$cards/card_3/AnimationPlayer.play("deselect")
|
||||
await $cards/card_3/AnimationPlayer.animation_finished
|
||||
$cards/card_1/AnimationPlayer.play("select")
|
||||
await $cards/card_1/AnimationPlayer.animation_finished
|
||||
$cards/card_1/AnimationPlayer.play("take")
|
||||
$cards/card_2/AnimationPlayer.play("unshuffle")
|
||||
$cards/card_3/AnimationPlayer.play("shuffle")
|
||||
await $cards/card_3/AnimationPlayer.animation_finished
|
||||
$cards/card_1/AnimationPlayer.play("select")
|
||||
await $cards/card_1/AnimationPlayer.animation_finished
|
||||
$cards/card_1/AnimationPlayer.play("deselect")
|
||||
$cards/card_2/AnimationPlayer.play("select")
|
||||
await $cards/card_1/AnimationPlayer.animation_finished
|
||||
$cards/card_2/AnimationPlayer.play("deselect")
|
||||
$cards/card_3/AnimationPlayer.play("select")
|
||||
await $cards/card_2/AnimationPlayer.animation_finished
|
||||
$cards/card_3/AnimationPlayer.play("deselect")
|
||||
await $cards/card_3/AnimationPlayer.animation_finished
|
||||
$cards/card_1/AnimationPlayer.play("select")
|
||||
await $cards/card_1/AnimationPlayer.animation_finished
|
||||
$cards/card_1/AnimationPlayer.play("take")
|
||||
$cards/card_2/AnimationPlayer.play("unshuffle")
|
||||
$cards/card_3/AnimationPlayer.play("shuffle")
|
||||
await $cards/card_3/AnimationPlayer.animation_finished
|
||||
|
||||
for card in $cards.get_children():
|
||||
card.get_child(1).play("RESET")
|
||||
for card in $cards.get_children():
|
||||
card.get_child(1).play("RESET")
|
||||
|
||||
$cards/card_2/AnimationPlayer.queue("select")
|
||||
await $cards/card_2/AnimationPlayer.animation_finished
|
||||
$cards/card_2/AnimationPlayer.play("take")
|
||||
$cards/card_3/AnimationPlayer.play("unshuffle")
|
||||
$cards/card_1/AnimationPlayer.play("shuffle")
|
||||
await $cards/card_1/AnimationPlayer.animation_finished
|
||||
$cards/card_2/AnimationPlayer.queue("select")
|
||||
await $cards/card_2/AnimationPlayer.animation_finished
|
||||
$cards/card_2/AnimationPlayer.play("take")
|
||||
$cards/card_3/AnimationPlayer.play("unshuffle")
|
||||
$cards/card_1/AnimationPlayer.play("shuffle")
|
||||
await $cards/card_1/AnimationPlayer.animation_finished
|
||||
|
||||
for card in $cards.get_children():
|
||||
card.get_child(1).play("RESET")
|
||||
for card in $cards.get_children():
|
||||
card.get_child(1).play("RESET")
|
||||
|
||||
$cards/card_3/AnimationPlayer.queue("select")
|
||||
await $cards/card_3/AnimationPlayer.animation_finished
|
||||
$cards/card_3/AnimationPlayer.play("take")
|
||||
$cards/card_1/AnimationPlayer.play("unshuffle")
|
||||
$cards/card_2/AnimationPlayer.play("shuffle")
|
||||
await $cards/card_2/AnimationPlayer.animation_finished
|
||||
$cards/card_3/AnimationPlayer.queue("select")
|
||||
await $cards/card_3/AnimationPlayer.animation_finished
|
||||
$cards/card_3/AnimationPlayer.play("take")
|
||||
$cards/card_1/AnimationPlayer.play("unshuffle")
|
||||
$cards/card_2/AnimationPlayer.play("shuffle")
|
||||
await $cards/card_2/AnimationPlayer.animation_finished
|
||||
|
||||
$sticky_notes.show()
|
||||
$sticky_notes.show()
|
||||
|
||||
for card in $sticky_notes.get_children():
|
||||
card.get_child(1).play("post")
|
||||
for card in $sticky_notes.get_children():
|
||||
card.get_child(1).play("post")
|
||||
|
||||
await $sticky_notes/sticky_note_1/AnimationPlayer.animation_finished
|
||||
await $sticky_notes/sticky_note_1/AnimationPlayer.animation_finished
|
||||
|
||||
$sticky_notes/sticky_note_1/AnimationPlayer.play("select")
|
||||
await $sticky_notes/sticky_note_1/AnimationPlayer.animation_finished
|
||||
$sticky_notes/sticky_note_1/AnimationPlayer.play("deselect")
|
||||
$sticky_notes/sticky_note_2/AnimationPlayer.play("select")
|
||||
await $sticky_notes/sticky_note_2/AnimationPlayer.animation_finished
|
||||
$sticky_notes/sticky_note_2/AnimationPlayer.play("deselect")
|
||||
$sticky_notes/sticky_note_3/AnimationPlayer.play("select")
|
||||
await $sticky_notes/sticky_note_3/AnimationPlayer.animation_finished
|
||||
$sticky_notes/sticky_note_3/AnimationPlayer.play("deselect")
|
||||
$sticky_notes/sticky_note_4/AnimationPlayer.play("select")
|
||||
await $sticky_notes/sticky_note_4/AnimationPlayer.animation_finished
|
||||
$sticky_notes/sticky_note_4/AnimationPlayer.play("deselect")
|
||||
$sticky_notes/sticky_note_1/AnimationPlayer.play("select")
|
||||
await get_tree().create_timer(1).timeout
|
||||
$sticky_notes/sticky_note_1/AnimationPlayer.play("pick")
|
||||
$sticky_notes/sticky_note_2/AnimationPlayer.play("shuffle")
|
||||
$sticky_notes/sticky_note_3/AnimationPlayer.play("unshuffle")
|
||||
$sticky_notes/sticky_note_4/AnimationPlayer.play("unshuffle")
|
||||
$sticky_notes/sticky_note_1/AnimationPlayer.play("select")
|
||||
await $sticky_notes/sticky_note_1/AnimationPlayer.animation_finished
|
||||
$sticky_notes/sticky_note_1/AnimationPlayer.play("deselect")
|
||||
$sticky_notes/sticky_note_2/AnimationPlayer.play("select")
|
||||
await $sticky_notes/sticky_note_2/AnimationPlayer.animation_finished
|
||||
$sticky_notes/sticky_note_2/AnimationPlayer.play("deselect")
|
||||
$sticky_notes/sticky_note_3/AnimationPlayer.play("select")
|
||||
await $sticky_notes/sticky_note_3/AnimationPlayer.animation_finished
|
||||
$sticky_notes/sticky_note_3/AnimationPlayer.play("deselect")
|
||||
$sticky_notes/sticky_note_4/AnimationPlayer.play("select")
|
||||
await $sticky_notes/sticky_note_4/AnimationPlayer.animation_finished
|
||||
$sticky_notes/sticky_note_4/AnimationPlayer.play("deselect")
|
||||
$sticky_notes/sticky_note_1/AnimationPlayer.play("select")
|
||||
await get_tree().create_timer(1).timeout
|
||||
$sticky_notes/sticky_note_1/AnimationPlayer.play("pick")
|
||||
$sticky_notes/sticky_note_2/AnimationPlayer.play("shuffle")
|
||||
$sticky_notes/sticky_note_3/AnimationPlayer.play("unshuffle")
|
||||
$sticky_notes/sticky_note_4/AnimationPlayer.play("unshuffle")
|
||||
|
||||
await $sticky_notes/sticky_note_2/AnimationPlayer.animation_finished
|
||||
await $sticky_notes/sticky_note_2/AnimationPlayer.animation_finished
|
||||
|
||||
for card in $sticky_notes.get_children():
|
||||
card.get_child(1).play("post")
|
||||
for card in $sticky_notes.get_children():
|
||||
card.get_child(1).play("post")
|
||||
|
||||
await $sticky_notes/sticky_note_1/AnimationPlayer.animation_finished
|
||||
await $sticky_notes/sticky_note_1/AnimationPlayer.animation_finished
|
||||
|
||||
$sticky_notes/sticky_note_2/AnimationPlayer.play("select")
|
||||
await get_tree().create_timer(1).timeout
|
||||
$sticky_notes/sticky_note_2/AnimationPlayer.play("pick")
|
||||
$sticky_notes/sticky_note_3/AnimationPlayer.play("shuffle")
|
||||
$sticky_notes/sticky_note_4/AnimationPlayer.play("unshuffle")
|
||||
$sticky_notes/sticky_note_1/AnimationPlayer.play("unshuffle")
|
||||
$sticky_notes/sticky_note_2/AnimationPlayer.play("select")
|
||||
await get_tree().create_timer(1).timeout
|
||||
$sticky_notes/sticky_note_2/AnimationPlayer.play("pick")
|
||||
$sticky_notes/sticky_note_3/AnimationPlayer.play("shuffle")
|
||||
$sticky_notes/sticky_note_4/AnimationPlayer.play("unshuffle")
|
||||
$sticky_notes/sticky_note_1/AnimationPlayer.play("unshuffle")
|
||||
|
||||
await $sticky_notes/sticky_note_3/AnimationPlayer.animation_finished
|
||||
await $sticky_notes/sticky_note_3/AnimationPlayer.animation_finished
|
||||
|
||||
for card in $sticky_notes.get_children():
|
||||
card.get_child(1).play("post")
|
||||
for card in $sticky_notes.get_children():
|
||||
card.get_child(1).play("post")
|
||||
|
||||
await $sticky_notes/sticky_note_1/AnimationPlayer.animation_finished
|
||||
await $sticky_notes/sticky_note_1/AnimationPlayer.animation_finished
|
||||
|
||||
$sticky_notes/sticky_note_3/AnimationPlayer.play("select")
|
||||
await get_tree().create_timer(1).timeout
|
||||
$sticky_notes/sticky_note_3/AnimationPlayer.play("pick")
|
||||
$sticky_notes/sticky_note_4/AnimationPlayer.play("shuffle")
|
||||
$sticky_notes/sticky_note_1/AnimationPlayer.play("unshuffle")
|
||||
$sticky_notes/sticky_note_2/AnimationPlayer.play("unshuffle")
|
||||
$sticky_notes/sticky_note_3/AnimationPlayer.play("select")
|
||||
await get_tree().create_timer(1).timeout
|
||||
$sticky_notes/sticky_note_3/AnimationPlayer.play("pick")
|
||||
$sticky_notes/sticky_note_4/AnimationPlayer.play("shuffle")
|
||||
$sticky_notes/sticky_note_1/AnimationPlayer.play("unshuffle")
|
||||
$sticky_notes/sticky_note_2/AnimationPlayer.play("unshuffle")
|
||||
|
||||
await $sticky_notes/sticky_note_4/AnimationPlayer.animation_finished
|
||||
await $sticky_notes/sticky_note_4/AnimationPlayer.animation_finished
|
||||
|
||||
for card in $sticky_notes.get_children():
|
||||
card.get_child(1).play("post")
|
||||
for card in $sticky_notes.get_children():
|
||||
card.get_child(1).play("post")
|
||||
|
||||
await $sticky_notes/sticky_note_1/AnimationPlayer.animation_finished
|
||||
await $sticky_notes/sticky_note_1/AnimationPlayer.animation_finished
|
||||
|
||||
$sticky_notes/sticky_note_4/AnimationPlayer.play("select")
|
||||
await get_tree().create_timer(1).timeout
|
||||
$sticky_notes/sticky_note_4/AnimationPlayer.play("pick")
|
||||
$sticky_notes/sticky_note_1/AnimationPlayer.play("shuffle")
|
||||
$sticky_notes/sticky_note_2/AnimationPlayer.play("unshuffle")
|
||||
$sticky_notes/sticky_note_3/AnimationPlayer.play("unshuffle")
|
||||
$sticky_notes/sticky_note_4/AnimationPlayer.play("select")
|
||||
await get_tree().create_timer(1).timeout
|
||||
$sticky_notes/sticky_note_4/AnimationPlayer.play("pick")
|
||||
$sticky_notes/sticky_note_1/AnimationPlayer.play("shuffle")
|
||||
$sticky_notes/sticky_note_2/AnimationPlayer.play("unshuffle")
|
||||
$sticky_notes/sticky_note_3/AnimationPlayer.play("unshuffle")
|
||||
|
|
|
|||
|
|
@ -5,35 +5,35 @@ extends Area3D
|
|||
@onready var viewport: SubViewport = $UiSprite/SubViewport
|
||||
|
||||
func _process(_delta):
|
||||
if billboard:
|
||||
var camera = get_viewport().get_camera_3d()
|
||||
if billboard:
|
||||
var camera = get_viewport().get_camera_3d()
|
||||
|
||||
var up = (camera.global_position - global_position)
|
||||
up = up.cross(Vector3.UP).cross(up)
|
||||
var up = (camera.global_position - global_position)
|
||||
up = up.cross(Vector3.UP).cross(up)
|
||||
|
||||
look_at(global_position - (camera.global_position - global_position), up)
|
||||
look_at(global_position - (camera.global_position - global_position), up)
|
||||
|
||||
func _unhandled_input(event):
|
||||
viewport.push_input(event)
|
||||
viewport.push_input(event)
|
||||
|
||||
func _on_input_event(_camera: Camera3D, event: InputEvent, pos: Vector3, _normal: Vector3, _shape_idx: int):
|
||||
if not State.focus_locked:
|
||||
# Position of the event in Sprite3D local coordinates.
|
||||
var texture_3d_position = sprite.get_global_transform().affine_inverse() * pos
|
||||
#if !is_zero_approx(texture_3d_position.z):
|
||||
# # Discard event because event didn't happen on the side of the Sprite3D.
|
||||
# return
|
||||
# Position of the event relative to the texture.
|
||||
var texture_position: Vector2 = Vector2(texture_3d_position.x, -texture_3d_position.y) / sprite.pixel_size - sprite.get_item_rect().position
|
||||
# Send mouse event.
|
||||
var e: InputEvent = event.duplicate()
|
||||
if e is InputEventMouse:
|
||||
e.set_position(texture_position)
|
||||
e.set_global_position(texture_position)
|
||||
viewport.push_input(e)
|
||||
if not State.focus_locked:
|
||||
# Position of the event in Sprite3D local coordinates.
|
||||
var texture_3d_position = sprite.get_global_transform().affine_inverse() * pos
|
||||
#if !is_zero_approx(texture_3d_position.z):
|
||||
# # Discard event because event didn't happen on the side of the Sprite3D.
|
||||
# return
|
||||
# Position of the event relative to the texture.
|
||||
var texture_position: Vector2 = Vector2(texture_3d_position.x, -texture_3d_position.y) / sprite.pixel_size - sprite.get_item_rect().position
|
||||
# Send mouse event.
|
||||
var e: InputEvent = event.duplicate()
|
||||
if e is InputEventMouse:
|
||||
e.set_position(texture_position)
|
||||
e.set_global_position(texture_position)
|
||||
viewport.push_input(e)
|
||||
|
||||
func _on_button_pressed():
|
||||
print("Button pressed")
|
||||
print("Button pressed")
|
||||
|
||||
func _on_line_edit_text_submitted(new_text):
|
||||
print("Text submitted: ", new_text)
|
||||
print("Text submitted: ", new_text)
|
||||
|
|
|
|||
|
|
@ -2,26 +2,26 @@
|
|||
extends Button
|
||||
|
||||
func hide():
|
||||
if visible == true:
|
||||
var tween:Tween = create_tween()
|
||||
custom_minimum_size = get_minimum_size()
|
||||
var tmp = text
|
||||
text = ""
|
||||
tween.tween_property(self, "custom_minimum_size", Vector2(size.x, 0), 0.2)
|
||||
update_minimum_size()
|
||||
await tween.finished
|
||||
visible = false
|
||||
text = tmp
|
||||
update_minimum_size()
|
||||
if visible == true:
|
||||
var tween:Tween = create_tween()
|
||||
custom_minimum_size = get_minimum_size()
|
||||
var tmp = text
|
||||
text = ""
|
||||
tween.tween_property(self, "custom_minimum_size", Vector2(size.x, 0), 0.2)
|
||||
update_minimum_size()
|
||||
await tween.finished
|
||||
visible = false
|
||||
text = tmp
|
||||
update_minimum_size()
|
||||
|
||||
func show():
|
||||
if visible == false:
|
||||
var tmp = text
|
||||
var tween:Tween = create_tween()
|
||||
tween.tween_property(self, "custom_minimum_size", get_minimum_size(), 0.2)
|
||||
text = ""
|
||||
update_minimum_size()
|
||||
visible = true
|
||||
await tween.finished
|
||||
text = tmp
|
||||
if visible == false:
|
||||
var tmp = text
|
||||
var tween:Tween = create_tween()
|
||||
tween.tween_property(self, "custom_minimum_size", get_minimum_size(), 0.2)
|
||||
text = ""
|
||||
update_minimum_size()
|
||||
visible = true
|
||||
await tween.finished
|
||||
text = tmp
|
||||
|
||||
|
|
|
|||
|
|
@ -1,40 +1,40 @@
|
|||
extends Control
|
||||
|
||||
func get_cards_by_scene_id(id: int) -> Array:
|
||||
var output:Array
|
||||
var output:Array
|
||||
|
||||
var scene = get_child(id)
|
||||
var scene = get_child(id)
|
||||
|
||||
for i in range(scene.get_child_count()):
|
||||
output.append(scene.get_child(i))
|
||||
for note in output[i].get_children():
|
||||
if note is StickyNote:
|
||||
output[i].remove_child(note)
|
||||
for i in range(scene.get_child_count()):
|
||||
output.append(scene.get_child(i))
|
||||
for note in output[i].get_children():
|
||||
if note is StickyNote:
|
||||
output[i].remove_child(note)
|
||||
|
||||
for card in output:
|
||||
card.transform = Transform3D()
|
||||
for sticky_note in card.own_sticky_notes:
|
||||
sticky_note.transform = Transform3D()
|
||||
for card in output:
|
||||
card.transform = Transform3D()
|
||||
for sticky_note in card.own_sticky_notes:
|
||||
sticky_note.transform = Transform3D()
|
||||
|
||||
return output
|
||||
return output
|
||||
|
||||
func get_cards_by_name_array(names: Array) -> Dictionary:
|
||||
var output:Dictionary = {
|
||||
"cards": [],
|
||||
"sticky_notes": []
|
||||
}
|
||||
var output:Dictionary = {
|
||||
"cards": [],
|
||||
"sticky_notes": []
|
||||
}
|
||||
|
||||
for scene in get_children():
|
||||
for card in scene.get_children():
|
||||
for sticky_note in card.get_children():
|
||||
if names.has(sticky_note.name):
|
||||
sticky_note.transform = Transform3D()
|
||||
output['sticky_notes'].append(sticky_note)
|
||||
for scene in get_children():
|
||||
for card in scene.get_children():
|
||||
for sticky_note in card.get_children():
|
||||
if names.has(sticky_note.name):
|
||||
sticky_note.transform = Transform3D()
|
||||
output['sticky_notes'].append(sticky_note)
|
||||
|
||||
if names.has(card.name):
|
||||
card.transform = Transform3D()
|
||||
output['cards'].append(card)
|
||||
for child in card.get_children():
|
||||
if child is StickyNote:
|
||||
child.reparent(self)
|
||||
return output
|
||||
if names.has(card.name):
|
||||
card.transform = Transform3D()
|
||||
output['cards'].append(card)
|
||||
for child in card.get_children():
|
||||
if child is StickyNote:
|
||||
child.reparent(self)
|
||||
return output
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
extends Node
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
extends Node
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var initialize_response: Dictionary = steamInitEx( true, 480 )
|
||||
print("Did Steam initialize?: %s " % initialize_response)
|
||||
|
|
@ -4,69 +4,69 @@ const dev_board_pre = preload("res://dev-util/board of devs.tscn")
|
|||
var dev_board: Control
|
||||
|
||||
func _ready():
|
||||
dev_board = dev_board_pre.instantiate()
|
||||
dev_board = dev_board_pre.instantiate()
|
||||
|
||||
if $cards.get_child_count(false) > 0:
|
||||
$cards.get_children(false)[0].grab_focus()
|
||||
if $cards.get_child_count(false) > 0:
|
||||
$cards.get_children(false)[0].grab_focus()
|
||||
|
||||
# Testing code
|
||||
for item in dev_board.find_children("*"):
|
||||
if item is Card:
|
||||
spawn_card((item as Card).duplicate())
|
||||
elif item is StickyNote:
|
||||
spawn_sticky_note((item as StickyNote).duplicate())
|
||||
# Testing code
|
||||
for item in dev_board.find_children("*"):
|
||||
if item is Card:
|
||||
spawn_card((item as Card).duplicate())
|
||||
elif item is StickyNote:
|
||||
spawn_sticky_note((item as StickyNote).duplicate())
|
||||
|
||||
func _process(delta: float):
|
||||
pass
|
||||
pass
|
||||
|
||||
func spawn_card(card: Card):
|
||||
$cards.add_child(card)
|
||||
$cards.add_child(card)
|
||||
|
||||
if $cards.get_child_count(false) == 1:
|
||||
$cards.get_children(false)[0].grab_focus()
|
||||
if $cards.get_child_count(false) == 1:
|
||||
$cards.get_children(false)[0].grab_focus()
|
||||
|
||||
populate_focus_neighbors()
|
||||
populate_focus_neighbors()
|
||||
|
||||
func spawn_sticky_note(sticky_note: StickyNote):
|
||||
$sticky_notes.add_child(sticky_note)
|
||||
$sticky_notes.add_child(sticky_note)
|
||||
|
||||
populate_focus_neighbors()
|
||||
populate_focus_neighbors()
|
||||
|
||||
func populate_focus_neighbors():
|
||||
# TODO reorder cards based on position
|
||||
# TODO reorder cards based on position
|
||||
|
||||
if $cards.get_child_count(false) <= 0:
|
||||
return
|
||||
if $cards.get_child_count(false) <= 0:
|
||||
return
|
||||
|
||||
var first_card = $cards.get_children(false)[0]
|
||||
var first_sticky_note = $sticky_notes.get_children(false)[0] if $sticky_notes.get_child_count(false) > 0 else first_card
|
||||
var first_card = $cards.get_children(false)[0]
|
||||
var first_sticky_note = $sticky_notes.get_children(false)[0] if $sticky_notes.get_child_count(false) > 0 else first_card
|
||||
|
||||
var first_board_card = $mindmap.get_children(false)[0] if $mindmap.get_child_count(false) > 0 else first_card
|
||||
var first_board_card = $mindmap.get_children(false)[0] if $mindmap.get_child_count(false) > 0 else first_card
|
||||
|
||||
var cards = $cards.get_children(false) as Array[Card]
|
||||
for i in cards.size():
|
||||
var card = cards[i]
|
||||
if card == first_card or not (card is Card):
|
||||
continue
|
||||
card.focus_neighbor_right = first_board_card # FIXME should be a valid focusable object, but it refuses
|
||||
card.focus_neighbor_left = first_sticky_note
|
||||
card.focus_neighbor_up = cards[(i - 1) % cards.size()]
|
||||
card.focus_neighbor_down = cards[(i + 1) % cards.size()]
|
||||
var cards = $cards.get_children(false) as Array[Card]
|
||||
for i in cards.size():
|
||||
var card = cards[i]
|
||||
if card == first_card or not (card is Card):
|
||||
continue
|
||||
card.focus_neighbor_right = first_board_card # FIXME should be a valid focusable object, but it refuses
|
||||
card.focus_neighbor_left = first_sticky_note
|
||||
card.focus_neighbor_up = cards[(i - 1) % cards.size()]
|
||||
card.focus_neighbor_down = cards[(i + 1) % cards.size()]
|
||||
|
||||
var sticky_notes = $sticky_notes.get_children(false) as Array[StickyNote]
|
||||
for i in sticky_notes.size():
|
||||
var sticky_note = sticky_notes[i]
|
||||
if not (sticky_note is StickyNote):
|
||||
continue
|
||||
sticky_note.focus_neighbor_right = first_card
|
||||
sticky_note.focus_neighbor_left = first_board_card
|
||||
sticky_note.focus_neighbor_up = sticky_notes[(i - 1) % sticky_notes.size()]
|
||||
sticky_note.focus_neighbor_down = sticky_notes[(i + 1) % sticky_notes.size()]
|
||||
var sticky_notes = $sticky_notes.get_children(false) as Array[StickyNote]
|
||||
for i in sticky_notes.size():
|
||||
var sticky_note = sticky_notes[i]
|
||||
if not (sticky_note is StickyNote):
|
||||
continue
|
||||
sticky_note.focus_neighbor_right = first_card
|
||||
sticky_note.focus_neighbor_left = first_board_card
|
||||
sticky_note.focus_neighbor_up = sticky_notes[(i - 1) % sticky_notes.size()]
|
||||
sticky_note.focus_neighbor_down = sticky_notes[(i + 1) % sticky_notes.size()]
|
||||
|
||||
var board_items = $mindmap.get_children(false) as Array
|
||||
for i in board_items.size():
|
||||
var board_item = board_items[i]
|
||||
board_item.focus_neighbor_right = first_sticky_note
|
||||
board_item.focus_neighbor_left = first_card
|
||||
board_item.focus_neighbor_up = board_items[(i - 1) % board_items.size()]
|
||||
board_item.focus_neighbor_down = board_items[(i + 1) % board_items.size()]
|
||||
var board_items = $mindmap.get_children(false) as Array
|
||||
for i in board_items.size():
|
||||
var board_item = board_items[i]
|
||||
board_item.focus_neighbor_right = first_sticky_note
|
||||
board_item.focus_neighbor_left = first_card
|
||||
board_item.focus_neighbor_up = board_items[(i - 1) % board_items.size()]
|
||||
board_item.focus_neighbor_down = board_items[(i + 1) % board_items.size()]
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ extends Area2D
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
if get_overlapping_areas().size() > 0:
|
||||
for area in get_overlapping_areas():
|
||||
var diff:Vector2 = position - area.position
|
||||
position -= diff.normalized() * ((diff.length()-diameter)/diameter) * bounce_speed * (delta/(1.0/60))
|
||||
if get_overlapping_areas().size() > 0:
|
||||
for area in get_overlapping_areas():
|
||||
var diff:Vector2 = position - area.position
|
||||
position -= diff.normalized() * ((diff.length()-diameter)/diameter) * bounce_speed * (delta/(1.0/60))
|
||||
|
|
|
|||
|
|
@ -3,4 +3,3 @@ extends Area2D
|
|||
|
||||
var is_dragged: bool = false
|
||||
@export var direction: Vector2 = Vector2.ZERO
|
||||
|
||||
|
|
|
|||
|
|
@ -9,30 +9,30 @@ extends PanelContainer
|
|||
enum {NAVIGATE, ASSIGN, DRAG}
|
||||
|
||||
var focus_stickies:bool = true:
|
||||
set(stickies):
|
||||
if stickies and sticky_note_container.get_child_count() == 0: return
|
||||
set(stickies):
|
||||
if stickies and sticky_note_container.get_child_count() == 0: return
|
||||
|
||||
focus_stickies = stickies
|
||||
focus_stickies = stickies
|
||||
|
||||
if not current_context == ASSIGN:
|
||||
if stickies:
|
||||
current_sticky_note_id = current_sticky_note_id
|
||||
else:
|
||||
current_dropzone_id = current_dropzone_id
|
||||
if not current_context == ASSIGN:
|
||||
if stickies:
|
||||
current_sticky_note_id = current_sticky_note_id
|
||||
else:
|
||||
current_dropzone_id = current_dropzone_id
|
||||
|
||||
var has_stage = false:
|
||||
set(focus):
|
||||
if focus:
|
||||
has_stage = true
|
||||
get_tree().call_group("interactables", "collapse")
|
||||
else:
|
||||
has_stage = false
|
||||
if is_node_ready():
|
||||
if focus:
|
||||
process_mode = Node.PROCESS_MODE_INHERIT
|
||||
else:
|
||||
process_mode = Node.PROCESS_MODE_DISABLED
|
||||
visible = has_stage
|
||||
set(focus):
|
||||
if focus:
|
||||
has_stage = true
|
||||
get_tree().call_group("interactables", "collapse")
|
||||
else:
|
||||
has_stage = false
|
||||
if is_node_ready():
|
||||
if focus:
|
||||
process_mode = Node.PROCESS_MODE_INHERIT
|
||||
else:
|
||||
process_mode = Node.PROCESS_MODE_DISABLED
|
||||
visible = has_stage
|
||||
|
||||
@onready var dropzone = $HBoxContainer/dropzone
|
||||
var dropzone_size: Vector2
|
||||
|
|
@ -41,63 +41,63 @@ var dropzone_size: Vector2
|
|||
@onready var board_of_devs = $"board of devs"
|
||||
var base_sticky_note_panel: Panel
|
||||
@onready var current_context:int = NAVIGATE:
|
||||
set(context):
|
||||
if current_context == ASSIGN and !context == ASSIGN:
|
||||
sticky_note_container.get_child(current_sticky_note_id).clear_if_empty()
|
||||
#match context:
|
||||
# NAVIGATE:
|
||||
# _return_sticky_notes_to_panels()
|
||||
# DRAG:
|
||||
# pass
|
||||
# ASSIGN:
|
||||
# pass
|
||||
current_context = context
|
||||
set(context):
|
||||
if current_context == ASSIGN and !context == ASSIGN:
|
||||
sticky_note_container.get_child(current_sticky_note_id).clear_if_empty()
|
||||
#match context:
|
||||
# NAVIGATE:
|
||||
# _return_sticky_notes_to_panels()
|
||||
# DRAG:
|
||||
# pass
|
||||
# ASSIGN:
|
||||
# pass
|
||||
current_context = context
|
||||
@onready var instructions = $instructions_panel/HBoxContainer/cards_remaining
|
||||
|
||||
var mementos_collected: int = 0:
|
||||
set(mementos):
|
||||
mementos_collected = mementos
|
||||
match mementos:
|
||||
1:
|
||||
instructions.text = "There are three Mementos left to find."
|
||||
2:
|
||||
instructions.text = "You have collected half of the mementos."
|
||||
3:
|
||||
instructions.text = "Find the last Memento to complete the Board."
|
||||
4:
|
||||
instructions.text = "Combine cards to order your thoughts."
|
||||
set(mementos):
|
||||
mementos_collected = mementos
|
||||
match mementos:
|
||||
1:
|
||||
instructions.text = "There are three Mementos left to find."
|
||||
2:
|
||||
instructions.text = "You have collected half of the mementos."
|
||||
3:
|
||||
instructions.text = "Find the last Memento to complete the Board."
|
||||
4:
|
||||
instructions.text = "Combine cards to order your thoughts."
|
||||
|
||||
@onready var currently_active_node: Area2D = null:
|
||||
set(new_node):
|
||||
if not currently_active_node == null:
|
||||
currently_active_node.highlighted = false
|
||||
currently_active_node = new_node
|
||||
if not currently_active_node == null:
|
||||
currently_active_node.highlighted = true
|
||||
set(new_node):
|
||||
if not currently_active_node == null:
|
||||
currently_active_node.highlighted = false
|
||||
currently_active_node = new_node
|
||||
if not currently_active_node == null:
|
||||
currently_active_node.highlighted = true
|
||||
|
||||
@onready var current_dropzone_id: int = 0:
|
||||
set(new_id):
|
||||
if new_id > dropzone.get_child_count() - 1: current_dropzone_id = 0
|
||||
elif new_id < 0: current_dropzone_id = dropzone.get_child_count() - 1
|
||||
else: current_dropzone_id = new_id
|
||||
if current_context == ASSIGN:
|
||||
while not dropzone.get_child(current_dropzone_id) is Card: current_dropzone_id = (current_dropzone_id + 1) % dropzone.get_child_count()
|
||||
dropzone.get_child(current_dropzone_id).preview_sticky_note(currently_active_node)
|
||||
set(new_id):
|
||||
if new_id > dropzone.get_child_count() - 1: current_dropzone_id = 0
|
||||
elif new_id < 0: current_dropzone_id = dropzone.get_child_count() - 1
|
||||
else: current_dropzone_id = new_id
|
||||
if current_context == ASSIGN:
|
||||
while not dropzone.get_child(current_dropzone_id) is Card: current_dropzone_id = (current_dropzone_id + 1) % dropzone.get_child_count()
|
||||
dropzone.get_child(current_dropzone_id).preview_sticky_note(currently_active_node)
|
||||
|
||||
elif not focus_stickies:
|
||||
currently_active_node = dropzone.get_child(current_dropzone_id)
|
||||
elif not focus_stickies:
|
||||
currently_active_node = dropzone.get_child(current_dropzone_id)
|
||||
|
||||
@onready var current_sticky_note_id: int = 0:
|
||||
set(new_id):
|
||||
if sticky_note_container.get_child_count() <= 1: return
|
||||
elif new_id > sticky_note_container.get_child_count() - 1: current_sticky_note_id = 0
|
||||
elif new_id < 0: current_sticky_note_id = sticky_note_container.get_child_count() - 1
|
||||
else: current_sticky_note_id = new_id
|
||||
if current_context == ASSIGN:
|
||||
_return_sticky_notes_to_panels()
|
||||
currently_active_node.preview_sticky_note(sticky_note_container.get_child(current_sticky_note_id).attached_sticky_note)
|
||||
else:
|
||||
currently_active_node = sticky_note_container.get_child(current_sticky_note_id).get_child(1)
|
||||
set(new_id):
|
||||
if sticky_note_container.get_child_count() <= 1: return
|
||||
elif new_id > sticky_note_container.get_child_count() - 1: current_sticky_note_id = 0
|
||||
elif new_id < 0: current_sticky_note_id = sticky_note_container.get_child_count() - 1
|
||||
else: current_sticky_note_id = new_id
|
||||
if current_context == ASSIGN:
|
||||
_return_sticky_notes_to_panels()
|
||||
currently_active_node.preview_sticky_note(sticky_note_container.get_child(current_sticky_note_id).attached_sticky_note)
|
||||
else:
|
||||
currently_active_node = sticky_note_container.get_child(current_sticky_note_id).get_child(1)
|
||||
|
||||
var cache: Array = []
|
||||
|
||||
|
|
@ -105,17 +105,17 @@ signal board_completed
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
base_sticky_note_panel = $HBoxContainer/ScrollContainer/VBoxContainer/Panel
|
||||
sticky_note_container.remove_child(base_sticky_note_panel)
|
||||
base_sticky_note_panel = $HBoxContainer/ScrollContainer/VBoxContainer/Panel
|
||||
sticky_note_container.remove_child(base_sticky_note_panel)
|
||||
|
||||
dropzone_size = get_viewport_rect().size - Vector2(dropzone_padding + base_sticky_note_panel.custom_minimum_size.x, dropzone_padding)
|
||||
dropzone_size = get_viewport_rect().size - Vector2(dropzone_padding + base_sticky_note_panel.custom_minimum_size.x, dropzone_padding)
|
||||
|
||||
if get_parent() == get_tree().root:
|
||||
populate_board(["c_void", 'c_joy', "p_wet", "p_thomas"])
|
||||
populate_board(["c_fighting", 'c_hit', "p_girly", "p_vent"])
|
||||
mementos_collected = 2
|
||||
if get_parent() == get_tree().root:
|
||||
populate_board(["c_void", 'c_joy', "p_wet", "p_thomas"])
|
||||
populate_board(["c_fighting", 'c_hit', "p_girly", "p_vent"])
|
||||
mementos_collected = 2
|
||||
|
||||
has_stage = has_stage
|
||||
has_stage = has_stage
|
||||
|
||||
#func _process(delta):
|
||||
# # drops dragged area when Mouse is no longer pressed.
|
||||
|
|
@ -124,228 +124,228 @@ func _ready():
|
|||
|
||||
# Will be used later to spawn Cards and Post-Its and remember them in the dictionary
|
||||
func populate_board(card_names: Array):
|
||||
mementos_collected += 1
|
||||
mementos_collected += 1
|
||||
|
||||
var all_new:Dictionary = board_of_devs.get_cards_by_name_array(card_names)
|
||||
var all_new:Dictionary = board_of_devs.get_cards_by_name_array(card_names)
|
||||
|
||||
var new_cards:Array = all_new["cards"]
|
||||
var new_sticky_notes:Array = all_new["sticky_notes"]
|
||||
var new_cards:Array = all_new["cards"]
|
||||
var new_sticky_notes:Array = all_new["sticky_notes"]
|
||||
|
||||
# spawning the cards and adding them to the dictionary
|
||||
for new_card in all_new["cards"]:
|
||||
add_card(new_card)
|
||||
for new_sticky_note in all_new["sticky_notes"]: # spawning a sticky note
|
||||
add_sticky_note(new_sticky_note)
|
||||
# spawning the cards and adding them to the dictionary
|
||||
for new_card in all_new["cards"]:
|
||||
add_card(new_card)
|
||||
for new_sticky_note in all_new["sticky_notes"]: # spawning a sticky note
|
||||
add_sticky_note(new_sticky_note)
|
||||
|
||||
#currently_active_node = area_dict["dropzone_content"][0] # set first Card as currently selected node by default
|
||||
currently_active_node = dropzone.get_child(0)
|
||||
#currently_active_node = area_dict["dropzone_content"][0] # set first Card as currently selected node by default
|
||||
currently_active_node = dropzone.get_child(0)
|
||||
|
||||
func add_card(card: Card):
|
||||
card.reparent(self)
|
||||
card.position = Vector2(randi_range(dropzone_padding, dropzone_size.x), randi_range(dropzone_padding, dropzone_size.y))
|
||||
insert_area(dropzone, card)
|
||||
card.set_owner(self)
|
||||
card.is_dragable = true
|
||||
card.reparent(self)
|
||||
card.position = Vector2(randi_range(dropzone_padding, dropzone_size.x), randi_range(dropzone_padding, dropzone_size.y))
|
||||
insert_area(dropzone, card)
|
||||
card.set_owner(self)
|
||||
card.is_dragable = true
|
||||
|
||||
func add_sticky_note(sticky: StickyNote):
|
||||
var new_panel = base_sticky_note_panel.duplicate()
|
||||
sticky_note_container.add_child(new_panel)
|
||||
new_panel.set_owner(self)
|
||||
new_panel.attatch_sticky_note(sticky, false)
|
||||
var new_panel = base_sticky_note_panel.duplicate()
|
||||
sticky_note_container.add_child(new_panel)
|
||||
new_panel.set_owner(self)
|
||||
new_panel.attatch_sticky_note(sticky, false)
|
||||
|
||||
# Checks if a Node is currently inside the dropzone
|
||||
func is_in_dropzone(to_check: Node) -> bool:
|
||||
return dropzone.get_rect().has_point(to_check.global_position)
|
||||
return dropzone.get_rect().has_point(to_check.global_position)
|
||||
|
||||
# called if a mouse button is pressed
|
||||
func handle_mouse_button(to_handle: Area2D, input: InputEvent):
|
||||
# No two areas can be dragged at the same time.
|
||||
# Make sure that only the same area is dragged.
|
||||
# Otherwise overlapping areas are dragged at the same time.
|
||||
if current_context == DRAG and to_handle != currently_active_node:
|
||||
return
|
||||
# No two areas can be dragged at the same time.
|
||||
# Make sure that only the same area is dragged.
|
||||
# Otherwise overlapping areas are dragged at the same time.
|
||||
if current_context == DRAG and to_handle != currently_active_node:
|
||||
return
|
||||
|
||||
currently_active_node = to_handle # update currently selected
|
||||
if input.is_action_pressed("mouse_left"):
|
||||
to_handle.is_dragged = true
|
||||
if to_handle is StickyNote:
|
||||
if not to_handle.on_board:
|
||||
to_handle.reparent(dropzone)
|
||||
to_handle.on_board = true
|
||||
to_handle.owner = self
|
||||
current_context = DRAG
|
||||
currently_active_node = to_handle # update currently selected
|
||||
if input.is_action_pressed("mouse_left"):
|
||||
to_handle.is_dragged = true
|
||||
if to_handle is StickyNote:
|
||||
if not to_handle.on_board:
|
||||
to_handle.reparent(dropzone)
|
||||
to_handle.on_board = true
|
||||
to_handle.owner = self
|
||||
current_context = DRAG
|
||||
|
||||
# when Drag stops ...
|
||||
if input.is_action_released("mouse_left"):
|
||||
to_handle.is_dragged = false
|
||||
if to_handle is StickyNote:
|
||||
if is_in_dropzone(to_handle):
|
||||
if to_handle.has_overlapping_areas():
|
||||
for area in to_handle.get_overlapping_areas():
|
||||
if area is Card:
|
||||
focus_stickies = false
|
||||
if area.has_sticky_note_attached():
|
||||
to_handle = area.exchange_sticky_note_with(to_handle)
|
||||
to_handle.reparent(dropzone)
|
||||
to_handle.on_board = true
|
||||
sticky_note_container.get_child(current_sticky_note_id).attached_sticky_note = to_handle
|
||||
to_handle.attached_to = sticky_note_container.get_child(current_sticky_note_id)
|
||||
to_handle.reset_drag()
|
||||
current_context = NAVIGATE
|
||||
return
|
||||
else:
|
||||
area.attach_sticky_note(to_handle)
|
||||
if not sticky_note_container.get_child_count() == 0:
|
||||
sticky_note_container.get_child(current_sticky_note_id).clear_if_empty()
|
||||
current_context = NAVIGATE
|
||||
if is_board_complete(): emit_signal("board_completed")
|
||||
return
|
||||
else:
|
||||
_return_sticky_notes_to_panels()
|
||||
return
|
||||
# when Drag stops ...
|
||||
if input.is_action_released("mouse_left"):
|
||||
to_handle.is_dragged = false
|
||||
if to_handle is StickyNote:
|
||||
if is_in_dropzone(to_handle):
|
||||
if to_handle.has_overlapping_areas():
|
||||
for area in to_handle.get_overlapping_areas():
|
||||
if area is Card:
|
||||
focus_stickies = false
|
||||
if area.has_sticky_note_attached():
|
||||
to_handle = area.exchange_sticky_note_with(to_handle)
|
||||
to_handle.reparent(dropzone)
|
||||
to_handle.on_board = true
|
||||
sticky_note_container.get_child(current_sticky_note_id).attached_sticky_note = to_handle
|
||||
to_handle.attached_to = sticky_note_container.get_child(current_sticky_note_id)
|
||||
to_handle.reset_drag()
|
||||
current_context = NAVIGATE
|
||||
return
|
||||
else:
|
||||
area.attach_sticky_note(to_handle)
|
||||
if not sticky_note_container.get_child_count() == 0:
|
||||
sticky_note_container.get_child(current_sticky_note_id).clear_if_empty()
|
||||
current_context = NAVIGATE
|
||||
if is_board_complete(): emit_signal("board_completed")
|
||||
return
|
||||
else:
|
||||
_return_sticky_notes_to_panels()
|
||||
return
|
||||
|
||||
## Dropping Cards and Sticky Notes not causing a return condition above.
|
||||
insert_area(dropzone, to_handle)
|
||||
current_context = NAVIGATE
|
||||
focus_stickies = false
|
||||
current_dropzone_id = dropzone.get_children().find(to_handle)
|
||||
if to_handle is StickyNote:
|
||||
to_handle.rotation = to_handle.base_rotation
|
||||
to_handle.scale = to_handle.base_scale
|
||||
## Dropping Cards and Sticky Notes not causing a return condition above.
|
||||
insert_area(dropzone, to_handle)
|
||||
current_context = NAVIGATE
|
||||
focus_stickies = false
|
||||
current_dropzone_id = dropzone.get_children().find(to_handle)
|
||||
if to_handle is StickyNote:
|
||||
to_handle.rotation = to_handle.base_rotation
|
||||
to_handle.scale = to_handle.base_scale
|
||||
|
||||
if input.is_action_pressed("mouse_right") and current_context == DRAG:
|
||||
to_handle.reset_drag()
|
||||
if input.is_action_pressed("mouse_right") and current_context == DRAG:
|
||||
to_handle.reset_drag()
|
||||
|
||||
func _return_sticky_notes_to_panels():
|
||||
for panel in sticky_note_container.get_children():
|
||||
panel.reclaim_sticky_note()
|
||||
for panel in sticky_note_container.get_children():
|
||||
panel.reclaim_sticky_note()
|
||||
|
||||
func is_board_complete() -> bool:
|
||||
if mementos_collected == 4:
|
||||
for card in dropzone.get_children():
|
||||
if card is Card:
|
||||
if not card.has_sticky_note_attached():
|
||||
return false
|
||||
return true
|
||||
return false
|
||||
if mementos_collected == 4:
|
||||
for card in dropzone.get_children():
|
||||
if card is Card:
|
||||
if not card.has_sticky_note_attached():
|
||||
return false
|
||||
return true
|
||||
return false
|
||||
|
||||
func is_board_lore() -> bool:
|
||||
for card in dropzone.get_children():
|
||||
if card.has_sticky_note_attached():
|
||||
if not card.current_sticky_note.is_in_group(card.name): return false
|
||||
return true
|
||||
for card in dropzone.get_children():
|
||||
if card.has_sticky_note_attached():
|
||||
if not card.current_sticky_note.is_in_group(card.name): return false
|
||||
return true
|
||||
|
||||
# Mark area that was hovered over as currently selected
|
||||
func handle_hover(to_handle: Area2D):
|
||||
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT): return
|
||||
currently_active_node = to_handle
|
||||
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT): return
|
||||
currently_active_node = to_handle
|
||||
|
||||
if is_in_dropzone(to_handle) or to_handle is Card:
|
||||
if not (to_handle is StickyNote and !to_handle.on_board):
|
||||
current_dropzone_id = dropzone.get_children().find(to_handle)
|
||||
focus_stickies = false
|
||||
else:
|
||||
current_sticky_note_id = sticky_note_container.get_children().find(to_handle.attached_to)
|
||||
focus_stickies = true
|
||||
if is_in_dropzone(to_handle) or to_handle is Card:
|
||||
if not (to_handle is StickyNote and !to_handle.on_board):
|
||||
current_dropzone_id = dropzone.get_children().find(to_handle)
|
||||
focus_stickies = false
|
||||
else:
|
||||
current_sticky_note_id = sticky_note_container.get_children().find(to_handle.attached_to)
|
||||
focus_stickies = true
|
||||
|
||||
# Adds a child at the correct child indext in an area
|
||||
func insert_area(parent: Control, node: Area2D):
|
||||
var children:Array = parent.get_children()
|
||||
var i = 0
|
||||
var children:Array = parent.get_children()
|
||||
var i = 0
|
||||
|
||||
if not node in parent.get_children():
|
||||
node.reparent(parent)
|
||||
if node is StickyNote:
|
||||
node.on_board = true
|
||||
node.owner = self
|
||||
if not node in parent.get_children():
|
||||
node.reparent(parent)
|
||||
if node is StickyNote:
|
||||
node.on_board = true
|
||||
node.owner = self
|
||||
|
||||
if children.size() > 0:
|
||||
children.erase(node)
|
||||
while children[i].global_position.y < node.global_position.y and i+1 < children.size():
|
||||
i+=1
|
||||
parent.move_child(node, i)
|
||||
if children.size() > 0:
|
||||
children.erase(node)
|
||||
while children[i].global_position.y < node.global_position.y and i+1 < children.size():
|
||||
i+=1
|
||||
parent.move_child(node, i)
|
||||
|
||||
# Takes the inputs for control inputs
|
||||
func _input(event):
|
||||
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
State.leave_stage(self)
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
State.leave_stage(self)
|
||||
|
||||
# Return, if the input is a mouse event (mouse events are handled separately)
|
||||
if event is InputEventMouse or !has_stage or not is_instance_valid(currently_active_node): return
|
||||
# Return, if the input is a mouse event (mouse events are handled separately)
|
||||
if event is InputEventMouse or !has_stage or not is_instance_valid(currently_active_node): return
|
||||
|
||||
if current_context != DRAG:
|
||||
if event.is_action_pressed("ui_up"):
|
||||
if focus_stickies:
|
||||
current_sticky_note_id -= 1
|
||||
else:
|
||||
current_dropzone_id -= 1
|
||||
if current_context != DRAG:
|
||||
if event.is_action_pressed("ui_up"):
|
||||
if focus_stickies:
|
||||
current_sticky_note_id -= 1
|
||||
else:
|
||||
current_dropzone_id -= 1
|
||||
|
||||
elif event.is_action_pressed("ui_down"): # down to select an element beneath
|
||||
if focus_stickies:
|
||||
current_sticky_note_id += 1
|
||||
else:
|
||||
current_dropzone_id += 1
|
||||
elif event.is_action_pressed("ui_down"): # down to select an element beneath
|
||||
if focus_stickies:
|
||||
current_sticky_note_id += 1
|
||||
else:
|
||||
current_dropzone_id += 1
|
||||
|
||||
elif event.is_action_pressed("ui_right"): # left to switch context to the left
|
||||
if not focus_stickies:
|
||||
if current_context == NAVIGATE:
|
||||
focus_stickies = true
|
||||
elif current_context == ASSIGN:
|
||||
current_context = NAVIGATE
|
||||
elif event.is_action_pressed("ui_right"): # left to switch context to the left
|
||||
if not focus_stickies:
|
||||
if current_context == NAVIGATE:
|
||||
focus_stickies = true
|
||||
elif current_context == ASSIGN:
|
||||
current_context = NAVIGATE
|
||||
|
||||
elif event.is_action_pressed("ui_left"): # right to switch context to the right
|
||||
if focus_stickies:
|
||||
if current_context == NAVIGATE:
|
||||
focus_stickies = false
|
||||
elif current_context == ASSIGN:
|
||||
current_context = NAVIGATE
|
||||
elif event.is_action_pressed("ui_left"): # right to switch context to the right
|
||||
if focus_stickies:
|
||||
if current_context == NAVIGATE:
|
||||
focus_stickies = false
|
||||
elif current_context == ASSIGN:
|
||||
current_context = NAVIGATE
|
||||
|
||||
elif event.is_action_pressed("ui_accept"): # select the selected note it
|
||||
var card:Card
|
||||
if dropzone.get_child(current_dropzone_id) is Card:
|
||||
card = dropzone.get_child(current_dropzone_id)
|
||||
if current_context == ASSIGN: # to assign it to a card
|
||||
if card.has_sticky_note_attached():
|
||||
currently_active_node = card.exchange_sticky_note_with(currently_active_node)
|
||||
current_dropzone_id = find_first_free_card()
|
||||
else:
|
||||
card.attach_sticky_note(sticky_note_container.get_child(current_sticky_note_id).attached_sticky_note)
|
||||
current_context = NAVIGATE
|
||||
focus_stickies = false
|
||||
if is_board_complete(): emit_signal("board_completed")
|
||||
else:
|
||||
if !focus_stickies and card.has_sticky_note_attached():
|
||||
currently_active_node = card.remove_sticky_note()
|
||||
add_sticky_note(currently_active_node)
|
||||
current_dropzone_id = -1
|
||||
else: current_dropzone_id = find_first_free_card()
|
||||
elif event.is_action_pressed("ui_accept"): # select the selected note it
|
||||
var card:Card
|
||||
if dropzone.get_child(current_dropzone_id) is Card:
|
||||
card = dropzone.get_child(current_dropzone_id)
|
||||
if current_context == ASSIGN: # to assign it to a card
|
||||
if card.has_sticky_note_attached():
|
||||
currently_active_node = card.exchange_sticky_note_with(currently_active_node)
|
||||
current_dropzone_id = find_first_free_card()
|
||||
else:
|
||||
card.attach_sticky_note(sticky_note_container.get_child(current_sticky_note_id).attached_sticky_note)
|
||||
current_context = NAVIGATE
|
||||
focus_stickies = false
|
||||
if is_board_complete(): emit_signal("board_completed")
|
||||
else:
|
||||
if !focus_stickies and card.has_sticky_note_attached():
|
||||
currently_active_node = card.remove_sticky_note()
|
||||
add_sticky_note(currently_active_node)
|
||||
current_dropzone_id = -1
|
||||
else: current_dropzone_id = find_first_free_card()
|
||||
|
||||
current_context = ASSIGN
|
||||
focus_stickies = !focus_stickies
|
||||
if focus_stickies:
|
||||
current_sticky_note_id = current_sticky_note_id
|
||||
else:
|
||||
current_dropzone_id = current_dropzone_id
|
||||
current_context = ASSIGN
|
||||
focus_stickies = !focus_stickies
|
||||
if focus_stickies:
|
||||
current_sticky_note_id = current_sticky_note_id
|
||||
else:
|
||||
current_dropzone_id = current_dropzone_id
|
||||
|
||||
|
||||
# move the note it so it floats next to the card where it should be attached
|
||||
func _select_card_for_assigning(sticky_note: Area2D, card: Area2D):
|
||||
sticky_note.tween_transform_to(card.get_child(3).global_position)
|
||||
sticky_note.tween_transform_to(card.get_child(3).global_position)
|
||||
|
||||
func on_scene_skipped(i: int):
|
||||
mementos_collected += i
|
||||
mementos_collected += i
|
||||
|
||||
func claim_focus():
|
||||
State.pass_stage_to(self)
|
||||
State.pass_stage_to(self)
|
||||
|
||||
func find_first_free_card() -> int:
|
||||
for i in range(dropzone.get_child_count()):
|
||||
# start searching at the current location, use modulo to avoid getting out of array bounds
|
||||
if !dropzone.get_child((i+current_dropzone_id)%dropzone.get_child_count()).has_sticky_note_attached():
|
||||
return (i+current_dropzone_id)%dropzone.get_child_count()
|
||||
return -1
|
||||
for i in range(dropzone.get_child_count()):
|
||||
# start searching at the current location, use modulo to avoid getting out of array bounds
|
||||
if !dropzone.get_child((i+current_dropzone_id)%dropzone.get_child_count()).has_sticky_note_attached():
|
||||
return (i+current_dropzone_id)%dropzone.get_child_count()
|
||||
return -1
|
||||
|
||||
func on_sticky_panel_cleared():
|
||||
if current_sticky_note_id == sticky_note_container.get_child_count() - 1:
|
||||
current_sticky_note_id -= 1
|
||||
if current_sticky_note_id == sticky_note_container.get_child_count() - 1:
|
||||
current_sticky_note_id -= 1
|
||||
|
|
|
|||
|
|
@ -12,54 +12,54 @@ var wiggle_tween
|
|||
var scale_tween
|
||||
|
||||
var transfor_arr: Array[Transform2D] = [
|
||||
Transform2D(0.9, Vector2(-125, -83)),
|
||||
Transform2D(-0.3, Vector2(-126, -75)),
|
||||
Transform2D(-0.3, Vector2(-126, -74)),
|
||||
Transform2D(-0.3, Vector2(-126, -73)),
|
||||
Transform2D(0.5, Vector2(-126, -77))
|
||||
Transform2D(0.9, Vector2(-125, -83)),
|
||||
Transform2D(-0.3, Vector2(-126, -75)),
|
||||
Transform2D(-0.3, Vector2(-126, -74)),
|
||||
Transform2D(-0.3, Vector2(-126, -73)),
|
||||
Transform2D(0.5, Vector2(-126, -77))
|
||||
]
|
||||
|
||||
@export var text: String = "" :
|
||||
set(value):
|
||||
text = value
|
||||
if get_children() != [] or Engine.is_editor_hint():
|
||||
$Label.text = value
|
||||
var curr_frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
|
||||
$BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
|
||||
$Label.rotation = deg_to_rad(transfor_arr[curr_frame].get_rotation())
|
||||
$Label.position = transfor_arr[curr_frame].origin
|
||||
if !Engine.is_editor_hint():
|
||||
wiggle_pos = float(text.hash() % 100)
|
||||
_handle_wiggle(0)
|
||||
set(value):
|
||||
text = value
|
||||
if get_children() != [] or Engine.is_editor_hint():
|
||||
$Label.text = value
|
||||
var curr_frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
|
||||
$BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
|
||||
$Label.rotation = deg_to_rad(transfor_arr[curr_frame].get_rotation())
|
||||
$Label.position = transfor_arr[curr_frame].origin
|
||||
if !Engine.is_editor_hint():
|
||||
wiggle_pos = float(text.hash() % 100)
|
||||
_handle_wiggle(0)
|
||||
@export var wiggle_strength: float = 0.2
|
||||
@export var wiggle_speed: float = 5
|
||||
@export_range(1, 2) var scale_bump: float = 1.05
|
||||
@export_range(1.0, 10.0) var bounce_speed: float = 5
|
||||
@export var highlighted: bool = false:
|
||||
set(highlight):
|
||||
if highlight != highlighted:
|
||||
highlighted = highlight
|
||||
set(highlight):
|
||||
if highlight != highlighted:
|
||||
highlighted = highlight
|
||||
|
||||
if is_inside_tree() and is_node_ready():
|
||||
if scale_tween: scale_tween.kill()
|
||||
if wiggle_tween: wiggle_tween.kill()
|
||||
if highlighted:
|
||||
scale_tween = get_tree().create_tween()
|
||||
scale_tween.tween_property(self, "scale", Vector2(scale_bump, scale_bump), 0.1)
|
||||
wiggle_tween = get_tree().create_tween()
|
||||
wiggle_tween.tween_property(self, "wiggle_intensity", 1, 0.2)
|
||||
else:
|
||||
scale_tween = get_tree().create_tween()
|
||||
scale_tween.tween_property(self, "scale", Vector2(1, 1), 0.3)
|
||||
wiggle_tween = get_tree().create_tween()
|
||||
wiggle_tween.tween_property(self, "wiggle_intensity", 0, 0.5)
|
||||
else:
|
||||
if highlighted:
|
||||
scale = Vector2(scale_bump, scale_bump)
|
||||
wiggle_intensity = 1
|
||||
else:
|
||||
scale = Vector2(1,1)
|
||||
wiggle_intensity = 0
|
||||
if is_inside_tree() and is_node_ready():
|
||||
if scale_tween: scale_tween.kill()
|
||||
if wiggle_tween: wiggle_tween.kill()
|
||||
if highlighted:
|
||||
scale_tween = get_tree().create_tween()
|
||||
scale_tween.tween_property(self, "scale", Vector2(scale_bump, scale_bump), 0.1)
|
||||
wiggle_tween = get_tree().create_tween()
|
||||
wiggle_tween.tween_property(self, "wiggle_intensity", 1, 0.2)
|
||||
else:
|
||||
scale_tween = get_tree().create_tween()
|
||||
scale_tween.tween_property(self, "scale", Vector2(1, 1), 0.3)
|
||||
wiggle_tween = get_tree().create_tween()
|
||||
wiggle_tween.tween_property(self, "wiggle_intensity", 0, 0.5)
|
||||
else:
|
||||
if highlighted:
|
||||
scale = Vector2(scale_bump, scale_bump)
|
||||
wiggle_intensity = 1
|
||||
else:
|
||||
scale = Vector2(1,1)
|
||||
wiggle_intensity = 0
|
||||
|
||||
@export var voice_line: AudioStream = null
|
||||
@export var is_dragable: bool = false
|
||||
|
|
@ -67,149 +67,149 @@ var transfor_arr: Array[Transform2D] = [
|
|||
@onready var sticky_note_anchor: Node2D = $"sticky note anchor"
|
||||
|
||||
var is_dragged: bool = false:
|
||||
set(dragged):
|
||||
is_dragged = dragged
|
||||
z_index = int(dragged)
|
||||
set(dragged):
|
||||
is_dragged = dragged
|
||||
z_index = int(dragged)
|
||||
|
||||
var is_mouse_entered: bool = false
|
||||
var mouse_offset: Vector2
|
||||
|
||||
func _ready():
|
||||
|
||||
_handle_wiggle(0)
|
||||
if not Engine.is_editor_hint() and is_inside_tree():
|
||||
for sticky_note in self.get_children():
|
||||
if sticky_note is StickyNote: self.own_sticky_notes.append(sticky_note as StickyNote)
|
||||
_handle_wiggle(0)
|
||||
if not Engine.is_editor_hint() and is_inside_tree():
|
||||
for sticky_note in self.get_children():
|
||||
if sticky_note is StickyNote: self.own_sticky_notes.append(sticky_note as StickyNote)
|
||||
|
||||
for sticky_note in get_tree().get_nodes_in_group(name):
|
||||
if sticky_note is StickyNote: self.compatible_sticky_notes.append(sticky_note as StickyNote)
|
||||
for sticky_note in get_tree().get_nodes_in_group(name):
|
||||
if sticky_note is StickyNote: self.compatible_sticky_notes.append(sticky_note as StickyNote)
|
||||
|
||||
compatible_sticky_notes.append_array(own_sticky_notes)
|
||||
compatible_sticky_notes.append_array(own_sticky_notes)
|
||||
|
||||
if own_sticky_notes.size() == 2:
|
||||
own_sticky_notes[0].sibling = own_sticky_notes[1]
|
||||
own_sticky_notes[1].sibling = own_sticky_notes[0]
|
||||
if own_sticky_notes.size() == 2:
|
||||
own_sticky_notes[0].sibling = own_sticky_notes[1]
|
||||
own_sticky_notes[1].sibling = own_sticky_notes[0]
|
||||
|
||||
$BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
|
||||
$Label.text = self.text
|
||||
$BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
|
||||
$Label.text = self.text
|
||||
|
||||
$Label.theme = State.current_main_theme
|
||||
State.theme_changed.connect(func change_theme(new_theme): $Label.theme = new_theme)
|
||||
$Label.theme = State.current_main_theme
|
||||
State.theme_changed.connect(func change_theme(new_theme): $Label.theme = new_theme)
|
||||
|
||||
wiggle_pos = float(text.hash() % 100)
|
||||
if not Engine.is_editor_hint():
|
||||
_handle_wiggle(0)
|
||||
wiggle_pos = float(text.hash() % 100)
|
||||
if not Engine.is_editor_hint():
|
||||
_handle_wiggle(0)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if highlighted:
|
||||
_handle_wiggle(delta)
|
||||
if highlighted:
|
||||
_handle_wiggle(delta)
|
||||
|
||||
if get_overlapping_areas().size() > 0 and is_dragable:
|
||||
for area in get_overlapping_areas():
|
||||
if area is Card or area is CardCollider:
|
||||
if area is CardCollider:
|
||||
position += area.direction * delta
|
||||
elif not (area.highlighted or self.highlighted) and area.is_dragable:
|
||||
var diff:Vector2 = position - area.position
|
||||
position -= diff.normalized() * ((diff.length()-diameter)/diameter) * bounce_speed * (delta/(1.0/60))
|
||||
if get_overlapping_areas().size() > 0 and is_dragable:
|
||||
for area in get_overlapping_areas():
|
||||
if area is Card or area is CardCollider:
|
||||
if area is CardCollider:
|
||||
position += area.direction * delta
|
||||
elif not (area.highlighted or self.highlighted) and area.is_dragable:
|
||||
var diff:Vector2 = position - area.position
|
||||
position -= diff.normalized() * ((diff.length()-diameter)/diameter) * bounce_speed * (delta/(1.0/60))
|
||||
|
||||
_move_card()
|
||||
_move_card()
|
||||
|
||||
func get_text() -> String:
|
||||
return $Label.text
|
||||
return $Label.text
|
||||
|
||||
func _handle_wiggle(delta):
|
||||
wiggle_pos += delta * wiggle_speed * wiggle_intensity
|
||||
wiggle_pos += delta * wiggle_speed * wiggle_intensity
|
||||
|
||||
rotation = noise.get_noise_1d(wiggle_pos)*wiggle_strength
|
||||
rotation = noise.get_noise_1d(wiggle_pos)*wiggle_strength
|
||||
|
||||
## Deprecated
|
||||
func replace_with(card: Card):
|
||||
self.text = card.text
|
||||
self.compatible_sticky_notes = card.compatible_sticky_notes
|
||||
self.own_sticky_notes = card.own_sticky_notes
|
||||
self.voice_line = card.voice_line
|
||||
self.name = card.name
|
||||
self.text = card.text
|
||||
self.compatible_sticky_notes = card.compatible_sticky_notes
|
||||
self.own_sticky_notes = card.own_sticky_notes
|
||||
self.voice_line = card.voice_line
|
||||
self.name = card.name
|
||||
|
||||
func _on_focus_entered():
|
||||
print(self, "is focused")
|
||||
print(self, "is focused")
|
||||
|
||||
func _on_focus_exited():
|
||||
print(self, "is not focused")
|
||||
print(self, "is not focused")
|
||||
|
||||
func _on_mouse_entered():
|
||||
is_mouse_entered = true
|
||||
if not Input.is_action_pressed("mouse_left"):
|
||||
# Do nothing if mouse hovers over sticky_note
|
||||
if has_sticky_note_attached():
|
||||
if get_child(-1).highlighted:
|
||||
return
|
||||
highlighted = true
|
||||
if "handle_hover" in owner:
|
||||
owner.handle_hover(self)
|
||||
is_mouse_entered = true
|
||||
if not Input.is_action_pressed("mouse_left"):
|
||||
# Do nothing if mouse hovers over sticky_note
|
||||
if has_sticky_note_attached():
|
||||
if get_child(-1).highlighted:
|
||||
return
|
||||
highlighted = true
|
||||
if "handle_hover" in owner:
|
||||
owner.handle_hover(self)
|
||||
|
||||
func _on_mouse_exited():
|
||||
highlighted = false
|
||||
is_mouse_entered = false
|
||||
highlighted = false
|
||||
is_mouse_entered = false
|
||||
|
||||
func _on_input_event(viewport, event, shape_idx):
|
||||
|
||||
if event is InputEventMouseMotion:
|
||||
_move_card()
|
||||
if event is InputEventMouseMotion:
|
||||
_move_card()
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_LEFT:
|
||||
if "handle_mouse_button" in owner:
|
||||
mouse_offset = (get_viewport().get_mouse_position() - position)
|
||||
if highlighted:
|
||||
owner.handle_mouse_button(self, event)
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_LEFT:
|
||||
if "handle_mouse_button" in owner:
|
||||
mouse_offset = (get_viewport().get_mouse_position() - position)
|
||||
if highlighted:
|
||||
owner.handle_mouse_button(self, event)
|
||||
|
||||
func _move_card():
|
||||
if is_dragged:
|
||||
position += (get_viewport().get_mouse_position() - position) - mouse_offset
|
||||
if is_dragged:
|
||||
position += (get_viewport().get_mouse_position() - position) - mouse_offset
|
||||
|
||||
func has_sticky_note_attached() -> bool:
|
||||
return get_child(-1) is StickyNote
|
||||
return get_child(-1) is StickyNote
|
||||
|
||||
func preview_sticky_note(sticky_note: StickyNote):
|
||||
sticky_note.reparent(self.get_parent())
|
||||
sticky_note.owner = owner
|
||||
sticky_note.tween_transform_to(Transform2D(0, sticky_note_anchor.global_position + 0 * Vector2(sticky_note.diameter, sticky_note.diameter)))
|
||||
sticky_note.reparent(self.get_parent())
|
||||
sticky_note.owner = owner
|
||||
sticky_note.tween_transform_to(Transform2D(0, sticky_note_anchor.global_position + 0 * Vector2(sticky_note.diameter, sticky_note.diameter)))
|
||||
|
||||
func attach_sticky_note(sticky_note: StickyNote) -> bool:
|
||||
if has_sticky_note_attached():
|
||||
return false
|
||||
sticky_note.reparent(self)
|
||||
sticky_note.owner = self.owner
|
||||
sticky_note.position = sticky_note_anchor.position
|
||||
sticky_note.on_board = false
|
||||
current_sticky_note = sticky_note
|
||||
sticky_note.attached_to = self
|
||||
return true
|
||||
if has_sticky_note_attached():
|
||||
return false
|
||||
sticky_note.reparent(self)
|
||||
sticky_note.owner = self.owner
|
||||
sticky_note.position = sticky_note_anchor.position
|
||||
sticky_note.on_board = false
|
||||
current_sticky_note = sticky_note
|
||||
sticky_note.attached_to = self
|
||||
return true
|
||||
|
||||
func remove_sticky_note() -> StickyNote:
|
||||
if not is_instance_valid(current_sticky_note): return null
|
||||
var former_child:StickyNote = current_sticky_note
|
||||
current_sticky_note = null
|
||||
former_child.reparent(get_parent())
|
||||
former_child.owner = self.owner
|
||||
former_child.on_board = true
|
||||
former_child.attached_to = null
|
||||
return former_child
|
||||
if not is_instance_valid(current_sticky_note): return null
|
||||
var former_child:StickyNote = current_sticky_note
|
||||
current_sticky_note = null
|
||||
former_child.reparent(get_parent())
|
||||
former_child.owner = self.owner
|
||||
former_child.on_board = true
|
||||
former_child.attached_to = null
|
||||
return former_child
|
||||
|
||||
func exchange_sticky_note_with(new_note: StickyNote) -> StickyNote:
|
||||
var tmp = remove_sticky_note()
|
||||
attach_sticky_note(new_note)
|
||||
return tmp
|
||||
var tmp = remove_sticky_note()
|
||||
attach_sticky_note(new_note)
|
||||
return tmp
|
||||
|
||||
## TODO why does this exist?
|
||||
func check_hover():
|
||||
if is_mouse_entered:
|
||||
_on_mouse_entered()
|
||||
if is_mouse_entered:
|
||||
_on_mouse_entered()
|
||||
|
||||
func reclaim_sticky_note():
|
||||
current_sticky_note.on_board = false
|
||||
current_sticky_note.tween_transform_to(sticky_note_anchor.global_transform)
|
||||
await current_sticky_note.transform_tween_finished
|
||||
current_sticky_note.reparent(self)
|
||||
current_sticky_note.owner = self.owner
|
||||
current_sticky_note.on_board = false
|
||||
current_sticky_note.tween_transform_to(sticky_note_anchor.global_transform)
|
||||
await current_sticky_note.transform_tween_finished
|
||||
current_sticky_note.reparent(self)
|
||||
current_sticky_note.owner = self.owner
|
||||
|
|
|
|||
|
|
@ -6,46 +6,46 @@ var attached_sticky_note: StickyNote
|
|||
@onready var ancor = $"sticky-note_anchor"
|
||||
|
||||
func _ready():
|
||||
ancor.position = Vector2(ancor.position.x, 0)
|
||||
custom_minimum_size = Vector2(custom_minimum_size.x, 0)
|
||||
ancor.position = Vector2(ancor.position.x, 0)
|
||||
custom_minimum_size = Vector2(custom_minimum_size.x, 0)
|
||||
|
||||
func attatch_sticky_note(attatchment: StickyNote, tween:bool = true):
|
||||
attatchment.on_board = false
|
||||
if tween:
|
||||
var height_tween: Tween = create_tween()
|
||||
height_tween.tween_property(self, "custom_minimum_size", minimum_size, 0.3)
|
||||
height_tween.tween_property(ancor, "position", Vector2(ancor.position.x, minimum_size.y/2), 0.3)
|
||||
attatchment.tween_transform_to(ancor.global_position)
|
||||
await attatchment.transform_tween_finished
|
||||
else:
|
||||
custom_minimum_size = minimum_size
|
||||
ancor.position = Vector2(ancor.position.x, minimum_size.y/2)
|
||||
attatchment.reparent(self)
|
||||
attached_sticky_note = attatchment
|
||||
attatchment.owner = self.owner
|
||||
attatchment.attached_to = self
|
||||
attatchment.transform = ancor.transform
|
||||
attatchment.on_board = false
|
||||
if tween:
|
||||
var height_tween: Tween = create_tween()
|
||||
height_tween.tween_property(self, "custom_minimum_size", minimum_size, 0.3)
|
||||
height_tween.tween_property(ancor, "position", Vector2(ancor.position.x, minimum_size.y/2), 0.3)
|
||||
attatchment.tween_transform_to(ancor.global_position)
|
||||
await attatchment.transform_tween_finished
|
||||
else:
|
||||
custom_minimum_size = minimum_size
|
||||
ancor.position = Vector2(ancor.position.x, minimum_size.y/2)
|
||||
attatchment.reparent(self)
|
||||
attached_sticky_note = attatchment
|
||||
attatchment.owner = self.owner
|
||||
attatchment.attached_to = self
|
||||
attatchment.transform = ancor.transform
|
||||
|
||||
func reclaim_sticky_note():
|
||||
if is_empty() and attached_sticky_note.on_board == true:
|
||||
attached_sticky_note.on_board = false
|
||||
attached_sticky_note.tween_transform_to(ancor.global_transform)
|
||||
await attached_sticky_note.transform_tween_finished
|
||||
attached_sticky_note.reparent(self)
|
||||
attached_sticky_note.owner = self.owner
|
||||
if is_empty() and attached_sticky_note.on_board == true:
|
||||
attached_sticky_note.on_board = false
|
||||
attached_sticky_note.tween_transform_to(ancor.global_transform)
|
||||
await attached_sticky_note.transform_tween_finished
|
||||
attached_sticky_note.reparent(self)
|
||||
attached_sticky_note.owner = self.owner
|
||||
|
||||
func clear_if_empty():
|
||||
if !is_empty(): return
|
||||
if attached_sticky_note.attached_to == self: attached_sticky_note.attached_to = null
|
||||
var height_tween: Tween = create_tween()
|
||||
height_tween.tween_property(self, "custom_minimum_size", Vector2.ZERO, 0.3)
|
||||
await height_tween.finished
|
||||
owner.on_sticky_panel_cleared()
|
||||
self.free()
|
||||
if !is_empty(): return
|
||||
if attached_sticky_note.attached_to == self: attached_sticky_note.attached_to = null
|
||||
var height_tween: Tween = create_tween()
|
||||
height_tween.tween_property(self, "custom_minimum_size", Vector2.ZERO, 0.3)
|
||||
await height_tween.finished
|
||||
owner.on_sticky_panel_cleared()
|
||||
self.free()
|
||||
|
||||
func replace_sticky_note_with(new_sticky_note: StickyNote):
|
||||
if is_empty():
|
||||
attached_sticky_note = new_sticky_note
|
||||
if is_empty():
|
||||
attached_sticky_note = new_sticky_note
|
||||
|
||||
func is_empty() -> bool:
|
||||
return get_child_count() == 1
|
||||
return get_child_count() == 1
|
||||
|
|
|
|||
|
|
@ -9,47 +9,47 @@ var modulate_tween
|
|||
signal transform_tween_finished
|
||||
|
||||
@export var text: String = "" :
|
||||
set (value):
|
||||
if is_inside_tree() or Engine.is_editor_hint():
|
||||
$Content/Label.text = value
|
||||
$Content/BackgroundSprite.frame = text.hash() % $Content/BackgroundSprite.sprite_frames.get_frame_count($Content/BackgroundSprite.animation)
|
||||
text = value
|
||||
set (value):
|
||||
if is_inside_tree() or Engine.is_editor_hint():
|
||||
$Content/Label.text = value
|
||||
$Content/BackgroundSprite.frame = text.hash() % $Content/BackgroundSprite.sprite_frames.get_frame_count($Content/BackgroundSprite.animation)
|
||||
text = value
|
||||
|
||||
|
||||
@export var shift_by: Vector2 = Vector2(-32, 0)
|
||||
@export_color_no_alpha var highlight_color: Color = Color(1.5, 1.5, 1.5)
|
||||
@export var highlighted: bool = false:
|
||||
set(highlight):
|
||||
if highlight != highlighted:
|
||||
highlighted = highlight
|
||||
set(highlight):
|
||||
if highlight != highlighted:
|
||||
highlighted = highlight
|
||||
|
||||
if is_inside_tree() and is_node_ready():
|
||||
if modulate_tween: modulate_tween.kill()
|
||||
if shift_tween: shift_tween.kill()
|
||||
if highlighted:
|
||||
modulate_tween = get_tree().create_tween()
|
||||
modulate_tween.tween_property(self, "modulate", highlight_color, 0.1)
|
||||
shift_tween = get_tree().create_tween()
|
||||
shift_tween.tween_property($Content, "position", shift_by, 0.2)
|
||||
else:
|
||||
modulate_tween = get_tree().create_tween()
|
||||
modulate_tween.tween_property(self, "modulate", Color(1, 1, 1), 0.3)
|
||||
shift_tween = get_tree().create_tween()
|
||||
shift_tween.tween_property($Content, "position", Vector2.ZERO, 0.5)
|
||||
else:
|
||||
if highlighted:
|
||||
modulate = Color(1, 1, 1)
|
||||
else:
|
||||
modulate = Color(1, 1, 1)
|
||||
if is_inside_tree() and is_node_ready():
|
||||
if modulate_tween: modulate_tween.kill()
|
||||
if shift_tween: shift_tween.kill()
|
||||
if highlighted:
|
||||
modulate_tween = get_tree().create_tween()
|
||||
modulate_tween.tween_property(self, "modulate", highlight_color, 0.1)
|
||||
shift_tween = get_tree().create_tween()
|
||||
shift_tween.tween_property($Content, "position", shift_by, 0.2)
|
||||
else:
|
||||
modulate_tween = get_tree().create_tween()
|
||||
modulate_tween.tween_property(self, "modulate", Color(1, 1, 1), 0.3)
|
||||
shift_tween = get_tree().create_tween()
|
||||
shift_tween.tween_property($Content, "position", Vector2.ZERO, 0.5)
|
||||
else:
|
||||
if highlighted:
|
||||
modulate = Color(1, 1, 1)
|
||||
else:
|
||||
modulate = Color(1, 1, 1)
|
||||
|
||||
@export var voice_line: AudioStream = null
|
||||
@export var is_dragable: bool = false
|
||||
@onready var base_rotation = rotation
|
||||
@onready var base_scale = scale
|
||||
var is_dragged: bool = false:
|
||||
set(dragged):
|
||||
is_dragged = dragged
|
||||
z_index = int(dragged)
|
||||
set(dragged):
|
||||
is_dragged = dragged
|
||||
z_index = int(dragged)
|
||||
|
||||
var initial_drag_position: Vector2
|
||||
var mouse_diff: Vector2
|
||||
|
|
@ -61,77 +61,77 @@ var attached_to: Node = null
|
|||
|
||||
func _ready() -> void:
|
||||
|
||||
$Content/Label.text = self.text
|
||||
$Content/BackgroundSprite.frame = text.hash() % $Content/BackgroundSprite.sprite_frames.get_frame_count($Content/BackgroundSprite.animation)
|
||||
$Content/Label.text = self.text
|
||||
$Content/BackgroundSprite.frame = text.hash() % $Content/BackgroundSprite.sprite_frames.get_frame_count($Content/BackgroundSprite.animation)
|
||||
|
||||
$Content/Label.theme = State.current_main_theme
|
||||
State.theme_changed.connect(func change_theme(new_theme): $Content/Label.theme = new_theme)
|
||||
$Content/Label.theme = State.current_main_theme
|
||||
State.theme_changed.connect(func change_theme(new_theme): $Content/Label.theme = new_theme)
|
||||
|
||||
func replace_with(sticky_note: StickyNote):
|
||||
self.text = sticky_note.text
|
||||
self.voice_line = sticky_note.voice_line
|
||||
self.sibling = sticky_note.sibling
|
||||
self.name = sticky_note.name
|
||||
for group in self.get_groups():
|
||||
self.remove_from_group(group)
|
||||
for group in sticky_note.get_groups():
|
||||
self.add_to_group(group)
|
||||
self.text = sticky_note.text
|
||||
self.voice_line = sticky_note.voice_line
|
||||
self.sibling = sticky_note.sibling
|
||||
self.name = sticky_note.name
|
||||
for group in self.get_groups():
|
||||
self.remove_from_group(group)
|
||||
for group in sticky_note.get_groups():
|
||||
self.add_to_group(group)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if get_overlapping_areas().size() > 0 and is_dragable and on_board:
|
||||
for area in get_overlapping_areas():
|
||||
if area is Card or area is CardCollider:
|
||||
if area is CardCollider:
|
||||
position += area.direction * delta
|
||||
elif not area.highlighted or self.highlighted:
|
||||
var diff:Vector2 = position - area.position
|
||||
position -= diff.normalized() * ((diff.length()-diameter)/diameter) * bounce_speed * (delta/(1.0/60))
|
||||
if get_overlapping_areas().size() > 0 and is_dragable and on_board:
|
||||
for area in get_overlapping_areas():
|
||||
if area is Card or area is CardCollider:
|
||||
if area is CardCollider:
|
||||
position += area.direction * delta
|
||||
elif not area.highlighted or self.highlighted:
|
||||
var diff:Vector2 = position - area.position
|
||||
position -= diff.normalized() * ((diff.length()-diameter)/diameter) * bounce_speed * (delta/(1.0/60))
|
||||
|
||||
_move_sticky_note()
|
||||
_move_sticky_note()
|
||||
|
||||
func _on_focus_entered():
|
||||
print(self, "is focused")
|
||||
print(self, "is focused")
|
||||
|
||||
func _on_focus_exited():
|
||||
print(self, "is not focused")
|
||||
print(self, "is not focused")
|
||||
|
||||
func _on_mouse_entered():
|
||||
if not Input.is_action_pressed("mouse_left"):
|
||||
highlighted = true
|
||||
if "handle_hover" in owner:
|
||||
owner.handle_hover(self)
|
||||
if not Input.is_action_pressed("mouse_left"):
|
||||
highlighted = true
|
||||
if "handle_hover" in owner:
|
||||
owner.handle_hover(self)
|
||||
|
||||
func _on_mouse_exited():
|
||||
highlighted = false
|
||||
if is_sticky_note_attached() and "check_hover" in get_parent():
|
||||
get_parent().check_hover()
|
||||
highlighted = false
|
||||
if is_sticky_note_attached() and "check_hover" in get_parent():
|
||||
get_parent().check_hover()
|
||||
|
||||
func _on_input_event(viewport, event, shape_idx):
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_LEFT or event.button_index == MOUSE_BUTTON_RIGHT:
|
||||
if "handle_mouse_button" in owner:
|
||||
mouse_diff = get_viewport().get_mouse_position()
|
||||
initial_drag_position = global_position
|
||||
owner.handle_mouse_button(self, event)
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_LEFT or event.button_index == MOUSE_BUTTON_RIGHT:
|
||||
if "handle_mouse_button" in owner:
|
||||
mouse_diff = get_viewport().get_mouse_position()
|
||||
initial_drag_position = global_position
|
||||
owner.handle_mouse_button(self, event)
|
||||
|
||||
func _move_sticky_note():
|
||||
if is_dragged:
|
||||
position = initial_drag_position + get_viewport().get_mouse_position() - mouse_diff
|
||||
if is_dragged:
|
||||
position = initial_drag_position + get_viewport().get_mouse_position() - mouse_diff
|
||||
|
||||
func is_sticky_note_attached() -> bool:
|
||||
# there is probably a nicer way to do this
|
||||
return self.get_parent().get_parent() is Card
|
||||
# there is probably a nicer way to do this
|
||||
return self.get_parent().get_parent() is Card
|
||||
|
||||
func tween_transform_to(target: Transform2D):
|
||||
var transform_tween: Tween = create_tween()
|
||||
transform_tween.tween_property(self, "transform", target, 0.25)
|
||||
await transform_tween.finished
|
||||
emit_signal("transform_tween_finished")
|
||||
var transform_tween: Tween = create_tween()
|
||||
transform_tween.tween_property(self, "transform", target, 0.25)
|
||||
await transform_tween.finished
|
||||
emit_signal("transform_tween_finished")
|
||||
|
||||
func reset_drag():
|
||||
if attached_to != null:
|
||||
attached_to.reclaim_sticky_note()
|
||||
if attached_to != null:
|
||||
attached_to.reclaim_sticky_note()
|
||||
|
||||
func _enter_tree():
|
||||
print("enter_tree")
|
||||
print("enter_tree")
|
||||
|
|
|
|||
|
|
@ -2,57 +2,57 @@ extends CenterContainer
|
|||
|
||||
#fixme INI is probably redundant.
|
||||
enum {
|
||||
INI,
|
||||
CARDS,
|
||||
CARDS_SELECTED,
|
||||
TRANSITION,
|
||||
POSTS,
|
||||
POSTS_SELECTED,
|
||||
DONE
|
||||
INI,
|
||||
CARDS,
|
||||
CARDS_SELECTED,
|
||||
TRANSITION,
|
||||
POSTS,
|
||||
POSTS_SELECTED,
|
||||
DONE
|
||||
}
|
||||
|
||||
@onready var source_board:Control = $"board of devs"
|
||||
|
||||
var has_stage = false:
|
||||
set(focus):
|
||||
if not focus == has_stage:
|
||||
if focus:
|
||||
process_mode = Node.PROCESS_MODE_INHERIT
|
||||
self.show()
|
||||
self.mouse_filter = Control.MOUSE_FILTER_PASS
|
||||
else:
|
||||
self.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
self.hide()
|
||||
process_mode = Node.PROCESS_MODE_DISABLED
|
||||
has_stage = focus
|
||||
set(focus):
|
||||
if not focus == has_stage:
|
||||
if focus:
|
||||
process_mode = Node.PROCESS_MODE_INHERIT
|
||||
self.show()
|
||||
self.mouse_filter = Control.MOUSE_FILTER_PASS
|
||||
else:
|
||||
self.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
self.hide()
|
||||
process_mode = Node.PROCESS_MODE_DISABLED
|
||||
has_stage = focus
|
||||
|
||||
var _input_locked = true
|
||||
var selection_state = INI:
|
||||
set(state):
|
||||
selection_state = state
|
||||
_input_locked = !(state == CARDS or state == POSTS)
|
||||
set(state):
|
||||
selection_state = state
|
||||
_input_locked = !(state == CARDS or state == POSTS)
|
||||
|
||||
if state == CARDS_SELECTED:
|
||||
var tween = get_tree().create_tween()
|
||||
tween.tween_property($thought_prompt, "modulate", Color(1, 1, 1, 0), 0.5)
|
||||
elif state == DONE:
|
||||
reset()
|
||||
if state == CARDS_SELECTED:
|
||||
var tween = get_tree().create_tween()
|
||||
tween.tween_property($thought_prompt, "modulate", Color(1, 1, 1, 0), 0.5)
|
||||
elif state == DONE:
|
||||
reset()
|
||||
|
||||
var anim_players:Array[AnimationPlayer] = []
|
||||
var curr_selection_id: int = -1:
|
||||
set(new_id):
|
||||
if selection_state == CARDS or selection_state == POSTS:
|
||||
if not curr_selection_id == -1: options[curr_selection_id].highlighted = false
|
||||
set(new_id):
|
||||
if selection_state == CARDS or selection_state == POSTS:
|
||||
if not curr_selection_id == -1: options[curr_selection_id].highlighted = false
|
||||
|
||||
if new_id > options.size() -1: curr_selection_id = 0
|
||||
elif new_id < 0: curr_selection_id = options.size() - 1
|
||||
else: curr_selection_id = new_id
|
||||
if new_id > options.size() -1: curr_selection_id = 0
|
||||
elif new_id < 0: curr_selection_id = options.size() - 1
|
||||
else: curr_selection_id = new_id
|
||||
|
||||
options[curr_selection_id].highlighted = true
|
||||
else:
|
||||
curr_selection_id = new_id
|
||||
options[curr_selection_id].highlighted = true
|
||||
else:
|
||||
curr_selection_id = new_id
|
||||
|
||||
print(curr_selection_id)
|
||||
print(curr_selection_id)
|
||||
|
||||
var output:Array = []
|
||||
var options:Array = []
|
||||
|
|
@ -61,166 +61,165 @@ signal cards_picked(Array)
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
reset()
|
||||
reset()
|
||||
|
||||
func reset():
|
||||
output = []
|
||||
options = []
|
||||
anim_players = []
|
||||
var card_controls = $cards.get_children()
|
||||
for control in card_controls:
|
||||
options.append(control.get_child(1))
|
||||
anim_players.append(control.get_child(0))
|
||||
curr_selection_id = 0
|
||||
for player in anim_players: player.play("reveal")
|
||||
output = []
|
||||
options = []
|
||||
anim_players = []
|
||||
var card_controls = $cards.get_children()
|
||||
for control in card_controls:
|
||||
options.append(control.get_child(1))
|
||||
anim_players.append(control.get_child(0))
|
||||
curr_selection_id = 0
|
||||
for player in anim_players: player.play("reveal")
|
||||
|
||||
func fill_card_slots(id: int):
|
||||
var new_cards = source_board.get_cards_by_scene_id(id)
|
||||
var new_cards = source_board.get_cards_by_scene_id(id)
|
||||
|
||||
for i in range(new_cards.size()):
|
||||
$cards.get_child(i).remove_child($cards.get_child(i).get_child(1))
|
||||
var new_card = new_cards[i]
|
||||
new_card.reparent($cards.get_child(i), false)
|
||||
new_card.owner = self
|
||||
new_card.connect("mouse_entered", Callable(self, "get_highlight"))
|
||||
options.append(new_card)
|
||||
anim_players.append($cards.get_child(i).get_child(0))
|
||||
reset()
|
||||
for i in range(new_cards.size()):
|
||||
$cards.get_child(i).remove_child($cards.get_child(i).get_child(1))
|
||||
var new_card = new_cards[i]
|
||||
new_card.reparent($cards.get_child(i), false)
|
||||
new_card.owner = self
|
||||
new_card.connect("mouse_entered", Callable(self, "get_highlight"))
|
||||
options.append(new_card)
|
||||
anim_players.append($cards.get_child(i).get_child(0))
|
||||
reset()
|
||||
|
||||
func fill_post_slots():
|
||||
var sticky_notes: Array[StickyNote] = []
|
||||
for card in output:
|
||||
sticky_notes.append_array(card.own_sticky_notes)
|
||||
var sticky_notes: Array[StickyNote] = []
|
||||
for card in output:
|
||||
sticky_notes.append_array(card.own_sticky_notes)
|
||||
|
||||
sticky_notes.shuffle()
|
||||
options = []
|
||||
for ancor in $sticky_notes.get_children():
|
||||
ancor.remove_child(ancor.get_child(1))
|
||||
sticky_notes.shuffle()
|
||||
options = []
|
||||
for ancor in $sticky_notes.get_children():
|
||||
ancor.remove_child(ancor.get_child(1))
|
||||
|
||||
for i in range(sticky_notes.size()):
|
||||
options.append(sticky_notes[i])
|
||||
$sticky_notes.get_child(i).add_child(options[i], false)
|
||||
options[i].owner = self
|
||||
for i in range(sticky_notes.size()):
|
||||
options.append(sticky_notes[i])
|
||||
$sticky_notes.get_child(i).add_child(options[i], false)
|
||||
options[i].owner = self
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("ui_end"):
|
||||
fill_card_slots(3)
|
||||
selection_state = CARDS
|
||||
if event.is_action_pressed("ui_end"):
|
||||
fill_card_slots(3)
|
||||
selection_state = CARDS
|
||||
|
||||
if has_stage:
|
||||
if !_input_locked:
|
||||
if event.is_action_pressed("ui_up") or event.is_action_pressed("ui_left") or event.is_action_pressed("ui_focus_next"):
|
||||
curr_selection_id -= 1
|
||||
elif event.is_action_pressed("ui_down") or event.is_action_pressed("ui_right") or event.is_action_pressed("ui_focus_prev"):
|
||||
curr_selection_id += 1
|
||||
if event.is_action_pressed("ui_accept"):
|
||||
pick(curr_selection_id)
|
||||
elif event.is_action_pressed("skip"):
|
||||
##fixme: using skip causes a lot of invalid state
|
||||
return
|
||||
if selection_state == CARDS_SELECTED:
|
||||
transition()
|
||||
show_posts()
|
||||
elif selection_state == POSTS_SELECTED:
|
||||
transition()
|
||||
elif selection_state == TRANSITION:
|
||||
show_posts()
|
||||
if has_stage:
|
||||
if !_input_locked:
|
||||
if event.is_action_pressed("ui_up") or event.is_action_pressed("ui_left") or event.is_action_pressed("ui_focus_next"):
|
||||
curr_selection_id -= 1
|
||||
elif event.is_action_pressed("ui_down") or event.is_action_pressed("ui_right") or event.is_action_pressed("ui_focus_prev"):
|
||||
curr_selection_id += 1
|
||||
if event.is_action_pressed("ui_accept"):
|
||||
pick(curr_selection_id)
|
||||
elif event.is_action_pressed("skip"):
|
||||
##fixme: using skip causes a lot of invalid state
|
||||
return
|
||||
if selection_state == CARDS_SELECTED:
|
||||
transition()
|
||||
show_posts()
|
||||
elif selection_state == POSTS_SELECTED:
|
||||
transition()
|
||||
elif selection_state == TRANSITION:
|
||||
show_posts()
|
||||
|
||||
|
||||
func pick(id: int):
|
||||
print("PICK")
|
||||
if id == -1:
|
||||
curr_selection_id = 0
|
||||
return
|
||||
print("PICK")
|
||||
if id == -1:
|
||||
curr_selection_id = 0
|
||||
return
|
||||
|
||||
if selection_state == CARDS:
|
||||
selection_state = CARDS_SELECTED
|
||||
elif selection_state == POSTS:
|
||||
selection_state = POSTS_SELECTED
|
||||
if selection_state == CARDS:
|
||||
selection_state = CARDS_SELECTED
|
||||
elif selection_state == POSTS:
|
||||
selection_state = POSTS_SELECTED
|
||||
|
||||
anim_players[id].play("pick")
|
||||
var yield_to = anim_players[id].animation_finished
|
||||
output.append(options[id])
|
||||
anim_players[id].play("pick")
|
||||
var yield_to = anim_players[id].animation_finished
|
||||
output.append(options[id])
|
||||
|
||||
options.remove_at(id)
|
||||
anim_players.remove_at(id)
|
||||
options.remove_at(id)
|
||||
anim_players.remove_at(id)
|
||||
|
||||
var sibling_id = -1
|
||||
if selection_state == POSTS_SELECTED:
|
||||
sibling_id = options.find(output.back().sibling)
|
||||
options.remove_at(sibling_id)
|
||||
anim_players[sibling_id].play("unshuffle")
|
||||
anim_players.remove_at(sibling_id)
|
||||
print("yeet sibling ", sibling_id)
|
||||
var sibling_id = -1
|
||||
if selection_state == POSTS_SELECTED:
|
||||
sibling_id = options.find(output.back().sibling)
|
||||
options.remove_at(sibling_id)
|
||||
anim_players[sibling_id].play("unshuffle")
|
||||
anim_players.remove_at(sibling_id)
|
||||
print("yeet sibling ", sibling_id)
|
||||
|
||||
var winning_id
|
||||
print(options[1].text)
|
||||
if !(options[1].text == "" and not id == 1):
|
||||
randomize()
|
||||
winning_id = randi() % options.size()
|
||||
var winning_id
|
||||
print(options[1].text)
|
||||
if !(options[1].text == "" and not id == 1):
|
||||
randomize()
|
||||
winning_id = randi() % options.size()
|
||||
|
||||
print("Winning ID ", id)
|
||||
print("Winning ID ", id)
|
||||
|
||||
elif options[0].text == "":
|
||||
winning_id = 1
|
||||
else:
|
||||
winning_id = 0
|
||||
else:
|
||||
Steam.setAchievement("FIGHT_BACK")
|
||||
Steam.storeStats()
|
||||
|
||||
output.append(options.pop_at(winning_id))
|
||||
anim_players.pop_at(winning_id).play("shuffle")
|
||||
output.append(options.pop_at(winning_id))
|
||||
anim_players.pop_at(winning_id).play("shuffle")
|
||||
|
||||
for anim in anim_players:
|
||||
anim.play("unshuffle")
|
||||
for anim in anim_players:
|
||||
anim.play("unshuffle")
|
||||
|
||||
await yield_to
|
||||
transition()
|
||||
await yield_to
|
||||
transition()
|
||||
|
||||
func transition():
|
||||
if selection_state == CARDS_SELECTED:
|
||||
selection_state = TRANSITION
|
||||
options = []
|
||||
anim_players = []
|
||||
for control in $sticky_notes.get_children():
|
||||
options.append(control.get_child(1))
|
||||
anim_players.append(control.get_child(0))
|
||||
control.get_child(0).play("post")
|
||||
curr_selection_id = -1
|
||||
if selection_state == CARDS_SELECTED:
|
||||
selection_state = TRANSITION
|
||||
options = []
|
||||
anim_players = []
|
||||
for control in $sticky_notes.get_children():
|
||||
options.append(control.get_child(1))
|
||||
anim_players.append(control.get_child(0))
|
||||
control.get_child(0).play("post")
|
||||
curr_selection_id = -1
|
||||
|
||||
fill_post_slots()
|
||||
fill_post_slots()
|
||||
|
||||
await anim_players[0].animation_finished
|
||||
show_posts()
|
||||
elif selection_state == POSTS_SELECTED:
|
||||
var out_str:Array[String] = []
|
||||
for card in output:
|
||||
out_str.append(card.name)
|
||||
emit_signal("cards_picked", out_str)
|
||||
print(out_str)
|
||||
selection_state = DONE
|
||||
State.leave_stage(self)
|
||||
await anim_players[0].animation_finished
|
||||
show_posts()
|
||||
elif selection_state == POSTS_SELECTED:
|
||||
var out_str:Array[String] = []
|
||||
for card in output:
|
||||
out_str.append(card.name)
|
||||
emit_signal("cards_picked", out_str)
|
||||
print(out_str)
|
||||
selection_state = DONE
|
||||
State.leave_stage(self)
|
||||
|
||||
func show_posts():
|
||||
selection_state = POSTS
|
||||
for player:AnimationPlayer in anim_players:
|
||||
player.play("reset")
|
||||
selection_state = POSTS
|
||||
for player:AnimationPlayer in anim_players:
|
||||
player.play("reset")
|
||||
|
||||
|
||||
func handle_hover(new_highlight):
|
||||
if not _input_locked:
|
||||
curr_selection_id = options.find(new_highlight)
|
||||
if not _input_locked:
|
||||
curr_selection_id = options.find(new_highlight)
|
||||
|
||||
func handle_mouse_button(new_selection: Node, button_event: InputEventMouseButton):
|
||||
if not _input_locked:
|
||||
if button_event.button_index == MOUSE_BUTTON_LEFT and button_event.pressed:
|
||||
pick(options.find(new_selection))
|
||||
if not _input_locked:
|
||||
if button_event.button_index == MOUSE_BUTTON_LEFT and button_event.pressed:
|
||||
pick(options.find(new_selection))
|
||||
|
||||
func scene_finished(id: int, repeat):
|
||||
print(name, id, repeat)
|
||||
if not repeat:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
fill_card_slots(id)
|
||||
State.transition_stage_to(self, true)
|
||||
selection_state = CARDS
|
||||
print(name, id, repeat)
|
||||
if not repeat:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
fill_card_slots(id)
|
||||
State.transition_stage_to(self, true)
|
||||
selection_state = CARDS
|
||||
|
||||
func play_scene(_id, _repeat):
|
||||
pass
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -16,151 +16,151 @@ var last_mouse_pos2D = null
|
|||
|
||||
|
||||
func _ready():
|
||||
node_area.connect("mouse_entered", Callable(self, "_mouse_entered_area"))
|
||||
node_area.connect("mouse_entered", Callable(self, "_mouse_entered_area"))
|
||||
|
||||
# If the material is NOT set to use billboard settings, then avoid running billboard specific code
|
||||
if billboard == 0:
|
||||
set_process(false)
|
||||
# If the material is NOT set to use billboard settings, then avoid running billboard specific code
|
||||
if billboard == 0:
|
||||
set_process(false)
|
||||
|
||||
|
||||
func _process(_delta):
|
||||
# NOTE: Remove this function if you don't plan on using billboard settings.
|
||||
rotate_area_to_billboard()
|
||||
# NOTE: Remove this function if you don't plan on using billboard settings.
|
||||
rotate_area_to_billboard()
|
||||
|
||||
|
||||
func _mouse_entered_area():
|
||||
is_mouse_inside = true
|
||||
is_mouse_inside = true
|
||||
|
||||
|
||||
func _unhandled_input(event):
|
||||
# Check if the event is a non-mouse/non-touch event
|
||||
var is_mouse_event = false
|
||||
for mouse_event in [InputEventMouseButton, InputEventMouseMotion, InputEventScreenDrag, InputEventScreenTouch]:
|
||||
if event is InputEventMouse:
|
||||
is_mouse_event = true
|
||||
break
|
||||
# Check if the event is a non-mouse/non-touch event
|
||||
var is_mouse_event = false
|
||||
for mouse_event in [InputEventMouseButton, InputEventMouseMotion, InputEventScreenDrag, InputEventScreenTouch]:
|
||||
if event is InputEventMouse:
|
||||
is_mouse_event = true
|
||||
break
|
||||
|
||||
# If the event is a mouse/touch event and/or the mouse is either held or inside the area, then
|
||||
# we need to do some additional processing in the handle_mouse function before passing the event to the viewport.
|
||||
# If the event is not a mouse/touch event, then we can just pass the event directly to the viewport.
|
||||
if is_mouse_event and (is_mouse_inside or is_mouse_held):
|
||||
handle_mouse(event)
|
||||
elif not is_mouse_event:
|
||||
node_viewport.push_input(event)
|
||||
# If the event is a mouse/touch event and/or the mouse is either held or inside the area, then
|
||||
# we need to do some additional processing in the handle_mouse function before passing the event to the viewport.
|
||||
# If the event is not a mouse/touch event, then we can just pass the event directly to the viewport.
|
||||
if is_mouse_event and (is_mouse_inside or is_mouse_held):
|
||||
handle_mouse(event)
|
||||
elif not is_mouse_event:
|
||||
node_viewport.push_input(event)
|
||||
|
||||
|
||||
# Handle mouse events inside Area. (Area.input_event had many issues with dragging)
|
||||
func handle_mouse(event):
|
||||
# Get mesh size to detect edges and make conversions. This code only support PlaneMesh and QuadMesh.
|
||||
render_size = pixel_size * node_viewport.size
|
||||
# Get mesh size to detect edges and make conversions. This code only support PlaneMesh and QuadMesh.
|
||||
render_size = pixel_size * node_viewport.size
|
||||
|
||||
# Detect mouse being held to mantain event while outside of bounds. Avoid orphan clicks
|
||||
if event is InputEventMouseButton or event is InputEventScreenTouch:
|
||||
is_mouse_held = event.pressed
|
||||
# Detect mouse being held to mantain event while outside of bounds. Avoid orphan clicks
|
||||
if event is InputEventMouseButton or event is InputEventScreenTouch:
|
||||
is_mouse_held = event.pressed
|
||||
|
||||
# Find mouse position in Area
|
||||
var mouse_pos3D = find_mouse(event.global_position)
|
||||
# Find mouse position in Area
|
||||
var mouse_pos3D = find_mouse(event.global_position)
|
||||
|
||||
# Check if the mouse is outside of bounds, use last position to avoid errors
|
||||
# NOTE: mouse_exited signal was unrealiable in this situation
|
||||
is_mouse_inside = mouse_pos3D != null
|
||||
if is_mouse_inside:
|
||||
# Convert click_pos from world coordinate space to a coordinate space relative to the Area node.
|
||||
# NOTE: affine_inverse accounts for the Area node's scale, rotation, and translation in the scene!
|
||||
mouse_pos3D = node_area.global_transform.affine_inverse() * mouse_pos3D
|
||||
last_mouse_pos3D = mouse_pos3D
|
||||
else:
|
||||
mouse_pos3D = last_mouse_pos3D
|
||||
if mouse_pos3D == null:
|
||||
mouse_pos3D = Vector3.ZERO
|
||||
# Check if the mouse is outside of bounds, use last position to avoid errors
|
||||
# NOTE: mouse_exited signal was unrealiable in this situation
|
||||
is_mouse_inside = mouse_pos3D != null
|
||||
if is_mouse_inside:
|
||||
# Convert click_pos from world coordinate space to a coordinate space relative to the Area node.
|
||||
# NOTE: affine_inverse accounts for the Area node's scale, rotation, and translation in the scene!
|
||||
mouse_pos3D = node_area.global_transform.affine_inverse() * mouse_pos3D
|
||||
last_mouse_pos3D = mouse_pos3D
|
||||
else:
|
||||
mouse_pos3D = last_mouse_pos3D
|
||||
if mouse_pos3D == null:
|
||||
mouse_pos3D = Vector3.ZERO
|
||||
|
||||
# TODO: adapt to bilboard mode or avoid completely
|
||||
# TODO: adapt to bilboard mode or avoid completely
|
||||
|
||||
# convert the relative event position from 3D to 2D
|
||||
var mouse_pos2D = Vector2(mouse_pos3D.x, -mouse_pos3D.y)
|
||||
# convert the relative event position from 3D to 2D
|
||||
var mouse_pos2D = Vector2(mouse_pos3D.x, -mouse_pos3D.y)
|
||||
|
||||
# Right now the event position's range is the following: (-quad_size/2) -> (quad_size/2)
|
||||
# We need to convert it into the following range: 0 -> quad_size
|
||||
mouse_pos2D += render_size / 2
|
||||
# Then we need to convert it into the following range: 0 -> 1
|
||||
mouse_pos2D = mouse_pos2D / render_size.x
|
||||
# Right now the event position's range is the following: (-quad_size/2) -> (quad_size/2)
|
||||
# We need to convert it into the following range: 0 -> quad_size
|
||||
mouse_pos2D += render_size / 2
|
||||
# Then we need to convert it into the following range: 0 -> 1
|
||||
mouse_pos2D = mouse_pos2D / render_size.x
|
||||
|
||||
# Finally, we convert the position to the following range: 0 -> viewport.size
|
||||
mouse_pos2D.x = mouse_pos2D.x * node_viewport.size.x
|
||||
mouse_pos2D.y = mouse_pos2D.y * node_viewport.size.y
|
||||
# We need to do these conversions so the event's position is in the viewport's coordinate system.
|
||||
# Finally, we convert the position to the following range: 0 -> viewport.size
|
||||
mouse_pos2D.x = mouse_pos2D.x * node_viewport.size.x
|
||||
mouse_pos2D.y = mouse_pos2D.y * node_viewport.size.y
|
||||
# We need to do these conversions so the event's position is in the viewport's coordinate system.
|
||||
|
||||
# Set the event's position and global position.
|
||||
event.position = mouse_pos2D
|
||||
event.global_position = mouse_pos2D
|
||||
# Set the event's position and global position.
|
||||
event.position = mouse_pos2D
|
||||
event.global_position = mouse_pos2D
|
||||
|
||||
# If the event is a mouse motion event...
|
||||
if event is InputEventMouseMotion:
|
||||
# If there is not a stored previous position, then we'll assume there is no relative motion.
|
||||
if last_mouse_pos2D == null:
|
||||
event.relative = Vector2(0, 0)
|
||||
# If there is a stored previous position, then we'll calculate the relative position by subtracting
|
||||
# the previous position from the new position. This will give us the distance the event traveled from prev_pos
|
||||
else:
|
||||
event.relative = mouse_pos2D - last_mouse_pos2D
|
||||
# Update last_mouse_pos2D with the position we just calculated.
|
||||
last_mouse_pos2D = mouse_pos2D
|
||||
# If the event is a mouse motion event...
|
||||
if event is InputEventMouseMotion:
|
||||
# If there is not a stored previous position, then we'll assume there is no relative motion.
|
||||
if last_mouse_pos2D == null:
|
||||
event.relative = Vector2(0, 0)
|
||||
# If there is a stored previous position, then we'll calculate the relative position by subtracting
|
||||
# the previous position from the new position. This will give us the distance the event traveled from prev_pos
|
||||
else:
|
||||
event.relative = mouse_pos2D - last_mouse_pos2D
|
||||
# Update last_mouse_pos2D with the position we just calculated.
|
||||
last_mouse_pos2D = mouse_pos2D
|
||||
|
||||
# Finally, send the processed input event to the viewport.
|
||||
node_viewport.push_input(event)
|
||||
# Finally, send the processed input event to the viewport.
|
||||
node_viewport.push_input(event)
|
||||
|
||||
|
||||
func find_mouse(global_position):
|
||||
var camera = get_viewport().get_camera_3d()
|
||||
var camera = get_viewport().get_camera_3d()
|
||||
|
||||
# From camera center to the mouse position in the Area
|
||||
var from = camera.project_ray_origin(global_position)
|
||||
var dist = find_further_distance_to(camera.transform.origin)
|
||||
var to = from + camera.project_ray_normal(global_position) * dist
|
||||
# From camera center to the mouse position in the Area
|
||||
var from = camera.project_ray_origin(global_position)
|
||||
var dist = find_further_distance_to(camera.transform.origin)
|
||||
var to = from + camera.project_ray_normal(global_position) * dist
|
||||
|
||||
|
||||
# Manually raycasts the are to find the mouse position
|
||||
var result = get_world_3d().direct_space_state.intersect_ray(PhysicsRayQueryParameters3D.create(from, to, node_area.collision_layer)) #for 3.1 changes
|
||||
# Manually raycasts the are to find the mouse position
|
||||
var result = get_world_3d().direct_space_state.intersect_ray(PhysicsRayQueryParameters3D.create(from, to, node_area.collision_layer)) #for 3.1 changes
|
||||
|
||||
if result.size() > 0:
|
||||
return result.position
|
||||
else:
|
||||
return null
|
||||
if result.size() > 0:
|
||||
return result.position
|
||||
else:
|
||||
return null
|
||||
|
||||
|
||||
func find_further_distance_to(origin):
|
||||
# Find edges of collision and change to global positions
|
||||
var edges = []
|
||||
edges.append(node_area.to_global(Vector3(render_size.x / 2, render_size.y / 2, 0)))
|
||||
edges.append(node_area.to_global(Vector3(render_size.x / 2, -render_size.y / 2, 0)))
|
||||
edges.append(node_area.to_global(Vector3(-render_size.x / 2, render_size.y / 2, 0)))
|
||||
edges.append(node_area.to_global(Vector3(-render_size.x / 2, -render_size.y / 2, 0)))
|
||||
# Find edges of collision and change to global positions
|
||||
var edges = []
|
||||
edges.append(node_area.to_global(Vector3(render_size.x / 2, render_size.y / 2, 0)))
|
||||
edges.append(node_area.to_global(Vector3(render_size.x / 2, -render_size.y / 2, 0)))
|
||||
edges.append(node_area.to_global(Vector3(-render_size.x / 2, render_size.y / 2, 0)))
|
||||
edges.append(node_area.to_global(Vector3(-render_size.x / 2, -render_size.y / 2, 0)))
|
||||
|
||||
# Get the furthest distance between the camera and collision to avoid raycasting too far or too short
|
||||
var far_dist = 0
|
||||
var temp_dist
|
||||
for edge in edges:
|
||||
temp_dist = origin.distance_to(edge)
|
||||
if temp_dist > far_dist:
|
||||
far_dist = temp_dist
|
||||
# Get the furthest distance between the camera and collision to avoid raycasting too far or too short
|
||||
var far_dist = 0
|
||||
var temp_dist
|
||||
for edge in edges:
|
||||
temp_dist = origin.distance_to(edge)
|
||||
if temp_dist > far_dist:
|
||||
far_dist = temp_dist
|
||||
|
||||
return far_dist
|
||||
return far_dist
|
||||
|
||||
|
||||
func rotate_area_to_billboard():
|
||||
# Try to match the area with the material's billboard setting, if enabled
|
||||
if billboard > 0:
|
||||
# Get the camera
|
||||
var camera = get_viewport().get_camera_3d()
|
||||
# Look in the same direction as the camera
|
||||
var look = camera.to_global(Vector3(0, 0, -100)) - camera.global_transform.origin
|
||||
look = node_area.position + look
|
||||
# Try to match the area with the material's billboard setting, if enabled
|
||||
if billboard > 0:
|
||||
# Get the camera
|
||||
var camera = get_viewport().get_camera_3d()
|
||||
# Look in the same direction as the camera
|
||||
var look = camera.to_global(Vector3(0, 0, -100)) - camera.global_transform.origin
|
||||
look = node_area.position + look
|
||||
|
||||
# Y-Billboard: Lock Y rotation, but gives bad results if the camera is tilted.
|
||||
if billboard == 2:
|
||||
look = Vector3(look.x, 0, look.z)
|
||||
# Y-Billboard: Lock Y rotation, but gives bad results if the camera is tilted.
|
||||
if billboard == 2:
|
||||
look = Vector3(look.x, 0, look.z)
|
||||
|
||||
node_area.look_at(look, Vector3.UP)
|
||||
node_area.look_at(look, Vector3.UP)
|
||||
|
||||
# Rotate in the Z axis to compensate camera tilt
|
||||
node_area.rotate_object_local(Vector3.BACK, camera.rotation.z)
|
||||
# Rotate in the Z axis to compensate camera tilt
|
||||
node_area.rotate_object_local(Vector3.BACK, camera.rotation.z)
|
||||
|
|
|
|||
|
|
@ -5,73 +5,73 @@ class_name Collectable_Ui
|
|||
@export var scene = Scenes.id
|
||||
|
||||
@export var collapsed = true:
|
||||
set(collapse):
|
||||
if is_inside_tree() and not Engine.is_editor_hint():
|
||||
if State.reduce_motion:
|
||||
collapsed = false
|
||||
return
|
||||
if collapse and not collapsed:
|
||||
if is_inside_tree():
|
||||
_hide_buttons()
|
||||
collapsed = collapse
|
||||
elif not collapse and collapsed:
|
||||
if is_inside_tree():
|
||||
_show_buttons()
|
||||
collapsed = collapse
|
||||
set(collapse):
|
||||
if is_inside_tree() and not Engine.is_editor_hint():
|
||||
if State.reduce_motion:
|
||||
collapsed = false
|
||||
return
|
||||
if collapse and not collapsed:
|
||||
if is_inside_tree():
|
||||
_hide_buttons()
|
||||
collapsed = collapse
|
||||
elif not collapse and collapsed:
|
||||
if is_inside_tree():
|
||||
_show_buttons()
|
||||
collapsed = collapse
|
||||
|
||||
if collapse and has_stage: State.leave_stage(self)
|
||||
if collapse and has_stage: State.leave_stage(self)
|
||||
|
||||
@export var is_story: bool = false:
|
||||
set(story):
|
||||
is_story = story
|
||||
if not story:
|
||||
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.text = "Order Thoughts"
|
||||
else:
|
||||
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.text = "Collect Memento"
|
||||
set(story):
|
||||
is_story = story
|
||||
if not story:
|
||||
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.text = "Order Thoughts"
|
||||
else:
|
||||
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.text = "Collect Memento"
|
||||
@export var has_stage: bool = false:
|
||||
set(focused):
|
||||
print("set focus of card to ", focused)
|
||||
set(focused):
|
||||
print("set focus of card to ", focused)
|
||||
|
||||
if has_stage == focused: return
|
||||
if has_stage == focused: return
|
||||
|
||||
if focused:
|
||||
has_stage = true
|
||||
collapsed = false
|
||||
if not visible: show()
|
||||
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.grab_focus()
|
||||
elif has_stage:
|
||||
has_stage = false
|
||||
get_viewport().gui_release_focus()
|
||||
if focused:
|
||||
has_stage = true
|
||||
collapsed = false
|
||||
if not visible: show()
|
||||
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.grab_focus()
|
||||
elif has_stage:
|
||||
has_stage = false
|
||||
get_viewport().gui_release_focus()
|
||||
|
||||
@export var collected: bool = false:
|
||||
set(set_collected):
|
||||
collected = set_collected
|
||||
if set_collected:
|
||||
$Panel/Content/Buttons/VBoxContainer/put_back.show()
|
||||
if is_story:
|
||||
$Panel/Content/Buttons/VBoxContainer/put_back.disabled = true
|
||||
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.text = "listen again"
|
||||
if State.allow_skipping:
|
||||
$Panel/Content/Buttons/VBoxContainer/skip.text = "discard cards (skip)"
|
||||
else:
|
||||
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.disabled = true
|
||||
$Panel/Content/Buttons/VBoxContainer/put_back.show()
|
||||
else:
|
||||
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.disabled = false
|
||||
set(set_collected):
|
||||
collected = set_collected
|
||||
if set_collected:
|
||||
$Panel/Content/Buttons/VBoxContainer/put_back.show()
|
||||
if is_story:
|
||||
$Panel/Content/Buttons/VBoxContainer/put_back.disabled = true
|
||||
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.text = "listen again"
|
||||
if State.allow_skipping:
|
||||
$Panel/Content/Buttons/VBoxContainer/skip.text = "discard cards (skip)"
|
||||
else:
|
||||
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.disabled = true
|
||||
$Panel/Content/Buttons/VBoxContainer/put_back.show()
|
||||
else:
|
||||
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.disabled = false
|
||||
|
||||
@export var skipped: bool = false
|
||||
|
||||
@export var item_name: String = "":
|
||||
set(new_name):
|
||||
item_name = new_name
|
||||
if is_inside_tree():
|
||||
$Panel/Content/Name.text = new_name
|
||||
set(new_name):
|
||||
item_name = new_name
|
||||
if is_inside_tree():
|
||||
$Panel/Content/Name.text = new_name
|
||||
|
||||
@export var content_notes: String = "":
|
||||
set(new_notes):
|
||||
content_notes = new_notes
|
||||
if is_inside_tree():
|
||||
$Panel/Content/ContentNotes.text = new_notes
|
||||
set(new_notes):
|
||||
content_notes = new_notes
|
||||
if is_inside_tree():
|
||||
$Panel/Content/ContentNotes.text = new_notes
|
||||
|
||||
signal card_collected
|
||||
signal open_board
|
||||
|
|
@ -79,70 +79,70 @@ signal scene_skipped(i: int)
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
#$Panel/Content/ContentNotes.visible = State.show_content_notes
|
||||
#$Panel/Content/Buttons/VBoxContainer/Summary.visible = State.provide_summaries
|
||||
#$Panel/Content/Buttons/VBoxContainer/skip.visible = State.allow_skipping
|
||||
if visible and not collapsed: _show_buttons()
|
||||
#$Panel/Content/ContentNotes.visible = State.show_content_notes
|
||||
#$Panel/Content/Buttons/VBoxContainer/Summary.visible = State.provide_summaries
|
||||
#$Panel/Content/Buttons/VBoxContainer/skip.visible = State.allow_skipping
|
||||
if visible and not collapsed: _show_buttons()
|
||||
|
||||
content_notes = content_notes
|
||||
is_story = is_story
|
||||
item_name = item_name
|
||||
content_notes = content_notes
|
||||
is_story = is_story
|
||||
item_name = item_name
|
||||
|
||||
func _hide_buttons():
|
||||
if is_inside_tree():
|
||||
if not State.reduce_motion:
|
||||
$AnimationPlayer.play_backwards("show_buttons")
|
||||
if is_inside_tree():
|
||||
if not State.reduce_motion:
|
||||
$AnimationPlayer.play_backwards("show_buttons")
|
||||
|
||||
func _show_buttons():
|
||||
if is_inside_tree():
|
||||
if not State.reduce_motion:
|
||||
$AnimationPlayer.play("show_buttons")
|
||||
else:
|
||||
$AnimationPlayer.play("RESET")
|
||||
else:
|
||||
$AnimationPlayer.play("RESET")
|
||||
if is_inside_tree():
|
||||
if not State.reduce_motion:
|
||||
$AnimationPlayer.play("show_buttons")
|
||||
else:
|
||||
$AnimationPlayer.play("RESET")
|
||||
else:
|
||||
$AnimationPlayer.play("RESET")
|
||||
|
||||
func hide():
|
||||
if visible:
|
||||
var tween = create_tween()
|
||||
tween.tween_property(self, "modulate", Color(0, 0, 0), 0.4)
|
||||
if not collapsed: _hide_buttons()
|
||||
await tween.finished
|
||||
visible = false
|
||||
if has_stage: State.leave_stage(self)
|
||||
if visible:
|
||||
var tween = create_tween()
|
||||
tween.tween_property(self, "modulate", Color(0, 0, 0), 0.4)
|
||||
if not collapsed: _hide_buttons()
|
||||
await tween.finished
|
||||
visible = false
|
||||
if has_stage: State.leave_stage(self)
|
||||
|
||||
func show():
|
||||
if !visible:
|
||||
$Panel/Content/ContentNotes.visible = State.show_content_notes
|
||||
$Panel/Content/Buttons/VBoxContainer/skip.visible = State.allow_skipping and is_story and not skipped
|
||||
if not collapsed:
|
||||
_show_buttons()
|
||||
modulate = Color()
|
||||
visible = true
|
||||
var tween = create_tween()
|
||||
tween.tween_property(self, "modulate", Color(1, 1, 1), 0.4)
|
||||
if !visible:
|
||||
$Panel/Content/ContentNotes.visible = State.show_content_notes
|
||||
$Panel/Content/Buttons/VBoxContainer/skip.visible = State.allow_skipping and is_story and not skipped
|
||||
if not collapsed:
|
||||
_show_buttons()
|
||||
modulate = Color()
|
||||
visible = true
|
||||
var tween = create_tween()
|
||||
tween.tween_property(self, "modulate", Color(1, 1, 1), 0.4)
|
||||
|
||||
func _yoink_focus():
|
||||
if not has_stage:
|
||||
State.transition_stage_to(self)
|
||||
if not has_stage:
|
||||
State.transition_stage_to(self)
|
||||
|
||||
func _on_pick_button_pressed():
|
||||
print("card collected!")
|
||||
if scene != null:
|
||||
State.leave_stage(self)
|
||||
get_tree().call_group("animation_player", "play_scene", scene, collected)
|
||||
if skipped: emit_signal("scene_skipped", -1)
|
||||
collected = true
|
||||
else:
|
||||
emit_signal("open_board")
|
||||
hide()
|
||||
print("card collected!")
|
||||
if scene != null:
|
||||
State.leave_stage(self)
|
||||
get_tree().call_group("animation_player", "play_scene", scene, collected)
|
||||
if skipped: emit_signal("scene_skipped", -1)
|
||||
collected = true
|
||||
else:
|
||||
emit_signal("open_board")
|
||||
hide()
|
||||
|
||||
|
||||
func _on_skip_pressed():
|
||||
print("Scene skipped!")
|
||||
if scene != null:
|
||||
emit_signal("scene_skipped", 1)
|
||||
skipped = true
|
||||
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.text = "collect (un-skip)"
|
||||
print("Scene skipped!")
|
||||
if scene != null:
|
||||
emit_signal("scene_skipped", 1)
|
||||
skipped = true
|
||||
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.text = "collect (un-skip)"
|
||||
|
||||
State.leave_stage(self)
|
||||
State.leave_stage(self)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
extends Panel
|
||||
|
||||
@onready var has_stage = true:
|
||||
set(focus):
|
||||
if focus:
|
||||
has_stage = State.request_focus(self)
|
||||
else:
|
||||
has_stage = false
|
||||
State.drop_own_focus(self)
|
||||
set(focus):
|
||||
if focus:
|
||||
has_stage = State.request_focus(self)
|
||||
else:
|
||||
has_stage = false
|
||||
State.drop_own_focus(self)
|
||||
|
||||
func _ready():
|
||||
theme = State.current_main_theme
|
||||
State.theme_changed.connect(func change_theme(new_theme): theme = new_theme)
|
||||
theme = State.current_main_theme
|
||||
State.theme_changed.connect(func change_theme(new_theme): theme = new_theme)
|
||||
|
|
|
|||
|
|
@ -9,38 +9,38 @@ var time_pressed: float = 0
|
|||
var pressed: bool
|
||||
|
||||
func _ready():
|
||||
owner = get_node(costum_owner)
|
||||
owner = get_node(costum_owner)
|
||||
|
||||
if owner == null:
|
||||
owner = get_parent().get_parent()
|
||||
if owner == null:
|
||||
owner = get_parent().get_parent()
|
||||
|
||||
owner.connect("visibility_changed", Callable(self, "owner_visibility_changed"))
|
||||
visible = owner.visible
|
||||
owner.connect("visibility_changed", Callable(self, "owner_visibility_changed"))
|
||||
visible = owner.visible
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
if pressed and visible:
|
||||
time_pressed += delta
|
||||
progress.value = time_pressed / skip_delay
|
||||
if time_pressed >= skip_delay:
|
||||
emit_signal("skip")
|
||||
pressed = false
|
||||
time_pressed = 0
|
||||
if pressed and visible:
|
||||
time_pressed += delta
|
||||
progress.value = time_pressed / skip_delay
|
||||
if time_pressed >= skip_delay:
|
||||
emit_signal("skip")
|
||||
pressed = false
|
||||
time_pressed = 0
|
||||
|
||||
func _input(event):
|
||||
if visible:
|
||||
if event.is_action_pressed("skip"):
|
||||
pressed = true
|
||||
elif event.is_action_released("skip"):
|
||||
pressed = false
|
||||
time_pressed = 0
|
||||
if visible:
|
||||
if event.is_action_pressed("skip"):
|
||||
pressed = true
|
||||
elif event.is_action_released("skip"):
|
||||
pressed = false
|
||||
time_pressed = 0
|
||||
|
||||
func owner_visibility_changed():
|
||||
visible = owner.visible
|
||||
visible = owner.visible
|
||||
|
||||
func _on_skip_button_toggled(button_pressed):
|
||||
if button_pressed:
|
||||
pressed = true
|
||||
else:
|
||||
pressed = false
|
||||
time_pressed = 0
|
||||
if button_pressed:
|
||||
pressed = true
|
||||
else:
|
||||
pressed = false
|
||||
time_pressed = 0
|
||||
|
|
|
|||
|
|
@ -1,31 +1,31 @@
|
|||
extends RigidBody3D
|
||||
|
||||
var has_stage: bool = false:
|
||||
set(on_stage):
|
||||
if has_stage != on_stage:
|
||||
if on_stage:
|
||||
has_stage = true
|
||||
if is_inside_tree():
|
||||
camera.make_current()
|
||||
get_viewport().gui_release_focus()
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
var jitter_tween: Tween = create_tween()
|
||||
jitter_tween.tween_property(self, "jitter_strength", 1, 1)
|
||||
if has_entered: emit_signal("ui_exited")
|
||||
elif has_stage:
|
||||
camera.current = true
|
||||
jitter_strength = 1
|
||||
else:
|
||||
if is_inside_tree() and has_stage:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
var jitter_tween: Tween = create_tween()
|
||||
jitter_tween.tween_property(self, "jitter_strength", 0, 0.5)
|
||||
if has_entered: emit_signal("ui_exited")
|
||||
else:
|
||||
jitter_strength = 0
|
||||
has_stage = false
|
||||
set(on_stage):
|
||||
if has_stage != on_stage:
|
||||
if on_stage:
|
||||
has_stage = true
|
||||
if is_inside_tree():
|
||||
camera.make_current()
|
||||
get_viewport().gui_release_focus()
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
var jitter_tween: Tween = create_tween()
|
||||
jitter_tween.tween_property(self, "jitter_strength", 1, 1)
|
||||
if has_entered: emit_signal("ui_exited")
|
||||
elif has_stage:
|
||||
camera.current = true
|
||||
jitter_strength = 1
|
||||
else:
|
||||
if is_inside_tree() and has_stage:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
var jitter_tween: Tween = create_tween()
|
||||
jitter_tween.tween_property(self, "jitter_strength", 0, 0.5)
|
||||
if has_entered: emit_signal("ui_exited")
|
||||
else:
|
||||
jitter_strength = 0
|
||||
has_stage = false
|
||||
|
||||
sleeping = has_stage
|
||||
sleeping = has_stage
|
||||
|
||||
@export_range (0, 10) var max_speed: float = 3
|
||||
@export_range (0, 10) var max_acceleration: float = 5
|
||||
|
|
@ -59,157 +59,157 @@ var on_crouch_cooldown:bool = false
|
|||
@onready var focus_ray: RayCast3D = $Yaw/Pitch/Mount/Camera3D/RayCast3D
|
||||
|
||||
var zoomed:
|
||||
set(zoom):
|
||||
if zoomed != zoom:
|
||||
if zoom:
|
||||
var zoom_tween = create_tween()
|
||||
zoom_tween.tween_property(camera, "fov", camera.fov*0.5, 0.5)
|
||||
else:
|
||||
var zoom_tween = create_tween()
|
||||
zoom_tween.tween_property(camera, "fov", camera.fov*2, 0.5)
|
||||
zoomed = zoom
|
||||
set(zoom):
|
||||
if zoomed != zoom:
|
||||
if zoom:
|
||||
var zoom_tween = create_tween()
|
||||
zoom_tween.tween_property(camera, "fov", camera.fov*0.5, 0.5)
|
||||
else:
|
||||
var zoom_tween = create_tween()
|
||||
zoom_tween.tween_property(camera, "fov", camera.fov*2, 0.5)
|
||||
zoomed = zoom
|
||||
signal ui_entered
|
||||
var has_entered:bool = false
|
||||
signal ui_exited
|
||||
|
||||
func _ready():
|
||||
_handle_jitter(0)
|
||||
_handle_jitter(0)
|
||||
|
||||
func _on_ini_room():
|
||||
State.take_stage(self)
|
||||
get_tree().call_group("animation_player", "play_scene", Scenes.id.YOUTH_DRAEVEN, false)
|
||||
State.queue_for_stage(self)
|
||||
State.take_stage(self)
|
||||
get_tree().call_group("animation_player", "play_scene", Scenes.id.YOUTH_DRAEVEN, false)
|
||||
State.queue_for_stage(self)
|
||||
|
||||
func _process(_delta):
|
||||
|
||||
if focus_ray.get_collider() != null and not has_entered:
|
||||
emit_signal("ui_entered")
|
||||
has_entered = true
|
||||
focus_ray.get_collider().reveal()
|
||||
if focus_ray.get_collider() != null and not has_entered:
|
||||
emit_signal("ui_entered")
|
||||
has_entered = true
|
||||
focus_ray.get_collider().reveal()
|
||||
|
||||
if has_stage:
|
||||
if has_entered:
|
||||
if focus_ray.get_collider() == null:
|
||||
emit_signal("ui_exited")
|
||||
has_entered = false
|
||||
if Input.is_action_just_pressed("ui_accept"):
|
||||
State.pass_stage_to(focus_ray.get_collider())
|
||||
else:
|
||||
if Input.is_action_just_pressed("zoom_in_controller"):
|
||||
zoomed = true
|
||||
elif Input.is_action_just_released("zoom_in_controller"):
|
||||
zoomed = false
|
||||
if has_stage:
|
||||
if has_entered:
|
||||
if focus_ray.get_collider() == null:
|
||||
emit_signal("ui_exited")
|
||||
has_entered = false
|
||||
if Input.is_action_just_pressed("ui_accept"):
|
||||
State.pass_stage_to(focus_ray.get_collider())
|
||||
else:
|
||||
if Input.is_action_just_pressed("zoom_in_controller"):
|
||||
zoomed = true
|
||||
elif Input.is_action_just_released("zoom_in_controller"):
|
||||
zoomed = false
|
||||
|
||||
func _physics_process(delta:float):
|
||||
if has_stage:
|
||||
_handle_movement(delta)
|
||||
_handle_rotation(delta)
|
||||
if jitter_strength > 0 and not State.reduce_motion: _handle_jitter(delta)
|
||||
if has_stage:
|
||||
_handle_movement(delta)
|
||||
_handle_rotation(delta)
|
||||
if jitter_strength > 0 and not State.reduce_motion: _handle_jitter(delta)
|
||||
|
||||
func _handle_movement(delta:float):
|
||||
var input:Vector2 = Vector2(Input.get_action_strength("player_right") - Input.get_action_strength("player_left"),
|
||||
Input.get_action_strength("player_backwards")*0.8 - Input.get_action_strength("player_forwards"))
|
||||
var input:Vector2 = Vector2(Input.get_action_strength("player_right") - Input.get_action_strength("player_left"),
|
||||
Input.get_action_strength("player_backwards")*0.8 - Input.get_action_strength("player_forwards"))
|
||||
|
||||
if input.length()>1:
|
||||
input = input.normalized()
|
||||
if input.length()>1:
|
||||
input = input.normalized()
|
||||
|
||||
var direction: Vector3 = Vector3(input.x, 0, input.y)
|
||||
var direction: Vector3 = Vector3(input.x, 0, input.y)
|
||||
|
||||
direction = yaw.global_transform.basis.x * direction.x + transform.basis.y * direction.y + yaw.global_transform.basis.z * direction.z
|
||||
direction = yaw.global_transform.basis.x * direction.x + transform.basis.y * direction.y + yaw.global_transform.basis.z * direction.z
|
||||
|
||||
if linear_velocity.length() > (linear_velocity + (direction*max_speed - linear_velocity)).length():
|
||||
direction = Vector3.ZERO
|
||||
else:
|
||||
direction *= (direction*max_speed - linear_velocity).length()*max_acceleration
|
||||
if linear_velocity.length() > (linear_velocity + (direction*max_speed - linear_velocity)).length():
|
||||
direction = Vector3.ZERO
|
||||
else:
|
||||
direction *= (direction*max_speed - linear_velocity).length()*max_acceleration
|
||||
|
||||
linear_damp = damp * max(0.5, 1 - input.length())
|
||||
linear_damp = damp * max(0.5, 1 - input.length())
|
||||
|
||||
apply_central_impulse(direction*delta)
|
||||
apply_central_impulse(direction*delta)
|
||||
|
||||
func _handle_rotation(delta:float):
|
||||
var smoothness = min(3, 60.0/Engine.get_frames_per_second())
|
||||
var smoothness = min(3, 60.0/Engine.get_frames_per_second())
|
||||
|
||||
var input_speed = Vector2( Input.get_action_strength("look_right")-Input.get_action_strength("look_left"), Input.get_action_strength("look_up")-Input.get_action_strength("look_down")) * gamepad_response
|
||||
var input_speed = Vector2( Input.get_action_strength("look_right")-Input.get_action_strength("look_left"), Input.get_action_strength("look_up")-Input.get_action_strength("look_down")) * gamepad_response
|
||||
|
||||
if current_mouse_rotation.length()>0:
|
||||
input_speed = current_mouse_rotation
|
||||
current_mouse_rotation = Vector2.ZERO
|
||||
if current_mouse_rotation.length()>0:
|
||||
input_speed = current_mouse_rotation
|
||||
current_mouse_rotation = Vector2.ZERO
|
||||
|
||||
rotation_speed = rotation_speed * (1-mouse_jerk*smoothness) + input_speed * mouse_jerk * smoothness
|
||||
rotation_speed = rotation_speed * (1-mouse_jerk*smoothness) + input_speed * mouse_jerk * smoothness
|
||||
|
||||
if rotation_speed.y > 0 and pitch.rotation_degrees.x < 0:
|
||||
rotation_speed.y *= 1-pow(pitch.rotation_degrees.x/-max_angle, 4)
|
||||
elif rotation_speed.y < 0 and pitch.rotation_degrees.x > 0 :
|
||||
rotation_speed.y *= 1-pow(pitch.rotation_degrees.x/max_angle, 4)
|
||||
if rotation_speed.y > 0 and pitch.rotation_degrees.x < 0:
|
||||
rotation_speed.y *= 1-pow(pitch.rotation_degrees.x/-max_angle, 4)
|
||||
elif rotation_speed.y < 0 and pitch.rotation_degrees.x > 0 :
|
||||
rotation_speed.y *= 1-pow(pitch.rotation_degrees.x/max_angle, 4)
|
||||
|
||||
yaw.rotate_y(deg_to_rad(-rotation_speed.x * delta * mouse_sensitivity.x))
|
||||
pitch.rotate_x(deg_to_rad(-rotation_speed.y * delta * mouse_sensitivity.y))
|
||||
yaw.rotate_y(deg_to_rad(-rotation_speed.x * delta * mouse_sensitivity.x))
|
||||
pitch.rotate_x(deg_to_rad(-rotation_speed.y * delta * mouse_sensitivity.y))
|
||||
|
||||
func _handle_jitter(delta):
|
||||
loc_noise_spot += Vector3(delta * camera_jitter_speed * location_jitter_speed)
|
||||
rot_noise_spot += Vector3(delta * camera_jitter_speed * angular_jitter_speed)
|
||||
pitch.position = Vector3(
|
||||
noise.get_noise_1d(loc_noise_spot.x),
|
||||
noise.get_noise_1d(loc_noise_spot.y),
|
||||
noise.get_noise_1d(loc_noise_spot.z)
|
||||
) * location_jitter * jitter_strength
|
||||
loc_noise_spot += Vector3(delta * camera_jitter_speed * location_jitter_speed)
|
||||
rot_noise_spot += Vector3(delta * camera_jitter_speed * angular_jitter_speed)
|
||||
pitch.position = Vector3(
|
||||
noise.get_noise_1d(loc_noise_spot.x),
|
||||
noise.get_noise_1d(loc_noise_spot.y),
|
||||
noise.get_noise_1d(loc_noise_spot.z)
|
||||
) * location_jitter * jitter_strength
|
||||
|
||||
if not State.reduce_motion: mount.rotation = Vector3(
|
||||
noise.get_noise_1d(rot_noise_spot.x),
|
||||
noise.get_noise_1d(rot_noise_spot.y),
|
||||
noise.get_noise_1d(rot_noise_spot.z)
|
||||
) * angular_jitter * jitter_strength
|
||||
if not State.reduce_motion: mount.rotation = Vector3(
|
||||
noise.get_noise_1d(rot_noise_spot.x),
|
||||
noise.get_noise_1d(rot_noise_spot.y),
|
||||
noise.get_noise_1d(rot_noise_spot.z)
|
||||
) * angular_jitter * jitter_strength
|
||||
|
||||
|
||||
func _handle_mouse_input(event:InputEventMouseMotion):
|
||||
if event.relative.length() < mouse_jerk_rejection:
|
||||
current_mouse_rotation = event.relative
|
||||
if event.relative.length() < mouse_jerk_rejection:
|
||||
current_mouse_rotation = event.relative
|
||||
|
||||
func _input(event:InputEvent):
|
||||
if has_stage:
|
||||
if event is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||
_handle_mouse_input(event)
|
||||
get_viewport().set_input_as_handled()
|
||||
if event is InputEventMouseButton and event.pressed:
|
||||
if Input.is_action_just_pressed("zoom_in_mouse"):
|
||||
zoomed = true
|
||||
elif Input.is_action_just_pressed("zoom_out_mouse"):
|
||||
zoomed = false
|
||||
else:
|
||||
State.free_focus()
|
||||
get_tree().call_group("interactables", "reveal")
|
||||
#if event.is_action_pressed("ui_accept"):
|
||||
# State.pass_stage_to(focus_ray.get_collider())
|
||||
# get_viewport().set_input_as_handled()
|
||||
else:
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_RIGHT and event.pressed:
|
||||
if !Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
|
||||
State.take_stage(self, true)
|
||||
get_tree().call_group("interactables", "collapse")
|
||||
if has_stage:
|
||||
if event is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||
_handle_mouse_input(event)
|
||||
get_viewport().set_input_as_handled()
|
||||
if event is InputEventMouseButton and event.pressed:
|
||||
if Input.is_action_just_pressed("zoom_in_mouse"):
|
||||
zoomed = true
|
||||
elif Input.is_action_just_pressed("zoom_out_mouse"):
|
||||
zoomed = false
|
||||
else:
|
||||
State.free_focus()
|
||||
get_tree().call_group("interactables", "reveal")
|
||||
#if event.is_action_pressed("ui_accept"):
|
||||
# State.pass_stage_to(focus_ray.get_collider())
|
||||
# get_viewport().set_input_as_handled()
|
||||
else:
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_RIGHT and event.pressed:
|
||||
if !Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
|
||||
State.take_stage(self, true)
|
||||
get_tree().call_group("interactables", "collapse")
|
||||
|
||||
func play_scene(id: int, _repeat):
|
||||
if id == Scenes.id.YOUTH_DRAEVEN:
|
||||
var rotation_tween = create_tween()
|
||||
if id == Scenes.id.YOUTH_DRAEVEN:
|
||||
var rotation_tween = create_tween()
|
||||
|
||||
func scene_finished(_id, repeat: bool):
|
||||
if repeat:
|
||||
State.take_stage(self, true)
|
||||
if repeat:
|
||||
State.take_stage(self, true)
|
||||
|
||||
func _on_bed_enter(_body):
|
||||
if not (crouched or on_crouch_cooldown):
|
||||
$PlayerAnimationPlayer.queue("crouch")
|
||||
var tween = create_tween()
|
||||
tween.tween_property(self, "max_speed", max_speed/2, 0.3)
|
||||
crouched = true
|
||||
if not (crouched or on_crouch_cooldown):
|
||||
$PlayerAnimationPlayer.queue("crouch")
|
||||
var tween = create_tween()
|
||||
tween.tween_property(self, "max_speed", max_speed/2, 0.3)
|
||||
crouched = true
|
||||
|
||||
func _on_bed_exit(_body):
|
||||
if crouched:
|
||||
crouched = false
|
||||
$PlayerAnimationPlayer.queue("stand_up")
|
||||
var tween = create_tween()
|
||||
tween.tween_property(self, "max_speed", max_speed*2, 1)
|
||||
if crouched:
|
||||
crouched = false
|
||||
$PlayerAnimationPlayer.queue("stand_up")
|
||||
var tween = create_tween()
|
||||
tween.tween_property(self, "max_speed", max_speed*2, 1)
|
||||
|
||||
on_crouch_cooldown = true
|
||||
await get_tree().create_timer(1.0).timeout
|
||||
on_crouch_cooldown = false
|
||||
on_crouch_cooldown = true
|
||||
await get_tree().create_timer(1.0).timeout
|
||||
on_crouch_cooldown = false
|
||||
|
|
|
|||
|
|
@ -3,4 +3,4 @@ extends HSlider
|
|||
@export var audio_bus_id: int = 0
|
||||
|
||||
func _on_value_changed(volume_lin: float):
|
||||
AudioServer.set_bus_volume_db(audio_bus_id, linear_to_db(volume_lin))
|
||||
AudioServer.set_bus_volume_db(audio_bus_id, linear_to_db(volume_lin))
|
||||
|
|
|
|||
14
src/main.gd
14
src/main.gd
|
|
@ -3,15 +3,15 @@ extends Node3D
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
pass # Replace with function body.
|
||||
|
||||
func debug_youth():
|
||||
get_child(1).hide()
|
||||
get_child(2).hide()
|
||||
get_child(3).hide()
|
||||
get_child(0).get_ready()
|
||||
get_child(0).start()
|
||||
get_child(1).hide()
|
||||
get_child(2).hide()
|
||||
get_child(3).hide()
|
||||
get_child(0).get_ready()
|
||||
get_child(0).start()
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
extends Node
|
||||
# For Startup Scene:
|
||||
# For Startup Scene:
|
||||
var screen_reader:bool = false # Screenreader
|
||||
var disable_rendering: bool = false # show nav button
|
||||
var simplified_navigation:bool = false # simplified controls
|
||||
|
|
@ -18,96 +18,90 @@ var focus_locked: bool = false
|
|||
signal theme_changed
|
||||
|
||||
var current_main_theme:Theme = preload("res://logic-scenes/themes/easy-handwriting.theme"):
|
||||
set(theme):
|
||||
current_main_theme = theme
|
||||
emit_signal("theme_changed", theme)
|
||||
set(theme):
|
||||
current_main_theme = theme
|
||||
emit_signal("theme_changed", theme)
|
||||
|
||||
func _ready():
|
||||
for child in get_parent().get_children():
|
||||
if "has_stage" in child:
|
||||
pass_stage_to(child)
|
||||
for child in get_parent().get_children():
|
||||
if "has_stage" in child:
|
||||
pass_stage_to(child)
|
||||
|
||||
# Meta: due to conflicting names with the internal focus handling of godot, a "stage-based" Metaphor is being used to refer to focus handling.
|
||||
|
||||
# Intented for use when an actor wants focus for itself, can reclaim focus, thus dropping the stack that focused.
|
||||
func take_stage(actor: Object, reclaim: bool = false) -> bool:
|
||||
if focus_locked: return false
|
||||
if reclaim:
|
||||
stage_list.front().has_stage = false
|
||||
if stage_list.has(actor):
|
||||
while stage_list.pop_front() != actor: break
|
||||
actor.has_stage = true
|
||||
stage_list.push_front(actor)
|
||||
return actor.has_stage
|
||||
push_warning(actor, " wanted to reclaim focus, but was not on list.")
|
||||
return pass_stage_to(actor)
|
||||
if focus_locked: return false
|
||||
if reclaim:
|
||||
stage_list.front().has_stage = false
|
||||
if stage_list.has(actor):
|
||||
while stage_list.pop_front() != actor: break
|
||||
actor.has_stage = true
|
||||
stage_list.push_front(actor)
|
||||
return actor.has_stage
|
||||
push_warning(actor, " wanted to reclaim focus, but was not on list.")
|
||||
return pass_stage_to(actor)
|
||||
|
||||
# Element no longer wants focus, if Element itself is also dropped, this option can be chosen aswell.
|
||||
func leave_stage(actor:Object, dropObject: bool = false) -> bool:
|
||||
if get_tree().paused:
|
||||
push_error(actor, " wanted to drop focus while tree is paused.")
|
||||
if get_tree().paused:
|
||||
push_error(actor, " wanted to drop focus while tree is paused.")
|
||||
|
||||
if not dropObject: actor.has_stage = false
|
||||
focus_locked = false
|
||||
stage_list.erase(actor)
|
||||
if not dropObject: actor.has_stage = false
|
||||
focus_locked = false
|
||||
stage_list.erase(actor)
|
||||
|
||||
if stage_list != []:
|
||||
stage_list.front().has_stage = true
|
||||
else:
|
||||
get_tree().quit()
|
||||
if stage_list != []:
|
||||
stage_list.front().has_stage = true
|
||||
else:
|
||||
get_tree().quit()
|
||||
|
||||
return false
|
||||
return false
|
||||
|
||||
func get_current_actor(): return stage_list.front()
|
||||
|
||||
# Used to put a new target on top of the Focus Stack.
|
||||
func pass_stage_to(target:Object, force = false, lock_focus = true) -> bool:
|
||||
if "pass_to_actor" in target:
|
||||
pass_stage_to(target.pass_to_actor)
|
||||
if (focus_locked or get_tree().paused) and not force:
|
||||
push_error(target, " requested focus while it was locked or tree is paused.")
|
||||
elif !is_instance_valid(target):
|
||||
push_error("Focus instance not valid")
|
||||
elif !"has_stage" in target:
|
||||
push_error(target, " has no has focus method.")
|
||||
else:
|
||||
if stage_list.size() > 0:
|
||||
if stage_list.front() == target:
|
||||
push_warning(target, " is already target. Abort passing focus.")
|
||||
return false
|
||||
if not stage_list.size() == 0: stage_list.front().has_stage = false
|
||||
target.has_stage = true
|
||||
if target.has_stage:
|
||||
stage_list.push_front(target)
|
||||
assert(stage_list.size() < 100)
|
||||
return true
|
||||
return false
|
||||
if "pass_to_actor" in target:
|
||||
pass_stage_to(target.pass_to_actor)
|
||||
if (focus_locked or get_tree().paused) and not force:
|
||||
push_error(target, " requested focus while it was locked or tree is paused.")
|
||||
elif !is_instance_valid(target):
|
||||
push_error("Focus instance not valid")
|
||||
elif !"has_stage" in target:
|
||||
push_error(target, " has no has focus method.")
|
||||
else:
|
||||
if stage_list.size() > 0:
|
||||
if stage_list.front() == target:
|
||||
push_warning(target, " is already target. Abort passing focus.")
|
||||
return false
|
||||
if not stage_list.size() == 0: stage_list.front().has_stage = false
|
||||
target.has_stage = true
|
||||
if target.has_stage:
|
||||
stage_list.push_front(target)
|
||||
assert(stage_list.size() < 100)
|
||||
return true
|
||||
return false
|
||||
|
||||
# Currently focused element loses focus, but remains in stack.
|
||||
func free_focus():
|
||||
if focus_locked: return false
|
||||
if stage_list.size() > 0: stage_list.front().has_stage = false
|
||||
if focus_locked: return false
|
||||
if stage_list.size() > 0: stage_list.front().has_stage = false
|
||||
|
||||
func transition_stage_to(thief: Object, lock_focus = false):
|
||||
focus_locked = lock_focus
|
||||
if stage_list.size() > 0:
|
||||
if stage_list.front().has_stage:
|
||||
stage_list.pop_front().has_stage = false
|
||||
return pass_stage_to(thief, true)
|
||||
focus_locked = lock_focus
|
||||
if stage_list.size() > 0:
|
||||
if stage_list.front().has_stage:
|
||||
stage_list.pop_front().has_stage = false
|
||||
return pass_stage_to(thief, true)
|
||||
|
||||
func queue_for_stage(target: Object, index: int = 1):
|
||||
stage_list.insert(index, target)
|
||||
stage_list.insert(index, target)
|
||||
|
||||
func print_settings():
|
||||
print_debug("Screenreader: ", screen_reader, " / ",
|
||||
"Disable rendering: ", disable_rendering, " / ",
|
||||
"Simplified controls: ", simplified_navigation, " / ",
|
||||
"Show navigation buttons: ", show_navigation_buttons, " / ",
|
||||
"Enable subtitles: ", enable_subtitles, " / ",
|
||||
"Enable CC: ", enable_closed_caption, " / ")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
print_debug("Screenreader: ", screen_reader, " / ",
|
||||
"Disable rendering: ", disable_rendering, " / ",
|
||||
"Simplified controls: ", simplified_navigation, " / ",
|
||||
"Show navigation buttons: ", show_navigation_buttons, " / ",
|
||||
"Enable subtitles: ", enable_subtitles, " / ",
|
||||
"Enable CC: ", enable_closed_caption, " / ")
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
extends Node
|
||||
|
||||
enum id {
|
||||
YOUTH_CHILDHOOD,
|
||||
YOUTH_VOICE_TRAINING,
|
||||
YOUTH_JUI_JUTSU,
|
||||
YOUTH_DRAEVEN,
|
||||
ADULT_DND,
|
||||
ADULD_VOLUNTARY,
|
||||
ADULD_CHRISTMAS
|
||||
YOUTH_CHILDHOOD,
|
||||
YOUTH_VOICE_TRAINING,
|
||||
YOUTH_JUI_JUTSU,
|
||||
YOUTH_DRAEVEN,
|
||||
ADULT_DND,
|
||||
ADULD_VOLUNTARY,
|
||||
ADULD_CHRISTMAS
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ Frame of mind is
|
|||
made by betalars
|
||||
|
||||
They were suppored by:
|
||||
Adrian Schmid and tilcreator - programming
|
||||
Adrian Schmid and somebody that I used to know - programming
|
||||
Jas Arianna - voice acting
|
||||
STTLE - OST
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue