diff --git a/.editorconfig b/.editorconfig old mode 100644 new mode 100755 index 5b05198..dfdebae --- a/.editorconfig +++ b/.editorconfig @@ -7,5 +7,5 @@ end_of_line = lf insert_final_newline = true [*.gd] -indent_style = tab +indent_style = space indent_size = 2 diff --git a/.gitattributes b/.gitattributes old mode 100644 new mode 100755 diff --git a/.github/workflows/Format.yml b/.github/workflows/Format.yml old mode 100644 new mode 100755 index b6ea2ef..24baab2 --- a/.github/workflows/Format.yml +++ b/.github/workflows/Format.yml @@ -23,4 +23,4 @@ jobs: sudo pip3 install -r requirements.txt - name: Format checks via gdformat - run: gdformat -d **/*.gd + run: gdformat --use-space=2 --line-length=120 -d **/*.gd diff --git a/.github/workflows/Lint.yml b/.github/workflows/Lint.yml old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index 71d4c2e..ecace21 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,16 @@ # Build bin/ .sconsign.dblite +.scons-cache/ +*.os + +# SConstruct +.sconf_temp +.sconsign.dblite +*.pyc # Godot-specific ignores +.godot/ .import/ export.cfg export_presets.cfg diff --git a/Assets/Animations/EyesAnimation.res b/Assets/Animations/EyesAnimation.res new file mode 100755 index 0000000..2ffcde1 Binary files /dev/null and b/Assets/Animations/EyesAnimation.res differ diff --git a/Assets/Animations/EyesBaseAnimationRoot.tres b/Assets/Animations/EyesBaseAnimationRoot.tres new file mode 100644 index 0000000..7240f9c --- /dev/null +++ b/Assets/Animations/EyesBaseAnimationRoot.tres @@ -0,0 +1,26 @@ +[gd_resource type="AnimationNodeStateMachine" load_steps=6 format=3 uid="uid://ly7ccqfk3mok"] + +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_1j00c"] +animation = &"Blink" + +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_pul01"] +animation = &"Idle" + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_3qovn"] +advance_mode = 2 + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_xxh8x"] + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_618iv"] +switch_mode = 2 +advance_mode = 2 + +[resource] +states/Blink/node = SubResource("AnimationNodeAnimation_1j00c") +states/Blink/position = Vector2(477.667, 142.667) +states/End/position = Vector2(690.667, 82.4444) +states/Idle/node = SubResource("AnimationNodeAnimation_pul01") +states/Idle/position = Vector2(477, 17.5473) +states/Start/position = Vector2(334, 17.6543) +transitions = ["Start", "Idle", SubResource("AnimationNodeStateMachineTransition_3qovn"), "Idle", "Blink", SubResource("AnimationNodeStateMachineTransition_xxh8x"), "Blink", "Idle", SubResource("AnimationNodeStateMachineTransition_618iv")] +graph_offset = Vector2(-225, -52) diff --git a/Assets/Animations/FaceAnimation.res b/Assets/Animations/FaceAnimation.res new file mode 100755 index 0000000..66a806b Binary files /dev/null and b/Assets/Animations/FaceAnimation.res differ diff --git a/Assets/Animations/PortraitBaseAnimationRoot.tres b/Assets/Animations/PortraitBaseAnimationRoot.tres new file mode 100755 index 0000000..78d74b5 --- /dev/null +++ b/Assets/Animations/PortraitBaseAnimationRoot.tres @@ -0,0 +1,3 @@ +[gd_resource type="AnimationNodeStateMachine" format=3 uid="uid://dhrcry6fbo6f0"] + +[resource] diff --git a/Assets/Animations/Portrait_base.tres b/Assets/Animations/Portrait_base.tres old mode 100644 new mode 100755 diff --git a/Assets/Animations/Portrait_base_anim.tres b/Assets/Animations/Portrait_base_anim.tres old mode 100644 new mode 100755 diff --git a/Assets/Fonts/FSEX302.ttf b/Assets/Fonts/FSEX302.ttf old mode 100644 new mode 100755 diff --git a/Assets/Fonts/FSEX302.ttf.import b/Assets/Fonts/FSEX302.ttf.import old mode 100644 new mode 100755 index 6247651..1b21491 --- a/Assets/Fonts/FSEX302.ttf.import +++ b/Assets/Fonts/FSEX302.ttf.import @@ -23,6 +23,7 @@ allow_system_fallback=true force_autohinter=false hinting=1 subpixel_positioning=1 +keep_rounding_remainders=true oversampling=0.0 Fallbacks=null fallbacks=[] diff --git a/Assets/Fonts/FixedsysExcelsior.tres b/Assets/Fonts/FixedsysExcelsior.tres old mode 100644 new mode 100755 diff --git a/Assets/Icons/Folder.svg b/Assets/Icons/Folder.svg new file mode 100755 index 0000000..a06a2a7 --- /dev/null +++ b/Assets/Icons/Folder.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Assets/Icons/Folder.svg.import b/Assets/Icons/Folder.svg.import new file mode 100755 index 0000000..271b214 --- /dev/null +++ b/Assets/Icons/Folder.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b0p30x4icgtuy" +path="res://.godot/imported/Folder.svg-6fe71eea16322e5e4071b3eb167cc4a7.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/Suada/Assets/Icons/Folder.svg" +dest_files=["res://.godot/imported/Folder.svg-6fe71eea16322e5e4071b3eb167cc4a7.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 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/Assets/Sounds/vocal_sound_1.ogg b/Assets/Sounds/vocal_sound_1.ogg old mode 100644 new mode 100755 diff --git a/Assets/Sounds/vocal_sound_1.ogg.import b/Assets/Sounds/vocal_sound_1.ogg.import old mode 100644 new mode 100755 diff --git a/Assets/Sounds/vocal_sound_short_1.ogg b/Assets/Sounds/vocal_sound_short_1.ogg old mode 100644 new mode 100755 diff --git a/Assets/Sounds/vocal_sound_short_1.ogg.import b/Assets/Sounds/vocal_sound_short_1.ogg.import old mode 100644 new mode 100755 diff --git a/Assets/Sprites/Eyes.png b/Assets/Sprites/Eyes.png new file mode 100755 index 0000000..e37f3b0 --- /dev/null +++ b/Assets/Sprites/Eyes.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:65b05f0574c1a13e107a623cc33479190bc0b088fababd9ab57125a675b88544 +size 107 diff --git a/Assets/Sprites/Eyes.png.import b/Assets/Sprites/Eyes.png.import new file mode 100755 index 0000000..f16704c --- /dev/null +++ b/Assets/Sprites/Eyes.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://brgog63rm2a5c" +path="res://.godot/imported/Eyes.png-1b69cc53dbbb59e9e7a9b9ea55d6d24f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/Suada/Assets/Sprites/Eyes.png" +dest_files=["res://.godot/imported/Eyes.png-1b69cc53dbbb59e9e7a9b9ea55d6d24f.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 diff --git a/Assets/Sprites/Rela.png b/Assets/Sprites/Rela.png new file mode 100755 index 0000000..bc9b78a --- /dev/null +++ b/Assets/Sprites/Rela.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4cbed209d4f9eb5c5bc84b7b26e4e1d6484192d35b237aa86b3b9623e47c21f8 +size 512 diff --git a/Assets/Sprites/Rela.png.import b/Assets/Sprites/Rela.png.import new file mode 100755 index 0000000..a8653b7 --- /dev/null +++ b/Assets/Sprites/Rela.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://4mqv4h4t4yw8" +path="res://.godot/imported/Rela.png-9c2303cd088c7a5374ba9d1f9df64055.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/Suada/Assets/Sprites/Rela.png" +dest_files=["res://.godot/imported/Rela.png-9c2303cd088c7a5374ba9d1f9df64055.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 diff --git a/Assets/Sprites/default_portrait.png b/Assets/Sprites/default_portrait.png old mode 100644 new mode 100755 diff --git a/Assets/Sprites/default_portrait.png.import b/Assets/Sprites/default_portrait.png.import old mode 100644 new mode 100755 diff --git a/Assets/Sprites/dialogue_box.png b/Assets/Sprites/dialogue_box.png old mode 100644 new mode 100755 diff --git a/Assets/Sprites/dialogue_box.png.import b/Assets/Sprites/dialogue_box.png.import old mode 100644 new mode 100755 diff --git a/Assets/Sprites/dialogue_box_9_tile.png b/Assets/Sprites/dialogue_box_9_tile.png old mode 100644 new mode 100755 diff --git a/Assets/Sprites/dialogue_box_9_tile.png.import b/Assets/Sprites/dialogue_box_9_tile.png.import old mode 100644 new mode 100755 diff --git a/Assets/Sprites/indicator.png b/Assets/Sprites/indicator.png old mode 100644 new mode 100755 diff --git a/Assets/Sprites/indicator.png.import b/Assets/Sprites/indicator.png.import old mode 100644 new mode 100755 diff --git a/Assets/Sprites/name_box.png b/Assets/Sprites/name_box.png old mode 100644 new mode 100755 diff --git a/Assets/Sprites/name_box.png.import b/Assets/Sprites/name_box.png.import old mode 100644 new mode 100755 diff --git a/Assets/Sprites/name_box_9_tile.png b/Assets/Sprites/name_box_9_tile.png old mode 100644 new mode 100755 diff --git a/Assets/Sprites/name_box_9_tile.png.import b/Assets/Sprites/name_box_9_tile.png.import old mode 100644 new mode 100755 diff --git a/Assets/Sprites/portrait_background.png b/Assets/Sprites/portrait_background.png old mode 100644 new mode 100755 diff --git a/Assets/Sprites/portrait_background.png.import b/Assets/Sprites/portrait_background.png.import old mode 100644 new mode 100755 diff --git a/Assets/Sprites/portrait_base_idle1.png b/Assets/Sprites/portrait_base_idle1.png old mode 100644 new mode 100755 diff --git a/Assets/Sprites/portrait_base_idle1.png.import b/Assets/Sprites/portrait_base_idle1.png.import old mode 100644 new mode 100755 diff --git a/Assets/Sprites/portrait_base_idle2.png b/Assets/Sprites/portrait_base_idle2.png old mode 100644 new mode 100755 diff --git a/Assets/Sprites/portrait_base_idle2.png.import b/Assets/Sprites/portrait_base_idle2.png.import old mode 100644 new mode 100755 diff --git a/Assets/Sprites/portrait_base_idle3.png b/Assets/Sprites/portrait_base_idle3.png old mode 100644 new mode 100755 diff --git a/Assets/Sprites/portrait_base_idle3.png.import b/Assets/Sprites/portrait_base_idle3.png.import old mode 100644 new mode 100755 diff --git a/Assets/Sprites/portrait_frame.png b/Assets/Sprites/portrait_frame.png old mode 100644 new mode 100755 diff --git a/Assets/Sprites/portrait_frame.png.import b/Assets/Sprites/portrait_frame.png.import old mode 100644 new mode 100755 diff --git a/Assets/Themes/main_theme.tres b/Assets/Themes/main_theme.tres index bfc1654..68e377b 100644 --- a/Assets/Themes/main_theme.tres +++ b/Assets/Themes/main_theme.tres @@ -1,7 +1,7 @@ [gd_resource type="Theme" load_steps=4 format=3 uid="uid://bruovco3l4r7k"] [ext_resource type="FontFile" uid="uid://do40he6kkb8dk" path="res://addons/Suada/Assets/Fonts/FixedsysExcelsior.tres" id="1"] -[ext_resource type="Texture2D" uid="uid://b03mcowynm1j4" path="res://addons/Suada_bk/Assets/Sprites/dialogue_box_9_tile.png" id="2"] +[ext_resource type="Texture2D" uid="uid://b03mcowynm1j4" path="res://addons/Suada/Assets/Sprites/dialogue_box_9_tile.png" id="2"] [sub_resource type="StyleBoxTexture" id="1"] texture = ExtResource("2") diff --git a/Assets/Themes/name_theme.tres b/Assets/Themes/name_theme.tres index 526d6d7..04f701e 100644 --- a/Assets/Themes/name_theme.tres +++ b/Assets/Themes/name_theme.tres @@ -1,7 +1,7 @@ [gd_resource type="Theme" load_steps=4 format=3 uid="uid://ddetutsupn7m0"] [ext_resource type="FontFile" uid="uid://do40he6kkb8dk" path="res://addons/Suada/Assets/Fonts/FixedsysExcelsior.tres" id="1"] -[ext_resource type="Texture2D" uid="uid://csr38a60osub6" path="res://addons/Suada_bk/Assets/Sprites/name_box_9_tile.png" id="2"] +[ext_resource type="Texture2D" uid="uid://csr38a60osub6" path="res://addons/Suada/Assets/Sprites/name_box_9_tile.png" id="2"] [sub_resource type="StyleBoxTexture" id="2"] texture = ExtResource("2") diff --git a/Assets/example_portrait.png.import b/Assets/example_portrait.png.import old mode 100644 new mode 100755 diff --git a/Assets/portrait_aunt.png.import b/Assets/portrait_aunt.png.import old mode 100644 new mode 100755 diff --git a/Assets/portrait_base_idle5.png.import b/Assets/portrait_base_idle5.png.import old mode 100644 new mode 100755 diff --git a/Assets/portrait_char.png.import b/Assets/portrait_char.png.import old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/Nodes/Dialogue.tscn b/Nodes/Dialogue.tscn old mode 100644 new mode 100755 diff --git a/Nodes/DialogueAudioPlayer.gd b/Nodes/DialogueAudioPlayer.gd index 13ba5cd..300e287 100644 --- a/Nodes/DialogueAudioPlayer.gd +++ b/Nodes/DialogueAudioPlayer.gd @@ -2,19 +2,13 @@ class_name DialogueAudioPlayer extends AudioStreamPlayer2D -## Sets the audio of the voice. -## -## @param audio The voice. -func set_voice_sound(audio: AudioStream): - stream = audio +func set_voice(voice: AudioStream) -> void: + stream = voice -## Play the voice sound. -## -## @param wait_to_play If true, waits until the last sound was played. -func play_voice_sound(wait_to_play: bool = true): - if wait_to_play: - if !playing: - play() - else: - play() +func play_voice(wait: bool) -> void: + if wait: + if playing: + play() + else: + play() diff --git a/Nodes/DialogueAudioPlayer.gd.uid b/Nodes/DialogueAudioPlayer.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/DialogueBox.gd b/Nodes/DialogueBox.gd index 42ee6f0..c0a60ff 100644 --- a/Nodes/DialogueBox.gd +++ b/Nodes/DialogueBox.gd @@ -4,90 +4,110 @@ extends Control var _text_next_char_it: float = 0 var _parsed_dialog: ParsedDialog = null var _pause: bool = false +var _text_prev_char_pos: int = -1 -@onready var _text_label = $Panel/Text as RichTextLabel -@onready var _portrait_box: PortraitBox = $"../PortraitBox" -@onready var _finished_effect: Sprite2D = $FinishEffect +@export var _text_label: RichTextLabel +@export var _portrait_box: PortraitBox +@export var _finished_effect: Sprite2D -func _ready(): - if SuadaConfig.text_speed == -1: - _text_label.visible_characters = -1 +func _ready() -> void: + if SuadaConfig.text_speed == -1: + _text_label.visible_characters = -1 -func _process(_delta): - if _text_label.text.is_empty() or !_text_label.visible: - return +func _process(_delta: float) -> void: + if _text_label.text.is_empty() or !_text_label.visible: + return + if _text_label.visible_ratio == 1: + _finished_effect.visible = true + return + if _pause: + return - if _text_label.visible_ratio == 1: - _finished_effect.visible = true - return + _text_next_char_it = ( + SuadaConfig.text_speed if _text_next_char_it >= 1 else _text_next_char_it + SuadaConfig.text_speed + ) + _text_label.visible_characters += _text_next_char_it - if _pause: - return + # This prevent repeat same letter when the increase integer. + var current_text_pos: int = _text_label.visible_characters + if current_text_pos == _text_prev_char_pos: + return + _text_prev_char_pos = _text_label.visible_characters - _text_next_char_it = ( - SuadaConfig.text_speed - if _text_next_char_it >= 1 - else _text_next_char_it + SuadaConfig.text_speed - ) - _text_label.visible_characters += _text_next_char_it + _handle_effects(current_text_pos) - var letter = _text_label.text[_text_label.visible_characters - 1].to_lower() - _handle_effects(_text_label.visible_characters as int) - _handle_letter_pauses(letter) + # HACK: As the render is slower than the process, minus 2 trigger effects when that letter appear. + var letter = _text_label.text[current_text_pos - 2].to_lower() + _handle_letter_pauses(letter) - if SuadaConfig.vocal_sound: - if letter == "a" or letter == "e" or letter == "i" or letter == "o" or letter == "u": - _portrait_box.play_voice() - else: - _portrait_box.play_voice() + if SuadaConfig.vocal_sound: + if letter == "a" or letter == "e" or letter == "i" or letter == "o" or letter == "u": + _play_voice() + else: + _play_voice() + + +func reset() -> void: + _text_next_char_it = 0 + _parsed_dialog = null + _pause = false + _text_prev_char_pos = -1 func set_text(text: String, font: Font, colour: Color = Color.WHITE, visible: bool = false) -> void: - var text_without_suada_effect = BBCParser.bbc_remover(text, BBCCodes.BBC_REXP) - _text_label.text = text - _parsed_dialog = BBCParser.parse(_text_label.get_parsed_text()) - _text_label.text = text_without_suada_effect + reset() + + var text_without_suada_effect = BBCParser.bbc_remover(text, BBCCodes.BBC_REXP) + _text_label.text = text + _parsed_dialog = BBCParser.parse(_text_label.get_parsed_text()) + _text_label.text = text_without_suada_effect - _text_label.add_theme_font_override("normal_font", font) - _text_label.add_theme_color_override("default_color", colour) - _text_label.visible_characters = -1 if visible else 0 + _text_label.add_theme_font_override("normal_font", font) + _text_label.add_theme_color_override("default_color", colour) + _text_label.visible_characters = -1 if visible else 0 -func show_all_text(): - _text_label.visible_characters = -1 +func show_all_text() -> void: + _text_label.visible_characters = -1 func is_complete() -> bool: - return _text_label.visible_ratio == 1 + return _text_label.visible_ratio == 1 + + +func _play_voice() -> void: + if not _portrait_box: + return + _portrait_box.play_voice() -func _handle_effects(pos: int): - if not _parsed_dialog.effects.has(pos): - return - var curr_effect: EffectLocation = _parsed_dialog.effects[pos] - _parsed_dialog.effects.erase(pos) +func _handle_effects(pos: int) -> void: + if not _parsed_dialog.effects.has(pos): + return + var curr_effect: EffectLocation = _parsed_dialog.effects[pos] + _parsed_dialog.effects.erase(pos) - match curr_effect.effect: - BBCCodes.BBC_EFFECT.WAIT: - _handle_pause(curr_effect.value.to_int()) - _: - pass + match curr_effect.effect: + BBCCodes.BBC_EFFECT.WAIT: + _handle_pause(curr_effect.value.to_int()) + _: + pass -func _handle_letter_pauses(letter: String): - match letter: - ",", ".": - _handle_pause(0.1) - "?", "!": - _handle_pause(0.2) - _: - pass +func _handle_letter_pauses(letter: String) -> void: + match letter: + ",", ".": + _handle_pause(0.1) + "?", "!": + _handle_pause(0.2) + _: + pass func _handle_pause(time: float) -> void: - _pause = true - await get_tree().create_timer(time).timeout - _pause = false + _pause = true + await get_tree().create_timer(time).timeout + _pause = false diff --git a/Nodes/DialogueBox.gd.uid b/Nodes/DialogueBox.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/DialogueSystem.gd b/Nodes/DialogueSystem.gd index a77f183..283d4d1 100644 --- a/Nodes/DialogueSystem.gd +++ b/Nodes/DialogueSystem.gd @@ -2,183 +2,187 @@ class_name DialogueSystem extends Control # Customise (FOR USER) -@export -var _voice_snd_effect: AudioStream = load("res://addons/Suada/Assets/Sounds/vocal_sound_1.ogg") +@export var _voice_snd_effect: AudioStream = load("res://addons/Suada/Assets/Sounds/vocal_sound_1.ogg") @export var _default_font: Font = load("res://addons/Suada/Assets/Fonts/FixedsysExcelsior.tres") @export var _default_color: Color = Color.WHITE @export var _default_choice: Color = Color.YELLOW -@export var _interact_key: String = "key_a" -@export var _up_key: String = "key_up" -@export var _down_key: String = "key_down" +@export var _interact_key: String = "ok" +@export var _up_key: String = "up" +@export var _down_key: String = "down" # Setup var _interact_key_pressed: bool = false var _up_key_pressed: int = 0 var _down_key_pressed: int = 0 -var _scale_factor = 1 +var _scale_factor: float = 1.0 var _offset: Vector2 = Vector2(10 * _scale_factor, 14 * _scale_factor) -var _page = 0 +var _page: int = 0 var _next_line: Array = [] -var _pause = false -var _exiting = false -var _chosen = false -var _choice = 0 +var _pause: bool = false +var _exiting: bool = false +var _chosen: bool = false +var _choice: int = 0 var _conversation: Dictionary[int, Dialog] = {} -@onready var _dialogue_box: DialogueTextBox = $DialogueContainer/TextBox -@onready var _name_box: MarginContainer = $NameBox -@onready var _name_box_text: NameTextBox = $NameBox/TextBox/Text -@onready var _portrait_box: MarginContainer = $DialogueContainer/PortraitBox +@export var _dialogue_text_box: DialogueTextBox +@export var _name_box: NameBox +@export var _name_box_text: NameText +@export var _portrait_box: PortraitBox ## Add a convesation and setup the dialog system. func add_conversation(conversation: Dictionary[int, Dialog]) -> void: - _conversation = conversation - _setup() + _conversation = conversation + _setup() func _set_portrait(portrait: Portrait) -> void: - _portrait_box.setup(load(portrait.portrait_path) as SpriteFrames, _voice_snd_effect) + _portrait_box.setup(load(portrait.portrait_path) as Texture2D, _voice_snd_effect) func _reset_keys_states() -> void: - _interact_key_pressed = false - _up_key_pressed = 0 - _down_key_pressed = 0 - - -func _process(_delta): - if _page < 0 or _page >= _conversation.size(): - if _interact_key_pressed: - _handle_exit(0.2) - return - - if not _dialogue_box.is_complete(): - if _interact_key_pressed: - _dialogue_box.show_all_text() - _reset_keys_states() - return - - # Interact behaviour - if _interact_key_pressed: - if _conversation[_page].type == Types.DialogType.NORMAL: - _page = _conversation[_page].next - if _page != -1: - _set_portrait(_conversation[_page].portrait) - _setup() - else: - _handle_exit(0.5) - elif _conversation[_page].type == Types.DialogType.CHOICE and not _chosen: - _chosen = true - _handle_dialogue_choice() - # Change Choice - elif _down_key_pressed or _up_key_pressed: - var change_choice = _down_key_pressed - _up_key_pressed - if change_choice != 0: - _choice += change_choice - - if _choice < 0: - _choice = len(_conversation[_page].choices) - 1 - elif _choice > len(_conversation[_page].choices) - 1: - _choice = 0 - - _handle_dialogue_change_choice(true) - - _reset_keys_states() - - -func _input(event): - if event.is_action_pressed(_interact_key): - _interact_key_pressed = true - else: - _interact_key_pressed = false - - # Do not check up/down keys if text is not complete - if _dialogue_box.is_complete(): - if event.is_action_pressed(_up_key): - _up_key_pressed = 1 - else: - _up_key_pressed = 0 - - if event.is_action_pressed(_down_key): - _down_key_pressed = 1 - else: - _down_key_pressed = 0 + _interact_key_pressed = false + _up_key_pressed = 0 + _down_key_pressed = 0 + + +func _process(_delta: float) -> void: + if _page < 0 or _page >= _conversation.size(): + if _interact_key_pressed: + _handle_exit(0.2) + return + + if not _dialogue_text_box.is_complete(): + if _interact_key_pressed: + _dialogue_text_box.show_all_text() + _reset_keys_states() + return + + # Interact behaviour + if _interact_key_pressed: + if _conversation[_page].type == Types.DIALOG_TYPE.NORMAL: + _page = _conversation[_page].next + if _page != -1: + _setup() + else: + _handle_exit(0.5) + elif _conversation[_page].type == Types.DIALOG_TYPE.CHOICE and not _chosen: + _chosen = true + _handle_dialogue_choice() + # Change Choice + elif _down_key_pressed or _up_key_pressed: + var change_choice = _down_key_pressed - _up_key_pressed + if change_choice != 0: + _choice += change_choice + + if _choice < 0: + _choice = len(_conversation[_page].choices) - 1 + elif _choice > len(_conversation[_page].choices) - 1: + _choice = 0 + + _handle_dialogue_change_choice(true) + + _reset_keys_states() + + +func _input(event: InputEvent) -> void: + if event.is_action_pressed(_interact_key): + _interact_key_pressed = true + else: + _interact_key_pressed = false + + # Do not check up/down keys if text is not complete + if _dialogue_text_box.is_complete(): + if event.is_action_pressed(_up_key): + _up_key_pressed = 1 + else: + _up_key_pressed = 0 + + if event.is_action_pressed(_down_key): + _down_key_pressed = 1 + else: + _down_key_pressed = 0 func _reset() -> void: - _choice = 0 - _chosen = false - _pause = false + _choice = 0 + _chosen = false + _pause = false + _name_box.visible = false + _portrait_box.visible = false func _setup() -> void: - _reset() + if _page < 0: + return - _portrait_box.setup( - load(_conversation[0].portrait.portrait_path) as SpriteFrames, _voice_snd_effect - ) + _reset() - if _page < 0 or _page >= _conversation.size(): - printerr("Wrong conversation position.") - return + if _page >= _conversation.size(): + printerr("Wrong conversation position.") + return - var name_str = _conversation[_page].name - _name_box.visible = !name_str.is_empty() - if _name_box.visible: - _name_box_text.change_name(name_str) + var portrait = _conversation[_page].portrait + if portrait: + _portrait_box.visible = true + _portrait_box.setup(load(portrait.portrait_path) as Texture2D, _voice_snd_effect) - var text = _conversation[_page].text - if _conversation[_page].type == Types.DialogType.CHOICE: - _handle_dialogue_change_choice() - return + var name_str = _conversation[_page].name + _name_box.visible = !name_str.is_empty() + if _name_box.visible: + _name_box_text.character_name = name_str - _dialogue_box.set_text(text, _default_font) + var text = _conversation[_page].text + if _conversation[_page].type == Types.DIALOG_TYPE.CHOICE: + _handle_dialogue_change_choice() + return + + _dialogue_text_box.set_text(text, _default_font) ## Handle the dialogue choice func _handle_dialogue_choice() -> void: - _handle_pause(0.1) + _handle_pause(0.1) - if _choice > _conversation.size(): - printerr("Choice position out of conversation.") - queue_free() - return + if _choice > _conversation.size(): + printerr("Choice position out of conversation.") + queue_free() + return - if _choice == -1: - queue_free() - return + if _choice == -1: + queue_free() + return - _page = _conversation[_page].choices[_choice].next - _setup() + _page = _conversation[_page].choices[_choice].next + _setup() func _handle_dialogue_change_choice(visible: bool = false) -> void: - var text = _conversation[_page].text - for choice_index in _conversation[_page].choices.size(): - var choice_text = _conversation[_page].choices[choice_index].text + var text = _conversation[_page].text + for choice_index in _conversation[_page].choices.size(): + var choice_text = _conversation[_page].choices[choice_index].text - text += "\n" + text += "\n" - if choice_index == _choice: - text += "[color=" + _default_choice.to_html() + "]" + choice_text + "[/color]" - else: - text += choice_text + if choice_index == _choice: + text += "[color=" + _default_choice.to_html() + "]" + choice_text + "[/color]" + else: + text += choice_text - _dialogue_box.set_text(text, _default_font, _default_color, visible) + _dialogue_text_box.set_text(text, _default_font, _default_color, visible) func _handle_pause(time: float) -> void: - _pause = true - await get_tree().create_timer(time) - _pause = false + _pause = true + await get_tree().create_timer(time) + _pause = false func _handle_exit(time: float) -> void: - if _exiting: - return + if _exiting: + return - _exiting = true - await get_tree().create_timer(time) - queue_free() + _exiting = true + await get_tree().create_timer(time) + queue_free() diff --git a/Nodes/DialogueSystem.gd.uid b/Nodes/DialogueSystem.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/DialogueTheme.tscn b/Nodes/DialogueTheme.tscn old mode 100644 new mode 100755 diff --git a/Nodes/Effects/RichTextEffectFlicker.gd b/Nodes/Effects/RichTextEffectFlicker.gd old mode 100644 new mode 100755 index db1edcf..610e083 --- a/Nodes/Effects/RichTextEffectFlicker.gd +++ b/Nodes/Effects/RichTextEffectFlicker.gd @@ -9,11 +9,11 @@ var bbcode = "flicker" func _process_custom_fx(char_fx): - # Get parameters, or use the provided default value if missing. - var speed = char_fx.env.get("freq", 5.0) + # Get parameters, or use the provided default value if missing. + var speed = char_fx.env.get("freq", 5.0) - var val: float = char_fx.elapsed_time * 100 - var shift: float = sin(val * PI * speed / SuadaGlobals.TARGET_FPS) + randf_range(-1.0, 1.0) - char_fx.color.a = shift + var val: float = char_fx.elapsed_time * 100 + var shift: float = sin(val * PI * speed / SuadaGlobals.TARGET_FPS) + randf_range(-1.0, 1.0) + char_fx.color.a = shift - return true + return true diff --git a/Nodes/Effects/RichTextEffectFlicker.gd.uid b/Nodes/Effects/RichTextEffectFlicker.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/Effects/RichTextEffectGhost.gd b/Nodes/Effects/RichTextEffectGhost.gd old mode 100644 new mode 100755 index c09c9ea..04c0238 --- a/Nodes/Effects/RichTextEffectGhost.gd +++ b/Nodes/Effects/RichTextEffectGhost.gd @@ -9,11 +9,11 @@ var bbcode = "ghost" func _process_custom_fx(char_fx): - # Get parameters, or use the provided default value if missing. - var speed = char_fx.env.get("freq", 5.0) - var span = char_fx.env.get("span", 10.0) + # Get parameters, or use the provided default value if missing. + var speed = char_fx.env.get("freq", 5.0) + var span = char_fx.env.get("span", 10.0) - var alpha = sin(char_fx.elapsed_time * speed + (char_fx.range.x / span)) * 0.5 + 0.5 - char_fx.color.a = alpha + var alpha = sin(char_fx.elapsed_time * speed + (char_fx.range.x / span)) * 0.5 + 0.5 + char_fx.color.a = alpha - return true + return true diff --git a/Nodes/Effects/RichTextEffectGhost.gd.uid b/Nodes/Effects/RichTextEffectGhost.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/Effects/RichTextEffectMatrix.gd b/Nodes/Effects/RichTextEffectMatrix.gd old mode 100644 new mode 100755 index bb391b8..4224c9e --- a/Nodes/Effects/RichTextEffectMatrix.gd +++ b/Nodes/Effects/RichTextEffectMatrix.gd @@ -10,26 +10,24 @@ var bbcode = "matrix" # Gets TextServer for retrieving font information. func get_text_server(): - return TextServerManager.get_primary_interface() + return TextServerManager.get_primary_interface() func _process_custom_fx(char_fx): - # Get parameters, or use the provided default value if missing. - var clear_time = char_fx.env.get("clean", 2.0) - var dirty_time = char_fx.env.get("dirty", 1.0) - var text_span = char_fx.env.get("span", 50) + # Get parameters, or use the provided default value if missing. + var clear_time = char_fx.env.get("clean", 2.0) + var dirty_time = char_fx.env.get("dirty", 1.0) + var text_span = char_fx.env.get("span", 50) - var value = char_fx.glyph_index + var value = char_fx.glyph_index - var matrix_time = fmod( - char_fx.elapsed_time + (char_fx.range.x / float(text_span)), clear_time + dirty_time - ) + var matrix_time = fmod(char_fx.elapsed_time + (char_fx.range.x / float(text_span)), clear_time + dirty_time) - matrix_time = 0.0 if matrix_time < clear_time else (matrix_time - clear_time) / dirty_time + matrix_time = 0.0 if matrix_time < clear_time else (matrix_time - clear_time) / dirty_time - if matrix_time > 0.0: - value = int(1 * matrix_time * (126 - 65)) - value %= (126 - 65) - value += 65 - char_fx.glyph_index = get_text_server().font_get_glyph_index(char_fx.font, 1, value, 0) - return true + if matrix_time > 0.0: + value = int(1 * matrix_time * (126 - 65)) + value %= (126 - 65) + value += 65 + char_fx.glyph_index = get_text_server().font_get_glyph_index(char_fx.font, 1, value, 0) + return true diff --git a/Nodes/Effects/RichTextEffectMatrix.gd.uid b/Nodes/Effects/RichTextEffectMatrix.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/Effects/RichTextEffectPulse.gd b/Nodes/Effects/RichTextEffectPulse.gd old mode 100644 new mode 100755 index 8c2641b..5ed0857 --- a/Nodes/Effects/RichTextEffectPulse.gd +++ b/Nodes/Effects/RichTextEffectPulse.gd @@ -9,14 +9,14 @@ var bbcode = "pulse" func _process_custom_fx(char_fx): - # Get parameters, or use the provided default value if missing. - var color = Color(char_fx.env.get("color", Color(1, 1, 1, 0.2))) - var freq = char_fx.env.get("freq", 1.0) - var param_ease = char_fx.env.get("ease", -2.0) - var height = char_fx.env.get("height", 0) + # Get parameters, or use the provided default value if missing. + var color = Color(char_fx.env.get("color", Color(1, 1, 1, 0.2))) + var freq = char_fx.env.get("freq", 1.0) + var param_ease = char_fx.env.get("ease", -2.0) + var height = char_fx.env.get("height", 0) - var sined_time = ease(pingpong(char_fx.elapsed_time, 1.0 / freq) * freq, param_ease) - var y_off = sined_time * height - char_fx.color = char_fx.color.lerp(char_fx.color * color, sined_time) - char_fx.offset = Vector2(0, -1) * y_off - return true + var sined_time = ease(pingpong(char_fx.elapsed_time, 1.0 / freq) * freq, param_ease) + var y_off = sined_time * height + char_fx.color = char_fx.color.lerp(char_fx.color * color, sined_time) + char_fx.offset = Vector2(0, -1) * y_off + return true diff --git a/Nodes/Effects/RichTextEffectPulse.gd.uid b/Nodes/Effects/RichTextEffectPulse.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/Effects/RichTextEffectShift.gd b/Nodes/Effects/RichTextEffectShift.gd old mode 100644 new mode 100755 index b038077..aae12a7 --- a/Nodes/Effects/RichTextEffectShift.gd +++ b/Nodes/Effects/RichTextEffectShift.gd @@ -9,11 +9,11 @@ var bbcode = "shift" func _process_custom_fx(char_fx): - # Get parameters, or use the provided default value if missing. - var speed = char_fx.env.get("freq", 5.0) + # Get parameters, or use the provided default value if missing. + var speed = char_fx.env.get("freq", 5.0) - var color_value: float = char_fx.elapsed_time * speed / 255 - var color_normalized: float = color_value - floor(color_value) - char_fx.color = Color.from_hsv(color_normalized, 1, 1) + var color_value: float = char_fx.elapsed_time * speed / 255 + var color_normalized: float = color_value - floor(color_value) + char_fx.color = Color.from_hsv(color_normalized, 1, 1) - return true + return true diff --git a/Nodes/Effects/RichTextEffectShift.gd.uid b/Nodes/Effects/RichTextEffectShift.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/Effects/RichTextEffectSpin.gd b/Nodes/Effects/RichTextEffectSpin.gd index 9c6794c..8ed1186 100755 --- a/Nodes/Effects/RichTextEffectSpin.gd +++ b/Nodes/Effects/RichTextEffectSpin.gd @@ -9,11 +9,11 @@ var bbcode = "spin" func _process_custom_fx(char_fx: CharFXTransform): - var freq = char_fx.env.get("freq", 5.0) + var freq = char_fx.env.get("freq", 5.0) - var val: float = char_fx.elapsed_time * 100 - var shift: float = sin(val * PI * freq / SuadaGlobals.TARGET_FPS) - var rotation = shift / 4 - char_fx.transform = char_fx.transform.rotated_local(rotation) + var val: float = char_fx.elapsed_time * 100 + var shift: float = sin(val * PI * freq / SuadaGlobals.TARGET_FPS) + var rotation = shift / 4 + char_fx.transform = char_fx.transform.rotated_local(rotation) - return true + return true diff --git a/Nodes/Effects/RichTextEffectSpin.gd.uid b/Nodes/Effects/RichTextEffectSpin.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/FinishEffect.gd b/Nodes/FinishEffect.gd index 4b52554..c2639c4 100644 --- a/Nodes/FinishEffect.gd +++ b/Nodes/FinishEffect.gd @@ -3,13 +3,14 @@ extends Sprite2D var _cnt: int = 0 -func _ready(): - visible = false +func _ready() -> void: + visible = false -func _process(_delta): - if visible: - _cnt += 1 - var shift: float = sin(_cnt * PI * SuadaGlobals.FREQUENCY / SuadaGlobals.TARGET_FPS) * 0.1 +func _process(_delta: float) -> void: + if not visible: + return - position.y += shift + _cnt += 1 + var shift: float = sin(_cnt * PI * SuadaGlobals.FREQUENCY / SuadaGlobals.TARGET_FPS) * 0.1 + position.y += shift diff --git a/Nodes/FinishEffect.gd.uid b/Nodes/FinishEffect.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/Globals/BBCCodes.gd b/Nodes/Globals/BBCCodes.gd old mode 100644 new mode 100755 index ceb4196..b2114fb --- a/Nodes/Globals/BBCCodes.gd +++ b/Nodes/Globals/BBCCodes.gd @@ -5,7 +5,7 @@ enum BBC_EFFECT { NONE, WAIT } # BBCode effects. const BBC_CODES_MAP: Dictionary[String, BBC_EFFECT] = { - "wait": BBC_EFFECT.WAIT, + "wait": BBC_EFFECT.WAIT, } # BBCode regular expression. diff --git a/Nodes/Globals/BBCCodes.gd.uid b/Nodes/Globals/BBCCodes.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/Globals/SuadaConfig.gd b/Nodes/Globals/SuadaConfig.gd old mode 100644 new mode 100755 diff --git a/Nodes/Globals/SuadaConfig.gd.uid b/Nodes/Globals/SuadaConfig.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/Globals/SuadaGlobals.gd b/Nodes/Globals/SuadaGlobals.gd old mode 100644 new mode 100755 diff --git a/Nodes/Globals/SuadaGlobals.gd.uid b/Nodes/Globals/SuadaGlobals.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/Globals/Types.gd b/Nodes/Globals/Types.gd old mode 100644 new mode 100755 index 3a818a5..b421d90 --- a/Nodes/Globals/Types.gd +++ b/Nodes/Globals/Types.gd @@ -1,4 +1,4 @@ class_name Types ## Dialog types. -enum DialogType { NORMAL, CHOICE } +enum DIALOG_TYPE { NORMAL, CHOICE } diff --git a/Nodes/Globals/Types.gd.uid b/Nodes/Globals/Types.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/NameBox.gd b/Nodes/NameBox.gd index 837dda7..872bca7 100644 --- a/Nodes/NameBox.gd +++ b/Nodes/NameBox.gd @@ -1,28 +1,28 @@ +class_name NameBox extends Control const OFFSET: int = 10 var _text_diff: int = -1 -@onready var _name_box_panel: Panel = $NameBoxPanel -@onready var _name_box_text: RichTextLabel = $NameTextBox +@export var _name_box_panel: Panel +@export var _name_box_text: RichTextLabel func _ready(): - _text_diff = (_name_box_panel.size.x - ceil(_name_box_text.size.x * _name_box_text.scale.x)) + _text_diff = (_name_box_panel.size.x - ceil(_name_box_text.size.x * _name_box_text.scale.x)) func _resize_box(width: int) -> void: - var new_width = width + OFFSET + var new_width = width + OFFSET - _name_box_panel.rect_size.x = new_width - _name_box_text.rect_size.x = ceil((new_width - _text_diff) / _name_box_text.rect_scale.x) + _name_box_panel.rect_size.x = new_width + _name_box_text.rect_size.x = ceil((new_width - _text_diff) / _name_box_text.rect_scale.x) func set_name_label(name: String, font: Font) -> void: - var name_width = font.get_string_size(name).x + var name_width = font.get_string_size(name).x - if name_width > _name_box_text.rect_size.x: - _resize_box(name_width) - - _name_box_text.bbcode_text = "[center]" + name + "[/center]" + if name_width > _name_box_text.rect_size.x: + _resize_box(name_width) + _name_box_text.bbcode_text = "[center]" + name + "[/center]" diff --git a/Nodes/NameBox.gd.uid b/Nodes/NameBox.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/NameText.gd b/Nodes/NameText.gd old mode 100644 new mode 100755 index 1068bba..99b8bcf --- a/Nodes/NameText.gd +++ b/Nodes/NameText.gd @@ -1,19 +1,13 @@ -class_name NameTextBox +class_name NameText extends RichTextLabel -var character_name: String = "Name": - get: - return character_name - - -func _ready(): - update() +var character_name: String: + get: + return name + set(value): + name = value + update() func update(): - text = "[center]" + character_name + "[/center]" - - -func change_name(character_name: String): - self.character_name = character_name - update() + text = "[center]" + character_name + "[/center]" diff --git a/Nodes/NameText.gd.uid b/Nodes/NameText.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/Objects/Choice.gd b/Nodes/Objects/Choice.gd old mode 100644 new mode 100755 index 3b3d455..6a114ba --- a/Nodes/Objects/Choice.gd +++ b/Nodes/Objects/Choice.gd @@ -11,5 +11,5 @@ var next: int = -1 ## Initialise the dialog object. func _init(text: String, next: int = -1): - self.text = text - self.next = next + self.text = text + self.next = next diff --git a/Nodes/Objects/Choice.gd.uid b/Nodes/Objects/Choice.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/Objects/Conversation.gd b/Nodes/Objects/Conversation.gd old mode 100644 new mode 100755 index d088929..9a074ae --- a/Nodes/Objects/Conversation.gd +++ b/Nodes/Objects/Conversation.gd @@ -7,10 +7,10 @@ extends Resource var dialogs: Array[Dialog] = [] var length: int = 0: - get: - return dialogs.size() + get: + return dialogs.size() ## Initialise the dialog object. func _init(dialogs: Array[Dialog]): - self.dialogs = dialogs + self.dialogs = dialogs diff --git a/Nodes/Objects/Conversation.gd.uid b/Nodes/Objects/Conversation.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/Objects/Dialog.gd b/Nodes/Objects/Dialog.gd old mode 100644 new mode 100755 index e6388b6..3a982ca --- a/Nodes/Objects/Dialog.gd +++ b/Nodes/Objects/Dialog.gd @@ -9,28 +9,26 @@ var id: int = -1 var text: String = "" var name: String = "" var portrait: Portrait = null -var type: int = Types.DialogType.NORMAL +var type: int = Types.DIALOG_TYPE.NORMAL var choices: Array[Choice] = [] var next: int = -1 ## Initialise the dialog object. func _init( - id: int, - text: String, - name: String, - portrait_path: String, - type: int, - next = -1, - choices: Array[Choice] = [] + id: int, + text: String, + name: String, + portrait_path: String, + next = -1, + choices: Array[Choice] = [] ): - self.id = id - self.text = text - self.name = name + self.id = id + self.text = text + self.name = name - if !portrait_path.is_empty(): - portrait = Portrait.new(portrait_path) - - self.type = type - self.next = next - self.choices = choices + if !portrait_path.is_empty(): + portrait = Portrait.new(portrait_path) + self.type = Types.DIALOG_TYPE.NORMAL if choices.size() == 0 else Types.DIALOG_TYPE.CHOICE + self.next = next + self.choices = choices diff --git a/Nodes/Objects/Dialog.gd.uid b/Nodes/Objects/Dialog.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/Objects/EffectLocation.gd b/Nodes/Objects/EffectLocation.gd old mode 100644 new mode 100755 index a1c4fc1..54ba6a6 --- a/Nodes/Objects/EffectLocation.gd +++ b/Nodes/Objects/EffectLocation.gd @@ -9,5 +9,5 @@ var value: String func _init(ef: BBCCodes.BBC_EFFECT, val: String): - effect = ef - value = val + effect = ef + value = val diff --git a/Nodes/Objects/EffectLocation.gd.uid b/Nodes/Objects/EffectLocation.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/Objects/ParsedDialog.gd b/Nodes/Objects/ParsedDialog.gd old mode 100644 new mode 100755 index 16be926..03ece08 --- a/Nodes/Objects/ParsedDialog.gd +++ b/Nodes/Objects/ParsedDialog.gd @@ -9,13 +9,13 @@ var text: String = "" var effects: Dictionary[int, EffectLocation] = {} var text_len: int: - get: - return text.length() + get: + return text.length() var effects_len: int: - get: - return effects.size() + get: + return effects.size() func _init(text: String): - orig_text = text + orig_text = text diff --git a/Nodes/Objects/ParsedDialog.gd.uid b/Nodes/Objects/ParsedDialog.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/Objects/Portrait.gd b/Nodes/Objects/Portrait.gd old mode 100644 new mode 100755 index e111383..51b7249 --- a/Nodes/Objects/Portrait.gd +++ b/Nodes/Objects/Portrait.gd @@ -13,11 +13,7 @@ var animation_trigger: int = 120 var animation_trigger_range: Vector2 = Vector2(100, 200) -func _init( - portrait_path: String, - animation_trigger: int = 100, - animation_trigger_range: Vector2 = Vector2(100, 200) -): - self.portrait_path = portrait_path - self.animation_trigger = animation_trigger - self.animation_trigger_range = animation_trigger_range +func _init(portrait_path: String, animation_trigger: int = 100, animation_trigger_range: Vector2 = Vector2(100, 200)): + self.portrait_path = portrait_path + self.animation_trigger = animation_trigger + self.animation_trigger_range = animation_trigger_range diff --git a/Nodes/Objects/Portrait.gd.uid b/Nodes/Objects/Portrait.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/Objects/Types.gd b/Nodes/Objects/Types.gd deleted file mode 100644 index c65278e..0000000 --- a/Nodes/Objects/Types.gd +++ /dev/null @@ -1,2 +0,0 @@ -## Dialog types. -enum DialogType { NORMAL, CHOICE } diff --git a/Nodes/PortraitBox.gd b/Nodes/PortraitBox.gd index a826d4c..6a75898 100644 --- a/Nodes/PortraitBox.gd +++ b/Nodes/PortraitBox.gd @@ -1,21 +1,21 @@ class_name PortraitBox extends Control -@onready var _audio_player: DialogueAudioPlayer = $"../../AudioPlayer" -@onready var _portrait: PortraitFrame = $Panel/Portrait +@export var _audio_player: DialogueAudioPlayer +@export var _portrait: PortraitFrame -func setup(portrait: SpriteFrames, audio: AudioStream) -> void: - _portrait.setup(portrait, 1, Vector2(1, 2)) - _audio_player.set_voice_sound(audio) +func setup(portrait: Texture2D, audio: AudioStream) -> void: + # _portrait.setup(portrait, 1, Vector2(1, 2)) + _audio_player.set_voice(audio) -func set_voice_sound(audio: AudioStream) -> void: - _audio_player.set_voice_sound(audio) +func set_voice(audio: AudioStream) -> void: + _audio_player.set_voice(audio) ## Play the voice sound. ## Pass True to wait for previous sound to finish, otherwise False. -func play_voice(talk_anim: String = "talk", wait_to_play: bool = false) -> void: - _portrait.play_animation(talk_anim) - _audio_player.play_voice_sound(wait_to_play) +func play_voice(talk_anim: String = "Talk", wait_to_play: bool = false) -> void: + _audio_player.play_voice(wait_to_play) + _portrait.play_animation(talk_anim) diff --git a/Nodes/PortraitBox.gd.uid b/Nodes/PortraitBox.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/PortraitFrame.gd b/Nodes/PortraitFrame.gd new file mode 100755 index 0000000..7af2061 --- /dev/null +++ b/Nodes/PortraitFrame.gd @@ -0,0 +1,20 @@ +class_name PortraitFrame +extends Sprite2D + +# Exports +@export var anim_tree: AnimationTree + +@onready var state: AnimationNodeStateMachinePlayback = anim_tree.get("parameters/playback") + + +func _ready(): + state.travel("Idle") + pass + + +func setup(portrait: Texture2D): + texture = portrait + + +func play_animation(animation_str: String) -> void: + state.travel(animation_str) diff --git a/Nodes/PortraitFrame.gd.uid b/Nodes/PortraitFrame.gd.uid new file mode 100755 index 0000000..7b5b2c6 --- /dev/null +++ b/Nodes/PortraitFrame.gd.uid @@ -0,0 +1 @@ +uid://ck2p0lyyoc81w diff --git a/Nodes/PortraitSprite.gd b/Nodes/PortraitSprite.gd deleted file mode 100644 index 445397b..0000000 --- a/Nodes/PortraitSprite.gd +++ /dev/null @@ -1,63 +0,0 @@ -class_name PortraitFrame -extends AnimatedSprite2D - -## Portrait states. -const PORTRAIT_STATES: Dictionary[String, int] = { - "idle": 0, ## Idle. - "talk": 1, ## Talking. -} - -## Portrait animations names -const PORTRAIT_ANIM_NAMES: Dictionary[String, String] = { - "idle": "idle", ## Idle. - "talk": "talk", ## Talk -} - -var _state: int = PORTRAIT_STATES.idle - -var _animation_cnt: float = -1 -var _animation_trigger: int = -1 -var _animation_trigger_range: Vector2 = Vector2(1, 1) - - -func _ready(): - connect("animation_finished", Callable(self, "_on_portrait_animation_finish")) - - -func _process(_delta): - _animation_cnt += 1 - if _state == PORTRAIT_STATES.idle and is_playing() and _animation_cnt >= _animation_trigger: - play() - - -func setup(portrait: SpriteFrames, animation_trigger: int, anim_trigger_range: Vector2) -> void: - set_portrait_sprite(portrait) - _animation_trigger = animation_trigger - _animation_trigger_range = anim_trigger_range - - -func set_portrait_sprite(portrait: SpriteFrames) -> void: - sprite_frames = portrait - animation = PORTRAIT_ANIM_NAMES.idle - _state = PORTRAIT_STATES.idle - - -func play_animation(animation_str: String) -> void: - if animation_str not in PORTRAIT_ANIM_NAMES and animation_str not in PORTRAIT_STATES: - printerr("Wrong animation name.") - return - - stop() - animation = PORTRAIT_ANIM_NAMES[animation_str] - _state = PORTRAIT_STATES[animation] - play() - - -func _on_portrait_animation_finish() -> void: - stop() - animation = PORTRAIT_ANIM_NAMES.idle - _state = PORTRAIT_STATES.idle - _animation_cnt = 0 - _animation_trigger = ( - randi() % (_animation_trigger_range.y as int) + _animation_trigger_range.x as int - ) diff --git a/Nodes/PortraitSprite.gd.uid b/Nodes/PortraitSprite.gd.uid old mode 100644 new mode 100755 diff --git a/Nodes/SuadaGlobals.gd b/Nodes/SuadaGlobals.gd old mode 100644 new mode 100755 diff --git a/Nodes/SuadaGlobals.gd.uid b/Nodes/SuadaGlobals.gd.uid new file mode 100755 index 0000000..83fb8d6 --- /dev/null +++ b/Nodes/SuadaGlobals.gd.uid @@ -0,0 +1 @@ +uid://bvghc33exjsf4 diff --git a/Nodes/Utils/BBCParser.gd b/Nodes/Utils/BBCParser.gd old mode 100644 new mode 100755 index 353e3e9..530b397 --- a/Nodes/Utils/BBCParser.gd +++ b/Nodes/Utils/BBCParser.gd @@ -1,22 +1,6 @@ class_name BBCParser -static func _get_value(text: String, pos: int) -> Array: - var value = "" - - while pos < text.length(): - var in_letter: String = text[pos] - - if in_letter != "]" && in_letter != "/" && in_letter != "=": - value += in_letter - elif in_letter == "]": - break - - pos += 1 - - return [value, pos] - - ## Parse a text to get the data to show it on the dialog. ## ## Returns a [ParseReturn] object with the data without BBCodes and a list of effects and colours @@ -27,44 +11,38 @@ static func _get_value(text: String, pos: int) -> Array: ## @param text The text to parse. ## @returns A [ParseReturn] object. static func parse(text: String) -> ParsedDialog: - var parsed_dialog := ParsedDialog.new(text) - - var regex: RegEx = RegEx.new() - regex.compile(BBCCodes.BBC_REXP) - - while regex.search(text): - var regex_match = regex.search(text) - var match_start = regex_match.get_start() + var parsed_dialog := ParsedDialog.new(text) - if ( - regex_match.get_group_count() != 3 - and !BBCCodes.BBC_CODES_MAP.has(regex_match.strings[1]) - ): - printerr("Wrong BBCode format") - return parsed_dialog + var regex: RegEx = RegEx.new() + regex.compile(BBCCodes.BBC_REXP) - var effect = BBCCodes.BBC_CODES_MAP[regex_match.strings[1]] - var effect_value = regex_match.strings[2] - parsed_dialog.effects[match_start] = EffectLocation.new(effect, effect_value) + while regex.search(text): + var regex_match = regex.search(text) + var match_start = regex_match.get_start() - var new_text = text.substr(0, match_start) - var match_end = regex_match.get_end() - new_text += text.substr(match_end) - text = new_text + if regex_match.get_group_count() != 3 and !BBCCodes.BBC_CODES_MAP.has(regex_match.strings[1]): + printerr("Wrong BBCode format") + return parsed_dialog + var effect = BBCCodes.BBC_CODES_MAP[regex_match.strings[1]] + var effect_value = regex_match.strings[2] + parsed_dialog.effects[match_start] = EffectLocation.new(effect, effect_value) - return parsed_dialog + var new_text = text.substr(0, match_start) + var match_end = regex_match.get_end() + new_text += text.substr(match_end) + text = new_text + return parsed_dialog static func bbc_remover(text: String, regex_str: String) -> String: - var regex := RegEx.new() - regex.compile(regex_str) - - var out = "" - var last_pos = 0 - for regex_match in regex.search_all(text): - var start := regex_match.get_start() - out += text.substr(last_pos, start - last_pos) - last_pos = regex_match.get_end() - - out += text.substr(last_pos) - return out + var regex := RegEx.new() + regex.compile(regex_str) + + var out = "" + var last_pos = 0 + for regex_match in regex.search_all(text): + var start := regex_match.get_start() + out += text.substr(last_pos, start - last_pos) + last_pos = regex_match.get_end() + out += text.substr(last_pos) + return out diff --git a/Nodes/Utils/BBCParser.gd.uid b/Nodes/Utils/BBCParser.gd.uid old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/Scenes/Dialogue.tscn b/Scenes/Dialogue.tscn index a4bfdc4..986b0f6 100644 --- a/Scenes/Dialogue.tscn +++ b/Scenes/Dialogue.tscn @@ -1,22 +1,52 @@ -[gd_scene load_steps=28 format=3 uid="uid://x6mnw54gmo8v"] +[gd_scene load_steps=39 format=3 uid="uid://x6mnw54gmo8v"] -[ext_resource type="Script" uid="uid://7u5tl70iop21" path="res://addons/Suada_bk/Nodes/DialogueSystem.gd" id="1"] +[ext_resource type="Script" uid="uid://7u5tl70iop21" path="res://addons/Suada/Nodes/DialogueSystem.gd" id="1"] [ext_resource type="Theme" uid="uid://ddetutsupn7m0" path="res://addons/Suada/Assets/Themes/name_theme.tres" id="2"] +[ext_resource type="Script" uid="uid://by5tek2mm1kds" path="res://addons/Suada/Nodes/PortraitBox.gd" id="2_jstwi"] [ext_resource type="Theme" uid="uid://bruovco3l4r7k" path="res://addons/Suada/Assets/Themes/main_theme.tres" id="3"] -[ext_resource type="Texture2D" uid="uid://d4d46x70xfeaa" path="res://addons/Suada_bk/Assets/Sprites/indicator.png" id="5"] -[ext_resource type="Script" uid="uid://dxciertla70xt" path="res://addons/Suada_bk/Nodes/DialogueBox.gd" id="8"] -[ext_resource type="Script" uid="uid://by5tek2mm1kds" path="res://addons/Suada_bk/Nodes/PortraitBox.gd" id="9"] -[ext_resource type="SpriteFrames" uid="uid://b5l6qnwf46vyd" path="res://addons/Suada/Assets/Animations/Portrait_base_anim.tres" id="9_rdh7m"] -[ext_resource type="Script" uid="uid://blrkxba5rjrdd" path="res://addons/Suada_bk/Nodes/Effects/RichTextEffectGhost.gd" id="9_ydpfn"] -[ext_resource type="Script" uid="uid://bisrw25bck2i6" path="res://addons/Suada_bk/Nodes/DialogueAudioPlayer.gd" id="10"] -[ext_resource type="Script" uid="uid://biw6a0o6espjc" path="res://addons/Suada_bk/Nodes/Effects/RichTextEffectPulse.gd" id="10_mlhx6"] -[ext_resource type="Script" uid="uid://cvnq24ncd7wdb" path="res://addons/Suada_bk/Nodes/FinishEffect.gd" id="10_typqo"] -[ext_resource type="Script" uid="uid://wx5n10oc1vki" path="res://addons/Suada_bk/Nodes/PortraitSprite.gd" id="11"] -[ext_resource type="Script" uid="uid://cojx35wpxirrm" path="res://addons/Suada_bk/Nodes/Effects/RichTextEffectMatrix.gd" id="11_53617"] -[ext_resource type="Script" uid="uid://5yswxgvifti8" path="res://addons/Suada_bk/Nodes/Effects/RichTextEffectFlicker.gd" id="11_bbs34"] -[ext_resource type="Script" uid="uid://bbvp37cw5mk81" path="res://addons/Suada_bk/Nodes/Effects/RichTextEffectSpin.gd" id="12_2n2xh"] -[ext_resource type="Script" uid="uid://dt3sbbh26vbd8" path="res://addons/Suada_bk/Nodes/NameText.gd" id="12_mja5r"] -[ext_resource type="Script" uid="uid://drmvnbvsiehsq" path="res://addons/Suada_bk/Nodes/Effects/RichTextEffectShift.gd" id="12_njesn"] +[ext_resource type="Texture2D" uid="uid://d4d46x70xfeaa" path="res://addons/Suada/Assets/Sprites/indicator.png" id="5"] +[ext_resource type="Script" uid="uid://ck2p0lyyoc81w" path="res://addons/Suada/Nodes/PortraitFrame.gd" id="5_owmf0"] +[ext_resource type="Texture2D" uid="uid://brgog63rm2a5c" path="res://addons/Suada/Assets/Sprites/Eyes.png" id="6_pu34k"] +[ext_resource type="Texture2D" uid="uid://4mqv4h4t4yw8" path="res://addons/Suada/Assets/Sprites/Rela.png" id="6_tfncl"] +[ext_resource type="AnimationLibrary" uid="uid://fbnywhgnxp4t" path="res://addons/Suada/Assets/Animations/FaceAnimation.res" id="7_73o6y"] +[ext_resource type="Script" uid="uid://dxciertla70xt" path="res://addons/Suada/Nodes/DialogueBox.gd" id="8"] +[ext_resource type="Script" uid="uid://blrkxba5rjrdd" path="res://addons/Suada/Nodes/Effects/RichTextEffectGhost.gd" id="9_ydpfn"] +[ext_resource type="AnimationNodeStateMachine" uid="uid://ly7ccqfk3mok" path="res://addons/Suada/Assets/Animations/EyesBaseAnimationRoot.tres" id="10_73o6y"] +[ext_resource type="Script" uid="uid://biw6a0o6espjc" path="res://addons/Suada/Nodes/Effects/RichTextEffectPulse.gd" id="10_mlhx6"] +[ext_resource type="AnimationLibrary" uid="uid://c5dskldy72a46" path="res://addons/Suada/Assets/Animations/EyesAnimation.res" id="10_owmf0"] +[ext_resource type="Script" uid="uid://cvnq24ncd7wdb" path="res://addons/Suada/Nodes/FinishEffect.gd" id="10_typqo"] +[ext_resource type="Script" uid="uid://cojx35wpxirrm" path="res://addons/Suada/Nodes/Effects/RichTextEffectMatrix.gd" id="11_53617"] +[ext_resource type="Script" uid="uid://5yswxgvifti8" path="res://addons/Suada/Nodes/Effects/RichTextEffectFlicker.gd" id="11_bbs34"] +[ext_resource type="Script" uid="uid://bbvp37cw5mk81" path="res://addons/Suada/Nodes/Effects/RichTextEffectSpin.gd" id="12_2n2xh"] +[ext_resource type="Script" uid="uid://drmvnbvsiehsq" path="res://addons/Suada/Nodes/Effects/RichTextEffectShift.gd" id="12_njesn"] +[ext_resource type="Script" uid="uid://c6du80pgr26nq" path="res://addons/Suada/Nodes/NameBox.gd" id="18_73o6y"] +[ext_resource type="Script" uid="uid://bisrw25bck2i6" path="res://addons/Suada/Nodes/DialogueAudioPlayer.gd" id="20_73o6y"] +[ext_resource type="Script" uid="uid://dt3sbbh26vbd8" path="res://addons/Suada/Nodes/NameText.gd" id="21_jr6s1"] + +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_jstwi"] +animation = &"Idle" + +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_73o6y"] +animation = &"Talk" + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_owmf0"] +advance_mode = 2 + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_jstwi"] +switch_mode = 2 +advance_mode = 2 + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_73o6y"] + +[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_rpgqq"] +states/End/position = Vector2(616, 47.3086) +states/Idle/node = SubResource("AnimationNodeAnimation_jstwi") +states/Idle/position = Vector2(418.963, 47.3169) +states/Start/position = Vector2(217.333, 47.1687) +states/Talk/node = SubResource("AnimationNodeAnimation_73o6y") +states/Talk/position = Vector2(418.444, 146.667) +transitions = ["Start", "Idle", SubResource("AnimationNodeStateMachineTransition_owmf0"), "Talk", "Idle", SubResource("AnimationNodeStateMachineTransition_jstwi"), "Idle", "Talk", SubResource("AnimationNodeStateMachineTransition_73o6y")] +graph_offset = Vector2(-218, -43) [sub_resource type="RichTextEffect" id="RichTextEffect_omcs0"] script = ExtResource("9_ydpfn") @@ -88,7 +118,7 @@ func _process_custom_fx(char_fx: CharFXTransform) -> bool: [sub_resource type="RichTextEffect" id="RichTextEffect_jiwwu"] script = SubResource("GDScript_qmumq") -[node name="Dialogue" type="Control"] +[node name="Dialogue" type="Control" node_paths=PackedStringArray("_dialogue_text_box", "_name_box", "_name_box_text", "_portrait_box")] layout_mode = 3 anchors_preset = 8 anchor_left = 0.5 @@ -103,6 +133,15 @@ grow_horizontal = 2 grow_vertical = 2 scale = Vector2(2, 2) script = ExtResource("1") +_default_color = null +_default_choice = null +_interact_key = null +_up_key = null +_down_key = null +_dialogue_text_box = NodePath("DialogueContainer/TextBox") +_name_box = NodePath("NameBox") +_name_box_text = NodePath("NameBox/TextBox/NameBoxText") +_portrait_box = NodePath("DialogueContainer/PortraitBox") [node name="DialogueContainer" type="HBoxContainer" parent="."] layout_mode = 0 @@ -111,27 +150,62 @@ offset_bottom = 72.0 size_flags_vertical = 8 theme_override_constants/separation = 0 -[node name="PortraitBox" type="MarginContainer" parent="DialogueContainer"] +[node name="PortraitBox" type="MarginContainer" parent="DialogueContainer" node_paths=PackedStringArray("_audio_player", "_portrait")] +physics_interpolation_mode = 0 custom_minimum_size = Vector2(72, 72) layout_mode = 2 -script = ExtResource("9") +script = ExtResource("2_jstwi") +_audio_player = NodePath("../../AudioPlayer") +_portrait = NodePath("Panel/Portrait") [node name="Panel" type="Panel" parent="DialogueContainer/PortraitBox"] layout_mode = 2 theme = ExtResource("3") -[node name="Portrait" type="AnimatedSprite2D" parent="DialogueContainer/PortraitBox/Panel"] +[node name="Portrait" type="Sprite2D" parent="DialogueContainer/PortraitBox/Panel" node_paths=PackedStringArray("anim_tree")] position = Vector2(4, 4) -sprite_frames = ExtResource("9_rdh7m") -animation = &"idle" +scale = Vector2(3.2, 3.2) +texture = ExtResource("6_tfncl") centered = false -script = ExtResource("11") +hframes = 2 +script = ExtResource("5_owmf0") +anim_tree = NodePath("PortraitAnimationTree") -[node name="TextBox" type="MarginContainer" parent="DialogueContainer"] +[node name="PortraitAnimationPlayer" type="AnimationPlayer" parent="DialogueContainer/PortraitBox/Panel/Portrait"] +libraries = { +&"": ExtResource("7_73o6y") +} + +[node name="PortraitAnimationTree" type="AnimationTree" parent="DialogueContainer/PortraitBox/Panel/Portrait"] +tree_root = SubResource("AnimationNodeStateMachine_rpgqq") +anim_player = NodePath("../PortraitAnimationPlayer") + +[node name="Eyes" type="Sprite2D" parent="DialogueContainer/PortraitBox/Panel"] +position = Vector2(4, 4) +scale = Vector2(3.2, 3.2) +texture = ExtResource("6_pu34k") +centered = false +hframes = 2 + +[node name="EyesAnimationPlayer" type="AnimationPlayer" parent="DialogueContainer/PortraitBox/Panel/Eyes"] +root_node = NodePath("../..") +libraries = { +&"": ExtResource("10_owmf0") +} + +[node name="EyesAnimationTree" type="AnimationTree" parent="DialogueContainer/PortraitBox/Panel/Eyes"] +root_node = NodePath("../..") +tree_root = ExtResource("10_73o6y") +anim_player = NodePath("../EyesAnimationPlayer") + +[node name="TextBox" type="MarginContainer" parent="DialogueContainer" node_paths=PackedStringArray("_text_label", "_portrait_box", "_finished_effect")] custom_minimum_size = Vector2(320, 70) layout_mode = 2 -size_flags_horizontal = 3 +size_flags_horizontal = 4 script = ExtResource("8") +_text_label = NodePath("Panel/Text") +_portrait_box = NodePath("../PortraitBox") +_finished_effect = NodePath("../PanelContainer/FinishEffect") [node name="Panel" type="Panel" parent="DialogueContainer/TextBox"] layout_mode = 2 @@ -155,22 +229,30 @@ scroll_active = false custom_effects = [SubResource("RichTextEffect_omcs0"), SubResource("RichTextEffect_mfy4b"), SubResource("RichTextEffect_p8ibk"), SubResource("RichTextEffect_i3ro0"), SubResource("RichTextEffect_kkw1g"), SubResource("RichTextEffect_s5tcp"), SubResource("RichTextEffect_xw4hv"), SubResource("RichTextEffect_jiwwu")] visible_characters_behavior = 2 -[node name="FinishEffect" type="Sprite2D" parent="DialogueContainer/TextBox"] -position = Vector2(311, 63.5) +[node name="PanelContainer" type="PanelContainer" parent="DialogueContainer"] +layout_mode = 2 +size_flags_horizontal = 8 +size_flags_vertical = 8 + +[node name="FinishEffect" type="Sprite2D" parent="DialogueContainer/PanelContainer"] +position = Vector2(-10, -10) rotation = 1.5708 scale = Vector2(0.25, 0.25) texture = ExtResource("5") script = ExtResource("10_typqo") -[node name="NameBox" type="MarginContainer" parent="."] +[node name="NameBox" type="MarginContainer" parent="." node_paths=PackedStringArray("_name_box_panel", "_name_box_text")] custom_minimum_size = Vector2(64, 25) layout_mode = 0 offset_left = 74.0 offset_top = -24.0 offset_right = 138.0 offset_bottom = 1.0 +script = ExtResource("18_73o6y") +_name_box_panel = NodePath("NameBoxPanel") +_name_box_text = NodePath("TextBox/NameBoxText") -[node name="Panel" type="Panel" parent="NameBox"] +[node name="NameBoxPanel" type="Panel" parent="NameBox"] layout_mode = 2 theme = ExtResource("2") @@ -180,7 +262,8 @@ theme_override_constants/margin_left = 5 theme_override_constants/margin_top = 5 theme_override_constants/margin_right = 5 -[node name="Text" type="RichTextLabel" parent="NameBox/TextBox"] +[node name="NameBoxText" type="RichTextLabel" parent="NameBox/TextBox"] +physics_interpolation_mode = 0 layout_mode = 2 theme = ExtResource("2") bbcode_enabled = true @@ -188,7 +271,10 @@ fit_content = true scroll_active = false autowrap_mode = 0 visible_characters_behavior = 2 -script = ExtResource("12_mja5r") +script = ExtResource("21_jr6s1") + +[node name="NameTextLabel" type="RichTextLabel" parent="NameBox/TextBox"] +layout_mode = 2 [node name="AudioPlayer" type="AudioStreamPlayer2D" parent="."] -script = ExtResource("10") +script = ExtResource("20_73o6y") diff --git a/SuadaPlugin.gd b/SuadaPlugin.gd old mode 100644 new mode 100755 index 866fe6e..5a1c723 --- a/SuadaPlugin.gd +++ b/SuadaPlugin.gd @@ -1,10 +1,42 @@ @tool extends EditorPlugin +const SUADA_EDITOR := preload("./UI/SuadaEditor.tscn") + +@export var suada_editor: SuadaEditor + + +func _init() -> void: + self.name = "SuadaPlugin" + func _enter_tree(): - add_autoload_singleton("SuadaConfig", "res://addons/Suada/Nodes/Globals/SuadaConfig.gd") + add_autoload_singleton("SuadaConfig", "res://addons/Suada/Nodes/Globals/SuadaConfig.gd") + + if Engine.is_editor_hint(): + Engine.set_meta("SuadaPlugin", self) + suada_editor = SUADA_EDITOR.instantiate() + suada_editor.hide() + EditorInterface.get_editor_main_screen().add_child(suada_editor) + _make_visible(false) func _exit_tree(): - remove_autoload_singleton("SuadaConfig") + remove_autoload_singleton("SuadaConfig") + + if is_instance_valid(suada_editor): + suada_editor.queue_free() + Engine.remove_meta("SuadaPlugin") + + +func _has_main_screen() -> bool: + return true + + +func _make_visible(visible: bool): + if suada_editor: + suada_editor.visible = visible + + +func _get_plugin_name() -> String: + return "SuadaPlugin" diff --git a/SuadaPlugin.gd.uid b/SuadaPlugin.gd.uid old mode 100644 new mode 100755 diff --git a/UI/SuadaEditor.gd b/UI/SuadaEditor.gd new file mode 100755 index 0000000..79e3c94 --- /dev/null +++ b/UI/SuadaEditor.gd @@ -0,0 +1,3 @@ +@tool +class_name SuadaEditor +extends MarginContainer diff --git a/UI/SuadaEditor.gd.uid b/UI/SuadaEditor.gd.uid new file mode 100755 index 0000000..bce683a --- /dev/null +++ b/UI/SuadaEditor.gd.uid @@ -0,0 +1 @@ +uid://u1x867y42ndo diff --git a/UI/SuadaEditor.tscn b/UI/SuadaEditor.tscn new file mode 100755 index 0000000..7b555ac --- /dev/null +++ b/UI/SuadaEditor.tscn @@ -0,0 +1,80 @@ +[gd_scene load_steps=3 format=3 uid="uid://nik7ox4130w5"] + +[ext_resource type="Script" uid="uid://u1x867y42ndo" path="res://addons/Suada/UI/SuadaEditor.gd" id="1_ugryu"] +[ext_resource type="Texture2D" uid="uid://b0p30x4icgtuy" path="res://addons/Suada/Assets/Icons/Folder.svg" id="2_n7dxj"] + +[node name="SuadaEditor" type="MarginContainer"] +clip_contents = true +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +script = ExtResource("1_ugryu") + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +layout_mode = 2 + +[node name="HeaderBar" type="HBoxContainer" parent="VBoxContainer"] +layout_mode = 2 + +[node name="File" type="Button" parent="VBoxContainer/HeaderBar"] +layout_mode = 2 +tooltip_text = "Open file" +icon = ExtResource("2_n7dxj") + +[node name="DataContent" type="HBoxContainer" parent="VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="VSplitContainer" type="HSplitContainer" parent="VBoxContainer/DataContent"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/DataContent/VSplitContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="LineEdit" type="LineEdit" parent="VBoxContainer/DataContent/VSplitContainer/VBoxContainer"] +layout_mode = 2 +placeholder_text = "Search..." + +[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer/DataContent/VSplitContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="Tree" type="Tree" parent="VBoxContainer/DataContent/VSplitContainer/VBoxContainer/ScrollContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="TabContainer" type="TabContainer" parent="VBoxContainer/DataContent/VSplitContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +size_flags_stretch_ratio = 4.0 +current_tab = 0 + +[node name="Dialogs" type="TabBar" parent="VBoxContainer/DataContent/VSplitContainer/TabContainer"] +layout_mode = 2 +metadata/_tab_index = 0 + +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/DataContent/VSplitContainer/TabContainer/Dialogs"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="CodeEdit" type="CodeEdit" parent="VBoxContainer/DataContent/VSplitContainer/TabContainer/Dialogs/HBoxContainer"] +layout_direction = 4 +layout_mode = 2 +size_flags_horizontal = 3 +placeholder_text = "Hello world!" +gutters_draw_line_numbers = true +indent_size = 2 +indent_use_spaces = true diff --git a/gdformatrc b/gdformatrc new file mode 100755 index 0000000..6ff99bb --- /dev/null +++ b/gdformatrc @@ -0,0 +1,2 @@ +excluded_directories: !!set + .git: null diff --git a/.gdlintrc b/gdlintrc old mode 100644 new mode 100755 similarity index 76% rename from .gdlintrc rename to gdlintrc index 785c3bc..7961317 --- a/.gdlintrc +++ b/gdlintrc @@ -2,9 +2,11 @@ class-definitions-order: - tools - classnames - extends +- docstrings - signals - enums - consts +- staticvars - exports - pubvars - prvvars @@ -15,11 +17,11 @@ class-load-variable-name: (([A-Z][a-z0-9]*)+|_?[a-z][a-z0-9]*(_[a-z0-9]+)*) class-name: ([A-Z][a-z0-9]*)+ class-variable-name: _?[a-z][a-z0-9]*(_[a-z0-9]+)* comparison-with-itself: null -constant-name: '[A-Z][A-Z0-9]*(_[A-Z0-9]+)*' +constant-name: _?[A-Z][A-Z0-9]*(_[A-Z0-9]+)* disable: [] duplicated-load: null enum-element-name: '[A-Z][A-Z0-9]*(_[A-Z0-9]+)*' -enum-name: ([A-Z][a-z0-9]*)+ +enum-name: '[A-Z][A-Z0-9]*(_[A-Z0-9]+)*' excluded_directories: !!set .git: null expression-not-assigned: null @@ -28,16 +30,18 @@ function-arguments-number: 10 function-name: (_on_([A-Z][a-z0-9]*)+(_[a-z0-9]+)*|_?[a-z][a-z0-9]*(_[a-z0-9]+)*) function-preload-variable-name: ([A-Z][a-z0-9]*)+ function-variable-name: '[a-z][a-z0-9]*(_[a-z0-9]+)*' -load-constant-name: (([A-Z][a-z0-9]*)+|[A-Z][A-Z0-9]*(_[A-Z0-9]+)*) +load-constant-name: (([A-Z][a-z0-9]*)+|_?[A-Z][A-Z0-9]*(_[A-Z0-9]+)*) loop-variable-name: _?[a-z][a-z0-9]*(_[a-z0-9]+)* max-file-lines: 1000 -max-line-length: 100 +max-line-length: 120 max-public-methods: 20 -mixed-tabs-and-spaces: null -private-method-call: null +max-returns: 6 +mixed-tabs-and-spaces: false +no-elif-return: null +no-else-return: null signal-name: '[a-z][a-z0-9]*(_[a-z0-9]+)*' sub-class-name: _?([A-Z][a-z0-9]*)+ tab-characters: 1 -trailing-whitespace: null +trailing-whitespace: true unnecessary-pass: null unused-argument: null diff --git a/plugin.cfg b/plugin.cfg old mode 100644 new mode 100755 diff --git a/readme_assets/suada_sample.gif b/readme_assets/suada_sample.gif old mode 100644 new mode 100755 diff --git a/requirements.txt b/requirements.txt old mode 100644 new mode 100755