Skip to content

Commit

Permalink
Merge branch 'main' into 87-map-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
Turtyo authored Apr 22, 2024
2 parents 98941b7 + 0adc407 commit 33931cf
Show file tree
Hide file tree
Showing 74 changed files with 13,077 additions and 1 deletion.
Binary file added Art/Background/0-0.test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Art/Background/0-0.test.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://d4irj3je6odom"
path="res://.godot/imported/0-0.test.png-7d85cee674d3c368edee07176a9ad081.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Art/Background/0-0.test.png"
dest_files=["res://.godot/imported/0-0.test.png-7d85cee674d3c368edee07176a9ad081.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file added Art/NPC/rescued_saplings_comfy_sleepy-1.test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Art/NPC/rescued_saplings_comfy_sleepy-1.test.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://jdd721vyn4lp"
path="res://.godot/imported/rescued_saplings_comfy_sleepy-1.test.png-f63d28d050934f744e0f15ef547d215e.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Art/NPC/rescued_saplings_comfy_sleepy-1.test.png"
dest_files=["res://.godot/imported/rescued_saplings_comfy_sleepy-1.test.png-f63d28d050934f744e0f15ef547d215e.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file added Art/NPC/rescued_saplings_nerd-1.test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Art/NPC/rescued_saplings_nerd-1.test.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://cnnelgrlm6grx"
path="res://.godot/imported/rescued_saplings_nerd-1.test.png-aed7cd7ec416325aa101246a37df79b7.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Art/NPC/rescued_saplings_nerd-1.test.png"
dest_files=["res://.godot/imported/rescued_saplings_nerd-1.test.png-aed7cd7ec416325aa101246a37df79b7.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
1 change: 1 addition & 0 deletions Art/naming_convention.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Background : <area_number>-<number> ;
Card_art : <name> ;
Card_layout : <name> ;
Character : <pose> ; default, hurt, took damage, defeated, etc...
Event : <name> ;
Items : <type?accessory/consumable>-<name> ; type is either accessory or consumable
Map : <name> ;
Menus : <name>-<number> ;
Expand Down
178 changes: 178 additions & 0 deletions Dialog/EventDialogueWindow.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
extends CanvasLayer

# Note from TyTy: Most of this script has been autogenerated by DialougeManager addon. The comments will mention if it's added
# behavior added in to fit the needs for the game!

## The action to use for advancing the dialogue
@export var next_action: StringName = &"ui_accept"

## The action to use to skip typing the dialogue
@export var skip_action: StringName = &"ui_cancel"

@onready var balloon: Control = %Balloon
@onready var character_label: RichTextLabel = %CharacterLabel
@onready var dialogue_label: DialogueLabel = %DialogueLabel
@onready var responses_menu: DialogueResponsesMenu = %ResponsesMenu
@onready var portrait: TextureRect = %Balloon/Panel/HBoxContainer/Control/Portrait

# Custom variables for the flavor doodles/text on the dialog that can be customizable in the dialog script
@onready var flavor_image_1: TextureRect = %Balloon/Panel/FlavorNode/FlavorImage1
@onready var flavor_image_2: TextureRect = %Balloon/Panel/FlavorNode/FlavorImage2
@onready var flavor_image_3: TextureRect = %Balloon/Panel/FlavorNode/FlavorImage3

@onready var flavor_text_1: RichTextLabel = %Balloon/Panel/FlavorNode/FlavorText1
@onready var flavor_text_2: RichTextLabel = %Balloon/Panel/FlavorNode/FlavorText2
@onready var flavor_text_3: RichTextLabel = %Balloon/Panel/FlavorNode/FlavorText3

## The dialogue resource
var resource: DialogueResource

## Temporary game states
var temporary_game_states: Array = []

## See if we are waiting for the player
var is_waiting_for_input: bool = false

## See if we are running a long mutation and should hide the balloon
var will_hide_balloon: bool = false

## The current line
var dialogue_line: DialogueLine:
set(next_dialogue_line):
is_waiting_for_input = false
balloon.focus_mode = Control.FOCUS_ALL
balloon.grab_focus()

# The dialogue has finished so close the balloon
if not next_dialogue_line:
queue_free()
return

# If the node isn't ready yet then none of the labels will be ready yet either
if not is_node_ready():
await ready

dialogue_line = next_dialogue_line

character_label.visible = not dialogue_line.character.is_empty()
character_label.text = tr(dialogue_line.character, "dialogue")

dialogue_label.hide()
dialogue_label.dialogue_line = dialogue_line

responses_menu.hide()
responses_menu.set_responses(dialogue_line.responses)

# Show our balloon
balloon.show()
will_hide_balloon = false

dialogue_label.show()
if not dialogue_line.text.is_empty():
dialogue_label.type_out()
await dialogue_label.finished_typing

# Wait for input
if dialogue_line.responses.size() > 0:
balloon.focus_mode = Control.FOCUS_NONE
responses_menu.show()
elif dialogue_line.time != "":
var time: float = dialogue_line.text.length() * 0.02 if dialogue_line.time == "auto" else dialogue_line.time.to_float()
await get_tree().create_timer(time).timeout
next(dialogue_line.next_id)
else:
is_waiting_for_input = true
balloon.focus_mode = Control.FOCUS_ALL
balloon.grab_focus()
get:
return dialogue_line


func _ready() -> void:
balloon.hide()
Engine.get_singleton("DialogueManager").mutated.connect(_on_mutated)

# If the responses menu doesn't have a next action set, use this one
if responses_menu.next_action.is_empty():
responses_menu.next_action = next_action


func _unhandled_input(_event: InputEvent) -> void:
# Only the balloon is allowed to handle input while it's showing
get_viewport().set_input_as_handled()


## Start some dialogue
func start(dialogue_resource: DialogueResource, title: String, extra_game_states: Array = []) -> void:
temporary_game_states = [self] + extra_game_states
is_waiting_for_input = false
resource = dialogue_resource
self.dialogue_line = await resource.get_next_dialogue_line(title, temporary_game_states)


## Go to the next line
func next(next_id: String) -> void:
self.dialogue_line = await resource.get_next_dialogue_line(next_id, temporary_game_states)


### Signals


func _on_mutated(_mutation: Dictionary) -> void:
is_waiting_for_input = false
will_hide_balloon = true
get_tree().create_timer(0.1).timeout.connect(func() -> void:
if will_hide_balloon:
will_hide_balloon = false
balloon.hide()
)


func _on_balloon_gui_input(event: InputEvent) -> void:
# See if we need to skip typing of the dialogue
if dialogue_label.is_typing:
var mouse_was_clicked: bool = event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.is_pressed()
var skip_button_was_pressed: bool = event.is_action_pressed(skip_action)
if mouse_was_clicked or skip_button_was_pressed:
get_viewport().set_input_as_handled()
dialogue_label.skip_typing()
return

if not is_waiting_for_input: return
if dialogue_line.responses.size() > 0: return

# When there are no response options the balloon itself is the clickable thing
get_viewport().set_input_as_handled()

if event is InputEventMouseButton and event.is_pressed() and event.button_index == MOUSE_BUTTON_LEFT:
next(dialogue_line.next_id)
elif event.is_action_pressed(next_action) and get_viewport().gui_get_focus_owner() == balloon:
next(dialogue_line.next_id)

# Custom function that is interacted via the .dialogue file to add a portrait to the scene
func add_portrait(art_name: String) -> void:
portrait.texture = load("res://Art/%s.png" % art_name)

# Custom function that is interacted via the .dialogue file to add some flavor image based on the index passed in
func add_flavor_image(image_name: String, flavor_number: int) -> void:
var flavor_image: Texture2D = load("res://Art/%s.png" % image_name)
match flavor_number:
1:
flavor_image_1.texture = flavor_image
2:
flavor_image_2.texture = flavor_image
3:
flavor_image_3.texture = flavor_image

# Custom function that is interacted via the .dialogue file to add some flavor text based on the index passed in
func add_flavor_text(flavor_text: String, flavor_number: int) -> void:
match flavor_number:
1:
flavor_text_1.add_text(flavor_text)
2:
flavor_text_2.add_text(flavor_text)
3:
flavor_text_3.add_text(flavor_text)

func _on_responses_menu_response_selected(response: DialogueResponse) -> void:
next(response.next_id)
Loading

0 comments on commit 33931cf

Please sign in to comment.