extends ScrollContainer class_name Stage signal save # (database_entry: Dictionary) signal discard # () #onready var process_id: LineEdit = get_node("touch_scroll/controls/process_id") #onready var surgery_id: LineEdit = get_node("touch_scroll/controls/surgery_id") #onready var date: DatePicker = get_node("touch_scroll/controls/date_picker") #onready var place: LineEdit = get_node("touch_scroll/controls/place") #onready var anesthetic: LineEdit = get_node("touch_scroll/controls/anesthetic") #onready var first_assistant: LineEdit = get_node("touch_scroll/controls/first_assistant") #onready var type: LineEdit = get_node("touch_scroll/controls/type") #onready var sub_type: LineEdit = get_node("touch_scroll/controls/sub_type") #onready var sub_sub_type: LineEdit = get_node("touch_scroll/controls/sub_sub_type") #onready var pathology: LineEdit = get_node("touch_scroll/controls/pathology") #onready var intervention: LineEdit = get_node("touch_scroll/controls/intervention") #onready var is_urgency: Button = get_node("touch_scroll/controls/is_urgency") #onready var notes: LineEdit = get_node("touch_scroll/controls/notes") #onready var save_button: Button = get_node("touch_scroll/controls/save") #onready var discard_button: Button = get_node("touch_scroll/controls/discard") onready var process_id: LineEdit = get_node("controls/process_id") onready var surgery_id: LineEdit = get_node("controls/surgery_id") onready var date: DatePicker = get_node("controls/date_picker") onready var place: LineEdit = get_node("controls/place") onready var anesthetic: LineEdit = get_node("controls/anesthetic") onready var first_assistant: LineEdit = get_node("controls/first_assistant") onready var type: LineEdit = get_node("controls/type") onready var sub_type: LineEdit = get_node("controls/sub_type") onready var sub_sub_type: LineEdit = get_node("controls/sub_sub_type") onready var pathology: LineEdit = get_node("controls/pathology") onready var intervention: LineEdit = get_node("controls/intervention") onready var is_urgency: Button = get_node("controls/is_urgency") onready var notes: LineEdit = get_node("controls/notes") onready var save_button: Button = get_node("controls/save") onready var discard_button: Button = get_node("controls/discard") func _ready(): save_button.connect("pressed", self, "save_action") discard_button.connect("pressed", self, "discard_action") for it in get_node("controls").get_children(): # print("%s" % it.name) match it.name: "date_picker", "save", "discard": print("- %s" % it.name) _: # "first_assistant": print("+ %s" % it.name) var touch_scroll = TouchScroll.new() touch_scroll.name = "touch_scroll" touch_scroll.click_target_path = "../" touch_scroll.scroll_target_path = "../../../" touch_scroll.scroll_bar_get_method = "get_v_scrollbar" touch_scroll.mouse_default_cursor_shape = Control.CURSOR_IBEAM (it as Control).add_child(touch_scroll) touch_scroll.anchor_right = 1.0 touch_scroll.anchor_bottom = 1.0 func save_action(): self.visible = false emit_signal("save", get_stage()) func discard_action(): self.visible = false emit_signal("discard") func set_stage(entry: Dictionary): process_id.text = entry.process_id surgery_id.text = entry.surgery_id date.set_date(entry.date_year, entry.date_month, entry.date_day) place.text = entry.place anesthetic.text = entry.anesthetic first_assistant.text = entry.first_assistant type.text = entry.type sub_type.text = entry.sub_type sub_sub_type.text = entry.sub_sub_type pathology.text = entry.pathology intervention.text = entry.intervention is_urgency.pressed = entry.is_urgency notes.text = entry.notes self.scroll_vertical = 0 # @DAM TODO func get_stage() -> Dictionary: # 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, # }) # @DAM Simplify all this... avoid creating multiple entries/dictionaries. 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 # @DAM Testing. Needs all children controllers to have Mouse > Filter : Pass. #func _gui_input(event): # accept_event() # if event is InputEventScreenDrag: # self.scroll_vertical -= event.relative.y # return func _notification(what: int): if what == MainLoop.NOTIFICATION_WM_GO_BACK_REQUEST: discard_action()