diff --git a/addons/dialogic/Editor/CharacterEditor/character_editor.gd b/addons/dialogic/Editor/CharacterEditor/character_editor.gd index 9096fbbf4..42275c372 100644 --- a/addons/dialogic/Editor/CharacterEditor/character_editor.gd +++ b/addons/dialogic/Editor/CharacterEditor/character_editor.gd @@ -60,8 +60,6 @@ func _open_resource(resource:Resource) -> void: %CharacterName.text = character.unique_short_path $NoCharacterScreen.hide() - - func _save() -> void: @@ -239,6 +237,8 @@ func setup_portrait_list_tab() -> void: %PortraitTree.item_selected.connect(load_selected_portrait) %PortraitTree.item_edited.connect(_on_item_edited) + %PortraitTree.item_activated.connect(func(): %PortraitTree.get_selected().set_editable(0, true); %PortraitTree.edit_selected()) + func open_portrait_folder_select() -> void: find_parent("EditorView").godot_file_dialog( @@ -273,7 +273,10 @@ func add_portrait(portrait_name:String='New portrait', portrait_data:Dictionary= parent = %PortraitTree.get_selected() else: parent = %PortraitTree.get_selected().get_parent() - %PortraitTree.add_portrait_item(portrait_name, portrait_data, parent).select(0) + var item :TreeItem = %PortraitTree.add_portrait_item(portrait_name, portrait_data, parent) + item.set_editable(0, true) + item.select(0) + %PortraitTree.call_deferred('edit_selected') something_changed() @@ -281,7 +284,10 @@ func add_portrait_group() -> void: var parent_item :TreeItem = %PortraitTree.get_root() if %PortraitTree.get_selected() and %PortraitTree.get_selected().get_metadata(0).has('group'): parent_item = %PortraitTree.get_selected() - %PortraitTree.add_portrait_group("Group", parent_item) + var item :TreeItem = %PortraitTree.add_portrait_group("Group", parent_item) + item.set_editable(0, true) + item.select(0) + %PortraitTree.call_deferred('edit_selected') func load_portrait_tree() -> void: @@ -343,10 +349,10 @@ func list_portraits(tree_items:Array[TreeItem], dict:Dictionary = {}, path_prefi func load_selected_portrait(): if selected_item and is_instance_valid(selected_item): selected_item.set_editable(0, false) - + selected_item = %PortraitTree.get_selected() - - if selected_item and !selected_item.get_metadata(0).has('group'): + + if selected_item and selected_item.get_metadata(0) != null and !selected_item.get_metadata(0).has('group'): %PortraitSettingsSection.show() var current_portrait_data :Dictionary = selected_item.get_metadata(0) portrait_selected.emit(%PortraitTree.get_full_item_name(selected_item), current_portrait_data) @@ -378,6 +384,17 @@ func duplicate_item(item:TreeItem) -> void: %PortraitTree.add_portrait_item(item.get_text(0)+'_duplicated', item.get_metadata(0).duplicate(true), item.get_parent()).select(0) +func _input(event:InputEvent) -> void: + if !is_visible_in_tree() or (get_viewport().gui_get_focus_owner()!= null and !name+'/' in str(get_viewport().gui_get_focus_owner().get_path())): + return + if event is InputEventKey and event.pressed: + if event.keycode == KEY_F2 and %PortraitTree.get_selected(): + %PortraitTree.get_selected().set_editable(0, true) + %PortraitTree.edit_selected() + get_viewport().set_input_as_handled() + elif event.keycode == KEY_DELETE and get_viewport().gui_get_focus_owner() is Tree and %PortraitTree.get_selected(): + delete_portrait_item(%PortraitTree.get_selected()) + get_viewport().set_input_as_handled() func _on_portrait_right_click_menu_index_pressed(id:int) -> void: # DELETE BUTTON @@ -410,6 +427,7 @@ func _on_item_edited(): if selected_item: if %PreviewLabel.text.trim_prefix('Preview of "').trim_suffix('"') == current_resource.default_portrait: current_resource.default_portrait = %PortraitTree.get_full_item_name(selected_item) + selected_item.set_editable(0, false) update_preview() @@ -420,7 +438,7 @@ func _on_item_edited(): func update_preview() -> void: %ScenePreviewWarning.hide() - if selected_item and is_instance_valid(selected_item) and !selected_item.get_metadata(0).has('group'): + if selected_item and is_instance_valid(selected_item) and selected_item.get_metadata(0) != null and !selected_item.get_metadata(0).has('group'): %PreviewLabel.text = 'Preview of "'+%PortraitTree.get_full_item_name(selected_item)+'"' var current_portrait_data: Dictionary = selected_item.get_metadata(0) diff --git a/addons/dialogic/Editor/CharacterEditor/character_editor.tscn b/addons/dialogic/Editor/CharacterEditor/character_editor.tscn index d9daf09d2..5a38d454e 100644 --- a/addons/dialogic/Editor/CharacterEditor/character_editor.tscn +++ b/addons/dialogic/Editor/CharacterEditor/character_editor.tscn @@ -15,7 +15,7 @@ corner_radius_top_right = 2 corner_radius_bottom_right = 2 corner_radius_bottom_left = 2 -[sub_resource type="Image" id="Image_brdaj"] +[sub_resource type="Image" id="Image_7bycs"] data = { "data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 93, 93, 55, 255, 97, 97, 58, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 98, 98, 47, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 94, 94, 46, 255, 93, 93, 236, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), "format": "RGBA8", @@ -25,11 +25,11 @@ data = { } [sub_resource type="ImageTexture" id="ImageTexture_mpcxh"] -image = SubResource("Image_brdaj") +image = SubResource("Image_7bycs") [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_4xgdx"] -[sub_resource type="Image" id="Image_y0t2k"] +[sub_resource type="Image" id="Image_2yk54"] data = { "data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 93, 93, 55, 255, 97, 97, 58, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 98, 98, 47, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 94, 94, 46, 255, 93, 93, 236, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), "format": "RGBA8", @@ -38,8 +38,8 @@ data = { "width": 16 } -[sub_resource type="ImageTexture" id="ImageTexture_4mqhk"] -image = SubResource("Image_y0t2k") +[sub_resource type="ImageTexture" id="ImageTexture_oq50w"] +image = SubResource("Image_2yk54") [node name="CharacterEditor" type="MarginContainer"] self_modulate = Color(0, 0, 0, 1) @@ -171,10 +171,10 @@ script = ExtResource("2_vad0i") size = Vector2i(118, 100) item_count = 2 item_0/text = "Duplicate" -item_0/icon = SubResource("ImageTexture_4mqhk") +item_0/icon = SubResource("ImageTexture_oq50w") item_0/id = 0 item_1/text = "Delete" -item_1/icon = SubResource("ImageTexture_4mqhk") +item_1/icon = SubResource("ImageTexture_oq50w") item_1/id = 1 [node name="RightSection" type="VBoxContainer" parent="Split"] diff --git a/addons/dialogic/Editor/CharacterEditor/character_editor_portrait_tree.gd b/addons/dialogic/Editor/CharacterEditor/character_editor_portrait_tree.gd index 32750c62f..0318c74ef 100644 --- a/addons/dialogic/Editor/CharacterEditor/character_editor_portrait_tree.gd +++ b/addons/dialogic/Editor/CharacterEditor/character_editor_portrait_tree.gd @@ -60,10 +60,10 @@ func create_necessary_group_items(path:String) -> TreeItem: return last_item -func _on_item_mouse_selected(pos:Vector2, mouse_button_index): +func _on_item_mouse_selected(pos:Vector2, mouse_button_index:int) -> void: if mouse_button_index == MOUSE_BUTTON_RIGHT: + $PortraitRightClickMenu.set_item_disabled(0, get_selected().get_metadata(0).has('group')) $PortraitRightClickMenu.popup_on_parent(Rect2(get_global_mouse_position(),Vector2())) - ################################################################################ diff --git a/addons/dialogic/Editor/Events/Fields/ComplexPicker.gd b/addons/dialogic/Editor/Events/Fields/ComplexPicker.gd index a516f65e3..6ba52b8b5 100644 --- a/addons/dialogic/Editor/Events/Fields/ComplexPicker.gd +++ b/addons/dialogic/Editor/Events/Fields/ComplexPicker.gd @@ -67,7 +67,6 @@ func _ready(): %BG.add_theme_stylebox_override('panel', get_theme_stylebox('normal', 'LineEdit')) %Focus.add_theme_stylebox_override('panel', get_theme_stylebox('focus', 'LineEdit')) %Search.text_changed.connect(_on_Search_text_changed) - %Search.focus_entered.connect(_on_Search_focus_entered) %Search.text_submitted.connect(_on_Search_text_entered) var scale: float = DialogicUtil.get_editor_scale() %SelectButton.icon = get_theme_icon("Collapse", "EditorIcons") @@ -140,6 +139,7 @@ func _on_Search_text_changed(new_text:String, just_update:bool = false) -> void: current_selected = -1 %Search.grab_focus() + func get_default_suggestions(input:String) -> Dictionary: if file_extension.is_empty(): return {'Nothing found!':{'value':''}} var suggestions: Dictionary = {} @@ -185,19 +185,46 @@ func _input(event:InputEvent): if %Suggestions.visible: if !%Suggestions.get_global_rect().has_point(get_global_mouse_position()): hide_suggestions() + func hide_suggestions() -> void: %SelectButton.button_pressed = false %Suggestions.hide() -func _on_Search_focus_entered() -> void: - if %Search.text == "" or current_value == null or (typeof(current_value) == TYPE_STRING and current_value.is_empty()): - _on_Search_text_changed("") func _on_SelectButton_toggled(button_pressed:bool) -> void: if button_pressed: _on_Search_text_changed('', true) +func _on_focus_entered(): + %Search.grab_focus() + + + +func _on_search_gui_input(event): + if event is InputEventKey and (event.keycode == KEY_DOWN or event.keycode == KEY_UP) and event.pressed: + if !%Suggestions.visible: + _on_Search_text_changed('', true) + current_selected = -1 + if event.keycode == KEY_DOWN: + current_selected = wrapi(current_selected+1, 0, %Suggestions.item_count) + if event.keycode == KEY_UP: + current_selected = wrapi(current_selected-1, 0, %Suggestions.item_count) + %Suggestions.select(current_selected) + %Suggestions.ensure_current_is_visible() + +func _on_search_focus_entered(): + if %Search.text == "" or current_value == null or (typeof(current_value) == TYPE_STRING and current_value.is_empty()): + _on_Search_text_changed("") + %Search.call_deferred('select_all') + %Focus.show() + + +func _on_search_focus_exited(): + %Focus.hide() + if !%Suggestions.get_global_rect().has_point(get_global_mouse_position()): + hide_suggestions() + ################################################################################ ## DRAG AND DROP ################################################################################ @@ -227,26 +254,3 @@ func _drop_data(position, data) -> void: set_value(file) emit_signal("value_changed", property_name, file) - -func _on_focus_entered(): - %Search.grab_focus() - -func _on_search_gui_input(event): - if event is InputEventKey and (event.keycode == KEY_DOWN or event.keycode == KEY_UP) and event.pressed: - if !%Suggestions.visible: - _on_Search_text_changed('', true) - current_selected = -1 - if event.keycode == KEY_DOWN: - current_selected = wrapi(current_selected+1, 0, %Suggestions.item_count) - if event.keycode == KEY_UP: - current_selected = wrapi(current_selected-1, 0, %Suggestions.item_count) - %Suggestions.select(current_selected) - %Suggestions.ensure_current_is_visible() - -func _on_search_focus_entered(): - %Focus.show() - -func _on_search_focus_exited(): - %Focus.hide() - if !%Suggestions.get_global_rect().has_point(get_global_mouse_position()): - hide_suggestions() diff --git a/addons/dialogic/Editor/Events/Fields/ComplexPicker.tscn b/addons/dialogic/Editor/Events/Fields/ComplexPicker.tscn index 0a203a5ab..14cdf7f20 100644 --- a/addons/dialogic/Editor/Events/Fields/ComplexPicker.tscn +++ b/addons/dialogic/Editor/Events/Fields/ComplexPicker.tscn @@ -2,7 +2,7 @@ [ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/ComplexPicker.gd" id="1"] -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_eo5hy"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_f2drj"] content_margin_left = 4.0 content_margin_top = 4.0 content_margin_right = 4.0 @@ -18,7 +18,7 @@ corner_detail = 5 [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_vennf"] -[sub_resource type="Image" id="Image_ykvnc"] +[sub_resource type="Image" id="Image_qk1wv"] data = { "data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 93, 93, 55, 255, 97, 97, 58, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 98, 98, 47, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 94, 94, 46, 255, 93, 93, 236, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), "format": "RGBA8", @@ -27,10 +27,10 @@ data = { "width": 16 } -[sub_resource type="ImageTexture" id="ImageTexture_ay30j"] -image = SubResource("Image_ykvnc") +[sub_resource type="ImageTexture" id="ImageTexture_rt3wv"] +image = SubResource("Image_qk1wv") -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_w5nny"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_km8pw"] content_margin_left = 4.0 content_margin_top = 4.0 content_margin_right = 4.0 @@ -78,7 +78,7 @@ theme_override_constants/margin_bottom = 0 unique_name_in_owner = true layout_mode = 2 mouse_filter = 2 -theme_override_styles/panel = SubResource("StyleBoxFlat_eo5hy") +theme_override_styles/panel = SubResource("StyleBoxFlat_f2drj") metadata/_edit_use_anchors_ = true [node name="MarginContainer" type="MarginContainer" parent="PanelContainer"] @@ -134,7 +134,7 @@ layout_mode = 2 focus_mode = 0 toggle_mode = true shortcut_in_tooltip = false -icon = SubResource("ImageTexture_ay30j") +icon = SubResource("ImageTexture_rt3wv") flat = true [node name="Focus" type="Panel" parent="PanelContainer"] @@ -142,7 +142,7 @@ unique_name_in_owner = true visible = false layout_mode = 2 mouse_filter = 2 -theme_override_styles/panel = SubResource("StyleBoxFlat_w5nny") +theme_override_styles/panel = SubResource("StyleBoxFlat_km8pw") metadata/_edit_use_anchors_ = true [connection signal="focus_entered" from="." to="." method="_on_focus_entered"] diff --git a/addons/dialogic/Editor/TimelineEditor/TextEditor/timeline_editor_text.gd b/addons/dialogic/Editor/TimelineEditor/TextEditor/timeline_editor_text.gd index 5d08ac4e4..310c5b135 100644 --- a/addons/dialogic/Editor/TimelineEditor/TextEditor/timeline_editor_text.gd +++ b/addons/dialogic/Editor/TimelineEditor/TextEditor/timeline_editor_text.gd @@ -339,7 +339,7 @@ func _request_code_completion(force): # Text Event Suggestions else: - if not ':' in line and symbol == '(': + if not ':' in line.substr(0, get_caret_column()) and symbol == '(': var character := completion_text_character_getter_regex.search(line).get_string('name') suggest_portraits(character) if symbol == '[': diff --git a/addons/dialogic/Modules/Background/default_background.gd b/addons/dialogic/Modules/Background/default_background.gd index 28da041a9..cb873b9e6 100644 --- a/addons/dialogic/Modules/Background/default_background.gd +++ b/addons/dialogic/Modules/Background/default_background.gd @@ -1,30 +1,20 @@ -extends TextureRect +extends DialogicBackground -## This is the DefaultBackground scene that can simply display a image -## -## You can create your own scenes. They can override the following methods: -## - _update_background(@argument:String, @time:float) -## - _fade_in(@time) (if not overriden modulate is animated) -## - _fade_out(@time) (if not overriden modulate is animated) -## make sure to free the scene at the end of the fade -## - _should_do_background_update(@arg) -> bool +## The default background scene. +## Extend the DialogicBackground class to create your own background scene. func _ready() -> void: - expand_mode = TextureRect.EXPAND_IGNORE_SIZE - stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_COVERED + $Image.expand_mode = TextureRect.EXPAND_IGNORE_SIZE + $Image.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_COVERED - anchor_right = 1 - anchor_bottom = 1 + $Image.anchor_right = 1 + $Image.anchor_bottom = 1 + -# load the new background in here. -# The time argument is given for when [_should_do_background_update] returns true -# (then you have to do the transition in here) func _update_background(argument:String, time:float) -> void: - texture = load(argument) + $Image.texture = load(argument) -# if a Background event with this scene is encountered while this background is used, -# this decides whether to create a new instance and call fade_out or just call [_update_background] # on this scene. Default is false func _should_do_background_update(argument:String) -> bool: return false diff --git a/addons/dialogic/Modules/Background/default_background.tscn b/addons/dialogic/Modules/Background/default_background.tscn index ac9f4c730..186964760 100644 --- a/addons/dialogic/Modules/Background/default_background.tscn +++ b/addons/dialogic/Modules/Background/default_background.tscn @@ -2,8 +2,20 @@ [ext_resource type="Script" path="res://addons/dialogic/Modules/Background/default_background.gd" id="1_nkdrp"] -[node name="DefaultBackground" type="TextureRect"] -offset_right = 40.0 -offset_bottom = 40.0 -mouse_filter = 0 +[node name="DefaultBackground" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 script = ExtResource("1_nkdrp") + +[node name="Image" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 0 diff --git a/addons/dialogic/Modules/Background/dialogic_background.gd b/addons/dialogic/Modules/Background/dialogic_background.gd new file mode 100644 index 000000000..2f0a25889 --- /dev/null +++ b/addons/dialogic/Modules/Background/dialogic_background.gd @@ -0,0 +1,31 @@ +extends Node +class_name DialogicBackground + +## This is the base class for dialogic backgrounds. +## Extend it and override it's methods when you create a custom background. +## You can take a look at the default background to get an idea of how it's working. + + +## Load the new background in here. +## The time argument is given for when [_should_do_background_update] returns true +## (then you have to do a transition in here) +func _update_background(argument:String, time:float) -> void: + pass + + +## If a background event with this scene is encountered while this background is used, +## this decides whether to create a new instance and call fade_out or just call [_update_background] # on this scene. Default is false +func _should_do_background_update(argument:String) -> bool: + return false + + +## Called by dialogic when first created. +## If you return false (by default) it will attempt to animate the "modulate" property. +func _fade_in(time:float) -> bool: + return false + + +## Called by dialogic before removing (done by dialogic). +## If you return false (by default) it will attempt to animate the "modulate" property. +func _fade_out(time:float) -> bool: + return false diff --git a/addons/dialogic/Modules/Background/subsystem_backgrounds.gd b/addons/dialogic/Modules/Background/subsystem_backgrounds.gd index 4a5c07510..4998c9107 100644 --- a/addons/dialogic/Modules/Background/subsystem_backgrounds.gd +++ b/addons/dialogic/Modules/Background/subsystem_backgrounds.gd @@ -47,9 +47,7 @@ func update_background(scene:String = '', argument:String = '', fade_time:float # remove previous backgrounds for old_bg in node.get_children(): - if old_bg.has_method('_fade_out'): - old_bg._fade_out(fade_time) - elif "modulate" in old_bg: + if !old_bg._fade_out(fade_time) and "modulate" in old_bg: var tween := old_bg.create_tween() tween.tween_property(old_bg, "modulate", Color.TRANSPARENT, fade_time) tween.tween_callback(old_bg.queue_free) @@ -70,10 +68,7 @@ func update_background(scene:String = '', argument:String = '', fade_time:float if new_node.has_method('_update_background'): new_node._update_background(argument, fade_time) - if new_node.has_method('_fade_in'): - new_node._fade_in(fade_time) - - elif "modulate" in new_node: + if !new_node._fade_in(fade_time) and "modulate" in new_node: new_node.modulate = Color.TRANSPARENT var tween := new_node.create_tween() tween.tween_property(new_node, "modulate", Color.WHITE, fade_time) diff --git a/addons/dialogic/Modules/Character/default_portrait.gd b/addons/dialogic/Modules/Character/default_portrait.gd index 32654f8f7..1aa943de1 100644 --- a/addons/dialogic/Modules/Character/default_portrait.gd +++ b/addons/dialogic/Modules/Character/default_portrait.gd @@ -1,49 +1,29 @@ @tool -class_name DialogicDefaultPortrait # TODO: Question should this have a class_name? To be extended or what? -extends Node +extends DialogicPortrait ## Default portrait scene. -## Stores the character that this scene displays. -var character: DialogicCharacter -## Stores the name of the current portrait. -var portrait: String - - -## Function to accept and use the extra data, if the custom portrait wants to accept it -func _set_extra_data(data: String) -> void: - pass - - -## This function can be overridden. Defaults to true, if not overridden! -func _should_do_portrait_update(character:DialogicCharacter, portrait:String) -> bool: - return true - +## The parent class has a character and portrait variable. ## If the custom portrait accepts a change, then accept it here func _update_portrait(passed_character:DialogicCharacter, passed_portrait:String) -> void: - if passed_portrait == "" or not passed_portrait in passed_character.portraits.keys(): - passed_portrait = passed_character['default_portrait'] - portrait = passed_portrait - if passed_character != null: - if character == null or character != passed_character: - character = passed_character - + super._update_portrait(passed_character, passed_portrait) if character.portraits.has(portrait): var path :String = character.portraits[portrait].get('image', '') $Portrait.texture = null if !path.is_empty(): $Portrait.texture = load(path) $Portrait.centered = false + $Portrait.scale = Vector2.ONE $Portrait.position = $Portrait.get_rect().size * Vector2(-0.5, -1) -## If implemented, this is called when the mirror changes +## This is called when the mirror changes func _set_mirror(mirror:bool) -> void: $Portrait.flip_h = mirror -## If implemented, this is used by the editor for the "full view" mode +## This is used by the editor preview and portrait containers func _get_covered_rect() -> Rect2: - if $Portrait.texture == null: + if $Portrait.texture == null: return Rect2() return Rect2($Portrait.position, $Portrait.get_rect().size) diff --git a/addons/dialogic/Modules/Character/default_portrait.tscn b/addons/dialogic/Modules/Character/default_portrait.tscn index 216386a03..524db9a64 100644 --- a/addons/dialogic/Modules/Character/default_portrait.tscn +++ b/addons/dialogic/Modules/Character/default_portrait.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=3 format=3] +[gd_scene load_steps=3 format=3 uid="uid://b32paf0ll6um8"] [ext_resource type="Script" path="res://addons/dialogic/Modules/Character/default_portrait.gd" id="1_wn77n"] diff --git a/addons/dialogic/Modules/Character/dialogic_portrait.gd b/addons/dialogic/Modules/Character/dialogic_portrait.gd new file mode 100644 index 000000000..8dad86384 --- /dev/null +++ b/addons/dialogic/Modules/Character/dialogic_portrait.gd @@ -0,0 +1,53 @@ +class_name DialogicPortrait +extends Node + +## Default portrait class. Should be extended by custom portraits. + +## Stores the character that this scene displays. +var character: DialogicCharacter +## Stores the name of the current portrait. +var portrait: String + + +## This function can be overridden. +## If this returns true, it won't insatnce a new scene, but call _update_portrait on this one. +## This is only relevant if the next portrait uses the same scene. +## This allows implmenting transitions between portraits that use the same scene. +func _should_do_portrait_update(character:DialogicCharacter, portrait:String) -> bool: + return true + + +## If the custom portrait accepts a change, then accept it here +## You should position your portrait so that the root node is at the pivot point*. +## For example for a simple sprite this code would work: +## >>> $Sprite.position = $Sprite.get_rect().size * Vector2(-0.5, -1) +## +## * this depends on the portrait containers, but it will most likely be the bottom center (99% of cases) +func _update_portrait(passed_character:DialogicCharacter, passed_portrait:String) -> void: + if passed_portrait == "" or not passed_portrait in passed_character.portraits.keys(): + passed_portrait = passed_character.default_portrait + + portrait = passed_portrait + character = passed_character + + +## This should be implemented. It is used for sizing in the +## character editor preview and in portrait containers. +## Scale and offset will be applied by dialogic. +## For example for a simple sprite this should work: +## >>> return Rect2($Sprite.position, $Sprite.get_rect().size) +## +## This will only work as expected if the portrait is positioned so that the root is at the pivot point. +func _get_covered_rect() -> Rect2: + return Rect2() + + +## If implemented, this is called when the mirror changes +func _set_mirror(mirror:bool) -> void: + pass + + +## Function to accept and use the extra data, if the custom portrait wants to accept it +func _set_extra_data(data: String) -> void: + pass + diff --git a/addons/dialogic/Modules/Character/subsystem_portraits.gd b/addons/dialogic/Modules/Character/subsystem_portraits.gd index e73db8139..b9c53a269 100644 --- a/addons/dialogic/Modules/Character/subsystem_portraits.gd +++ b/addons/dialogic/Modules/Character/subsystem_portraits.gd @@ -98,7 +98,8 @@ func _change_portrait(character_node:Node2D, portrait:String, update_transform:= # remove previous portrait if character_node.get_child_count(): character_node.get_child(0).queue_free() - + character_node.remove_child(character_node.get_child(0)) + if scene_path.is_empty(): portrait_node = default_portrait_scene.instantiate() else: @@ -150,7 +151,7 @@ func _update_portrait_transform(character_node:Node2D, time:float = 0.0) -> void var portrait_info :Dictionary = character.portraits.get(character_node.get_meta('portrait'), {}) # ignore the character scale on custom portraits that have 'ignore_char_scale' set to true - var apply_character_scale :bool= portrait_info.get('scene', '') or !portrait_info.get('ignore_char_scale', false) + var apply_character_scale :bool= !portrait_info.get('ignore_char_scale', false) var transform :Rect2 = character_node.get_parent().get_local_portrait_transform( portrait_node._get_covered_rect(), (character.scale * portrait_info.get('scale', 1))*int(apply_character_scale)+portrait_info.get('scale')*int(!apply_character_scale)) @@ -176,7 +177,7 @@ func _update_portrait_transform(character_node:Node2D, time:float = 0.0) -> void ## Animates the portrait in the given container with the given animation. func _animate_portrait(character_node:Node2D, animation_path:String, length:float, repeats = 1) -> DialogicAnimation: - if character_node.get_meta('animation_node', null) != null and is_instance_valid(character_node.get_meta('animation_node')): + if character_node.get_meta('animation_node', null) != null and is_instance_valid(character_node.get_meta('animation_node', null)): character_node.get_meta('animation_node').queue_free() var anim_script :Script = load(animation_path) @@ -214,6 +215,7 @@ func _change_portrait_z_index(character_node:Node2D, z_index:int, update_zindex: func _remove_portrait(character_node:Node2D) -> void: + character_node.get_parent().remove_child(character_node) character_node.queue_free() @@ -236,12 +238,15 @@ func join_character(character:DialogicCharacter, portrait:String, position_idx: await get_tree().create_timer(animation_length).timeout dialogic.current_state = Dialogic.states.IDLE move_character(character, position_idx, animation_length) + change_character_mirror(character, mirrored) return var character_node := add_character(character, portrait, position_idx) if character_node == null: return null + dialogic.current_state_info['portraits'][character.resource_path] = {'portrait':portrait, 'node':character_node, 'position_index':position_idx, 'custom_mirror':mirrored} + _change_portrait_mirror(character_node, mirrored) _change_portrait_extradata(character_node, extra_data) _change_portrait_z_index(character_node, z_index) @@ -315,6 +320,8 @@ func change_character_portrait(character:DialogicCharacter, portrait:String, upd var info := _change_portrait(dialogic.current_state_info.portraits[character.resource_path].node, portrait, update_transform) dialogic.current_state_info.portraits[character.resource_path].portrait = info.portrait + if dialogic.current_state_info.portraits[character.resource_path].get('custom_mirror', false): + _change_portrait_mirror(dialogic.current_state_info.portraits[character.resource_path].node, true) character_portrait_changed.emit(info) @@ -322,7 +329,9 @@ func change_character_portrait(character:DialogicCharacter, portrait:String, upd func change_character_mirror(character:DialogicCharacter, mirrored:= false, force:= false) -> void: if !is_character_joined(character): return + _change_portrait_mirror(dialogic.current_state_info.portraits[character.resource_path].node, mirrored, force) + dialogic.current_state_info.portraits[character.resource_path]['custom_mirror'] = mirrored ## Changes the z_index of a character. Only works with joined characters @@ -392,10 +401,15 @@ func leave_character(character:DialogicCharacter, animation_name :String = "", a func leave_all_characters(animation_name:String="", animation_length:float= 0, animation_wait:= false) -> void: for character in get_joined_characters(): leave_character(character, animation_name, animation_length, false) - if animation_wait: - dialogic.current_state = Dialogic.states.ANIMATING - await get_tree().create_timer(animation_length).timeout - dialogic.current_state = Dialogic.states.IDLE + + if animation_name.is_empty(): + animation_length = ProjectSettings.get_setting('dialogic/animations/leave_default_length', 0.5) + animation_wait = ProjectSettings.get_setting('dialogic/animations/leave_default_wait', true) + + if animation_wait: + dialogic.current_state = Dialogic.states.ANIMATING + await get_tree().create_timer(animation_length).timeout + dialogic.current_state = Dialogic.states.IDLE ## Removes the given characters portrait. Only works with joined characters @@ -510,6 +524,10 @@ func change_speaker(speaker:DialogicCharacter= null, portrait:= ""): else: _change_portrait(con.get_child(0), portrait) + # if the character has no portraits _change_portrait won't actually add a child node + if con.get_child(0).get_child_count() == 0: + return + _change_portrait_mirror(con.get_child(0)) diff --git a/addons/dialogic/Modules/DefaultStyles/Default/DialogicDefaultLayout.gd b/addons/dialogic/Modules/DefaultStyles/Default/DialogicDefaultLayout.gd index 7cab1fd22..0cf043537 100644 --- a/addons/dialogic/Modules/DefaultStyles/Default/DialogicDefaultLayout.gd +++ b/addons/dialogic/Modules/DefaultStyles/Default/DialogicDefaultLayout.gd @@ -18,12 +18,13 @@ enum Alignments {Left, Center, Right} @export var box_size : Vector2 = Vector2(550, 110) @export_subgroup("Name Label") +@export var name_label_alignment := Alignments.Left @export var name_label_font_size := 15 -@export_file('*.ttf') var name_label_font : String = "" -@export var name_label_use_character_color := true @export var name_label_color := Color.WHITE +@export var name_label_use_character_color := true +@export_file('*.ttf') var name_label_font : String = "" @export var name_label_box_modulate : Color = box_modulate -@export var name_label_alignment := Alignments.Left +@export var name_label_box_offset := Vector2.ZERO @export_group("Other") @@ -35,8 +36,8 @@ enum Alignments {Left, Center, Right} @export var next_indicator_show_on_autoadvance := false -func _ready(): - add_to_group('dialogic_main_node') +@export_subgroup('Portraits') +@export var portrait_size_mode := DialogicNode_PortraitContainer.SizeModes.FitScaleHeight ## Called by dialogic whenever export overrides might change @@ -80,11 +81,11 @@ func _apply_export_overrides(): %NameLabelPanel.self_modulate = name_label_box_modulate - %NameLabelPanel.position.x = 0 + %NameLabelPanel.position = name_label_box_offset+Vector2(0, -50) %NameLabelPanel.anchor_left = name_label_alignment/2.0 %NameLabelPanel.anchor_right = name_label_alignment/2.0 %NameLabelPanel.grow_horizontal = [1, 2, 0][name_label_alignment] - + ## NEXT INDICATOR SETTINGS if !next_indicator_enabled: %NextIndicator.queue_free() @@ -94,4 +95,7 @@ func _apply_export_overrides(): %NextIndicator.texture = load(next_indicator_texture) %NextIndicator.show_on_questions = next_indicator_show_on_questions %NextIndicator.show_on_autoadvance = next_indicator_show_on_autoadvance - + + ## PORTRAIT SETTINGS + for child in %Portraits.get_children(): + child.size_mode = portrait_size_mode diff --git a/addons/dialogic/Modules/DefaultStyles/Default/DialogicDefaultLayout.tscn b/addons/dialogic/Modules/DefaultStyles/Default/DialogicDefaultLayout.tscn index 959e55a98..fc0818da7 100644 --- a/addons/dialogic/Modules/DefaultStyles/Default/DialogicDefaultLayout.tscn +++ b/addons/dialogic/Modules/DefaultStyles/Default/DialogicDefaultLayout.tscn @@ -110,7 +110,7 @@ tracks/1/interp = 1 tracks/1/loop_wrap = true tracks/1/keys = { "handle_modes": PackedInt32Array(3, 3, 3, 3, 3), -"points": PackedFloat32Array(0, -0.025, 0, 0.025, 0, 0.0149876, -0.025, 0, 0.025, 0, -0.00561064, -0.025, 0, 0.025, 0, 0.00851069, -0.025, 0, 0.025, 0, 0, -0.025, 0, 0.025, 0), +"points": PackedFloat32Array(0, -0.025, 0, 0.025, 0, 0.005, -0.025, 0, 0.025, 0, -0.005, -0.025, 0, 0.025, 0, 0.005, -0.025, 0, 0.025, 0, 0, -0.025, 0, 0.025, 0), "times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4) } @@ -215,6 +215,7 @@ expand_margin_bottom = 5.0 [node name="DefaultDialogNode" type="CanvasLayer"] script = ExtResource("1") name_label_box_modulate = Color(0.00784314, 0.00784314, 0.00784314, 0.843137) +name_label_box_offset = null [node name="DialogicNode_BackgroundHolder" type="CanvasLayer" parent="."] layer = -1 @@ -223,7 +224,8 @@ script = ExtResource("5_uvb2c") [node name="Portraits" type="CanvasLayer" parent="."] layer = 0 -[node name="Control" type="Control" parent="Portraits"] +[node name="Portraits" type="Control" parent="Portraits"] +unique_name_in_owner = true layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -232,19 +234,20 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 -[node name="DialogicNode_PortraitContainer1" type="Control" parent="Portraits/Control"] +[node name="DialogicNode_PortraitContainer1" type="Control" parent="Portraits/Portraits"] layout_mode = 1 -anchor_left = 0.00434028 -anchor_right = 0.217882 -anchor_bottom = 1.0 +anchor_left = 0.0572917 +anchor_top = 0.725309 +anchor_right = 0.177951 +anchor_bottom = 1.00309 grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 script = ExtResource("3_dbhei") -size_mode = 0 +size_mode = 1 metadata/_edit_use_anchors_ = true -[node name="DialogicNode_PortraitContainer2" type="Control" parent="Portraits/Control"] +[node name="DialogicNode_PortraitContainer2" type="Control" parent="Portraits/Portraits"] layout_mode = 1 anchor_left = 0.190104 anchor_right = 0.401042 @@ -254,10 +257,9 @@ grow_vertical = 2 mouse_filter = 2 script = ExtResource("3_dbhei") position_index = 1 -size_mode = 0 metadata/_edit_use_anchors_ = true -[node name="DialogicNode_PortraitContainer3" type="Control" parent="Portraits/Control"] +[node name="DialogicNode_PortraitContainer3" type="Control" parent="Portraits/Portraits"] layout_mode = 1 anchor_left = 0.371528 anchor_right = 0.625868 @@ -267,23 +269,21 @@ grow_vertical = 2 mouse_filter = 2 script = ExtResource("3_dbhei") position_index = 2 -size_mode = 0 metadata/_edit_use_anchors_ = true -[node name="DialogicNode_PortraitContainer4" type="Control" parent="Portraits/Control"] +[node name="DialogicNode_PortraitContainer4" type="Control" parent="Portraits/Portraits"] layout_mode = 1 anchor_left = 0.592882 anchor_right = 0.805556 -anchor_bottom = 1.0 +anchor_bottom = 0.996914 grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 script = ExtResource("3_dbhei") position_index = 3 -size_mode = 0 metadata/_edit_use_anchors_ = true -[node name="DialogicNode_PortraitContainer5" type="Control" parent="Portraits/Control"] +[node name="DialogicNode_PortraitContainer5" type="Control" parent="Portraits/Portraits"] layout_mode = 1 anchor_left = 0.776042 anchor_top = -0.00462963 @@ -294,7 +294,6 @@ grow_vertical = 2 mouse_filter = 2 script = ExtResource("3_dbhei") position_index = 4 -size_mode = 0 metadata/_edit_use_anchors_ = true [node name="DefaultStyle" type="Control" parent="."] @@ -316,17 +315,10 @@ script = ExtResource("16_07l6b") [node name="Choices" type="VBoxContainer" parent="DefaultStyle"] layout_mode = 1 -anchors_preset = 8 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -115.0 -offset_top = -103.0 -offset_right = 115.0 -offset_bottom = 103.0 -grow_horizontal = 2 -grow_vertical = 2 +offset_left = 19.0 +offset_top = 15.0 +offset_right = 192.0 +offset_bottom = 221.0 alignment = 1 metadata/_edit_layout_mode = 1 @@ -486,7 +478,7 @@ metadata/_edit_layout_mode = 1 [node name="TextInputPanel" type="PanelContainer" parent="DefaultStyle/DialogicNode_TextInput"] unique_name_in_owner = true -self_modulate = Color(0.00784314, 0.00784314, 0.00784314, 0.843137) +self_modulate = Color(0.360784, 0.0941176, 0.168627, 1) layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 diff --git a/addons/dialogic/Modules/DefaultStyles/RPG_BoxPortrait/DialogicRPGLayout.gd b/addons/dialogic/Modules/DefaultStyles/RPG_BoxPortrait/DialogicRPGLayout.gd new file mode 100644 index 000000000..2df8d4711 --- /dev/null +++ b/addons/dialogic/Modules/DefaultStyles/RPG_BoxPortrait/DialogicRPGLayout.gd @@ -0,0 +1,91 @@ +extends CanvasLayer + +enum Alignments {Left, Center, Right} +enum LimitedAlignments {Left=0, Right=1} + +@export_group('Main') +@export_subgroup("Text") +@export var text_alignment :Alignments= Alignments.Left +@export var text_size := 15 +@export var text_color : Color = Color.WHITE +@export_file('*.ttf') var normal_font:String = "" +@export_file('*.ttf') var bold_font:String = "" +@export_file('*.ttf') var italic_font:String = "" +@export_file('*.ttf') var bold_italic_font:String = "" + +@export_subgroup("Name Label") +@export var name_label_alignment := Alignments.Left +@export var name_label_font_size := 15 +@export var name_label_color := Color.WHITE +@export var name_label_use_character_color := true +@export_file('*.ttf') var name_label_font : String = "" +@export var name_label_hide_when_no_character := false + +@export_group('Box & Portrait') +@export_subgroup("Box") +@export var box_modulate : Color = Color(0.47247135639191, 0.31728461384773, 0.16592600941658) +@export var box_size : Vector2 = Vector2(600, 160) +@export var box_distance := 25 +@export var box_corner_radius := 5 +@export var box_padding := 10 +@export_range(-0.3, 0.3) var box_tilt := 0.079 + +@export_subgroup('Portrait') +@export var portrait_stretch_factor = 0.3 +@export var portrait_position :LimitedAlignments = LimitedAlignments.Left +@export var portrait_bg_modulate := Color(0, 0, 0, 0.5137255191803) + + +## Called by dialogic whenever export overrides might change +func _apply_export_overrides(): + if !is_inside_tree(): + await ready + + ## FONT SETTINGS + %DialogicNode_DialogText.alignment = text_alignment + + %DialogicNode_DialogText.add_theme_font_size_override("normal_font_size", text_size) + %DialogicNode_DialogText.add_theme_font_size_override("bold_font_size", text_size) + %DialogicNode_DialogText.add_theme_font_size_override("italics_font_size", text_size) + %DialogicNode_DialogText.add_theme_font_size_override("bold_italics_font_size", text_size) + + %DialogicNode_DialogText.add_theme_color_override("default_color", text_color) + + if !normal_font.is_empty(): + %DialogicNode_DialogText.add_theme_font_override("normal_font", load(normal_font)) + if !bold_font.is_empty(): + %DialogicNode_DialogText.add_theme_font_override("bold_font", load(bold_font)) + if !italic_font.is_empty(): + %DialogicNode_DialogText.add_theme_font_override("italitc_font", load(italic_font)) + if !bold_italic_font.is_empty(): + %DialogicNode_DialogText.add_theme_font_override("bold_italics_font", load(bold_italic_font)) + + ## BOX SETTINGS + %Panel.self_modulate = box_modulate + %Panel.size = box_size + %Panel.position = Vector2(-box_size.x/2, -box_size.y-box_distance) + %PortraitPanel.size_flags_stretch_ratio = portrait_stretch_factor + + var stylebox :StyleBoxFlat = %Panel.get_theme_stylebox('panel', 'PanelContainer') + stylebox.set_corner_radius_all(box_corner_radius) + stylebox.set_content_margin_all(box_padding) + stylebox.skew.x = box_tilt + + ## PORTRAIT SETTINGS + %PortraitBackgroundColor.color = portrait_bg_modulate + %PortraitPanel.get_parent().move_child(%PortraitPanel, portrait_position) + stylebox = %PortraitPanel.get_theme_stylebox('panel', 'Panel') + stylebox.set_corner_radius_all(box_corner_radius) + stylebox.skew.x = box_tilt + + ## NAME LABEL SETTINGS + %DialogicNode_NameLabel.add_theme_font_size_override("font_size", name_label_font_size) + + if !name_label_font.is_empty(): + %DialogicNode_NameLabel.add_theme_font_override('font', load(name_label_font)) + + %DialogicNode_NameLabel.add_theme_color_override("font_color", name_label_color) + %DialogicNode_NameLabel.use_character_color = name_label_use_character_color + %DialogicNode_NameLabel.horizontal_alignment = name_label_alignment + + %DialogicNode_NameLabel.hide_when_empty = name_label_hide_when_no_character diff --git a/addons/dialogic/Modules/DefaultStyles/RPG_BoxPortrait/DialogicRPGLayout.tscn b/addons/dialogic/Modules/DefaultStyles/RPG_BoxPortrait/DialogicRPGLayout.tscn index 969e7e850..c4ef76594 100644 --- a/addons/dialogic/Modules/DefaultStyles/RPG_BoxPortrait/DialogicRPGLayout.tscn +++ b/addons/dialogic/Modules/DefaultStyles/RPG_BoxPortrait/DialogicRPGLayout.tscn @@ -1,5 +1,6 @@ -[gd_scene load_steps=7 format=3 uid="uid://cgc2samfe5ghg"] +[gd_scene load_steps=8 format=3 uid="uid://cgc2samfe5ghg"] +[ext_resource type="Script" path="res://addons/dialogic/Modules/DefaultStyles/RPG_BoxPortrait/DialogicRPGLayout.gd" id="1_ry4cs"] [ext_resource type="Script" path="res://addons/dialogic/Modules/Character/node_portrait_container.gd" id="2_ih78e"] [ext_resource type="Script" path="res://addons/dialogic/Modules/Text/node_dialog_text.gd" id="3"] [ext_resource type="Script" path="res://addons/dialogic/Modules/Text/node_name_label.gd" id="6"] @@ -10,57 +11,85 @@ content_margin_left = 10.0 content_margin_top = 10.0 content_margin_right = 10.0 content_margin_bottom = 10.0 -bg_color = Color(0.447059, 0.282353, 0.109804, 1) -skew = Vector2(0.079, 0) -corner_radius_top_left = 5 -corner_radius_top_right = 5 -corner_radius_bottom_right = 5 -corner_radius_bottom_left = 5 +bg_color = Color(1, 1, 1, 1) +skew = Vector2(0.088, 0) +corner_radius_top_left = 2 +corner_radius_top_right = 2 +corner_radius_bottom_right = 2 +corner_radius_bottom_left = 2 [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_775n1"] -bg_color = Color(0.266667, 0.172549, 0.0823529, 1) +bg_color = Color(0.254902, 0.254902, 0.254902, 1) skew = Vector2(0.073, 0) -corner_radius_top_left = 5 -corner_radius_top_right = 5 -corner_radius_bottom_right = 5 -corner_radius_bottom_left = 5 +corner_radius_top_left = 3 +corner_radius_top_right = 3 +corner_radius_bottom_right = 3 +corner_radius_bottom_left = 3 [node name="RPG_ExampleNode" type="CanvasLayer"] layer = 3 +script = ExtResource("1_ry4cs") -[node name="PanelContainer" type="PanelContainer" parent="."] +[node name="Anchor" type="Control" parent="."] +layout_mode = 3 anchors_preset = 7 anchor_left = 0.5 anchor_top = 1.0 anchor_right = 0.5 anchor_bottom = 1.0 -offset_left = -352.0 -offset_top = -204.0 -offset_right = 359.0 -offset_bottom = -49.0 +grow_horizontal = 2 +grow_vertical = 0 + +[node name="Panel" type="PanelContainer" parent="Anchor"] +unique_name_in_owner = true +self_modulate = Color(0.533333, 0.376471, 0.176471, 1) +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -89.0 +offset_top = -66.0 +offset_right = 112.0 +offset_bottom = -16.0 grow_horizontal = 2 grow_vertical = 0 theme_override_styles/panel = SubResource("StyleBoxFlat_smrwn") -[node name="HBox" type="HBoxContainer" parent="PanelContainer"] +[node name="HBox" type="HBoxContainer" parent="Anchor/Panel"] layout_mode = 2 theme_override_constants/separation = 15 -[node name="Panel" type="Panel" parent="PanelContainer/HBox"] -clip_children = 2 -custom_minimum_size = Vector2(150, 0) +[node name="PortraitPanel" type="Panel" parent="Anchor/Panel/HBox"] +unique_name_in_owner = true +clip_children = 1 layout_mode = 2 +size_flags_horizontal = 3 +size_flags_stretch_ratio = 0.3 theme_override_styles/panel = SubResource("StyleBoxFlat_775n1") -[node name="DialogicNode_PortraitContainer" type="Control" parent="PanelContainer/HBox/Panel"] +[node name="PortraitBackgroundColor" type="ColorRect" parent="Anchor/Panel/HBox/PortraitPanel"] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -123.0 +offset_right = 123.0 +offset_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0, 0, 0, 0.231373) + +[node name="DialogicNode_PortraitContainer" type="Control" parent="Anchor/Panel/HBox/PortraitPanel/PortraitBackgroundColor"] layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -offset_left = -9.0 -offset_top = -2.0 -offset_right = 9.0 -offset_bottom = 3.0 +offset_left = -2.0 +offset_top = 4.0 +offset_right = 2.0 grow_horizontal = 2 grow_vertical = 2 script = ExtResource("2_ih78e") @@ -69,58 +98,68 @@ portrait_prefix = "Faces/" size_mode = 2 debug_character_portrait = "speaker" -[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/HBox"] +[node name="VBoxContainer" type="VBoxContainer" parent="Anchor/Panel/HBox"] layout_mode = 2 size_flags_horizontal = 3 -[node name="DialogicNode_NameLabel" type="Label" parent="PanelContainer/HBox/VBoxContainer"] +[node name="DialogicNode_NameLabel" type="Label" parent="Anchor/Panel/HBox/VBoxContainer"] +unique_name_in_owner = true layout_mode = 2 +theme_override_font_sizes/font_size = 8 text = "Name" script = ExtResource("6") -[node name="DialogicNode_DialogText" type="RichTextLabel" parent="PanelContainer/HBox/VBoxContainer"] +[node name="DialogicNode_DialogText" type="RichTextLabel" parent="Anchor/Panel/HBox/VBoxContainer"] +unique_name_in_owner = true layout_mode = 2 size_flags_vertical = 3 +theme_override_font_sizes/normal_font_size = 6 bbcode_enabled = true text = "Some text" scroll_following = true script = ExtResource("3") -[node name="VBoxContainer" type="HBoxContainer" parent="PanelContainer/HBox/VBoxContainer"] +[node name="VBoxContainer" type="HBoxContainer" parent="Anchor/Panel/HBox/VBoxContainer"] layout_mode = 2 alignment = 2 -[node name="DialogicNode_ChoiceButton" type="Button" parent="PanelContainer/HBox/VBoxContainer/VBoxContainer"] +[node name="DialogicNode_ChoiceButton" type="Button" parent="Anchor/Panel/HBox/VBoxContainer/VBoxContainer"] +visible = false layout_mode = 2 text = "Text" flat = true script = ExtResource("9") -[node name="DialogicNode_ChoiceButton2" type="Button" parent="PanelContainer/HBox/VBoxContainer/VBoxContainer"] +[node name="DialogicNode_ChoiceButton2" type="Button" parent="Anchor/Panel/HBox/VBoxContainer/VBoxContainer"] +visible = false layout_mode = 2 text = "Text" flat = true script = ExtResource("9") -[node name="DialogicNode_ChoiceButton3" type="Button" parent="PanelContainer/HBox/VBoxContainer/VBoxContainer"] +[node name="DialogicNode_ChoiceButton3" type="Button" parent="Anchor/Panel/HBox/VBoxContainer/VBoxContainer"] +visible = false layout_mode = 2 text = "Text" flat = true script = ExtResource("9") -[node name="DialogicNode_ChoiceButton4" type="Button" parent="PanelContainer/HBox/VBoxContainer/VBoxContainer"] +[node name="DialogicNode_ChoiceButton4" type="Button" parent="Anchor/Panel/HBox/VBoxContainer/VBoxContainer"] +visible = false layout_mode = 2 text = "Text" flat = true script = ExtResource("9") -[node name="DialogicNode_ChoiceButton5" type="Button" parent="PanelContainer/HBox/VBoxContainer/VBoxContainer"] +[node name="DialogicNode_ChoiceButton5" type="Button" parent="Anchor/Panel/HBox/VBoxContainer/VBoxContainer"] +visible = false layout_mode = 2 text = "Text" flat = true script = ExtResource("9") -[node name="DialogicNode_ChoiceButton6" type="Button" parent="PanelContainer/HBox/VBoxContainer/VBoxContainer"] +[node name="DialogicNode_ChoiceButton6" type="Button" parent="Anchor/Panel/HBox/VBoxContainer/VBoxContainer"] +visible = false layout_mode = 2 text = "Text" flat = true diff --git a/addons/dialogic/Modules/DefaultStyles/RPG_BoxPortrait/style.cfg b/addons/dialogic/Modules/DefaultStyles/RPG_BoxPortrait/style.cfg index b86a89e5d..d957ef940 100644 --- a/addons/dialogic/Modules/DefaultStyles/RPG_BoxPortrait/style.cfg +++ b/addons/dialogic/Modules/DefaultStyles/RPG_BoxPortrait/style.cfg @@ -1,5 +1,5 @@ [style] name = "RPG Single Portrait" author = "Jowan Spooner" -description = "An example RPG layout. Comes with only 1 portrait position (intended to be used with RPG-portrait mode)." +description = "An example RPG layout. Has no portrait positions, only a speaker portrait." scene = "DialogicRPGLayout.tscn" diff --git a/addons/dialogic/Modules/Text/character_settings/character_moods_settings.gd b/addons/dialogic/Modules/Text/character_settings/character_moods_settings.gd index e9d17d030..3faf41c06 100644 --- a/addons/dialogic/Modules/Text/character_settings/character_moods_settings.gd +++ b/addons/dialogic/Modules/Text/character_settings/character_moods_settings.gd @@ -83,6 +83,15 @@ func update_mood_list(selected_name := "") -> void: %MoodList.visible = %MoodList.item_count != 0 +func _input(event:InputEvent) -> void: + if !is_visible_in_tree() or !name+'/' in str(get_viewport().gui_get_focus_owner().get_path()): + return + if event is InputEventKey and event.keycode == KEY_F2 and event.pressed: + if %MoodList.is_anything_selected(): + %Name.grab_focus() + %Name.select_all() + get_viewport().set_input_as_handled() + func _on_mood_list_item_selected(index:int) -> void: if current_mood: diff --git a/addons/dialogic/Modules/Text/character_settings/character_moods_settings.tscn b/addons/dialogic/Modules/Text/character_settings/character_moods_settings.tscn index 78ec96c12..d677dc31e 100644 --- a/addons/dialogic/Modules/Text/character_settings/character_moods_settings.tscn +++ b/addons/dialogic/Modules/Text/character_settings/character_moods_settings.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=12 format=3 uid="uid://8ad1pwbjuqpt"] +[gd_scene load_steps=10 format=3 uid="uid://8ad1pwbjuqpt"] [ext_resource type="Script" path="res://addons/dialogic/Modules/Text/character_settings/character_moods_settings.gd" id="1_3px07"] [ext_resource type="PackedScene" uid="uid://7mvxuaulctcq" path="res://addons/dialogic/Editor/Events/Fields/FilePicker.tscn" id="2_e1vyd"] @@ -16,7 +16,7 @@ corner_radius_top_right = 20 corner_radius_bottom_right = 10 corner_radius_bottom_left = 10 -[sub_resource type="Image" id="Image_lpkqi"] +[sub_resource type="Image" id="Image_ff1hv"] data = { "data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 93, 93, 55, 255, 97, 97, 58, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 98, 98, 47, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 94, 94, 46, 255, 93, 93, 236, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), "format": "RGBA8", @@ -25,20 +25,8 @@ data = { "width": 16 } -[sub_resource type="ImageTexture" id="ImageTexture_vsi0a"] -image = SubResource("Image_lpkqi") - -[sub_resource type="Image" id="Image_vrt1e"] -data = { -"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 93, 93, 55, 255, 97, 97, 58, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 98, 98, 47, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 94, 94, 46, 255, 93, 93, 236, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), -"format": "RGBA8", -"height": 16, -"mipmaps": false, -"width": 16 -} - -[sub_resource type="ImageTexture" id="ImageTexture_hh3bs"] -image = SubResource("Image_vrt1e") +[sub_resource type="ImageTexture" id="ImageTexture_01qx8"] +image = SubResource("Image_ff1hv") [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_40fkd"] content_margin_left = 10.0 @@ -52,7 +40,7 @@ border_width_bottom = 1 corner_radius_bottom_right = 10 corner_radius_bottom_left = 10 -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_oq2xs"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_oxg6q"] content_margin_left = 4.0 content_margin_top = 0.0 content_margin_right = 4.0 @@ -77,6 +65,7 @@ theme_override_constants/separation = 0 [node name="ListPanel" type="PanelContainer" parent="VBox"] unique_name_in_owner = true +self_modulate = Color(0, 0, 0, 1) layout_mode = 2 theme_override_styles/panel = SubResource("StyleBoxFlat_y7t05") @@ -91,19 +80,19 @@ alignment = 2 unique_name_in_owner = true layout_mode = 2 tooltip_text = "Add type sound mood" -icon = SubResource("ImageTexture_vsi0a") +icon = SubResource("ImageTexture_01qx8") [node name="Duplicate" type="Button" parent="VBox/ListPanel/Vbox/HBoxContainer"] unique_name_in_owner = true layout_mode = 2 tooltip_text = "Duplicate" -icon = SubResource("ImageTexture_hh3bs") +icon = SubResource("ImageTexture_01qx8") [node name="Delete" type="Button" parent="VBox/ListPanel/Vbox/HBoxContainer"] unique_name_in_owner = true layout_mode = 2 tooltip_text = "Delete mood" -icon = SubResource("ImageTexture_hh3bs") +icon = SubResource("ImageTexture_01qx8") [node name="VSeparator" type="VSeparator" parent="VBox/ListPanel/Vbox/HBoxContainer"] layout_mode = 2 @@ -112,14 +101,14 @@ layout_mode = 2 unique_name_in_owner = true layout_mode = 2 tooltip_text = "Preview" -icon = SubResource("ImageTexture_hh3bs") +icon = SubResource("ImageTexture_01qx8") [node name="Default" type="Button" parent="VBox/ListPanel/Vbox/HBoxContainer"] unique_name_in_owner = true layout_mode = 2 tooltip_text = "Default" toggle_mode = true -icon = SubResource("ImageTexture_hh3bs") +icon = SubResource("ImageTexture_01qx8") [node name="MoodList" type="ItemList" parent="VBox/ListPanel/Vbox"] unique_name_in_owner = true @@ -163,6 +152,7 @@ anchor_bottom = 1.0 offset_left = -31.0 grow_horizontal = 0 grow_vertical = 2 +texture = SubResource("ImageTexture_01qx8") stretch_mode = 3 [node name="Label6" type="Label" parent="VBox/Margin/Settings/Grid"] @@ -193,7 +183,7 @@ unique_name_in_owner = true custom_minimum_size = Vector2(100, 0) layout_mode = 2 size_flags_horizontal = 3 -theme_override_styles/panel = SubResource("StyleBoxFlat_oq2xs") +theme_override_styles/panel = SubResource("StyleBoxFlat_oxg6q") file_filter = "*.ogg, *.mp3, *.wav" file_mode = 3 diff --git a/addons/dialogic/Modules/Text/event_text.gd b/addons/dialogic/Modules/Text/event_text.gd index 3ee1003c5..abb1ae183 100644 --- a/addons/dialogic/Modules/Text/event_text.gd +++ b/addons/dialogic/Modules/Text/event_text.gd @@ -63,7 +63,7 @@ func _execute() -> void: if check_portrait and character.portraits.get(check_portrait, {}).get('sound_mood', '') in character.custom_info.get('sound_moods', {}): dialogic.Text.update_typing_sound_mood(character.custom_info.get('sound_moods', {}).get(character.portraits[check_portrait].get('sound_mood', {}), {})) elif !character.custom_info.get('sound_mood_default', '').is_empty(): - dialogic.Text.update_typing_sound_mood(character.custom_info.get('sound_moods', {}).get(character.custom_info.get('sound_mood_default'))) + dialogic.Text.update_typing_sound_mood(character.custom_info.get('sound_moods', {}).get(character.custom_info.get('sound_mood_default'), {})) else: dialogic.Text.update_typing_sound_mood() diff --git a/addons/dialogic/Modules/Text/node_name_label.gd b/addons/dialogic/Modules/Text/node_name_label.gd index 9688a557e..80d6d3851 100644 --- a/addons/dialogic/Modules/Text/node_name_label.gd +++ b/addons/dialogic/Modules/Text/node_name_label.gd @@ -18,4 +18,6 @@ func _set(property, what): text = what if hide_when_empty: visible = !what.is_empty() + else: + show() return true diff --git a/addons/dialogic/Other/index_class.gd b/addons/dialogic/Other/index_class.gd index e050331b3..c94ac9150 100644 --- a/addons/dialogic/Other/index_class.gd +++ b/addons/dialogic/Other/index_class.gd @@ -78,7 +78,7 @@ func scan_for_layouts() -> Array[Dictionary]: 'name': config.get_value('style', 'name', 'Unnamed Layout'), 'path': this_folder.path_join(dir_name).path_join(config.get_value('style', 'scene')), 'author': config.get_value('style', 'author', 'Anonymous'), - 'description': config.get_value('style', 'descriptin', 'No description'), + 'description': config.get_value('style', 'description', 'No description'), 'preview_image': [config.get_value('style', 'image', default_image_path)] }) dir_name = dir.get_next()