From 8ab166ae0bd784145c3706aba0c3f3326cbbaac1 Mon Sep 17 00:00:00 2001 From: Spartan322 Date: Sun, 23 Apr 2023 16:01:49 -0400 Subject: Add SaveManager autoload singleton Globally handles save finding, creation, removal, changes, naming, and flushing Globally handles the session tags for the active save Add SaveLoadMenu to GameSession Add Start Date Panel and Save Panel loading to LobbyMenu Includes session tag filter Add LobbyPanelButton and SavePanelButton scene and scripts Add SaveResource to handle saving and loading individual save files Add localization for SaveLoadMenu Expand localization for additions to LobbyMenu Add ButtonContainer variation type to default theme Fulfill: UI-82, UI-83, UI-84, UI-85, UI-87, UI-89, UI-90, UI-91, UI-92, UI-94 UIFUN-82, UIFUN-83, UIFUN-84, UIFUN-86, UIFUN-87, UIFUN-89 FS-28 --- game/src/LobbyMenu/LobbyPanelButton.gd | 102 +++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 game/src/LobbyMenu/LobbyPanelButton.gd (limited to 'game/src/LobbyMenu/LobbyPanelButton.gd') diff --git a/game/src/LobbyMenu/LobbyPanelButton.gd b/game/src/LobbyMenu/LobbyPanelButton.gd new file mode 100644 index 0000000..5f3ea46 --- /dev/null +++ b/game/src/LobbyMenu/LobbyPanelButton.gd @@ -0,0 +1,102 @@ +@tool +class_name LobbyPanelButton +extends Container + +signal button_down +signal button_up +signal pressed +signal toggled(button_pressed : bool) + +var is_start_date : bool: + get = _is_start_date + +func _is_start_date() -> bool: + return true + +@export_group("Nodes") +@export var background_button : BaseButton +@export var name_label : Label + +var text : StringName: + get = get_text, + set = set_text + +func get_text() -> StringName: + return name_label.text + +func set_text(value : StringName) -> void: + name_label.text = value + +func _get_minimum_size() -> Vector2: + var result := Vector2() + for child in get_children(): + child = child as Control + if child == null or not child.visible: + continue + if child.top_level: + continue + + var minsize : Vector2 = child.get_combined_minimum_size() + result.x = max(result.x, minsize.x) + result.y = max(result.y, minsize.y) + + var draw_style := _get_draw_mode_style() + if draw_style != null: + result += draw_style.get_minimum_size() + + return result + +func _get_draw_mode_name(support_rtl : bool = true) -> StringName: + var rtl := support_rtl and background_button != null and background_button.is_layout_rtl() + match background_button.get_draw_mode() if background_button != null else BaseButton.DrawMode.DRAW_NORMAL: + BaseButton.DrawMode.DRAW_NORMAL: + if rtl: return &"normal_mirrored" + return &"normal" + BaseButton.DrawMode.DRAW_PRESSED: + if rtl: return &"pressed_mirrored" + return &"pressed" + BaseButton.DrawMode.DRAW_HOVER: + if rtl: return &"hover_mirrored" + return &"hover" + BaseButton.DrawMode.DRAW_DISABLED: + if rtl: return &"disabled_mirrored" + return &"disabled" + BaseButton.DrawMode.DRAW_HOVER_PRESSED: + if rtl: return &"hover_pressed_mirrored" + return &"hover_pressed" + return &"" + +func _get_draw_mode_style() -> StyleBox: + if background_button == null: return null + var result := background_button.get_theme_stylebox(_get_draw_mode_name()) + if result == null: + return background_button.get_theme_stylebox(_get_draw_mode_name(false)) + return result + +func _notification(what) -> void: + if what == NOTIFICATION_SORT_CHILDREN: + var _size := size + var offset := Vector2() + var style := _get_draw_mode_style() + if style != null: + _size -= style.get_minimum_size() + offset += style.get_offset() + + for child in get_children(): + child = child as Control + if child == null or not child.is_visible_in_tree() or child.top_level: + continue + + fit_child_in_rect(child, Rect2(offset, _size)) + +func _on_background_button_button_down(): + button_down.emit() + +func _on_background_button_button_up(): + button_up.emit() + +func _on_background_button_pressed(): + pressed.emit() + +func _on_background_button_toggled(button_pressed : bool): + toggled.emit(button_pressed) -- cgit v1.2.3-56-ga3b1