diff --git a/documentation/custom-portraits.md b/documentation/custom-portraits.md index ef04f3e..d20e347 100644 --- a/documentation/custom-portraits.md +++ b/documentation/custom-portraits.md @@ -9,7 +9,7 @@ ## 1. Introduction -Oftentimes you want something more complex than a simple image: an animated image (e.g. `AnimatedSprite`), a rigged and animated character, a character with a single body but many face variations, or something else entirely. +Oftentimes, you want something more complex than a simple image: an animated image (e.g., `AnimatedSprite`), a rigged and animated character, a character with a single body but many face variations, or something entirely different. To achieve these, you will have to create a **custom portrait scene**. @@ -19,13 +19,13 @@ One scene can be used for one or multiple portraits. If a scene is used for mult ## 2. Requirements -There are not a lot of requirements for portrait scenes: +There are not many requirements for portrait scenes: - **Root needs to be Node2D or Control:** - *The root nodes need a position and scale property, so it must be a Node2D or Control node (or a subclass). - Because the root will act as the "pivot-point" it's suggested to use a simple node like Marker2D and have all functional nodes (like sprites, animation players etc.) be children of it.* + *The root nodes need a position and scale property, so they must be a Node2D or Control node (or a subclass). + Because the root will act as the "pivot point," it's suggested to use a simple node like Marker2D and have all functional nodes (like sprites, animation players etc.) be children of it.* - **Root script extends `DialogicPortrait`:** - *The root nodes script should extend the `DialogicPortrait` class and overwrite some of its methods.* + *The root node script should extend the `DialogicPortrait` class and overwrite some of its methods.* --- @@ -35,20 +35,20 @@ You can customize the behavior by adding a script to the root node and adding sp Like `_ready` or `_process` these will be called automatically by dialogic when needed, and if implemented: -- **_update_portrait(@character, @portrait_name):** +- **_update_portrait(character: DialogicCharacter, portrait_name: String):** *This method is called when the portrait is instanced and when a change to another portrait using the same scene is performed. For example, you could play a specific animation in an `AnimatedSprite` based on the portrait name or show a specific image.* -- **_set_mirror(@mirrored):** +- **_set_mirror(is_mirrored: bool):** *Different scenes might want to mirror differently (AnimationSprite.flip_h; self.scale.x = -1, etc.). Thus, you will have to implement this functionality yourself.* - **_get_covered_rect() -> Rect2:** *This is used for correctly sizing your scene, as it's mostly impossible to know the size of your portrait. If you implement this and return a rect2 that covers your portrait (relative to the root node's position), the portrait_containers size modes and the character editors `Full View` will work.* -- **_set_extra_data(@data_string):** +- **_set_extra_data(data: String):** *The Character event Join/Update mode allows specifying some extra information in the text editor. If some information is given, this method will be called. This can be very useful to enable certain things. For example, your character could have different modes or items.* -- **_should_do_portrait_update(@character, @portrait_name):** - *Rarely needed, but if overridden this will be checked, if the portrait change is performed to a portrait with the same scene. If you return false, then this instance will be deleted and a new instance will be made. If not implemented, this defaults to true, meaning this instance will be used for the portrait update too.* +- **_should_do_portrait_update(character: DialogicCharacter, portrait: String):** + *Rarely needed, but if overridden, this will be checked if the portrait change is performed to a portrait with the same scene. If you return false, then this instance will be deleted and a new instance will be made. If not implemented, this defaults to true, meaning this instance will be used for the portrait update too.* --- @@ -72,7 +72,7 @@ If you define an export group called `Main` all the settings in it will be displ ## 5. Tips and Tricks -In most portraits, you should call `apply_character_and_portrait()` as the first thing in your `_update_portrait()` method. This method simply sets the character and portrait and will switch the portrait string to the default portrait if the portrait is not valid. +In most portraits, you should call `apply_character_and_portrait()` the first thing in your `_update_portrait()` method. This method simply sets the character and portrait and will switch the portrait string to the default portrait if the portrait is not valid. ```gdscript func _update_portrait(passed_character:DialogicCharacter, passed_portrait:String) -> void: @@ -94,6 +94,6 @@ func _update_portrait(passed_character:DialogicCharacter, passed_portrait:String ## 6. Examples -Besides the `DefaultPortrait` scene (in `addons/dialogic/Other`) there are some example scenes in `addons/dialogic/Example Assets/Portraits`, that implement some or all of these methods to achieve different effects. +Besides the `DefaultPortrait` scene (in `addons/dialogic/Other`) there are some example scenes in `addons/dialogic/Example Assets/Portraits`, that implements some or all of these methods to achieve different effects. Take a look at them if you feel unsure how to implement a valid portrait scene!