This commit is contained in:
Torsten 2024-07-13 08:13:23 +02:00
parent e3ebcc9975
commit 5656d527f3
26 changed files with 238 additions and 3 deletions

View file

@ -1,4 +1,4 @@
{
"accentColor": "",
"theme": "moonstone"
"theme": "obsidian"
}

View file

@ -1,3 +1,4 @@
[
"obsidian-excalidraw-plugin"
"obsidian-excalidraw-plugin",
"oz-clear-unused-images"
]

View file

@ -0,0 +1,7 @@
{
"deleteOption": "system-trash",
"logsModal": true,
"excludedFolders": "",
"ribbonIcon": true,
"excludeSubfolders": false
}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,10 @@
{
"id": "oz-clear-unused-images",
"name": "Clear Unused Images",
"version": "1.1.0",
"minAppVersion": "0.11.13",
"description": "Clear the images that you are not using anymore in your markdown notes to save space.",
"author": "Ozan",
"authorUrl": "https://www.ozan.pl",
"isDesktopOnly": false
}

View file

@ -0,0 +1,10 @@
.unused-images-logs {
margin-bottom: 13px;
margin-top: 5px;
}
.unused-images-center-wrapper {
display: flex;
align-items: center;
justify-content: center;
}

View file

@ -0,0 +1 @@
https://school.gdquest.com/courses/learn_2d_gamedev_godot_4/telling_a_story/overview

View file

@ -0,0 +1,127 @@
Nothing new here, just replacement of TextureRect images
```python
extends Control
var expressions := {
"happy": preload ("res://assets/emotion_happy.png"),
"regular": preload ("res://assets/emotion_regular.png"),
"sad": preload ("res://assets/emotion_sad.png"),
}
var bodies := {
"sophia": preload ("res://assets/sophia.png"),
"pink": preload ("res://assets/pink.png")
}
## Data to display in the dialogue. Each dictionary in this array has three properties:
##
## - expression: a [code]Texture[/code] containing an expression
## - text: a [code]String[/code] containing the text the character says
## - character: a [code]Texture[/code] representing the character
var dialogue_items: Array[Dictionary] = [
{
"expression": expressions["regular"],
"text": "I've been studying arrays and dictionaries lately.",
"character": bodies["sophia"],
},
{
"expression": expressions["regular"],
"text": "Oh, nice. How has it been going?",
"character": bodies["pink"],
},
{
"expression": expressions["sad"],
"text": "Well... it's a little complicated!",
"character": bodies["sophia"],
},
{
"expression": expressions["sad"],
"text": "Oh!",
"character": bodies["pink"],
},
{
"expression": expressions["regular"],
"text": "It sure takes time to click at first.",
"character": bodies["pink"],
},
{
"expression": expressions["happy"],
"text": "If you keep at it, eventually, you'll get the hang of it!",
"character": bodies["pink"],
},
{
"expression": expressions["regular"],
"text": "Mhhh... I see. I'll keep at it, then.",
"character": bodies["sophia"],
},
{
"expression": expressions["happy"],
"text": "Thanks for the encouragement. Time to LEARN!!!",
"character": bodies["sophia"],
},
]
var current_item_index := 0
@onready var rich_text_label: RichTextLabel = %RichTextLabel
@onready var next_button: Button = %NextButton
@onready var audio_stream_player: AudioStreamPlayer = %AudioStreamPlayer
@onready var body: TextureRect = %Body
@onready var expression_texture_rect: TextureRect = %Expression
func _ready() -> void:
show_text()
next_button.pressed.connect(advance)
func show_text() -> void:
# We first extract data for the current dialogue item and apply it to the UI
# elements.
var current_item := dialogue_items[current_item_index]
rich_text_label.text = current_item["text"]
expression_texture_rect.texture = current_item["expression"]
body.texture = current_item["character"]
# We then hide the text and animate it appearing.
rich_text_label.visible_ratio = 0.0
var tween := create_tween()
var text_appearing_duration: float = current_item["text"].length() / 30.0
tween.tween_property(rich_text_label, "visible_ratio", 1.0, text_appearing_duration)
# We randomize the audio playback's start time to make it sound different
# every time and play the sound until the text finishes displaying.
var sound_max_length := audio_stream_player.stream.get_length() - text_appearing_duration
var sound_start_position := randf() * sound_max_length
audio_stream_player.play(sound_start_position)
tween.finished.connect(audio_stream_player.stop)
# We animate the character sliding in.
slide_in()
## Advances the dialogue to the next item or quits the game if there are no more
## items.
func advance() -> void:
current_item_index += 1
if current_item_index == dialogue_items.size():
get_tree().quit()
else:
show_text()
## Animates the character sliding in.
func slide_in() -> void:
var slide_tween := create_tween()
slide_tween.set_ease(Tween.EASE_OUT)
body.position.x = get_viewport_rect().size.x / 7
slide_tween.tween_property(body, "position:x", 0, 0.3)
body.modulate.a = 0
slide_tween.parallel().tween_property(body, "modulate:a", 1, 0.2
```

View file

@ -0,0 +1,78 @@
ProjectProject Settings...Input Map
Define action + button there
![[Pasted image 20240713073756.png]]
Next, select a button, and open Shortcut section
![[Pasted image 20240713073933.png]]
Click the <empty> Shortcut field, then select New Shortcut
The `Shortcut` resource takes an array of inputs as its data because in case you'd want to trigger the same button with multiple different inputs or input actions.
sadfs
![[Pasted image 20240713074212.png]]
![[Pasted image 20240713074345.png]]
Click on the created InputEventAction to expand it.
![[Pasted image 20240713080012.png]]
Set action to advance_text ( The action we created in the very first screenshot of this page)
![[Pasted image 20240713080125.png]]
Disabling button until tween finished
```python
func show_text() -> void:
# We first extract data for the current dialogue item and apply it to the UI
# elements.
# ...
next_button.disabled = true
tween.finished.connect(func() -> void:
next_button.disabled = false
)
```
Note to self: It seems to be possible to connect an event to more than 1 function. Here the full function from the tutorial. Note the tween.connect re-use
```python
func show_text() -> void:
# We first extract data for the current dialogue item and apply it to the UI
# elements.
var current_item := dialogue_items[current_item_index]
rich_text_label.text = current_item["text"]
expression_texture_rect.texture = current_item["expression"]
body.texture = current_item["character"]
# We then hide the text and animate it appearing.
rich_text_label.visible_ratio = 0.0
var tween := create_tween()
var text_appearing_duration: float = current_item["text"].length() / 30.0
tween.tween_property(rich_text_label, "visible_ratio", 1.0, text_appearing_duration)
# We randomize the audio playback's start time to make it sound different
# every time and play the sound until the text finishes displaying.
var sound_max_length := audio_stream_player.stream.get_length() - text_appearing_duration
var sound_start_position := randf() * sound_max_length
audio_stream_player.play(sound_start_position)
tween.finished.connect(audio_stream_player.stop)
# We animate the character sliding in.
slide_in()
# Finally, we disable the next button until the text finishes displaying.
next_button.disabled = true
tween.finished.connect(func() -> void:
next_button.disabled = false
)
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

View file

@ -1 +0,0 @@
{}

View file

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 209 KiB

After

Width:  |  Height:  |  Size: 209 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 198 KiB

After

Width:  |  Height:  |  Size: 198 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 2 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 KiB