diff options
Diffstat (limited to 'menu')
| -rw-r--r-- | menu/menu.gd | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/menu/menu.gd b/menu/menu.gd index c3e3185..d6e1501 100644 --- a/menu/menu.gd +++ b/menu/menu.gd @@ -8,7 +8,6 @@ const menu_items: Array = [ { label = "Export Database", action = "export_database_action" }, { label = "Clear Database", action = "clear_database_action" }, { label = "About", action = "about_action" }, -# { label = "TEST_FAKE_DB", action = "test_fake_db_action" }, ] const license_font_b612: String = "res://licenses/font_b612.txt" const license_godot: String = "res://licenses/godot.txt" @@ -42,11 +41,16 @@ func import_option_sets_action_accepted(): file_picker.current_dir = OS.get_system_dir(OS.SYSTEM_DIR_DOWNLOADS) file_picker.filters = ["*.json", "*.csv"] file_picker.current_file = "" - file_picker.connect("file_selected", stage, "load_option_sets") + file_picker.connect("file_selected", self, "import_option_sets") file_picker.show_modal(true) file_picker.invalidate() +func import_option_sets(file_path: String): + stage.load_option_sets(file_path) + stage.save_option_sets() + + func export_option_sets_action(): file_picker.mode = FileDialog.MODE_SAVE_FILE file_picker.current_dir = OS.get_system_dir(OS.SYSTEM_DIR_DOWNLOADS) @@ -59,10 +63,15 @@ func export_option_sets_action(): func clear_option_sets_action(): dialog.setup("All option sets from the dropdown menus will be deleted.", "Delete all", "No") - dialog.connect("accepted", stage, "clear_option_sets") + dialog.connect("accepted", self, "clear_option_sets") popup.open_popup("Clear option sets?", dialog) +func clear_option_sets(): + stage.clear_option_sets() + stage.save_option_sets() + + func import_database_action(): dialog.setup("All entries from the database will be replaced.", "Continue", "No") dialog.connect("accepted", self, "import_database_action_accepted") @@ -74,11 +83,16 @@ func import_database_action_accepted(): file_picker.current_dir = OS.get_system_dir(OS.SYSTEM_DIR_DOWNLOADS) file_picker.filters = ["*.json", "*.csv"] file_picker.current_file = "" - file_picker.connect("file_selected", database, "load_database") + file_picker.connect("file_selected", self, "import_database") file_picker.show_modal(true) file_picker.invalidate() +func import_database(file_path: String): + database.load_database(file_path) + database.save_database() + + func export_database_action(): file_picker.mode = FileDialog.MODE_SAVE_FILE file_picker.current_dir = OS.get_system_dir(OS.SYSTEM_DIR_DOWNLOADS) @@ -91,19 +105,17 @@ func export_database_action(): func clear_database_action(): dialog.setup("All entries from the database will be deleted.", "Delete all", "No") - dialog.connect("accepted", database, "clear_database") + dialog.connect("accepted", self, "clear_database") popup.open_popup("Clear database?", dialog) +func clear_database(): + database.clear_database() + database.save_database() + + func about_action(): dialog.setup("Surgery Log\nversion 0.1", "", "") popup.open_popup("About", dialog) -# @DAM Hide this debug method before release. -func test_fake_db_action(): - dialog.setup("All entries from the database will be deleted and new fake entries inserted.", "Yes", "No") - dialog.connect("accepted", database, "fake_database") - popup.open_popup("Fake DB?", dialog) - - |
