diff options
| author | dam <dam@gudinoff> | 2022-03-27 16:57:14 +0000 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2022-03-27 16:57:14 +0000 |
| commit | f6369eaee39abe3d360ba42278a5a2a1d166f5af (patch) | |
| tree | 1fec29cbf9de9537efec5a4b7ddd870e4fc2f512 /logic | |
| parent | a6d836d53a09c5b2abedccba51ac428fcfc74379 (diff) | |
| download | surgery-log-f6369eaee39abe3d360ba42278a5a2a1d166f5af.tar.zst surgery-log-f6369eaee39abe3d360ba42278a5a2a1d166f5af.zip | |
Implemented prototype of option set list component.
Diffstat (limited to 'logic')
| -rw-r--r-- | logic/database.gd | 2 | ||||
| -rw-r--r-- | logic/popup.gd | 36 | ||||
| -rw-r--r-- | logic/popup_list.gd | 28 |
3 files changed, 37 insertions, 29 deletions
diff --git a/logic/database.gd b/logic/database.gd index c4482f4..370a679 100644 --- a/logic/database.gd +++ b/logic/database.gd @@ -118,7 +118,7 @@ func save_stage(entry: Dictionary): next_selected_idx = staged_idx else: db.append(entry) - add_item(get_entry_view(entry)) + self.add_item(get_entry_view(entry)) next_selected_idx = db.size() - 1 select(next_selected_idx) diff --git a/logic/popup.gd b/logic/popup.gd new file mode 100644 index 0000000..1b1813a --- /dev/null +++ b/logic/popup.gd @@ -0,0 +1,36 @@ +extends Control +class_name ModalPopup + +var control : Control + + +func _init(): + anchor_right = 1.0 + anchor_bottom = 1.0 + +func popup_control(item: Control): + control = item + control.connect("visibility_changed", self, "closed") + var background = $background + control.anchor_left = background.anchor_left + control.anchor_top = background.anchor_top + control.anchor_right = background.anchor_right + control.anchor_bottom = background.anchor_bottom + control.margin_left = 20 + control.margin_top = 20 + control.margin_right = -20 + control.margin_bottom = -20 + add_child(control) + show() + control.show() +# self.visible = true + + +func closed(): + if control.visible == true: + return + control.disconnect("visibility_changed", self, "closed") + remove_child(control) + self.hide() + + diff --git a/logic/popup_list.gd b/logic/popup_list.gd deleted file mode 100644 index 7e049fb..0000000 --- a/logic/popup_list.gd +++ /dev/null @@ -1,28 +0,0 @@ -extends Popup -class_name PopupList - -signal item_selected - -onready var item_list := get_node("list") as TouchItemList -onready var blur := get_node("blur") as ColorRect - - -func _ready(): - item_list.connect("item_selected", self, "selected") - - -func popup_options(options: Array): - item_list.v_scroll_bar.value = 0.0 - item_list.clear() - for it in options: - item_list.add_item(it) - self.popup_centered_ratio(0.9) - blur.rect_global_position = Vector2.ZERO - blur.rect_size = get_viewport_rect().size - - -func selected(index: int): - self.hide() - emit_signal("item_selected", index) - - |
