Explorar el Código

Dump GodotSlideShowPlugin to v1.1.0

DricomDragon hace 2 meses
padre
commit
8c28b4eadd
Se han modificado 1 ficheros con 28 adiciones y 5 borrados
  1. 28 5
      godot/addons/slide_show/projector/show/Show.gd

+ 28 - 5
godot/addons/slide_show/projector/show/Show.gd

@@ -3,6 +3,8 @@ extends Node2D
 # Manage slide cycling
 
 
+signal end_reached
+
 const VOID_SLIDE_ID := -1
 
 @export_group("Slide management")
@@ -15,11 +17,17 @@ const VOID_SLIDE_ID := -1
 @export var action_previous_slide := "ui_left"
 @export var action_home_slide := "ui_cancel"
 
+@export_group("Export")
+@export var one_slide_per_frame := true
+@export var quit_after_last_slide := true
+
 var current_id := VOID_SLIDE_ID
 var current_slide: Slide
 
 @onready var focus: Focus = $"../Focus"
 @onready var slides: Array = get_children()
+@onready var movie_enabled: bool = OS.has_feature("movie")
+@onready var auto_next_slide: bool = movie_enabled and one_slide_per_frame
 
 
 func _ready() -> void:
@@ -31,9 +39,18 @@ func _ready() -> void:
 
 	_global_slide_setup()
 
+	if auto_next_slide:
+		end_reached.connect(get_tree().quit)
+		return
+
 	go_slowly_to_next_slide()
 
 
+func _process(_delta: float) -> void:
+	if auto_next_slide:
+		go_fast_to_next_slide()
+
+
 func go_slowly_to_next_slide() -> void:
 	next_slide(Focus.Transit.SMOOTH)
 
@@ -52,11 +69,20 @@ func next_slide(trans: Focus.Transit) -> void:
 
 func next_slide_at(next_id: int, trans: Focus.Transit) -> void:
 	_disable_current_slide()
+
 	current_id = next_id
 	current_slide = _focus_slide(current_id, trans)
+
+	if is_last_slide():
+		end_reached.emit()
+
 	_enable_current_slide()
 
 
+func is_last_slide() -> bool:
+	return current_id == slides.size() - 1
+
+
 func _focus_slide(id: int, trans: Focus.Transit) -> Slide:
 	var slide: Slide = slides[id]
 	focus.focus_on(slide.get_center(), slide.get_scale().x, trans)
@@ -106,13 +132,10 @@ func _enforce_children() -> void:
 func _next_id() -> int:
 	if current_id == VOID_SLIDE_ID:
 		return start_slide
-
-	var next_id: int = current_id + 1
-
-	if next_id >= slides.size():
+	elif is_last_slide():
 		return 0
 
-	return next_id
+	return current_id + 1
 
 
 func _previous_id() -> int: