diff options
| author | dam <dam@gudinoff> | 2021-12-16 17:04:09 +0000 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2021-12-16 17:04:09 +0000 |
| commit | 3f29bb41d713240eb7ba831f68981674d4db9eb9 (patch) | |
| tree | 02fb3dac92dfc3c7e4856932ac50033e67af5de2 | |
| parent | 9724fb73abf9fd3760a4f3f3ac941a119708c97b (diff) | |
| download | surgery-log-3f29bb41d713240eb7ba831f68981674d4db9eb9.tar.zst surgery-log-3f29bb41d713240eb7ba831f68981674d4db9eb9.zip | |
Fix issues when creating/editing entries. Fix android icon.
| -rw-r--r-- | export_presets.cfg | 6 | ||||
| -rwxr-xr-x | icons/icon.png | bin | 19327 -> 42947 bytes | |||
| -rw-r--r-- | icons/icon.xcf | bin | 0 -> 112237 bytes | |||
| -rw-r--r-- | icons/icon_background.png | bin | 0 -> 36824 bytes | |||
| -rw-r--r-- | icons/icon_background.png.import | 35 | ||||
| -rw-r--r-- | icons/icon_foreground.png | bin | 0 -> 6327 bytes | |||
| -rw-r--r-- | icons/icon_foreground.png.import | 35 | ||||
| -rw-r--r-- | logic/database.gd | 52 | ||||
| -rw-r--r-- | logic/stage.gd | 45 | ||||
| -rw-r--r-- | project.godot | 2 |
10 files changed, 127 insertions, 48 deletions
diff --git a/export_presets.cfg b/export_presets.cfg index ae6c4cf..06377bd 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -35,9 +35,9 @@ package/name="" package/signed=true package/classify_as_game=false package/retain_data_on_uninstall=false -launcher_icons/main_192x192="" -launcher_icons/adaptive_foreground_432x432="" -launcher_icons/adaptive_background_432x432="" +launcher_icons/main_192x192="res://icons/icon.png" +launcher_icons/adaptive_foreground_432x432="res://icons/icon_foreground.png" +launcher_icons/adaptive_background_432x432="res://icons/icon_background.png" graphics/32_bits_framebuffer=true graphics/opengl_debug=false xr_features/xr_mode=0 diff --git a/icons/icon.png b/icons/icon.png Binary files differindex 4b35a32..63760ec 100755 --- a/icons/icon.png +++ b/icons/icon.png diff --git a/icons/icon.xcf b/icons/icon.xcf Binary files differnew file mode 100644 index 0000000..abfbec1 --- /dev/null +++ b/icons/icon.xcf diff --git a/icons/icon_background.png b/icons/icon_background.png Binary files differnew file mode 100644 index 0000000..6ee62e1 --- /dev/null +++ b/icons/icon_background.png diff --git a/icons/icon_background.png.import b/icons/icon_background.png.import new file mode 100644 index 0000000..7b6caab --- /dev/null +++ b/icons/icon_background.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon_background.png-7c479113bc74649f6884d5867344a330.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icons/icon_background.png" +dest_files=[ "res://.import/icon_background.png-7c479113bc74649f6884d5867344a330.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/icons/icon_foreground.png b/icons/icon_foreground.png Binary files differnew file mode 100644 index 0000000..919f2ff --- /dev/null +++ b/icons/icon_foreground.png diff --git a/icons/icon_foreground.png.import b/icons/icon_foreground.png.import new file mode 100644 index 0000000..8427899 --- /dev/null +++ b/icons/icon_foreground.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon_foreground.png-386f0ed4375c2b690a85127a54f3c7b2.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icons/icon_foreground.png" +dest_files=[ "res://.import/icon_foreground.png-386f0ed4375c2b690a85127a54f3c7b2.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/logic/database.gd b/logic/database.gd index 1abb984..db449ae 100644 --- a/logic/database.gd +++ b/logic/database.gd @@ -52,38 +52,34 @@ func _ready(): add_button.connect("pressed", self, "add_action") stage.connect("save", self, "save") stage.connect("discard", self, "discard") - refresh_list() + for it in db: + self.add_item(get_entry_view(it)) func get_entry_view(database_entry: Dictionary) -> String: return "%6s | %6s | %s" % [database_entry.process_id, database_entry.surgery_id, get_entry_date(database_entry)] -func refresh_list(): - self.clear() - for it in db: - self.add_item(get_entry_view(it)) - - func clear_selection(): unselect_all() func delete_action(): - # @DAM Could do some performance improvements var selected_entries_idx := self.get_selected_items() - var sorted_idx := Array(selected_entries_idx) - sorted_idx.sort() - sorted_idx.invert() - for idx in sorted_idx: - db.remove(idx) - self.remove_item(idx) + if selected_entries_idx.size() == 0: + return + assert(selected_entries_idx.size() == 1, "Multiple selected items not supported.") + var selected_idx = selected_entries_idx[0] + db.remove(selected_idx) + self.remove_item(selected_idx) + store_database() func edit_action(): var selected_entries_idx := self.get_selected_items() - if selected_entries_idx.size() != 1: + if selected_entries_idx.size() == 0: return + assert(selected_entries_idx.size() == 1, "Multiple selected items not supported.") staged_idx = selected_entries_idx[0] self.visible = false stage.visible = true @@ -95,20 +91,17 @@ func add_action(): stage.visible = true var staged := instance_entry() stage.set_stage(staged) - # @DAM This signal is connected but, if we select "DISCARD" it stays connectd. - # Maybe I should always keep the connection and use two different buttons on sage screen. - stage.connect("save", self, "save_new", [], CONNECT_ONESHOT) func save(database_entry: Dictionary): + database_entry = instance_entry(database_entry) # @DAM Maybe we could not be creating endless dictionaries? if staged_idx >= 0: db[staged_idx] = database_entry set_item_text(staged_idx, get_entry_view(database_entry)) -# items[staged_idx] = get_entry_view(database_entry) else: db.append(database_entry) add_item(get_entry_view(database_entry)) - + store_database() staged_idx = -1 self.visible = true @@ -118,9 +111,9 @@ func discard(): self.visible = true -func load_database(): +func load_database(file_path: String = DATABASE_FILE_PATH): var file := File.new() - file.open(DATABASE_FILE_PATH, File.READ_WRITE) + file.open(file_path, File.READ_WRITE) var headers: PoolStringArray var is_first_line := true # while database_file.eof_reached() == false: @@ -177,9 +170,9 @@ func load_database(): ] -func store_database(): +func store_database(file_path: String = DATABASE_FILE_PATH): var file := File.new() - file.open(DATABASE_FILE_PATH, File.WRITE) + file.open(file_path, File.WRITE) var header := PoolStringArray(ENTRY_PROTOTYPE.keys()) file.store_csv_line(header) var entry := PoolStringArray() @@ -188,14 +181,17 @@ func store_database(): file.close() -func instance_entry(params: Dictionary = {}) -> Dictionary: +static func instance_entry(params: Dictionary = {}) -> Dictionary: var new_entry := ENTRY_PROTOTYPE.duplicate(true) new_entry.process_id = params.get("process_id", "") new_entry.surgery_id = params.get("surgery_id", "") new_entry.place = params.get("place", "") var today = OS.get_date() - set_entry_date(new_entry, params.get("date", DATE_FORMAT % [today.year, today.month, today.day])) + new_entry.date_year = params.get("date_year", today.year) + new_entry.date_month = params.get("date_month", today.month) + new_entry.date_day = params.get("date_day", today.day) + new_entry.date = params.get("date", get_entry_date(new_entry)) new_entry.anesthetic = params.get("anesthetic", "") new_entry.first_assistant = params.get("first_assistant", "") @@ -210,11 +206,11 @@ func instance_entry(params: Dictionary = {}) -> Dictionary: return new_entry -func get_entry_date(entry: Dictionary) -> String: +static func get_entry_date(entry: Dictionary) -> String: return DATE_FORMAT % [entry.date_year, entry.date_month, entry.date_day] -func set_entry_date(entry: Dictionary, date: String): +static func set_entry_date(entry: Dictionary, date: String): date = date.strip_edges().replace(" ", DATE_SEPARATOR).replace("/", DATE_SEPARATOR).replace("\\", DATE_SEPARATOR) var year_month_idx := date.find(DATE_SEPARATOR) var month_day_idx := date.find(DATE_SEPARATOR, year_month_idx + 1) diff --git a/logic/stage.gd b/logic/stage.gd index a9f4fee..19018fa 100644 --- a/logic/stage.gd +++ b/logic/stage.gd @@ -54,22 +54,35 @@ func set_stage(entry: Dictionary): func get_stage() -> Dictionary: - var entry: Dictionary - entry.process_id = process_id.text - entry.surgery_id = surgery_id.text - entry.date_year = date.get_year() - entry.date_month = date.get_month() - entry.date_day = date.get_day() - entry.place = place.text - entry.anesthetic = anesthetic.text - entry.first_assistant = first_assistant.text - entry.type = type.text - entry.sub_type = sub_type.text - entry.sub_sub_type = sub_sub_type.text - entry.pathology = pathology.text - entry.intervention = intervention.text - entry.is_urgency = is_urgency.pressed - entry.notes = notes.text + +# var entry: Dictionary = Database.instance_entry({ +# "process_id": process_id.text, +# "surgery_id": surgery_id.text, +# "date_year": date.get_year(), +# "date_month": date.get_month(), +# "date_day": date.get_day(), +# "place": place.text, +# "anesthetic": anesthetic.text, +# "first_assistant": first_assistant.text, +# "type": type.text, +# }) + var entry: Dictionary = { + "process_id": process_id.text, + "surgery_id": surgery_id.text, + "date_year": date.get_year(), + "date_month": date.get_month(), + "date_day": date.get_day(), + "place": place.text, + "anesthetic": anesthetic.text, + "first_assistant": first_assistant.text, + "type": type.text, + "sub_type": sub_type.text, + "sub_sub_type": sub_sub_type.text, + "pathology": pathology.text, + "intervention": intervention.text, + "is_urgency": is_urgency.pressed, + "notes": notes.text, + } return entry diff --git a/project.godot b/project.godot index 41969be..584ffa8 100644 --- a/project.godot +++ b/project.godot @@ -43,7 +43,7 @@ run/main_scene="res://main.tscn" boot_splash/image="res://icons/icon.png" boot_splash/fullsize=false boot_splash/use_filter=false -boot_splash/bg_color=Color( 0, 0, 0, 1 ) +boot_splash/bg_color=Color( 0, 0, 0, 0 ) config/icon="res://icons/icon.png" config/quit_on_go_back=false |
