4 Commits 3e455e21cc ... cc6f6435af

Author SHA1 Message Date
  DricomDragon cc6f6435af :tada: Create install script 2 months ago
  DricomDragon ab2403fd60 Dump version to 1.3.0 2 months ago
  DricomDragon 10391f4a98 :tada: Create parameter to set up home-slide 2 months ago
  DricomDragon 428eda1bda :truck: Deplace screenshots dans la doc 2 months ago

+ 13 - 3
README.md

@@ -111,14 +111,14 @@ By default, to prevent side-effects and overcharge your computer resources, Slid
 4. Instantiate a game scene as a child of the SubViewport
 5. Make the SubViewport a child of a *SubViewportContainer*
 
-![example embedding a game using a SubViewportContainer](godot/example/screenshots/slide-show-plugin-embed-game-subviewportcontainer.png)
+![example embedding a game using a SubViewportContainer](doc/img/slide-show-plugin-embed-game-subviewportcontainer.png)
 
 *Alternative of merging games* : If you have conflicts when you merge your games files, you'd rather prefer to keep it in its own subfolder of your SlideShow project. Keep in mind that you have to fix every string in scripts referencing a resource by its path! (You can mitigate this by referencing uuid of resources instead).
 
 *Alternative for SubViewportContainer* : This node is useful to pass inputs to your game ; if you want only to demonstrate a visual effect, you can use a viewport texture referencing the subviewport parent of your demo scene, for instance in a `Sprite2D` or a `TextureRect`.
 
-![example embedding a scene using a TextureRect](godot/example/screenshots/slide-show-plugin-embed-scene-sprite.png)
-![example embedding a scene using a Sprite](godot/example/screenshots/slide-show-plugin-embed-scene-texturerect.png)
+![example embedding a scene using a TextureRect](doc/img/slide-show-plugin-embed-scene-sprite.png)
+![example embedding a scene using a Sprite](doc/img/slide-show-plugin-embed-scene-texturerect.png)
 
 #### Export your slides
 
@@ -150,6 +150,16 @@ Sorry, Godot override scale when using physics.
 
 To prevent the scale of your slide in the main scene to disturb your physics simulation, embed it into a subviewport. See the "embed your game" instruction above.
 
+## Bonus
+
+### Install script
+
+[fish](https://fishshell.com/) required.
+
+```sh
+GD_SHOW_PROJECTS=../myProject1/godot/ ./install.fish
+```
+
 ## License
 
 This plugin is free software licensed under the [MIT license](https://mit-license.org/), the same license used by the Godot engine itself.

godot/example/screenshots/slide-show-plugin-embed-game-subviewportcontainer.png → doc/img/slide-show-plugin-embed-game-subviewportcontainer.png


godot/example/screenshots/slide-show-plugin-embed-scene-sprite.png → doc/img/slide-show-plugin-embed-scene-sprite.png


godot/example/screenshots/slide-show-plugin-embed-scene-texturerect.png → doc/img/slide-show-plugin-embed-scene-texturerect.png


+ 1 - 1
godot/addons/slide_show/plugin.cfg

@@ -3,5 +3,5 @@
 name="SlideShowPlugin"
 description="A plugin to easily create and animate slides in Godot 4."
 author="Jovian HERSEMEULE"
-version="1.0.0"
+version="1.3.0"
 script="plugin.gd"

+ 24 - 6
godot/addons/slide_show/projector/show/Show.gd

@@ -9,6 +9,7 @@ const VOID_SLIDE_ID := -1
 
 @export_group("Slide management")
 @export var start_slide := 0 ## Id of the slide focused at startup
+@export var home_slide := -1 ## Id of the slide to focus when triggering "Home Slide" action ; fallback to start_slide id when negative
 @export var hide_slides := false ## Hide every slide at startup (except the ones with always_visible enabled)
 
 @export_group("Input setup", "action_")
@@ -80,7 +81,7 @@ func next_slide_at(next_id: int, trans: Focus.Transit) -> void:
 
 
 func is_last_slide() -> bool:
-	return current_id == slides.size() - 1
+	return current_id == _last_slide_id()
 
 
 func _focus_slide(id: int, trans: Focus.Transit) -> Slide:
@@ -120,7 +121,9 @@ func _enforce_parameters() -> void:
 	assert(start_slide >= 0,
 		"Negative index is not supported for start_slide")
 	assert(start_slide < slides.size(),
-		"start_slide index is out of bound (max is %s)" % (slides.size() - 1))
+		"start_slide index is out of bound (max is %s)" % (_last_slide_id()))
+	assert(home_slide < slides.size(),
+		"home_slide index is out of bound (max is %s)" % (_last_slide_id()))
 
 
 func _enforce_children() -> void:
@@ -142,13 +145,13 @@ func _previous_id() -> int:
 	var next_id: int = current_id - 1
 
 	if next_id < 0:
-		return slides.size() - 1
+		return _last_slide_id()
 
 	return next_id
 
 
-func _reset_id() -> void:
-		current_id = VOID_SLIDE_ID
+func _last_slide_id() -> int:
+	return slides.size() - 1
 
 
 func _unhandled_key_input(event: InputEvent) -> void:
@@ -163,7 +166,7 @@ func _unhandled_key_input(event: InputEvent) -> void:
 		go_fast_to_previous_slide()
 	elif event.is_action(action_home_slide):
 		get_viewport().set_input_as_handled()
-		_reset_id()
+		_reset_id_just_before_home()
 		go_slowly_to_next_slide()
 
 
@@ -190,5 +193,20 @@ func _search_nearest_slide_from(target_pos: Vector2) -> Slide:
 	return nearest_slide
 
 
+func _reset_id_just_before_home() -> void:
+	var home_id = _get_home_slide_id()
+	current_id = home_id - 1
+
+
+## Get Home slide id, with backup
+func _get_home_slide_id() -> int:
+	if home_slide >= 0:
+		return home_slide
+	elif start_slide >= 0:
+		return start_slide
+	else:
+		return 0
+
+
 func _on_current_slide_finished() -> void:
 	go_slowly_to_next_slide()

+ 1 - 1
godot/project.godot

@@ -11,7 +11,7 @@ config_version=5
 [application]
 
 config/name="Godot Slide Show Plugin"
-config/version="1.2.1"
+config/version="1.3.0"
 config/tags=PackedStringArray("dricom")
 run/main_scene="res://example/example_slide_show.tscn"
 config/features=PackedStringArray("4.4", "GL Compatibility")

+ 26 - 0
install.fish

@@ -0,0 +1,26 @@
+#!/usr/bin/fish
+
+if test -z $GD_SHOW_PROJECTS
+	echo "List your Godot project folder in env var GD_SHOW_PROJECTS (separated by spaces)"
+	exit 1
+end
+
+set SRC_FOLDER ./godot/addons/slide_show
+if not test -d $SRC_FOLDER
+	echo "This script should run in the Git Root folder"
+	exit 2
+end
+
+for f in $GD_SHOW_PROJECTS
+	echo "install GodotSlideShowPlugin in : $f"
+	if not test -d $f
+		echo "directory expected : $f"
+		exit 3
+	end
+	if not test -f $f/project.godot
+		echo "project.godot expected in : $f"
+		exit 4
+	end
+	mkdir --parents $f/addons/slide_show
+	rsync --delete --recursive --verbose $SRC_FOLDER $f/addons/
+end