Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-fix-PR #1999

Merged
merged 10 commits into from
Jan 9, 2024
4 changes: 2 additions & 2 deletions addons/dialogic/Editor/Events/EventBlock/event_block.gd
Original file line number Diff line number Diff line change
@@ -440,6 +440,6 @@ func _on_EventNode_gui_input(event:InputEvent) -> void:
popup.current_event = self
popup.popup_on_parent(Rect2(get_global_mouse_position(),Vector2()))
if resource.help_page_path == "":
popup.set_item_disabled(0, true)
popup.set_item_disabled(2, true)
else:
popup.set_item_disabled(0, false)
popup.set_item_disabled(2, false)
Original file line number Diff line number Diff line change
@@ -5,14 +5,16 @@ var current_event : Node = null

func _ready():
clear()
add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), "Duplicate")
add_separator()
add_icon_item(get_theme_icon("Help", "EditorIcons"), "Documentation")
add_icon_item(get_theme_icon("CodeHighlighter", "EditorIcons"), "Open Code")
add_separator()
add_icon_item(get_theme_icon("ArrowUp", "EditorIcons"), "Move up")
add_icon_item(get_theme_icon("ArrowDown", "EditorIcons"), "Move down")
add_separator()
add_icon_item(get_theme_icon("Remove", "EditorIcons"), "Delete")

var menu_background := StyleBoxFlat.new()
menu_background.bg_color = get_parent().get_theme_color("base_color", "Editor")
add_theme_stylebox_override('panel', menu_background)
Original file line number Diff line number Diff line change
@@ -701,11 +701,10 @@ func move_blocks_to_index(blocks:Array, index:int):
return
if "end_node" in event and event.end_node:
if !event.end_node in blocks:
if index > event.end_node.get_index():
if event.end_node.get_index() == event.get_index()+1:
blocks.append(event.end_node)
else:
return
if event.end_node.get_index() == event.get_index()+1:
blocks.append(event.end_node)
else:
return
index_shift += int(event.get_index() < index)

var do_indexes := {}
@@ -889,18 +888,22 @@ func indent_events() -> void:
func _on_event_popup_menu_index_pressed(index:int) -> void:
var item :Control = %EventPopupMenu.current_event
if index == 0:
if not item in selected_items:
selected_items = [item]
duplicate_selected()
elif index == 2:
if not item.resource.help_page_path.is_empty():
OS.shell_open(item.resource.help_page_path)
elif index == 1:
elif index == 3:
find_parent('EditorView').plugin_reference.get_editor_interface().set_main_screen_editor('Script')
find_parent('EditorView').plugin_reference.get_editor_interface().edit_script(item.resource.get_script(), 1, 1)
elif index == 3 or index == 4:
if index == 3:
elif index == 5 or index == 6:
if index == 5:
offset_blocks_by_index(selected_items, -1)
else:
offset_blocks_by_index(selected_items, +1)

elif index == 6:
elif index == 8:
var events_indexed := get_events_indexed([item])
TimelineUndoRedo.create_action("[D] Deleting 1 event.")
TimelineUndoRedo.add_do_method(delete_events_indexed.bind(events_indexed))
@@ -940,6 +943,16 @@ func _on_right_sidebar_resized():
#################### SHORTCUTS #################################################
################################################################################

func duplicate_selected() -> void:
if len(selected_items) > 0:
var events := get_events_indexed(selected_items).values()
var at_index: int = selected_items[-1].get_index()+1
TimelineUndoRedo.create_action("[D] Duplicate "+str(len(events))+" event(s).")
TimelineUndoRedo.add_do_method(add_events_at_index.bind(events, at_index))
TimelineUndoRedo.add_undo_method(delete_events_at_index.bind(at_index, len(events)))
TimelineUndoRedo.commit_action()


func _input(event:InputEvent) -> void:
# we protect this with is_visible_in_tree to not
# invoke a shortcut by accident
@@ -1064,13 +1077,7 @@ func _input(event:InputEvent) -> void:
get_viewport().set_input_as_handled()

"Ctrl+D":
if len(selected_items) > 0:
var events := get_events_indexed(selected_items).values()
var at_index :int= selected_items[-1].get_index()
TimelineUndoRedo.create_action("[D] Duplicate "+str(len(events))+" event(s).")
TimelineUndoRedo.add_do_method(add_events_at_index.bind(events, at_index))
TimelineUndoRedo.add_undo_method(delete_events_at_index.bind(at_index, len(events)))
TimelineUndoRedo.commit_action()
duplicate_selected()
get_viewport().set_input_as_handled()

"Alt+Up", "Option+Up":
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ func _ready() -> void:
func _highlight():
create_tween().tween_property(self, 'modulate', Color.WHITE, 0.15)
prev_z_index = DialogicUtil.autoload().Portraits.get_character_info(character).get('z_index', 0)
DialogicUtil.autoload().Portraits.change_character_z_index(character, 10)
DialogicUtil.autoload().Portraits.change_character_z_index(character, 99)


func _unhighlight():
9 changes: 5 additions & 4 deletions addons/dialogic/Modules/Character/subsystem_portraits.gd
Original file line number Diff line number Diff line change
@@ -23,7 +23,6 @@ func clear_game_state(clear_flag:=DialogicGameHandler.ClearFlags.FULL_CLEAR):
for character in dialogic.current_state_info.get('portraits', {}).keys():
remove_character(load(character))
dialogic.current_state_info['portraits'] = {}
dialogic.current_state_info['speaker_portraits'] = {}


func load_game_state(load_flag:=LoadFlags.FULL_LOAD):
@@ -37,8 +36,11 @@ func load_game_state(load_flag:=LoadFlags.FULL_LOAD):
character_info.get('z_index', 0),
character_info.get('extra_data', ""),
"InstantInOrOut", 0, false)
if dialogic.current_state_info.get('speaker', ''):
change_speaker(load(dialogic.current_state_info['speaker']))
var speaker: Variant = dialogic.current_state_info.get('speaker', "")
if speaker:
dialogic.current_state_info['speaker'] = ""
change_speaker(load(speaker))
dialogic.current_state_info['speaker'] = speaker


func pause() -> void:
@@ -599,7 +601,6 @@ func change_speaker(speaker:DialogicCharacter= null, portrait:= ""):

_change_portrait_mirror(con.get_child(0))


if speaker:
if speaker.resource_path != dialogic.current_state_info['speaker']:
if dialogic.current_state_info['speaker'] and is_character_joined(load(dialogic.current_state_info['speaker'])):
Original file line number Diff line number Diff line change
@@ -14,14 +14,3 @@ func load_info(text:String, character:String = "", character_color:=Color(), ico
else:
%Icon.show()
%Icon.texture = icon

#
#func prepare_textbox(history_root:Node) -> void:
#%TextBox.add_theme_font_override("normal_font", history_root.history_font_normal)
#%NameLabel.add_theme_font_override("font", history_root.history_font_normal)
#%NameLabel.add_theme_font_size_override("font_size", history_root.history_font_size)
#%TextBox.add_theme_font_override("bold_font", history_root.history_font_bold)
#%TextBox.add_theme_font_override("italics_font", history_root.history_font_italics)
#%TextBox.add_theme_font_size_override("normal_font_size", history_root.history_font_size)
#%TextBox.add_theme_font_size_override("bold_font_size", history_root.history_font_size)
#%TextBox.add_theme_font_size_override("italics_font_size", history_root.history_font_size)
Original file line number Diff line number Diff line change
@@ -38,6 +38,8 @@ var history_item_theme : Theme = null
func _ready() -> void:
if Engine.is_editor_hint():
return
Dialogic.History.open_requested.connect(_on_show_history_pressed)
Dialogic.History.close_requested.connect(_on_hide_history_pressed)


func _apply_export_overrides() -> void:
13 changes: 13 additions & 0 deletions addons/dialogic/Modules/History/subsystem_history.gd
Original file line number Diff line number Diff line change
@@ -23,6 +23,10 @@ var _was_last_event_already_read := false
signal already_read_event_reached
signal not_read_event_reached


signal open_requested
signal close_requested

####################################################################################################
## INITIALIZE
####################################################################################################
@@ -36,6 +40,15 @@ func _ready() -> void:
already_read_history_enabled = ProjectSettings.get_setting('dialogic/history/already_read_history_enabled', false)



func open_history() -> void:
open_requested.emit()


func close_history() -> void:
close_requested.emit()


####################################################################################################
## STATE
####################################################################################################
4 changes: 2 additions & 2 deletions addons/dialogic/Modules/StyleEditor/style_editor.gd
Original file line number Diff line number Diff line change
@@ -268,8 +268,8 @@ func _on_duplicate_button_pressed():
if !%StyleList.is_anything_selected():
return
find_parent('EditorView').godot_file_dialog(
add_style_undoable.bind(current_style.clone(), current_style),
'',
add_style_undoable.bind(current_style.clone(), null),
'*.tres',
EditorFileDialog.FILE_MODE_SAVE_FILE,
"Select folder for new style")

10 changes: 5 additions & 5 deletions addons/dialogic/Modules/Text/subsystem_text.gd
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ var _autopauses := {}
func clear_game_state(clear_flag:=DialogicGameHandler.ClearFlags.FULL_CLEAR) -> void:
update_dialog_text('', true)
update_name_label(null)
dialogic.current_state_info['speaker'] = null
dialogic.current_state_info['speaker'] = ""
dialogic.current_state_info['text'] = ''

set_text_reveal_skippable(ProjectSettings.get_setting('dialogic/text/initial_text_reveal_skippable', true))
@@ -58,8 +58,8 @@ func clear_game_state(clear_flag:=DialogicGameHandler.ClearFlags.FULL_CLEAR) ->
func load_game_state(load_flag:=LoadFlags.FULL_LOAD) -> void:
update_dialog_text(dialogic.current_state_info.get('text', ''), true)
var character:DialogicCharacter = null
if dialogic.current_state_info.get('speaker', null):
character = load(dialogic.current_state_info.get('speaker', null))
if dialogic.current_state_info.get('speaker', ""):
character = load(dialogic.current_state_info.get('speaker', ""))

if character:
update_name_label(character)
@@ -326,7 +326,7 @@ func skip_text_animation() -> void:


func get_current_speaker() -> DialogicCharacter:
return (load(dialogic.current_state_info['speaker']) as DialogicCharacter)
return (load(dialogic.current_state_info.get('speaker', "")) as DialogicCharacter)


#################### HELPERS & OTHER STUFF #########################################################
@@ -453,7 +453,7 @@ func effect_signal(text_node:Control, skipped:bool, argument:String) -> void:

func effect_mood(text_node:Control, skipped:bool, argument:String) -> void:
if argument.is_empty(): return
if dialogic.current_state_info.get('speaker', null):
if dialogic.current_state_info.get('speaker', ""):
update_typing_sound_mood(
load(dialogic.current_state_info.speaker).custom_info.get('sound_moods', {}).get(argument, {}))

5 changes: 1 addition & 4 deletions addons/dialogic/Resources/dialogic_style.gd
Original file line number Diff line number Diff line change
@@ -86,10 +86,7 @@ func move_layer(from_index:int, to_index:int) -> void:
if not has_layer(from_index) or not has_layer(to_index-1):
return

if from_index < to_index:
to_index -1

var info: DialogicLayoutLayer = layers.pop_at(from_index)
var info: Resource = layers.pop_at(from_index)
layers.insert(to_index, info)
changed.emit()

Loading