Add Classes model
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
|||||||
|
extends Object
|
||||||
|
|
||||||
|
var table = null
|
||||||
|
|
||||||
|
func _get_data(datas, index):
|
||||||
|
return datas[index].get_data()
|
||||||
|
|
||||||
|
func _set_data(value, id, type):
|
||||||
|
table.edit_data(id, type, String(value))
|
||||||
|
Global.database.save_db()
|
||||||
|
return value
|
||||||
|
|
||||||
|
func _get_data_id(prop_name, index):
|
||||||
|
print("[mbase#_get_data_id] : prop_name : "+String(prop_name))
|
||||||
|
print("[mbase#_get_data_id] : index : "+String(index))
|
||||||
|
|
||||||
|
if table.get_prop_at(index).get_prop_name() == prop_name:
|
||||||
|
print("[mbase#_get_data_id] : find prop with ID ")
|
||||||
|
var id = table.get_prop_at(index).get_prop_id()
|
||||||
|
|
||||||
|
print("[mbase#_get_data_id] : "+String(id))
|
||||||
|
return id
|
||||||
|
else:
|
||||||
|
return null
|
||||||
+102
@@ -0,0 +1,102 @@
|
|||||||
|
extends "res://db/MBase.gd"
|
||||||
|
|
||||||
|
var m_id = null
|
||||||
|
var m_value = { "id": null, "value": null }
|
||||||
|
var m_lock = { "id": null, "value": null }
|
||||||
|
var m_label = null
|
||||||
|
var m_tick_reference = { "id": null, "value": null }
|
||||||
|
var m_key = null
|
||||||
|
var m_level = null
|
||||||
|
var m_mesh = null
|
||||||
|
|
||||||
|
func _init(row_index):
|
||||||
|
print("scene#_init")
|
||||||
|
table = Global.database.get_table_by_name("scenes")
|
||||||
|
|
||||||
|
var datas = table.get_data_at_row_idx(row_index)
|
||||||
|
if _get_level(datas) == Global.current_scene_int:
|
||||||
|
m_key = _get_key(datas)
|
||||||
|
m_value["value"] = _get_value(datas)
|
||||||
|
m_lock["value"] = _get_lock(datas)
|
||||||
|
m_label = _get_label(datas)
|
||||||
|
m_tick_reference["value"] = _get_tick_reference(datas)
|
||||||
|
m_mesh = _get_mesh(datas)
|
||||||
|
|
||||||
|
func search_keys():
|
||||||
|
for prop_index in range(0, table.get_props_count()):
|
||||||
|
if table.get_prop_at(prop_index).get_prop_name() == "value" or \
|
||||||
|
table.get_prop_at(prop_index).get_prop_name() == "lock" or \
|
||||||
|
table.get_prop_at(prop_index).get_prop_name() == "tick_reference":
|
||||||
|
if m_value["id"] == null:
|
||||||
|
m_value["id"] = _get_value_id(prop_index)
|
||||||
|
if m_lock["id"] == null:
|
||||||
|
m_lock["id"] = _get_lock_id(prop_index)
|
||||||
|
if m_tick_reference["id"] == null:
|
||||||
|
m_tick_reference["id"] = _get_tick_reference_id(prop_index)
|
||||||
|
|
||||||
|
func object():
|
||||||
|
return {
|
||||||
|
"label": m_label,
|
||||||
|
"lock": m_lock["value"],
|
||||||
|
"value": m_value["value"],
|
||||||
|
"tick_reference": m_tick_reference["value"],
|
||||||
|
"mesh": m_mesh
|
||||||
|
}
|
||||||
|
|
||||||
|
func key():
|
||||||
|
return m_key
|
||||||
|
|
||||||
|
func lock():
|
||||||
|
return m_lock["value"]
|
||||||
|
|
||||||
|
func set_lock(value):
|
||||||
|
m_lock["value"] = _set_data(value, m_lock["id"], gddb_types.e_prop_type_bool)
|
||||||
|
|
||||||
|
func mesh():
|
||||||
|
return m_mesh
|
||||||
|
|
||||||
|
func set_mesh(value):
|
||||||
|
m_mesh = value
|
||||||
|
|
||||||
|
func tick_reference():
|
||||||
|
return m_tick_reference["value"]
|
||||||
|
|
||||||
|
func set_tick_reference(value):
|
||||||
|
m_tick_reference["value"] = _set_data(value, m_tick_reference["id"], gddb_types.e_prop_type_int)
|
||||||
|
|
||||||
|
func value():
|
||||||
|
return m_value["value"]
|
||||||
|
|
||||||
|
func set_value(value):
|
||||||
|
m_value["value"] = _set_data(value, m_value["id"], gddb_types.e_prop_type_float)
|
||||||
|
|
||||||
|
## PRIVATE
|
||||||
|
func _get_value(datas):
|
||||||
|
return _get_data(datas, 0) as float
|
||||||
|
|
||||||
|
func _get_value_id(index):
|
||||||
|
return _get_data_id("value", index)
|
||||||
|
|
||||||
|
func _get_lock(datas):
|
||||||
|
return int(_get_data(datas, 1)) as bool
|
||||||
|
|
||||||
|
func _get_lock_id(index):
|
||||||
|
return _get_data_id("lock", index)
|
||||||
|
|
||||||
|
func _get_label(datas):
|
||||||
|
return _get_data(datas, 2) as String
|
||||||
|
|
||||||
|
func _get_tick_reference(datas):
|
||||||
|
return _get_data(datas, 3) as int
|
||||||
|
|
||||||
|
func _get_tick_reference_id(index):
|
||||||
|
return _get_data_id("tick_reference", index)
|
||||||
|
|
||||||
|
func _get_key(datas):
|
||||||
|
return _get_data(datas, 4) as String
|
||||||
|
|
||||||
|
func _get_level(datas):
|
||||||
|
return _get_data(datas, 5) as int
|
||||||
|
|
||||||
|
func _get_mesh(datas):
|
||||||
|
return "Hidden Objects Items/" + String(_get_data(datas, 6))
|
||||||
Reference in New Issue
Block a user