7 コミット 6be2056432 ... f700017734

作者 SHA1 メッセージ 日付
  DricomDragon f700017734 :memo: Explain how to use the export feature 2 ヶ月 前
  DricomDragon a979b4cd5b :memo: Fix typo in README 2 ヶ月 前
  DricomDragon 38a93fd94f :wrench: [example] Set global export path 2 ヶ月 前
  DricomDragon 421218b1c6 :tada: [export] Quit when all slides are exported 2 ヶ月 前
  DricomDragon c2dccedae7 :wrench: Simplify next slide compute 2 ヶ月 前
  DricomDragon 7ca8c53532 :tada: Implement png slide export 2 ヶ月 前
  DricomDragon 7113cb665f :wrench: Upgrade to Godot 4.3 2 ヶ月 前

+ 3 - 0
.gitignore

@@ -1,2 +1,5 @@
 # Godot 4+ specific ignores
 .godot/
+
+# Generated
+dist/

+ 23 - 1
README.md

@@ -84,7 +84,7 @@ Default controls :
 
 #### Start from another slide
 
-If you want to specify a starting slide, you can specify its index via the inspetor. Can be useful to experiment parts of your slideshow.
+If you want to specify a starting slide, you can specify its index via the inspector. Can be useful to experiment parts of your slideshow.
 
 #### Hide slides before they got focus
 
@@ -94,6 +94,28 @@ To reveal slides on focus, check the `hide slides` in the Show. If you want some
 
 You can create your own actions, and give them to the Show node via the `input setup` section in the inspector.
 
+#### Export your slides
+
+The plugin leverages the [Godot Movie Maker](https://docs.godotengine.org/en/stable/tutorials/animation/creating_movies.html) to easily export every slides to png files.
+
+This feature can be useful when you need to share your work without the hassle to download your project and set up Godot. The exported slides can be used as a backup, or can be cliped into a video for instance.
+
+1. Set up your export path in the _Project settings > Editor > Movie maker_ (make sure the folder exists, and specify png), e.g. `../dist/export/slide.png` ;
+2. Enable the movie mode ;
+3. Run the project : the `Show` will quickly review every slide, and quit when the last one is reached ;
+4. It's already done : your slides are available in your export folder, with one *png* file for each slide.
+
+Note : the resolution of your exported slides are related to the resolution set up in your project.
+
+Warning : pay attention to the window resolution, especially if you are using a tiling windows manager!
+
+The export automation is enabled with two toggles in the `Show` node, in the _Export_ section :
+
+- [x] One Slide per Frame : automatically go to next slide at each frame ;
+- [x] Quit after last slide : automatically quit the game after the last slide is reached.
+
+Note : the export settings are effective only when the Movie Maker mode is enabled.
+
 ## License
 
 This plugin is free software licensed under the [MIT license](https://mit-license.org/), the same license used by the Godot engine itself.

+ 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:

+ 1 - 0
godot/example/example_slide_show.tscn

@@ -7,6 +7,7 @@
 [ext_resource type="PackedScene" uid="uid://bgleyjsx2qhus" path="res://example/slides/3Cool.tscn" id="5_h5p25"]
 
 [node name="ExampleSlideShow" type="Node2D"]
+metadata/movie_file = "../dist/movie/slide.png"
 
 [node name="Focus" type="Camera2D" parent="."]
 script = ExtResource("1_2ck0l")

+ 6 - 1
godot/project.godot

@@ -12,7 +12,7 @@ config_version=5
 
 config/name="Godot Slide Show Plugin"
 run/main_scene="res://example/example_slide_show.tscn"
-config/features=PackedStringArray("4.0", "GL Compatibility")
+config/features=PackedStringArray("4.3", "GL Compatibility")
 config/icon="res://icon.svg"
 
 [display]
@@ -20,6 +20,11 @@ config/icon="res://icon.svg"
 window/stretch/mode="canvas_items"
 window/stretch/aspect="expand"
 
+[editor]
+
+movie_writer/movie_file="../dist/export/slide.png"
+movie_writer/fps=25
+
 [editor_plugins]
 
 enabled=PackedStringArray("res://addons/slide_show/plugin.cfg")