diff options
| author | dam <dam@gudinoff> | 2022-02-18 01:34:43 +0000 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2022-02-18 01:34:43 +0000 |
| commit | 283c0f2d84420bd02550dd4404b306d427fd58af (patch) | |
| tree | 3999ad958556bcccba63b5fca05880accdc827f3 /logic | |
| parent | 48a26128f175047528fcc1c96590f1a7bbc281eb (diff) | |
| download | surgery-log-283c0f2d84420bd02550dd4404b306d427fd58af.tar.zst surgery-log-283c0f2d84420bd02550dd4404b306d427fd58af.zip | |
Implemented custom option set control. Fixed option sets text input zone being hidden below the button.
Diffstat (limited to 'logic')
| -rw-r--r-- | logic/popup_list.gd | 1 | ||||
| -rw-r--r-- | logic/stage.gd | 31 |
2 files changed, 7 insertions, 25 deletions
diff --git a/logic/popup_list.gd b/logic/popup_list.gd index 43bf2a1..7e049fb 100644 --- a/logic/popup_list.gd +++ b/logic/popup_list.gd @@ -1,4 +1,5 @@ extends Popup +class_name PopupList signal item_selected diff --git a/logic/stage.gd b/logic/stage.gd index 3cc5943..892dee4 100644 --- a/logic/stage.gd +++ b/logic/stage.gd @@ -49,11 +49,9 @@ func _ready(): save_button.connect("pressed", self, "save_action") discard_button.connect("pressed", self, "discard_action") - # @DAM Not working because we changed the stage/controls/.. estructure with the new option_sets. - # @DAM We could try to do a recursive approach or, build a stack of next items to process. for it in get_node("controls").get_children(): if it is LineEdit: - it.connect("focus_entered", it, "set_cursor_position", [99999999]) # @DAM Use MAX_INT + it.connect("focus_entered", it, "set", ["caret_position", it.max_length]) it.connect("focus_exited", it, "deselect") # Map option sets buttons. @@ -68,16 +66,12 @@ func _ready(): "intervention": intervention } for key in option_sets_map: -# var button := option_sets_map[key].get_node("option_set") as Button -# button.connect("pressed", self, "show_option_sets", [key]) - -# if key != "place": # @DAM DEBUG -# continue - var button := option_sets_map[key].get_node("options") as Button - button.connect("pressed", self, "show_option_sets", [key]) + var button := option_sets_map[key].get_node("options") as Button # @DAM Maybe rename "options". Also requires rename on option_set. + button.connect("pressed", self, "show_options", [key]) -func get_option_sets(field: String): +func show_options(field: String): + var option_set_field := self[field] as OptionSet var options: Array match field: @@ -92,20 +86,7 @@ func get_option_sets(field: String): options.append(OPTION_SETS_NOT_AVAILABLE) options.sort() - return options - - -# @DAM WIP I suspect that these should go inside the option_set class... -func show_option_sets(field: String): - var stage_options = get_node("/root/main/popup_list") as Popup - stage_options.connect("item_selected", self, "option_set_selected", [field], CONNECT_ONESHOT) - stage_options.popup_options(get_option_sets(field)) - - -func option_set_selected(index: int, field: String): - var field_input: LineEdit = self[field].get_node("input") - field_input.text = get_option_sets(field)[index] - field_input.caret_position = field_input.text.length() + option_set_field.show_options(options) func save_action(): |
