Skip to content

Commit

Permalink
Merge branch 'main' into clean-visual-fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Jowan-Spooner authored Jan 9, 2024
2 parents 91e2e0c + cc65d6b commit 2b997b3
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 47 deletions.
6 changes: 2 additions & 4 deletions addons/dialogic/Editor/Events/EventBlock/event_block.gd
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,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)

#endregion
popup.set_item_disabled(2, false)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ 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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 := {}
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
9 changes: 5 additions & 4 deletions addons/dialogic/Modules/Character/subsystem_portraits.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand Down Expand Up @@ -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'])):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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:
Expand Down
13 changes: 13 additions & 0 deletions addons/dialogic/Modules/History/subsystem_history.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
####################################################################################################
Expand All @@ -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
####################################################################################################
Expand Down
4 changes: 2 additions & 2 deletions addons/dialogic/Modules/StyleEditor/style_editor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
10 changes: 5 additions & 5 deletions addons/dialogic/Modules/Text/subsystem_text.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
Expand Down Expand Up @@ -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 #########################################################
Expand Down Expand Up @@ -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, {}))

Expand Down
5 changes: 1 addition & 4 deletions addons/dialogic/Resources/dialogic_style.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 2b997b3

Please sign in to comment.