feature/list-object-counter (#60)
Co-authored-by: VAILLANT Jeremy <vaillant.jeremy@dev-crea.com> Reviewed-on: Athena/game-source#60 Co-authored-by: darknight <vaillant.jeremy@dev-crea.com> Co-committed-by: darknight <vaillant.jeremy@dev-crea.com>
This commit is contained in:
+3
-9
@@ -5,13 +5,7 @@ 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))
|
||||
func _set_data(prop_id, row_id, data):
|
||||
table.edit_data(prop_id, row_id, String(data))
|
||||
Global.database.save_db()
|
||||
return value
|
||||
|
||||
func _get_data_id(prop_name, index):
|
||||
if table.get_prop_at(index).get_prop_name() == prop_name:
|
||||
return table.get_prop_at(index).get_prop_id()
|
||||
else:
|
||||
return null
|
||||
return data
|
||||
|
||||
+15
-6
@@ -3,15 +3,15 @@ extends "res://db/MBase.gd"
|
||||
var m_name = null
|
||||
var m_thumb = null
|
||||
var m_level = null
|
||||
var mscene = load("res://db/MScene.gd")
|
||||
|
||||
func _init(row_idx):
|
||||
m_level = row_idx
|
||||
table = Global.database.get_table_by_name("levels")
|
||||
|
||||
var datas = table.get_data_at_row_idx(m_level)
|
||||
if true:
|
||||
m_name = _get_name(datas)
|
||||
m_thumb = _get_thumb(datas)
|
||||
m_name = _get_name(datas)
|
||||
m_thumb = _get_thumb(datas)
|
||||
|
||||
func object_to_find():
|
||||
var count = 0
|
||||
@@ -22,15 +22,24 @@ func object_to_find():
|
||||
|
||||
return count as String
|
||||
|
||||
func reset():
|
||||
var scene_detail = null
|
||||
var t = Global.database.get_table_by_name("scenes")
|
||||
|
||||
for row_index in range(0, t.m_rows_count):
|
||||
scene_detail = mscene.new(row_index)
|
||||
if scene_detail.label() != null:
|
||||
scene_detail.set_lock(int(false))
|
||||
|
||||
func _scenes():
|
||||
return Global.database.get_table_by_name("scenes")
|
||||
|
||||
func object_finding():
|
||||
var count = 0
|
||||
var datas = _scenes().get_data_by_prop_name_and_data("lock", String(m_level))
|
||||
|
||||
if datas.size() != 0:
|
||||
count = datas.count(true)
|
||||
for datas in _scenes().get_dictionary_by_prop_name_and_data("level", String(m_level)):
|
||||
if int(datas['lock']) == 1:
|
||||
count = count + 1
|
||||
|
||||
return count as String
|
||||
|
||||
|
||||
+41
-52
@@ -1,38 +1,36 @@
|
||||
extends "res://db/MBase.gd"
|
||||
|
||||
var m_value = { "id": null, "value": null }
|
||||
var m_lock = { "id": null, "value": null }
|
||||
var m_value = 0
|
||||
var m_lock = null
|
||||
var m_label = null
|
||||
var m_label_id = null
|
||||
var m_tick_reference = { "id": null, "value": null }
|
||||
var m_label_counter = null
|
||||
var m_tick_reference = 0
|
||||
var m_key = null
|
||||
var m_level = null
|
||||
var m_mesh = null
|
||||
var m_counter = null
|
||||
var m_row_id = null
|
||||
|
||||
const LOCK_ID = 0
|
||||
const LABEL_ID = 1
|
||||
const KEY_ID = 2
|
||||
const LEVEL_ID = 3
|
||||
const MESH_ID = 4
|
||||
const LABEL_COUNTER = 5
|
||||
const COUNTER_ID = 6
|
||||
|
||||
func _init(row_index):
|
||||
table = Global.database.get_table_by_name("scenes")
|
||||
m_row_id = row_index
|
||||
var datas = table.get_data_at_row_idx(m_row_id)
|
||||
|
||||
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_lock = _get_lock(datas)
|
||||
m_label = _get_label(datas)
|
||||
m_label_id = _get_label_id(datas)
|
||||
m_tick_reference["value"] = _get_tick_reference(datas)
|
||||
m_label_counter = _get_label_counter(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)
|
||||
m_counter = _get_counter(datas)
|
||||
|
||||
func key():
|
||||
return m_key
|
||||
@@ -40,14 +38,14 @@ func key():
|
||||
func label():
|
||||
return m_label
|
||||
|
||||
func label_id():
|
||||
return m_label_id
|
||||
func label_counter():
|
||||
return m_label_counter
|
||||
|
||||
func lock():
|
||||
return m_lock["value"]
|
||||
return m_lock
|
||||
|
||||
func set_lock(value):
|
||||
m_lock["value"] = _set_data(value, m_lock["id"], gddb_types.e_prop_type_bool)
|
||||
m_lock = _set_data(LOCK_ID, m_row_id, value)
|
||||
|
||||
func mesh():
|
||||
return m_mesh
|
||||
@@ -56,52 +54,43 @@ func set_mesh(value):
|
||||
m_mesh = value
|
||||
|
||||
func tick_reference():
|
||||
return m_tick_reference["value"]
|
||||
return m_tick_reference
|
||||
|
||||
func set_tick_reference(value):
|
||||
m_tick_reference["value"] = _set_data(value, m_tick_reference["id"], gddb_types.e_prop_type_int)
|
||||
m_tick_reference = value
|
||||
|
||||
func value():
|
||||
return m_value["value"]
|
||||
return m_value
|
||||
|
||||
func set_value(value):
|
||||
m_value["value"] = _set_data(value, m_value["id"], gddb_types.e_prop_type_float)
|
||||
m_value = value
|
||||
|
||||
func audio_sound():
|
||||
var stream = load("res://assets/sounds/objects/" + label() + ".ogg")
|
||||
stream.set_loop(false)
|
||||
return stream
|
||||
|
||||
func counter():
|
||||
return m_counter
|
||||
|
||||
## 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)
|
||||
return int(_get_data(datas, LOCK_ID)) as bool
|
||||
|
||||
func _get_label(datas):
|
||||
return _get_data(datas, 2) as String
|
||||
|
||||
func _get_label_id(datas):
|
||||
return _get_data(datas, 7) 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)
|
||||
return _get_data(datas, LABEL_ID) as String
|
||||
|
||||
func _get_key(datas):
|
||||
return _get_data(datas, 4) as String
|
||||
return _get_data(datas, KEY_ID) as String
|
||||
|
||||
func _get_level(datas):
|
||||
return _get_data(datas, 5) as int
|
||||
return _get_data(datas, LEVEL_ID) as int
|
||||
|
||||
func _get_mesh(datas):
|
||||
return "Hidden Objects Items/" + String(_get_data(datas, 6))
|
||||
return "Hidden Objects Items/" + String(_get_data(datas, MESH_ID))
|
||||
|
||||
func _get_label_counter(datas):
|
||||
return _get_data(datas, LABEL_COUNTER) as String
|
||||
|
||||
func _get_counter(datas):
|
||||
return _get_data(datas, COUNTER_ID) as int
|
||||
|
||||
+39
-20
@@ -1,45 +1,64 @@
|
||||
extends "res://db/MBase.gd"
|
||||
|
||||
var m_langue = { "id": null, "value": null }
|
||||
var m_gyroscope = { "id": null, "value": null }
|
||||
var m_ambient_sound = { "id": null, "value": null }
|
||||
var m_langue = null
|
||||
var m_gyroscope = null
|
||||
var m_ambient_sound = null
|
||||
var m_resolution = null
|
||||
var m_fullscreen = null
|
||||
|
||||
const ROW = 0
|
||||
const ROW_ID = 0
|
||||
const LANGUE_ID = 0
|
||||
const GYRSOCPE_ID = 1
|
||||
const AMBIENT_SOUND = 2
|
||||
const RESOLUTION = 3
|
||||
const FULLSCREEN = 4
|
||||
|
||||
func _init():
|
||||
table = Global.database.get_table_by_name("settings")
|
||||
var datas = table.get_data_at_row_idx(ROW)
|
||||
var datas = table.get_data_at_row_idx(ROW_ID)
|
||||
|
||||
m_langue = _get_data_info(datas, 0)
|
||||
m_gyroscope = _get_data_info(datas, 1)
|
||||
m_ambient_sound = _get_data_info(datas, 2)
|
||||
|
||||
func _get_data_info(datas, id):
|
||||
return {
|
||||
"id": id,
|
||||
"value": _get_data(datas, id)
|
||||
}
|
||||
m_langue = _get_data(datas, LANGUE_ID)
|
||||
m_gyroscope = _get_data(datas, GYRSOCPE_ID)
|
||||
m_ambient_sound = _get_data(datas, AMBIENT_SOUND)
|
||||
m_resolution = _get_data(datas, RESOLUTION)
|
||||
m_fullscreen = _get_data(datas, FULLSCREEN)
|
||||
|
||||
func get_langue():
|
||||
return m_langue["value"]
|
||||
return m_langue as int
|
||||
|
||||
func get_gyroscope():
|
||||
return int(m_gyroscope["value"]) as bool
|
||||
return int(m_gyroscope) as bool
|
||||
|
||||
func get_ambient_sound():
|
||||
return int(m_ambient_sound["value"]) as bool
|
||||
return int(m_ambient_sound) as bool
|
||||
|
||||
func get_resolution():
|
||||
return m_resolution.split(" x ")
|
||||
|
||||
func get_fullscreen():
|
||||
return int(m_fullscreen) as bool
|
||||
|
||||
func set_langue(value):
|
||||
m_langue["value"] = _set_data(value, m_langue["id"], gddb_types.e_prop_type_string)
|
||||
m_langue = _set_data(LANGUE_ID, ROW_ID, value)
|
||||
|
||||
return get_langue()
|
||||
|
||||
func set_gyroscope(value):
|
||||
m_gyroscope["value"] = _set_data(value, m_gyroscope["id"], gddb_types.e_prop_type_bool)
|
||||
m_gyroscope = _set_data(GYRSOCPE_ID, ROW_ID, value)
|
||||
|
||||
return get_gyroscope()
|
||||
|
||||
func set_ambient_sound(value):
|
||||
m_ambient_sound["value"] = _set_data(value, m_ambient_sound["id"], gddb_types.e_prop_type_bool)
|
||||
m_ambient_sound = _set_data(AMBIENT_SOUND, ROW_ID, value)
|
||||
|
||||
return get_ambient_sound()
|
||||
|
||||
func set_resolution(value):
|
||||
m_resolution = _set_data(RESOLUTION, ROW_ID, value)
|
||||
|
||||
return get_resolution()
|
||||
|
||||
func set_fullscreen(value):
|
||||
m_fullscreen = _set_data(FULLSCREEN, ROW_ID, value)
|
||||
|
||||
return get_fullscreen()
|
||||
|
||||
+8
-7
@@ -5,11 +5,13 @@
|
||||
{
|
||||
"table_name":"settings",
|
||||
"props":[
|
||||
{"name":"langue","type":"3","auto_increment":"0"},
|
||||
{"name":"langue","type":"1","auto_increment":"0"},
|
||||
{"name":"gyroscope","type":"0","auto_increment":"0"},
|
||||
{"name":"ambiant_sound","type":"0","auto_increment":"0"}
|
||||
{"name":"ambiant_sound","type":"0","auto_increment":"0"},
|
||||
{"name":"resolution","type":"3","auto_increment":"0"},
|
||||
{"name":"fullscreen","type":"0","auto_increment":"0"}
|
||||
],
|
||||
"data":["fr","0","0"]
|
||||
"data":["fr","0","0","1920 x 1080","0"]
|
||||
},
|
||||
{
|
||||
"table_name":"levels",
|
||||
@@ -22,16 +24,15 @@
|
||||
{
|
||||
"table_name":"scenes",
|
||||
"props":[
|
||||
{"name":"value","type":"2","auto_increment":"0"},
|
||||
{"name":"lock","type":"0","auto_increment":"0"},
|
||||
{"name":"label","type":"3","auto_increment":"0"},
|
||||
{"name":"tick_reference","type":"1","auto_increment":"0"},
|
||||
{"name":"key","type":"3","auto_increment":"0"},
|
||||
{"name":"level","type":"table","table_name":"levels","auto_increment":"0"},
|
||||
{"name":"mesh","type":"3","auto_increment":"0"},
|
||||
{"name":"label_id","type":"1","auto_increment":"0"}
|
||||
{"name":"label_counter","type":"1","auto_increment":"0"},
|
||||
{"name":"counter","type":"1","auto_increment":"0"}
|
||||
],
|
||||
"data":["0.0","True","Dagger","0","dagger","0","dagger","0","0.0","0","Fiole","197246","fiole1","0","fioles/fiole1","1","0.97","0","Fiole","0","fiole2","0","fioles/fiole2","1","0.0","0","Fiole","0","fiole3","0","fioles/fiole_socle/fiole3","1","0.0","0","Spyglass","0","spyglass","0","spyglass","2","0.0","0","Coins","0","coin1","0","golds/coin1","3","0.0","0","Coins","0","coin2","0","golds/coin2","3","0.0","0","Coins","0","coin3","0","golds/coin3","3","0.0","0","Weapon Gun","0","weapon","0","weapon","4","0.0","0","Apple","0","apple1","0","apples/apple1","5","0.0","0","Apple","0","apple2","0","apples/apple2","5","0.0","0","Apple","0","apple3","0","apples/apple3","5","0.0","0","Apple","0","apple4","0","apples/apple4","5","0.0","0","Beer","0","beer","0","beer","6","0.0","0","SuperDagger","0","gadder","1","sm_super_dager","0"]
|
||||
"data":["1","Dagger","dagger","0","dagger","1","1","1","Fiole","fiole1","0","fioles/fiole1","1","3","0","Fiole","fiole2","0","fioles/fiole2","1","3","0","Fiole","fiole3","0","fioles/fiole_socle/fiole3","1","3","1","Spyglass","spyglass","0","spyglass","2","1","1","Coins","coin1","0","golds/coin1","3","3","0","Coins","coin2","0","golds/coin2","3","3","0","Coins","coin3","0","golds/coin3","3","3","0","Weapon Gun","weapon","0","weapon","4","1","0","Apple","apple1","0","apples/apple1","5","4","0","Apple","apple2","0","apples/apple2","5","4","0","Apple","apple3","0","apples/apple3","5","4","1","Apple","apple4","0","apples/apple4","5","4","0","Beer","beer","0","beer","6","1","0","SuperDagger","gadder","1","sm_super_dager","0","1"]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user