This repository hosts a plugin for the [Godot Engine]. It allows users to enter data items based on Godot classes which are then serialized in either as json or binaries. Serialized items may be encrypted if desired.
# Features
* Support for binary or json serialization
* Create data classes with the click of a button
* Use gdscript to add properties and logic to your data classes, all instances will be Nodes
* Make use of the built-in [export property hints]
* Add instance-specific custom properties
* Access data with a simple API using the _data_ singleton
* ALPHA: Use the notification/observer system to react to changes in data items
* Add the _data_ singleton which allows you to access the data later on. To do so, go to the Project Settings -> AutoLoad, then enter "addons/godot_data_editor/data.gd" as path and "data" as Node Name. Save the singleton by clicking on "Add".
There is a demo project available which shows how the plugin could be used in practice. Either download the file "DataEditorDemo.zip" or all content of the "demo" folder. It should be possible to simply import it.
Working with data is rather simple, use the provided _data_ class to access the items. The following code snippets demonstrates item retrieval as well as the observation feature:
```gdscript
extends Node
func _ready():
# Get a single item
var herb = data.get_item("shop_item", "herb")
var price = herb.price
# Get all items as dictionary (key: id, value: item)
var shop_items = data.get_items("shop_item")
for shop_item in shop_items.values():
print(shop_item.price)
pass
#######################################
# Observe Properties:
# Please note that you currently have to update properties using the "update_property" to make use of this feature
#######################################
# Be notified when something about this herb changes
data.observe_item(self, herb, "herb_changed")
herb.update_property("name", "better_herb")
# Be notified when the price of this herb changes,
Please feel free to contribute. Unfortunately, the code base still is not documented that well and there are a number of bugs which will need to be ironed out. I am sure that there are many things I have been doing wrong, especially in regard to memory management.
* Originally, the _data_ singleton was stored automatically in the engine.cfg configuration as soon as the plugin was loaded. This has lead to various issues though. For that reason, _data_ must currently be added manually.
* Internationalization is still lacking
* Under certain circumstances, integers cannot be entered
Stay calm, most issues can be resolved by either pressing the "Reload" button or activating and deactivating the plugin. If the problem persists, there is likely an issue with your data. Check if the name of the class (which are stored in the "classes" folder by default) is the same as the folder name of your instances (by default called "data"). If this is the case, there might be a conflict with duplicate IDs or the like. Please post an issue here if this happened without any external influence (e.g. you edited the files manually in another editor).