aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--logic/database.gd1
-rw-r--r--logic/stage.gd70
-rw-r--r--menu/menu.gd26
3 files changed, 71 insertions, 26 deletions
diff --git a/logic/database.gd b/logic/database.gd
index 3d74da3..b76fda5 100644
--- a/logic/database.gd
+++ b/logic/database.gd
@@ -125,7 +125,6 @@ func load_database(file_path: String = DATABASE_FILE_PATH):
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:
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):
diff --git a/menu/menu.gd b/menu/menu.gd
index b5e1ef2..9b7f99f 100644
--- a/menu/menu.gd
+++ b/menu/menu.gd
@@ -1,9 +1,9 @@
extends MenuButton
const menu_items: Array = [
- { label = "IMPORT FILTERS", action = "_menu_import_filters_action" },
- { label = "EXPORT FILTERS", action = "_menu_export_filters_action" },
- { label = "CLEAR FILTERS", action = "_menu_clear_filters_action" },
+ { label = "IMPORT OPTION SETS", action = "_menu_import_option_sets_action" },
+ { label = "EXPORT OPTION SETS", action = "_menu_export_option_sets_action" },
+ { label = "CLEAR OPTION SETS", action = "_menu_clear_option_sets_action" },
{ label = "EXPORT DATA", action = "_menu_export_data_action" },
{ label = "CLEAR DATA", action = "_menu_clear_data_action" },
{ label = "ABOUT", action = "_menu_about_action" },
@@ -37,28 +37,28 @@ func dialog_cancelled(confirmation_signal_name: String):
confirm_action.disconnect(it.signal, it.target, it.method)
-func _menu_import_filters_action():
- file_picker.window_title = "IMPORT FILTERS"
+func _menu_import_option_sets_action():
+ file_picker.window_title = "IMPORT OPTION SETS"
file_picker.mode = FileDialog.MODE_OPEN_FILE
file_picker.current_dir = OS.get_system_dir(OS.SYSTEM_DIR_DOWNLOADS)
- file_picker.connect("file_selected", stage, "load_filters", [], CONNECT_ONESHOT)
+ file_picker.connect("file_selected", stage, "load_option_sets", [], CONNECT_ONESHOT)
file_picker.show_modal(true)
file_picker.invalidate()
-func _menu_export_filters_action():
- file_picker.window_title = "EXPORT FILTERS"
+func _menu_export_option_sets_action():
+ file_picker.window_title = "EXPORT OPTION SETS"
file_picker.mode = FileDialog.MODE_SAVE_FILE
file_picker.current_dir = OS.get_system_dir(OS.SYSTEM_DIR_DOWNLOADS)
- file_picker.connect("file_selected", stage, "store_filters", [], CONNECT_ONESHOT)
+ file_picker.connect("file_selected", stage, "store_option_sets", [], CONNECT_ONESHOT)
file_picker.show_modal(true)
file_picker.invalidate()
-func _menu_clear_filters_action():
- confirm_action.window_title = "CLEAR FILTERS"
- confirm_action.dialog_text = "Do you want to delete all filters?"
- confirm_action.connect("confirmed", stage, "clear_filters", [true], CONNECT_ONESHOT)
+func _menu_clear_option_sets_action():
+ confirm_action.window_title = "CLEAR OPTION SETS"
+ confirm_action.dialog_text = "Do you want to delete all option sets?"
+ confirm_action.connect("confirmed", stage, "clear_option_sets", [true], CONNECT_ONESHOT)
confirm_action.show_modal(true)