aboutsummaryrefslogtreecommitdiff
path: root/logic/stage.gd
diff options
context:
space:
mode:
Diffstat (limited to 'logic/stage.gd')
-rw-r--r--logic/stage.gd70
1 files changed, 58 insertions, 12 deletions
diff --git a/logic/stage.gd b/logic/stage.gd
index e4627c2..1601522 100644
--- a/logic/stage.gd
+++ b/logic/stage.gd
@@ -4,10 +4,10 @@ class_name Stage
signal save # (database_entry: Dictionary)
signal discard # ()
-const FILTERS_FILE_PATH: String = "user://filters.csv"
+const OPTION_SETS_FILE_PATH: String = "user://option_sets.csv"
var staged_entry := {}
-var filters := {
+var option_sets := {
"place": {
"bloco central": null,
"tondela": null,
@@ -42,6 +42,33 @@ var filters := {
"xpto_28": null,
"xpto_29": null,
},
+ "type": {
+ "A": {
+ "sub_type": {
+ "aA": {
+ "sub_sub_type": {
+ "aaA": null,
+ "aaB": null,
+ "aaC": null,
+ }
+ },
+ "aB": {
+ "sub_sub_type": {
+ "abA": null,
+ "abB": null,
+ "abC": null,
+ }
+ },
+ },
+ },
+ "B": {
+ "sub_type": {
+ "bA": null,
+ "bB": null,
+ },
+ },
+ "C": null,
+ },
}
onready var process_id := get_node("controls/process_id") as LineEdit
@@ -83,12 +110,12 @@ func _ready():
func auto_populate(field: String):
var stage_options = get_node("/root/main/popup_list") as Popup
stage_options.connect("item_selected", self, "auto_selected", [field], CONNECT_ONESHOT)
- stage_options.popup_options(filters[field].keys())
+ stage_options.popup_options(option_sets[field].keys())
func auto_selected(index: int, field: String):
var field_input: LineEdit = self[field]
- field_input.text = filters[field].keys()[index]
+ field_input.text = option_sets[field].keys()[index]
field_input.caret_position = field_input.text.length()
@@ -139,12 +166,11 @@ func get_stage() -> Dictionary:
return staged_entry
-func load_filters(file_path: String = FILTERS_FILE_PATH):
+func load_option_sets(file_path: String = OPTION_SETS_FILE_PATH):
var file := File.new()
file.open(file_path, File.READ_WRITE)
var headers: PoolStringArray
var is_first_line := true
-# while file.eof_reached() == false: # @DAM Why this?
while file.get_position() < file.get_len():
var csv_entry := file.get_csv_line()
if is_first_line:
@@ -162,17 +188,37 @@ func load_filters(file_path: String = FILTERS_FILE_PATH):
# entry[field_name] = true if field_value.strip_edges().to_lower() == "true" else false
# _:
# entry[field_name] = field_value
-# filters.append(entry)
-
-
-func store_filters(file_path: String = FILTERS_FILE_PATH):
+# option_sets.append(entry)
+
+
+func store_option_sets(file_path: String = OPTION_SETS_FILE_PATH):
+ var list: Array
+ var entry := DatabaseEntry.instance_entry()
+ if option_sets.has("type"):
+ for type in option_sets["type"].keys():
+ entry.type = type
+ if option_sets["type"][type].has("sub_type"):
+ for sub_type in option_sets["type"][type]["sub_type"]:
+ entry.sub_type = sub_type
+ if option_sets["type"][type]["sub_type"].has("sub_sub_type"):
+ for sub_sub_type in option_sets["type"][type]["sub_type"][sub_type]["sub_sub_type"].keys():
+ entry.sub_sub_type = sub_sub_type
+ list.append(entry.duplicate())
+ else:
+ pass
+ else:
+ pass
+
+
+# if option_sets.has("type"):
+#
pass # @DAM TODO
-func clear_filters(save_changes: bool = false):
+func clear_option_sets(save_changes: bool = false):
pass # @DAM TODO
if save_changes:
- store_filters()
+ store_option_sets()
func pointer_input_on_click_handler(pointer: PointerInputSensor.PointerInputData):