Skip to content

Commit

Permalink
Many changes for 4.0 by Jowan(#1045)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jowan-Spooner authored Jul 28, 2022
1 parent d794bce commit 90b1f14
Show file tree
Hide file tree
Showing 79 changed files with 1,131 additions and 1,363 deletions.
23 changes: 11 additions & 12 deletions addons/dialogic/Editor/CharacterEditor/CharacterEditor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func load_character(resource: DialogicCharacter) -> void:
$'%MainScale'.value = 100*resource.scale
$'%MainOffsetX'.value = resource.offset.x
$'%MainOffsetY'.value = resource.offset.y
$'%MainMirror'.pressed = resource.mirror
$'%MainMirror'.button_pressed = resource.mirror
$'%PortraitSearch'.text = ""

for main_edit in $'%MainEditTabs'.get_children():
Expand All @@ -58,7 +58,7 @@ func save_character() -> void:
current_character.description = $'%DescriptionTextEdit'.text
current_character.scale = $'%MainScale'.value/100.0
current_character.offset = Vector2($'%MainOffsetX'.value, $'%MainOffsetY'.value)
current_character.mirror = $'%MainMirror'.pressed
current_character.mirror = $'%MainMirror'.button_pressed

for main_edit in $'%MainEditTabs'.get_children():
if main_edit.has_method('save_character'):
Expand All @@ -78,8 +78,7 @@ func save_character() -> void:
##############################################################################

func _ready() -> void:
var dialogic_plugin = get_tree().root.get_node('EditorNode/DialogicPlugin')
dialogic_plugin.dialogic_save.connect(save_character)
DialogicUtil.get_dialogic_plugin().dialogic_save.connect(save_character)

# Let's go connecting!
$'%NameLineEdit'.text_changed.connect(something_changed)
Expand All @@ -93,15 +92,15 @@ func _ready() -> void:
$'%MainMirror'.toggled.connect(main_portrait_settings_update)
$'%PortraitSearch'.text_changed.connect(update_portrait_list)

$'%NewPortrait'.pressed.connect(create_portrait_entry_instance, ['', {'path':'', 'scale':1, 'offset':Vector2(), 'mirror':false}])
$'%NewPortrait'.pressed.connect(create_portrait_entry_instance.bind('', {'path':'', 'scale':1, 'offset':Vector2(), 'mirror':false}))
$'%ImportFromFolder'.pressed.connect(open_portrait_folder_select)
$'%PreviewMode'.item_selected.connect(_on_PreviewMode_item_selected)
$'%PreviewMode'.select(DialogicUtil.get_project_setting('dialogic/editor/character_preview_mode', 0))
_on_PreviewMode_item_selected($'%PreviewMode'.selected)
$'%PreviewPositionIcon'.texture = get_theme_icon("EditorPosition", "EditorIcons")

if find_parent('EditorView'): # This prevents the view to turn black if you are editing this scene in Godot
var style = $Split/EditorScroll.get('custom_styles/bg')
var style = $Split/EditorScroll.get_theme_stylebox('custom_styles/bg')
style.set('bg_color', get_theme_color("dark_color_1", "Editor"))

$'%NewPortrait'.icon = get_theme_icon("Add", "EditorIcons")
Expand Down Expand Up @@ -130,7 +129,7 @@ func something_changed(fake_argument = "") -> void:


func open_portrait_folder_select() -> void:
find_parent("EditorView").godot_file_dialog(self, "_on_dir_selected","*", EditorFileDialog.MODE_OPEN_DIR)
find_parent("EditorView").godot_file_dialog(_on_dir_selected, "*", EditorFileDialog.FILE_MODE_OPEN_DIR)


func _on_dir_selected(path:String) -> void:
Expand Down Expand Up @@ -201,19 +200,19 @@ func update_portrait_preview(portrait_inst = "") -> void:
$'%PreviewLabel'.text = DTS.translate('Preview of')+' "'+current_portrait.get_portrait_name()+'"'

var path:String = current_portrait.portrait_data.get('path', '')
var mirror:bool = current_portrait.portrait_data.get('mirror', false) != $'%MainMirror'.pressed
var mirror:bool = current_portrait.portrait_data.get('mirror', false) != $'%MainMirror'.button_pressed
var scale:float = current_portrait.portrait_data.get('scale', 1) * $'%MainScale'.value/100.0
var offset:Vector2 = current_portrait.portrait_data.get('offset', Vector2()) + Vector2($'%MainOffsetX'.value, $'%MainOffsetY'.value)
var l_path = path.to_lower()
if '.png' in l_path or '.svg' in l_path:
$'%PreviewRealRect'.texture = load(path)
$'%PreviewFullRect'.texture = load(path)
$"%PreviewLabel".text += ' (' + str($'%PreviewRealRect'.texture.get_width()) + 'x' + str($'%PreviewRealRect'.texture.get_height())+')'
$'%PreviewRealRect'.rect_scale = Vector2(scale, scale)
$'%PreviewRealRect'.scale = Vector2(scale, scale)
$'%PreviewRealRect'.flip_h = mirror
$'%PreviewFullRect'.flip_h = mirror
$'%PreviewRealRect'.rect_position.x = -($'%PreviewRealRect'.texture.get_width()*scale/2.0)+offset.x
$'%PreviewRealRect'.rect_position.y = -($'%PreviewRealRect'.texture.get_height()*scale)+offset.y
$'%PreviewRealRect'.position.x = -($'%PreviewRealRect'.texture.get_width()*scale/2.0)+offset.x
$'%PreviewRealRect'.position.y = -($'%PreviewRealRect'.texture.get_height()*scale)+offset.y

$'%PortraitSettings'.show()
elif '.tscn' in l_path:
Expand All @@ -225,7 +224,7 @@ func update_portrait_preview(portrait_inst = "") -> void:
$'%PortraitScale'.value = current_portrait.portrait_data.get('scale', 1)*100
$'%PortraitOffsetX'.value = current_portrait.portrait_data.get('offset', Vector2()).x
$'%PortraitOffsetY'.value = current_portrait.portrait_data.get('offset', Vector2()).y
$'%PortraitMirror'.pressed = current_portrait.portrait_data.get('mirror', false)
$'%PortraitMirror'.button_pressed = current_portrait.portrait_data.get('mirror', false)

else:
$'%PortraitSettings'.hide()
Expand Down
517 changes: 201 additions & 316 deletions addons/dialogic/Editor/CharacterEditor/CharacterEditor.tscn

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion addons/dialogic/Editor/CharacterEditor/PortraitEntry.gd
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func _on_ButtonDelete_pressed() -> void:
queue_free()

func _on_ButtonSelect_pressed() -> void:
find_parent('EditorView').godot_file_dialog(self,'_on_file_selected', "*.png, *.svg, *.tscn")
find_parent('EditorView').godot_file_dialog(_on_file_selected, "*.png, *.svg, *.tscn")

func _on_file_selected(path:String) -> void:
$PathEdit.text = path
Expand Down
52 changes: 22 additions & 30 deletions addons/dialogic/Editor/CharacterEditor/PortraitEntry.tscn
Original file line number Diff line number Diff line change
@@ -1,55 +1,47 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=4 format=3 uid="uid://dfwnfu41utt3d"]

[ext_resource path="res://addons/dialogic/Editor/CharacterEditor/PortraitEntry.gd" type="Script" id=2]
[ext_resource type="Script" path="res://addons/dialogic/Editor/CharacterEditor/PortraitEntry.gd" id="2"]

[sub_resource type="Image" id=4]
[sub_resource type="Image" id="Image_euwjs"]
data = {
"data": PoolByteArray( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
"format": "LumAlpha8",
"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=3]
flags = 4
flags = 4
image = SubResource( 4 )
size = Vector2( 16, 16 )
[sub_resource type="ImageTexture" id="ImageTexture_c6uut"]
image = SubResource("Image_euwjs")

[node name="PortraitEntry" type="HBoxContainer"]
margin_right = 451.0
margin_bottom = 24.0
script = ExtResource( 2 )
script = ExtResource("2")

[node name="NameEdit" type="LineEdit" parent="."]
margin_right = 160.0
margin_bottom = 24.0
rect_min_size = Vector2( 160, 0 )
__meta__ = {
"_edit_use_anchors_": false
}
custom_minimum_size = Vector2(90, 0)
offset_right = 90.0
offset_bottom = 31.0

[node name="PathEdit" type="LineEdit" parent="."]
margin_left = 164.0
margin_right = 403.0
margin_bottom = 24.0
rect_min_size = Vector2( 150, 0 )
offset_left = 94.0
offset_right = 161.0
offset_bottom = 31.0
size_flags_horizontal = 3
editable = false
selecting_enabled = false

[node name="ButtonSelect" type="Button" parent="."]
margin_left = 407.0
margin_right = 419.0
margin_bottom = 24.0
offset_left = 165.0
offset_right = 189.0
offset_bottom = 31.0
icon = SubResource("ImageTexture_c6uut")
flat = true

[node name="ButtonDelete" type="Button" parent="."]
margin_left = 423.0
margin_right = 451.0
margin_bottom = 24.0
icon = SubResource( 3 )
offset_left = 193.0
offset_right = 217.0
offset_bottom = 31.0
icon = SubResource("ImageTexture_c6uut")
flat = true

[connection signal="focus_entered" from="NameEdit" to="." method="_on_focus_entered"]
Expand Down
8 changes: 4 additions & 4 deletions addons/dialogic/Editor/Common/TLabel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ extends Label

@export var text_key : String = ""

# TODO seems like this kind of export cant be made
#@export("Normal", "Title", "Info") var mode : String = "Normal"
@export var mode:String = "Normal"
enum LabelModes {Normal, Title, Info}

@export var mode : LabelModes = LabelModes.Normal

func set_text_from_key(value):
text = DTS.translate(value)
Expand All @@ -15,7 +15,7 @@ func _ready():
set_text_from_key(text_key)
remove_theme_color_override('font_color')
if find_parent('EditorView'):
if mode == "Title":
if mode == LabelModes.Title:
var x = StyleBoxFlat.new()
x.bg_color = Color(0.545098, 0.545098, 0.545098, 0.211765)
x.content_margin_bottom = 5
Expand Down
11 changes: 4 additions & 7 deletions addons/dialogic/Editor/Common/TLabel.tscn
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=2 format=3 uid="uid://duj8nl0vpms35"]

[ext_resource path="res://addons/dialogic/Editor/Common/TLabel.gd" type="Script" id=1]

[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 1, 1, 1, 0 )
[ext_resource type="Script" path="res://addons/dialogic/Editor/Common/TLabel.gd" id="1"]

[node name="TLabel" type="Label"]
anchor_right = 1.0
anchor_bottom = 1.0
custom_styles/normal = SubResource( 1 )
text = "Some cool text"
script = ExtResource( 1 )
script = ExtResource("1")
mode = null
14 changes: 6 additions & 8 deletions addons/dialogic/Editor/Common/Toolbar.gd
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@ func is_current_unsaved() -> bool:
################################################################################

func _on_AddTimeline_pressed():
get_node("%TimelineEditor").new_timeline()
get_parent().get_node("%TimelineEditor").new_timeline()

func _on_AddCharacter_pressed():
find_parent('EditorView').godot_file_dialog(
get_parent().get_node("CharacterEditor"),
'new_character',
get_parent().get_node("CharacterEditor").new_character,
'*.dch; DialogicCharacter',
EditorFileDialog.MODE_SAVE_FILE,
EditorFileDialog.FILE_MODE_OPEN_FILE,
'Save new Character',
'New_Character'
)
Expand Down Expand Up @@ -79,10 +78,10 @@ func load_timeline(timeline_path):
$PlayTimeline.show()

func play_timeline():
if get_node("%TimelineEditor").current_timeline:
if find_parent('EditorView').get_node("%TimelineEditor").current_timeline:
var dialogic_plugin = DialogicUtil.get_dialogic_plugin()
# Save the current opened timeline
ProjectSettings.set_setting('dialogic/editor/current_timeline_path', get_node("%TimelineEditor").current_timeline.resource_path)
ProjectSettings.set_setting('dialogic/editor/current_timeline_path', find_parent('EditorView').get_node("%TimelineEditor").current_timeline.resource_path)
ProjectSettings.save()
dialogic_plugin._editor_interface.play_custom_scene("res://addons/dialogic/Other/TestTimelineScene.tscn")

Expand All @@ -100,5 +99,4 @@ func load_character(character_path):

func _on_ResourcePicker_value_changed(property_name, value):
if value:
var dialogic_plugin = get_tree().root.get_node('EditorNode/DialogicPlugin')
dialogic_plugin._editor_interface.inspect_object(load(value))
DialogicUtil.get_dialogic_plugin()._editor_interface.inspect_object(load(value))
33 changes: 18 additions & 15 deletions addons/dialogic/Editor/EditorView.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@tool
extends Control

var plugin_reference = null

var editor_file_dialog:EditorFileDialog

signal continue_opening_resource
Expand All @@ -16,8 +18,7 @@ func _ready():
# Open the last edited scene
if ProjectSettings.has_setting('dialogic/editor/last_resources'):
var path = ProjectSettings.get_setting('dialogic/editor/last_resources')[0]
var dialogic_plugin = get_tree().root.get_node('EditorNode/DialogicPlugin')
dialogic_plugin._editor_interface.inspect_object(load(path))
DialogicUtil.get_dialogic_plugin()._editor_interface.inspect_object(load(path))

$SaveConfirmationDialog.add_button('No Saving Please!', true, 'nosave')
$SaveConfirmationDialog.hide()
Expand Down Expand Up @@ -52,7 +53,7 @@ func show_settings():

func save_current_resource():
$SaveConfirmationDialog.popup_centered()
$SaveConfirmationDialog.window_title = "Unsaved changes!"
$SaveConfirmationDialog.title = "Unsaved changes!"
$SaveConfirmationDialog.dialog_text = "Save before changing resource?"

func _on_SaveConfirmationDialog_confirmed():
Expand All @@ -67,24 +68,26 @@ func _on_SaveConfirmationDialog_custom_action(action):
$SaveConfirmationDialog.hide()
emit_signal("continue_opening_resource")

func godot_file_dialog(object, method, filter, mode = EditorFileDialog.MODE_OPEN_FILE, window_title = "Save", current_file_name = 'New_File'):
# TODO (No idea how this works in godot 4)
#for connection in editor_file_dialog.get_signal_connection_list('file_selected')+editor_file_dialog.get_signal_connection_list('dir_selected'):
# editor_file_dialog.disconnect('file_selected', connection.target, connection.method)
func godot_file_dialog(callable, filter, mode = EditorFileDialog.FILE_MODE_OPEN_FILE, window_title = "Save", current_file_name = 'New_File'):
for connection in editor_file_dialog.file_selected.get_connections():
editor_file_dialog.file_selected.disconnect(connection)
for connection in editor_file_dialog.dir_selected.get_connections():
editor_file_dialog.dir_selected.disconnect(connection)
editor_file_dialog.mode = mode
editor_file_dialog.clear_filters()
editor_file_dialog.popup_centered_ratio(0.75)
editor_file_dialog.add_filter(filter)
editor_file_dialog.window_title = window_title
editor_file_dialog.current_file = current_file_name
#if mode == EditorFileDialog.MODE_OPEN_FILE or mode == EditorFileDialog.MODE_SAVE_FILE:
# editor_file_dialog.file_selected.connect('file_selected', object, method, [], CONNECT_ONESHOT)
#elif mode == EditorFileDialog.MODE_OPEN_DIR:
# editor_file_dialog.connect('dir_selected', object, method, [], CONNECT_ONESHOT)
#elif mode == EditorFileDialog.MODE_OPEN_ANY:
# editor_file_dialog.connect('dir_selected', object, method, [], CONNECT_ONESHOT)
# editor_file_dialog.connect('file_selected', object, method, [], CONNECT_ONESHOT)
if mode == EditorFileDialog.FILE_MODE_OPEN_FILE or mode == EditorFileDialog.MODE_SAVE_FILE:
editor_file_dialog.file_selected.connect(callable, CONNECT_ONESHOT)
elif mode == EditorFileDialog.FILE_MODE_OPEN_DIR:
editor_file_dialog.dir_selected.connect(callable, CONNECT_ONESHOT)
elif mode == EditorFileDialog.FILE_MODE_OPEN_ANY:
editor_file_dialog.dir_selected.connect(callable, CONNECT_ONESHOT)
editor_file_dialog.file_selected.connect(callable, CONNECT_ONESHOT)
return editor_file_dialog



func _on_settings_editor_close_requested():
$SettingsEditor.hide()
Loading

0 comments on commit 90b1f14

Please sign in to comment.