feat: Implemented all dialog features. Fixes #345 (#376)

Co-authored-by: Dennis Ploeger <develop@dieploegers.de>
Co-authored-by: dploeger <dploeger@users.noreply.github.com>
This commit is contained in:
Dennis Ploeger
2021-08-27 08:15:52 +02:00
committed by GitHub
parent 2ed184ad4a
commit 1f28fdc8f3
19 changed files with 418 additions and 172 deletions

View File

@@ -21,25 +21,17 @@ A Regex that matches the end of a dialog
### REGEX
```gdscript
const REGEX: String = "^(\\s*)\\?( (?<type>[^ ]+))?( (?<avatar>[^ ]+))?( (?<timeout>[^ ]+))?( (?<timeout_option>.+))?$"
const REGEX: String = "^(\\s*)\\?( (?<avatar>[^ ]+))?( (?<timeout>[^ ]+))?( (?<timeout_option>.+))?$"
```
Regex that matches dialog lines
## Property Descriptions
### type
```gdscript
var type: String = ""
```
Dialog type
### avatar
```gdscript
var avatar: String = ""
var avatar: String = "-"
```
Avatar used in the dialog
@@ -84,7 +76,7 @@ Construct a dialog from a dialog string
func is_valid() -> bool
```
Dialogs have no conditions, just return true
Check if dialog is valid
### run

View File

@@ -0,0 +1,57 @@
<!-- Auto-generated from JSON by GDScript docs maker. Do not edit this document directly. -->
# ESCDialogOptionsChooser
**Extends:** [Node](../Node)
## Description
Base class for all dialog options implementations
## Property Descriptions
### dialog
```gdscript
var dialog: ESCDialog
```
The dialog to show
## Method Descriptions
### set\_dialog
```gdscript
func set_dialog(new_dialog: ESCDialog) -> void
```
Set the dialog used for the chooser
#### Parameters
- new_dialog: Dialog to set
### show\_chooser
```gdscript
func show_chooser() -> void
```
Show the dialog chooser UI
### hide\_chooser
```gdscript
func hide_chooser() -> void
```
Hide the dialog chooser UI
## Signals
- signal option_chosen(option): An option was chosen
##### Parameters
- option: The dialog option that was chosen

View File

@@ -20,18 +20,6 @@ Wether the player is currently speaking
## Method Descriptions
### preload\_resources
```gdscript
func preload_resources(path: String) -> void
```
Preload the dialog UI resources
#### Parameters
- path: Path where the actual dialog UI resources are located
### say
```gdscript
@@ -62,13 +50,21 @@ func start_dialog_choices(dialog: ESCDialog)
Display a list of choices
#### Parameters
- dialog: The dialog to start
### play\_dialog\_option\_chosen
```gdscript
func play_dialog_option_chosen(option: ESCDialogOption)
```
Called when an option was chosen
Called when an option was chosen and emits the option_chosen signal
#### Parameters
- option: Option, that was chosen.
## Signals

View File

@@ -13,7 +13,7 @@ Logging framework for Escoria
### LOG\_DEBUG
```gdscript
const LOG_WARNING: int = 1
const LOG_ERROR: int = 0
```
Valid log levels
@@ -21,7 +21,7 @@ Valid log levels
### LOG\_ERROR
```gdscript
const LOG_WARNING: int = 1
const LOG_ERROR: int = 0
```
Valid log levels
@@ -29,7 +29,7 @@ Valid log levels
### LOG\_INFO
```gdscript
const LOG_WARNING: int = 1
const LOG_ERROR: int = 0
```
Valid log levels
@@ -37,7 +37,7 @@ Valid log levels
### LOG\_WARNING
```gdscript
const LOG_WARNING: int = 1
const LOG_ERROR: int = 0
```
Valid log levels

View File

@@ -2,7 +2,7 @@
# text\_dialog\_choice.gd
**Extends:** [Control](../Control)
**Extends:** [ESCDialogOptionsChooser](../ESCDialogOptionsChooser) < [Node](../Node)
## Description
@@ -26,17 +26,17 @@ export var color_hover = "165,42,42,1"
export var font = "[Object:null]"
```
### commands
```gdscript
var commands
```
## Method Descriptions
### set\_answers
### show\_chooser
```gdscript
func set_answers(options: Array)
func show_chooser()
```
### hide\_chooser
```gdscript
func hide_chooser()
```

View File

@@ -394,17 +394,16 @@ Dialogs are specified by writing `?` with optional parameters, followed by a lis
The following parameters are available:
* type: (default value "default") the type of dialog menu to use.
* avatar: (default value "default") the avatar to use in the dialog ui.
* avatar: the path to a scene displaying an avatar used in the UI. Defaults to no avatar. To only set the remaining options, set this field to "-"
* timeout: (default value 0) timeout to select an option. After the time has passed, the "timeout_option" will be selected automatically. If the value is 0, there's no timeout.
* timeout_option: (default value 0) option selected when timeout is reached.
* timeout_option: (default value 0) index of option (starting from 1) selected when timeout is reached.
Example:
```
# character's "talk" event
:talk
? type avatar timeout timeout_option
? avatar timeout timeout_option
- "I'd like to buy a map." [!player_has_map]
say player "I'd like to buy a map"
say map_vendor "Do you know the secret code?"