Started updating the asset to work with 3.1 (alpha 4). It mostly works now, but a bunch of events still need to be fixed, also the new base classes will need to be implemented.

This commit is contained in:
Relintai 2019-02-03 23:03:31 +01:00
parent 8562947160
commit 4fac3e5016
19 changed files with 220 additions and 629 deletions

View File

@ -20,7 +20,7 @@ signal custom_property_delete_requested(custom_property_id)
func _ready():
pass
self.item_manager = Globals.get("item_manager")
self.item_manager = ProjectSettings.get("item_manager")
func build_properties(item):
self.item = item

View File

@ -11,21 +11,37 @@ signal data_item_class_opened(item_class)
func _enter_tree():
OS.set_low_processor_usage_mode(true)
name = "Data Editor"
# Currently, adding the singleton automatically, does not work
#check_for_data_singleton()
check_plugin_settings()
gui = data_editor_class.instance()
get_editor_viewport().add_child(gui)
gui.set_area_as_parent_rect()
gui.rect_min_size = Vector2(0, 500)
add_control_to_bottom_panel(gui, "Data Editor")
#get_editor_interface().get_editor_viewport().add_child(gui)
#gui.set_anchors_preset(Control.PRESET_WIDE)
#get_editor_interface().
#get_editor_interface().
#get_editor_interface().get_editor_viewport().add_
#gui.set_area_as_parent_rect()
gui.hide()
# Remove control and data singleton
func _exit_tree():
OS.set_low_processor_usage_mode(false)
get_editor_viewport().remove_child(gui)
remove_control_from_bottom_panel(gui)
#get_editor_interface().get_editor_viewport().remove_child(gui)
if gui:
gui.free()
var config = ConfigFile.new()
#var status = config.load("res://engine.cfg")
#if status == OK:
@ -34,15 +50,18 @@ func _exit_tree():
# config.save("res://engine.cfg")
# Check if the Classes and Data folders exist
Globals.clear("item_manager")
ProjectSettings.clear("item_manager")
ProjectSettings.save()
func _ready():
gui.connect("class_edit_requested", self, "edit_class", [])
Globals.set("debug_is_editor", true)
ProjectSettings.set("debug_is_editor", true)
# Opens the selected class in the Script Editor
func edit_class(item_class):
edit_resource(item_class)
get_editor_interface().edit_resource(item_class)
# TODO: Maybe there is a way to refresh the tree without restart?
@ -88,8 +107,10 @@ func has_main_screen():
# Virtual:
func make_visible(visible):
if gui and visible:
gui.reload()
gui.show()
elif gui:
gui.hide()

View File

@ -59,7 +59,7 @@ func _init():
item_manager = preload("item_manager.gd").new() # This item_manager will add itself to the globals
func _ready():
Globals.set("debug_is_editor", false)
ProjectSettings.set("debug_is_editor", false)
# Tree signals
@ -222,7 +222,7 @@ func _on_ItemTree_on_new_item_created(new_item):
func create_shortcut(keys):
var short_cut = ShortCut.new()
var input_event = InputEvent()
var input_event = InputEvent.new()
input_event.type = InputEvent.KEY
input_event.ID = keys
short_cut.set_shortcut(input_event)
@ -230,7 +230,7 @@ func create_shortcut(keys):
# TODO: Implement
func warn_about_reload():
if item_manager.has_unsaved_items():
input_dialog.popup(self, "reload_confirmed", tr("Confirm reload"), tr("Some changes have not been saved. \nThey will be discarded if you proceed. Are you sure you want to perform this action?"))
input_dialog.input_dialog_popup(self, "reload_confirmed", tr("Confirm reload"), tr("Some changes have not been saved. \nThey will be discarded if you proceed. Are you sure you want to perform this action?"))
func reload():
@ -293,19 +293,19 @@ func _on_NewClassIconFileDialog_file_selected(path):
# General handler for a lot of actions to centralize the GUI logic a bit
func handle_actions(action, argument = ""):
if action == "add":
input_dialog.popup(self, "_on_add_item_confirmed", tr("New Item"), tr("Please enter an ID for and optionally a display name the new item"), tr("ID"), "", tr("Display Name (optional)"), "")
input_dialog.input_dialog_popup(self, "_on_add_item_confirmed", tr("New Item"), tr("Please enter an ID for and optionally a display name the new item"), tr("ID"), "", tr("Display Name (optional)"), "")
elif action == "rename":
if selected_item:
input_dialog.popup(self, "_on_rename_item_confirmed", tr("Rename Item"), tr("Please enter a new ID for this item."), "ID", selected_id)
input_dialog.input_dialog_popup(self, "_on_rename_item_confirmed", tr("Rename Item"), tr("Please enter a new ID for this item."), "ID", selected_id)
else:
input_dialog.popup(self, "_on_rename_class_confirmed", tr("Rename Class"), tr("Please enter a new name for this class. All pending changes will be discarded!"), "ID", selected_class)
input_dialog.input_dialog_popup(self, "_on_rename_class_confirmed", tr("Rename Class"), tr("Please enter a new name for this class. All pending changes will be discarded!"), "ID", selected_class)
elif action == "duplicate":
var new_display_name = ""
if selected_item._dirty:
input_dialog.popup(self, "item_duplication_failed", tr("Item duplication failed"), tr("Before duplicating this item, please first save it."))
input_dialog.input_dialog_popup(self, "item_duplication_failed", tr("Item duplication failed"), tr("Before duplicating this item, please first save it."))
return
selected_item._display_name = ""
input_dialog.popup(self, "_on_duplicate_confirmed", tr("Duplicate Item"), tr("Please enter a new ID for this item"), "ID", selected_id, tr("Display Name (optional)"), new_display_name)
input_dialog.input_dialog_popup(self, "_on_duplicate_confirmed", tr("Duplicate Item"), tr("Please enter a new ID for this item"), "ID", selected_id, tr("Display Name (optional)"), new_display_name)
elif action == "save":
item_manager.save_item(selected_item)
item_tree.load_tree()
@ -321,9 +321,9 @@ func handle_actions(action, argument = ""):
_on_AddClassButton_button_down() # TODO: Incorporate into dialog handling
elif action == "delete":
if selected_item:
input_dialog.popup(self, "_on_delete_item_confirmed", tr("Delete Item"), tr("Are you sure you want to delete this item?"))
input_dialog.input_dialog_popup(self, "_on_delete_item_confirmed", tr("Delete Item"), tr("Are you sure you want to delete this item?"))
else:
input_dialog.popup(self, "_on_delete_class_confirmed", tr("Delete Class"), tr("Are you sure you want to delete class along with all items?"))
input_dialog.input_dialog_popup(self, "_on_delete_class_confirmed", tr("Delete Class"), tr("Are you sure you want to delete class along with all items?"))
elif action == "options":
options_screen.popup_centered()
elif action == "edit_class":
@ -333,7 +333,7 @@ func handle_actions(action, argument = ""):
elif action == "copy_get_item":
copy_get_item()
elif action == "change_display_name":
input_dialog.popup(self, "change_display_name", tr("Change Display Name"), tr("Please enter a display name for this item."), "Display Name", selected_item._display_name)
input_dialog.input_dialog_popup(self, "change_display_name", tr("Change Display Name"), tr("Please enter a display name for this item."), "Display Name", selected_item._display_name)
elif action == "add_custom_property":
new_custom_property_name.set_text("")
new_custom_property_dialog.popup_centered()

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,7 @@ func get_class():
if _class:
return _class
else:
_class = self.get_script().get_path().get_file().basename()
_class = self.get_script().get_path().get_file().get_basename()
return _class
@ -46,7 +46,7 @@ func set_display_name(name):
func update_property(property, value):
var data_singleton = Globals.get_singleton("data")
var data_singleton = ProjectSettings.get_singleton("data")
if data_singleton:
data_singleton.set_progress(_class, _id, property, value)

View File

@ -14,7 +14,7 @@ onready var line_edit_2 = get_node("VBox/LineEdit2")
#func _init(text, placerholder_1 = "", placeholder_2 = ""):
func popup(caller, callback_method, title, text, placeholder_1 = "", default_text_1 = "", placeholder_2 = "", default_text_2 = ""):
func input_dialog_popup(caller, callback_method, title, text, placeholder_1 = "", default_text_1 = "", placeholder_2 = "", default_text_2 = ""):
self.caller = caller
self.callback_method = callback_method
self.placeholder_1 = placeholder_1
@ -41,7 +41,7 @@ func popup(caller, callback_method, title, text, placeholder_1 = "", default_tex
line_edit_2.set_text(default_text_2)
self.popup_centered()
if not line_edit_1.is_hidden():
if line_edit_1.visible:
line_edit_1.grab_focus()
func _on_ConfirmationDialog_confirmed():

View File

@ -28,7 +28,7 @@ var default_type_values = {
str(TYPE_BOOL): false, # OK
str(TYPE_COLOR): Color(0,0,0),
str(TYPE_OBJECT): "res://",
str(TYPE_IMAGE): "res://",
#str(TYPE_IMAGE): "res://",
str(TYPE_INT): 0,
str(TYPE_NODE_PATH): @"",
str(TYPE_REAL): 0.0,
@ -40,8 +40,8 @@ var default_type_values = {
str(TYPE_TRANSFORM): Transform(Vector3(0,0,0),Vector3(0,0,0),Vector3(0,0,0),Vector3(0,0,0))
}
var type_names = {"STRING":TYPE_STRING, "BOOL":TYPE_BOOL, "COLOR":TYPE_COLOR, "OBJECT":TYPE_OBJECT, "IMAGE":TYPE_IMAGE, "INT":TYPE_INT, "NODE_PATH":TYPE_NODE_PATH, "REAL":TYPE_REAL, "RECT2":TYPE_RECT2, "VECTOR2":TYPE_VECTOR2, "VECTOR3":TYPE_VECTOR3, "PLANE":TYPE_PLANE, "QUAT":TYPE_QUAT, "TRANSFORM":TYPE_TRANSFORM }
var type_names = {"STRING":TYPE_STRING, "BOOL":TYPE_BOOL, "COLOR":TYPE_COLOR, "OBJECT":TYPE_OBJECT, "INT":TYPE_INT, "NODE_PATH":TYPE_NODE_PATH, "REAL":TYPE_REAL, "RECT2":TYPE_RECT2, "VECTOR2":TYPE_VECTOR2, "VECTOR3":TYPE_VECTOR3, "PLANE":TYPE_PLANE, "QUAT":TYPE_QUAT, "TRANSFORM":TYPE_TRANSFORM }
# "IMAGE":TYPE_IMAGE,
func _init():
load_manager()
@ -56,7 +56,7 @@ func load_manager():
set_up_item_folders()
load_items()
reload_unsaved_items()
Globals.set("item_manager", self)
ProjectSettings.set("item_manager", self)
# Try to keep unsaved changes when (re)loading the item_manager
var unsaved_items = []
@ -111,7 +111,7 @@ func load_class_names():
directory.list_dir_begin()
var file_name = directory.get_next()
while (file_name != ""):
if file_name.extension() == "gd" and not directory.current_is_dir() and file_name != "data_item.gd" :
if file_name.get_extension() == "gd" and not directory.current_is_dir() and file_name != "data_item.gd" :
class_names.append(file_name.replace(".gd", ""))
file_name = directory.get_next()
class_names.sort()
@ -142,7 +142,7 @@ func get_item_path(item):
return config_output_directory + "/" + item._class + "/" + item._id + "." + config_extension
func get_full_path(item):
return Globals.globalize_path(config_output_directory + "/" + item._class + "/" + item._id + "." + config_extension)
return ProjectSettings.globalize_path(config_output_directory + "/" + item._class + "/" + item._id + "." + config_extension)
# return config_output_directory.replace("res://", "") + "/" + item._class + "/" + item._id + "." + config_extension
func load_items():
@ -158,8 +158,8 @@ func load_items():
directory.list_dir_begin()
var file_name = directory.get_next()
while (file_name != ""):
if file_name.extension() == config_extension and not directory.current_is_dir() :
var id = file_name.basename()
if file_name.get_extension() == config_extension and not directory.current_is_dir() :
var id = file_name.get_basename()
if config_serializer == "json":
items[item_class][id] = load_json_item(item_class, file_name)
elif config_serializer == "binary":
@ -174,7 +174,7 @@ func load_items():
# Loads a single item stored in the binary format
func load_binary_item(item_class, file_name):
var file = File.new()
var id = file_name.basename()
var id = file_name.get_basename()
var status = 0
if not config_encrypt:
file.open(config_output_directory + "/" + item_class + "/" + file_name, File.READ)
@ -201,16 +201,14 @@ func load_binary_item(item_class, file_name):
# Loads a single item stored in the json format
func load_json_item(item_class, file_name):
var file = File.new()
var id = file_name.basename()
var id = file_name.get_basename()
var status = file.open(config_output_directory + "/" + item_class + "/" + file_name, File.READ)
var item = classes[item_class].new(id)
if status == OK:
var text = file.get_as_text()
var dict = {}
dict.parse_json(text)
var dict = parse_json(text)
for property_name in dict:
if property_name == "_custom_properties":
var value = dict["_custom_properties"]
@ -315,7 +313,7 @@ func save_json_item(item):
if property_name == "_custom_properties":
dict["_custom_properties"] = {}
for custom_property in value:
var type = value[custom_property][0]
type = value[custom_property][0]
var sanitized_value = sanitize_variant(value[custom_property][1], type)
dict["_custom_properties"][custom_property] = [sanitized_value, type]
pass
@ -329,7 +327,7 @@ func save_json_item(item):
else:
#TODO: Handle
pass
file.store_string(dict.to_json())
file.store_string(to_json(dict))
file.close()
@ -490,7 +488,7 @@ func create_class(name, icon_path):
var icon_resource = load(icon_path)
var icon_data = icon_resource.get_data()
if icon_data.get_width() <= 22 and icon_data.get_height() <= 22:
var directory = Directory.new()
directory = Directory.new()
var error = directory.copy(icon_path, config_class_directory + "/" + name + ".png")
if error != OK:
emit_signal("class_insertion_failed", tr("Could not copy icon"), tr("There was a problem while copying the icon. Was it already opened by another program?") + "\nError code: " + str(error))
@ -510,7 +508,7 @@ func create_class(name, icon_path):
class_source += "\tpass\n"
var script_file = File.new()
var directory = Directory.new()
directory = Directory.new()
if not directory.dir_exists(config_class_directory):
directory.make_dir(config_class_directory)

View File

@ -45,7 +45,7 @@ func load_tree(is_reload = false):
plugin_config = ConfigFile.new()
plugin_config.load("res://addons/godot_data_editor/plugin.cfg")
self.item_manager = Globals.get("item_manager")
self.item_manager = ProjectSettings.get("item_manager")
tree_elements = {}
tree_roots = {}
last_selected_id = ""

View File

@ -82,7 +82,7 @@ func _ready():
elif type == TYPE_TRANSFORM:
control = create_custom_editor_button(value);
create_custom_editor(12, 4, 16, ["xx", "xy", "xz", "xo", "yx", "yy", "yz", "yo", "zx", "zy", "zz", "zo"])
elif type == TYPE_OBJECT or type == TYPE_IMAGE:
elif type == TYPE_OBJECT:# or type == TYPE_IMAGE:
create_object_or_image()
else:
control = get_not_yet_supported()
@ -231,7 +231,7 @@ func create_color():
if typeof(value) == TYPE_STRING and value.find(","):
var split_color = value.split(",")
value = Color(split_color[0], split_color[1], split_color[2], split_color[3])
control.set_color(value)
control.set_pick_color(value)
control.connect("color_changed", self, "property_value_changed", [])
func create_node_path():
@ -351,7 +351,7 @@ func create_object_or_image():
object_type_line_edit.set_text(str(value))
object_type_line_edit.set_h_size_flags(SIZE_EXPAND_FILL)
object_type_line_edit.connect("text_changed", self, "property_value_changed", [])
if hint_text == "Texture" or type == TYPE_IMAGE:
if hint_text == "Texture":# or type == TYPE_IMAGE:
var f = File.new()
if value != null and f.file_exists(value):
var texture = load(value)
@ -377,7 +377,7 @@ func create_object_or_image():
control.add_child(load_button)
if Globals.get("debug_is_editor"):
if ProjectSettings.get("debug_is_editor"):
dialog = EditorFileDialog.new()
dialog.set_access(EditorFileDialog.ACCESS_RESOURCES)
dialog.set_mode(EditorFileDialog.MODE_OPEN_FILE)

View File

@ -4,53 +4,28 @@
[ext_resource path="res://addons/godot_data_editor/icons/icon_remove.png" type="Texture" id=2]
[node name="Panel" type="Panel"]
anchor_right = 1.0
anchor_bottom = 1.0
rect_min_size = Vector2( 0, 26 )
focus/ignore_mouse = false
focus/stop_mouse = false
size_flags_horizontal = 3
size_flags_vertical = 1
margin_left = 1.0
margin_top = 0.0
margin_right = 1.0
margin_bottom = -574.0
rect_min_size = Vector2( 0, 26 )
size_flags_horizontal = 3
script = ExtResource( 1 )
mouse_filter = 0
[node name="DeleteButton" type="ToolButton" parent="."]
visible = false
anchor_left = 1.0
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
focus/ignore_mouse = false
focus/stop_mouse = true
size_flags_horizontal = 1
size_flags_vertical = 1
margin_left = -1280.0
margin_top = -13.0
margin_right = -1252.0
margin_bottom = 11.0
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
icon = ExtResource( 2 )
flat = true
mouse_filter = 0
[node name="PopupMenu" type="PopupMenu" parent="."]
focus/ignore_mouse = false
focus/stop_mouse = true
size_flags_horizontal = 1
size_flags_vertical = 1
margin_left = 0.0
margin_top = 0.0
margin_right = 20.0
margin_bottom = 20.0
popup_exclusive = false
items = [ ]
mouse_filter = 0

View File

@ -1,6 +1,6 @@
extends "res://addons/godot_data_editor/data_item.gd"
export(String) var name = ""
export(String) var elementname = ""
export(Color) var color = Color(1,0,1)
export(Texture) var image = null

View File

@ -1,6 +1,6 @@
extends "res://addons/godot_data_editor/data_item.gd"
export(String, "Armor Shop", "Weapon Shop", "Inn", "Travelling Salesman") var name = ""
export(String, "Armor Shop", "Weapon Shop", "Inn", "Travelling Salesman") var merchantname = ""
export(String) var greeting = ""

View File

@ -1,6 +1,6 @@
extends "res://addons/godot_data_editor/data_item.gd"
export(String) var name = ""
export(String) var itemname = ""
export(Texture) var icon = null
export(int, 0, 9999) var price = 0
export(String, "Armor Shop", "Weapon Shop", "Inn", "Travelling Salesman") var seller = "Armor Shop"

View File

@ -1,13 +1,13 @@
extends "res://addons/godot_data_editor/data_item.gd"
export(String) var name = ""
export(String) var itemname = ""
export(String, MULTILINE) var description = ""
export(String, "water", "fire", "wind", "earth") var element = "water"
export(Texture) var icon = null
export(int, 0, 9999) var base_damage = 0
export(String, "One Enemy", "All Enemies", "One Player", "All Players") var target = "One Enemy"
export(PackedScene) var effect = null
export(Sample) var sound = null
#export(AudioStreamSample) var sound = null
func _init(id).(id):
pass

View File

@ -0,0 +1 @@
{"_class":["element",4],"_class_name":["Element",4],"_created":[1549229769,3],"_custom_properties":{},"_display_name":["fdf",4],"_id":["12",4],"_import_path":["",15],"_last_modified":[1549230859,2],"_persistent":[true,1],"color":["ffff00ff",14],"editor/display_folded":[false,1],"elementname":["dferfe",4],"image":[null,0]}

View File

@ -0,0 +1 @@
{"_class":["merchant",4],"_class_name":["Merchant",4],"_created":[1549229794,3],"_custom_properties":{},"_display_name":["sadfsdf",4],"_id":["43",4],"_import_path":["",15],"_last_modified":[1549230859,2],"_persistent":[true,1],"editor/display_folded":[false,1],"greeting":["adadadasdasd",4],"merchantname":["",4]}

View File

@ -0,0 +1 @@
{"_class":["shop_item",4],"_class_name":["Shop Item",4],"_created":[1549230837,2],"_custom_properties":{},"_display_name":["fwef",4],"_id":["12",4],"_import_path":["",15],"_last_modified":[1549230859,2],"_persistent":[false,1],"description":["asdfasdf",4],"editor/display_folded":[false,1],"icon":[null,0],"itemname":["thdthd",4],"price":[4,2],"seller":["Armor Shop",4]}

1
demo/data/spell/343.json Normal file
View File

@ -0,0 +1 @@
{"_class":["spell",4],"_class_name":["Spell",4],"_created":[1549230884,2],"_custom_properties":{},"_display_name":["sdfsdf",4],"_id":["343",4],"_import_path":["",15],"_last_modified":[1549230889,2],"_persistent":[false,1],"base_damage":[0,2],"description":["dadad",4],"editor/display_folded":[false,1],"effect":[null,0],"element":["water",4],"icon":[null,0],"itemname":["asdasd",4],"target":["One Enemy",4]}

View File

@ -12,12 +12,22 @@ _global_script_classes=[ ]
_global_script_class_icons={
}
debug_is_editor=false
[application]
config/name="demo"
run/main_scene="res://addons/godot_data_editor/data_editor_gui.tscn"
config/icon="res://icon.png"
[autoload]
data="*res://addons/godot_data_editor/data.gd"
[editor_plugins]
enabled=PoolStringArray( "godot_data_editor" )
[importer_defaults]
texture={