diff options
author | Spartan322 <Megacake1234@gmail.com> | 2023-06-03 20:37:10 +0200 |
---|---|---|
committer | Spartan322 <Megacake1234@gmail.com> | 2023-06-03 20:37:10 +0200 |
commit | cef940108fe15752c3ef66f43f5169403fa2f71d (patch) | |
tree | fe4de5a05830e3bddeae78f74f729503b7cee1e9 /game/src/LobbyMenu | |
parent | 73e29d02e48739aba5ca5db1b9575c67e795400f (diff) |
Reorganize the file structure of the files in `game/src`
Diffstat (limited to 'game/src/LobbyMenu')
-rw-r--r-- | game/src/LobbyMenu/LobbyMenu.gd | 165 | ||||
-rw-r--r-- | game/src/LobbyMenu/LobbyMenu.tscn | 138 | ||||
-rw-r--r-- | game/src/LobbyMenu/LobbyPanelButton.gd | 102 | ||||
-rw-r--r-- | game/src/LobbyMenu/LobbyPanelButton.tscn | 31 |
4 files changed, 0 insertions, 436 deletions
diff --git a/game/src/LobbyMenu/LobbyMenu.gd b/game/src/LobbyMenu/LobbyMenu.gd deleted file mode 100644 index db4f2ce..0000000 --- a/game/src/LobbyMenu/LobbyMenu.gd +++ /dev/null @@ -1,165 +0,0 @@ -extends HBoxContainer - -# REQUIREMENTS: -# * 1.4 Game Lobby Menu -# * SS-12 - -signal back_button_pressed -signal save_game_selected(save : SaveResource) -signal start_date_selected(index : int) - -@export var lobby_panel_button : PackedScene -@export var save_scene : PackedScene - -@export_group("Nodes") -@export var game_select_start_date : BoxContainer -@export var game_select_save_tab : TabBar -@export var game_select_save_list : BoxContainer -@export var start_button : BaseButton -@export var session_tag_line_edit : LineEdit -@export var session_tag_dialog : ConfirmationDialog -@export var delete_dialog : ConfirmationDialog - -func filter_for_tag(tag : StringName) -> void: - for child in game_select_save_list.get_children(): - if tag == &"": - child.show() - else: - if tag == child.resource.session_tag: - child.show() - else: - child.hide() - -func _build_date_list() -> void: - var start_date := lobby_panel_button.instantiate() - start_date.set_text(&"1836") - start_date.pressed.connect(_on_start_date_panel_button_pressed.bind(start_date)) - game_select_start_date.add_child(start_date) - start_date = lobby_panel_button.instantiate() - start_date.set_text(&"1863") - start_date.pressed.connect(_on_start_date_panel_button_pressed.bind(start_date)) - game_select_start_date.add_child(start_date) - -var _id_to_tag : Array[StringName] = [] - -# Requirements -# * FS-8 -func _build_save_list() -> void: - game_select_save_tab.add_tab("GAMELOBBY_SELECT_ALL") - for save_name in SaveManager._save_dictionary: - var save : SaveResource = SaveManager._save_dictionary[save_name] - var save_node := _create_save_node(save) - game_select_save_list.add_child(save_node) - if not _id_to_tag.has(save.session_tag): - _id_to_tag.append(save.session_tag) - game_select_save_tab.add_tab(save.session_tag) - -func _create_save_node(resource : SaveResource) -> Control: - var save_node = save_scene.instantiate() - save_node.resource = resource - save_node.pressed.connect(_on_save_node_pressed.bind(save_node)) - save_node.request_to_delete.connect(_on_save_node_delete_requested.bind(save_node)) - return save_node - -func _queue_clear_lists() -> void: - var full_list = game_select_start_date.get_children() - full_list.append_array(game_select_save_list.get_children()) - for child in full_list: - child.queue_free() - game_select_save_tab.clear_tabs() - _id_to_tag.clear() - -# REQUIREMENTS: -# * SS-16 -# * UIFUN-40 -func _on_back_button_button_down(): - print("Returning to Main Menu.") - SaveManager.current_session_tag = "" - SaveManager.current_save = null - back_button_pressed.emit() - -# REQUIREMENTS: -# * SS-21 -func _on_start_button_pressed(): - print("Starting new game.") - if SaveManager.current_session_tag == "": - # TODO: Get country tag as well - var datetime := Time.get_datetime_dict_from_system() - SaveManager.current_session_tag = "%s/%s/%s-%s:%s:%s" % [ - datetime["day"], - datetime["month"], - datetime["year"], - datetime["hour"], - datetime["minute"], - datetime["second"] - ] - if SaveManager.current_save == null and SaveManager.current_session_tag in _id_to_tag: - session_tag_dialog.dialog_text = tr("GAMELOBBY_SESSIONTAG_DIALOG_TEXT").format({ "session_tag": SaveManager.current_session_tag }) - session_tag_dialog.title = tr("GAMELOBBY_SESSIONTAG_DIALOG_TITLE").format({ "session_tag": SaveManager.current_session_tag }) - session_tag_dialog.popup_centered() - else: - _on_session_tag_dialog_confirmed() - -# REQUIREMENTS: -# * SS-19 -func _on_game_select_list_item_selected(index): - print("Selected save game: ", index) - save_game_selected.emit(index) - -# If the date is double-clicked, start the game! -func _on_game_select_list_item_activated(index): - _on_game_select_list_item_selected(index) - _on_start_button_pressed() - -func _on_session_tag_edit_text_submitted(new_text): - SaveManager.current_session_tag = new_text - _on_start_button_pressed() - -func _on_session_tag_dialog_confirmed(): - get_tree().change_scene_to_file("res://src/GameSession/GameSession.tscn") - -var _requested_node_to_delete : Control -func _on_save_node_delete_requested(node : Control) -> void: - _requested_node_to_delete = node - delete_dialog.dialog_text = tr("GAMELOBBY_DELETE_DIALOG_TEXT").format({ "file_name": _requested_node_to_delete.resource.save_name }) - delete_dialog.title = tr("GAMELOBBY_DELETE_DIALOG_TITLE").format({ "file_name": _requested_node_to_delete.resource.save_name }) - delete_dialog.popup_centered() - -var _start_date_index := -1 -func _on_start_date_panel_button_pressed(node : Control) -> void: - if node is LobbyPanelButton and node.get_index(true) == _start_date_index: - _on_start_button_pressed() - return - _start_date_index = node.get_index(true) - start_button.disabled = false - start_date_selected.emit(_start_date_index) - -func _on_save_node_pressed(node : Control) -> void: - if SaveManager.current_save != null and SaveManager.current_save == node.resource: - SaveManager.current_session_tag = SaveManager.current_save.session_tag - _on_start_button_pressed() - return - SaveManager.current_save = node.resource - if SaveManager.current_save != null: - session_tag_line_edit.text = SaveManager.current_save.session_tag - else: - session_tag_line_edit.text = "" - start_button.disabled = false - save_game_selected.emit(SaveManager.current_save) - -func _on_game_select_save_tab_tab_changed(tab) -> void: - if tab == 0: - filter_for_tag(&"") - else: - filter_for_tag(_id_to_tag[tab - 1]) - -func _on_delete_dialog_confirmed(): - _requested_node_to_delete.resource.delete() - _requested_node_to_delete.queue_free() - -func _on_visibility_changed(): - if visible: - _build_date_list() - _build_save_list() - else: - _queue_clear_lists() diff --git a/game/src/LobbyMenu/LobbyMenu.tscn b/game/src/LobbyMenu/LobbyMenu.tscn deleted file mode 100644 index 3b5796e..0000000 --- a/game/src/LobbyMenu/LobbyMenu.tscn +++ /dev/null @@ -1,138 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://do60kx0d3nrh4"] - -[ext_resource type="Script" path="res://src/LobbyMenu/LobbyMenu.gd" id="1_cvwum"] -[ext_resource type="PackedScene" uid="uid://k71f5gibwmtc" path="res://src/LobbyMenu/LobbyPanelButton.tscn" id="2_exh17"] -[ext_resource type="PackedScene" uid="uid://d2s7roinx2or7" path="res://src/SaveLoadMenu/SavePanelButton.tscn" id="3_4otj7"] - -[node name="LobbyMenu" type="HBoxContainer" node_paths=PackedStringArray("game_select_start_date", "game_select_save_tab", "game_select_save_list", "start_button", "session_tag_line_edit", "session_tag_dialog", "delete_dialog")] -editor_description = "UI-36" -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -script = ExtResource("1_cvwum") -lobby_panel_button = ExtResource("2_exh17") -save_scene = ExtResource("3_4otj7") -game_select_start_date = NodePath("GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList/GameSelectStartDate") -game_select_save_tab = NodePath("GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList/GameSelectSaveTab") -game_select_save_list = NodePath("GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList/GameSelectSaveList") -start_button = NodePath("GameStartPanel/VBoxContainer/StartButton") -session_tag_line_edit = NodePath("GameStartPanel/VBoxContainer/SessionTagEdit") -session_tag_dialog = NodePath("SessionTagDialog") -delete_dialog = NodePath("DeleteDialog") - -[node name="GameSelectPanel" type="PanelContainer" parent="."] -layout_mode = 2 -size_flags_horizontal = 3 - -[node name="VBoxContainer" type="VBoxContainer" parent="GameSelectPanel"] -layout_mode = 2 - -[node name="GameSelectScroll" type="ScrollContainer" parent="GameSelectPanel/VBoxContainer"] -editor_description = "UI-39" -layout_mode = 2 -size_flags_vertical = 3 -horizontal_scroll_mode = 0 - -[node name="GameSelectList" type="VBoxContainer" parent="GameSelectPanel/VBoxContainer/GameSelectScroll"] -layout_mode = 2 -size_flags_horizontal = 3 -size_flags_vertical = 3 - -[node name="GameSelectStartDate" type="VBoxContainer" parent="GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList"] -layout_mode = 2 - -[node name="GameSelectSaveTab" type="TabBar" parent="GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList"] -layout_mode = 2 -tab_count = 1 -tab_0/title = "GAMELOBBY_SELECT_ALL" - -[node name="GameSelectSaveList" type="VBoxContainer" parent="GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList"] -layout_mode = 2 -size_flags_vertical = 3 - -[node name="GameSelectList" type="ItemList" parent="GameSelectPanel/VBoxContainer"] -visible = false -layout_mode = 2 -size_flags_vertical = 3 -item_count = 2 -item_0/text = "1836" -item_1/text = "1863" - -[node name="Spacer" type="Control" parent="GameSelectPanel/VBoxContainer"] -custom_minimum_size = Vector2(0, 150) -layout_mode = 2 -size_flags_vertical = 3 - -[node name="BackButton" type="Button" parent="GameSelectPanel/VBoxContainer"] -editor_description = "UI-37" -layout_mode = 2 -text = "GAMELOBBY_BACK" - -[node name="Spacer2" type="Control" parent="GameSelectPanel/VBoxContainer"] -custom_minimum_size = Vector2(0, 33) -layout_mode = 2 - -[node name="Spacer" type="Control" parent="."] -layout_mode = 2 -size_flags_horizontal = 3 -size_flags_stretch_ratio = 2.75 -mouse_filter = 2 - -[node name="GameStartPanel" type="PanelContainer" parent="."] -layout_mode = 2 -size_flags_horizontal = 3 - -[node name="VBoxContainer" type="VBoxContainer" parent="GameStartPanel"] -layout_mode = 2 - -[node name="Spacer" type="Control" parent="GameStartPanel/VBoxContainer"] -custom_minimum_size = Vector2(0, 50) -layout_mode = 2 - -[node name="SelectedCountryNameLabel" type="Label" parent="GameStartPanel/VBoxContainer"] -layout_mode = 2 -text = "France" -horizontal_alignment = 1 - -[node name="Spacer2" type="Control" parent="GameStartPanel/VBoxContainer"] -custom_minimum_size = Vector2(0, 150) -layout_mode = 2 -size_flags_vertical = 3 - -[node name="SessionTagEdit" type="LineEdit" parent="GameStartPanel/VBoxContainer"] -layout_mode = 2 -placeholder_text = "GAMELOBBY_SESSION_TAG" - -[node name="StartButton" type="Button" parent="GameStartPanel/VBoxContainer"] -editor_description = "UI-43" -layout_mode = 2 -disabled = true -text = "GAMELOBBY_START" - -[node name="Spacer3" type="Control" parent="GameStartPanel/VBoxContainer"] -custom_minimum_size = Vector2(0, 33) -layout_mode = 2 - -[node name="SessionTagDialog" type="ConfirmationDialog" parent="."] -disable_3d = true -title = "GAMELOBBY_SESSIONTAG_DIALOG_TITLE" -ok_button_text = "DIALOG_OK" -dialog_text = "GAMELOBBY_SESSIONTAG_DIALOG_TEXT" -cancel_button_text = "DIALOG_CANCEL" - -[node name="DeleteDialog" type="ConfirmationDialog" parent="."] -disable_3d = true -title = "GAMELOBBY_DELETE_DIALOG_TITLE" -ok_button_text = "DIALOG_OK" -dialog_text = "GAMELOBBY_DELETE_DIALOG_TEXT" -cancel_button_text = "DIALOG_CANCEL" - -[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"] -[connection signal="tab_changed" from="GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList/GameSelectSaveTab" to="." method="_on_game_select_save_tab_tab_changed"] -[connection signal="button_down" from="GameSelectPanel/VBoxContainer/BackButton" to="." method="_on_back_button_button_down"] -[connection signal="text_submitted" from="GameStartPanel/VBoxContainer/SessionTagEdit" to="." method="_on_session_tag_edit_text_submitted"] -[connection signal="pressed" from="GameStartPanel/VBoxContainer/StartButton" to="." method="_on_start_button_pressed"] -[connection signal="confirmed" from="SessionTagDialog" to="." method="_on_session_tag_dialog_confirmed"] -[connection signal="confirmed" from="DeleteDialog" to="." method="_on_delete_dialog_confirmed"] diff --git a/game/src/LobbyMenu/LobbyPanelButton.gd b/game/src/LobbyMenu/LobbyPanelButton.gd deleted file mode 100644 index 5f3ea46..0000000 --- a/game/src/LobbyMenu/LobbyPanelButton.gd +++ /dev/null @@ -1,102 +0,0 @@ -@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) diff --git a/game/src/LobbyMenu/LobbyPanelButton.tscn b/game/src/LobbyMenu/LobbyPanelButton.tscn deleted file mode 100644 index f409a2e..0000000 --- a/game/src/LobbyMenu/LobbyPanelButton.tscn +++ /dev/null @@ -1,31 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://k71f5gibwmtc"] - -[ext_resource type="Script" path="res://src/LobbyMenu/LobbyPanelButton.gd" id="1_327u2"] - -[node name="LobbyPanelButton" type="Container" node_paths=PackedStringArray("background_button", "name_label")] -editor_description = "UI-41" -offset_right = 113.0 -offset_bottom = 48.0 -script = ExtResource("1_327u2") -background_button = NodePath("BackgroundButton") -name_label = NodePath("SaveList/NameLabel") - -[node name="BackgroundButton" type="Button" parent="."] -layout_mode = 2 -theme_type_variation = &"ButtonContainer" - -[node name="SaveList" type="HBoxContainer" parent="."] -layout_mode = 2 -size_flags_horizontal = 0 -mouse_filter = 2 - -[node name="NameLabel" type="Label" parent="SaveList"] -layout_mode = 2 -size_flags_vertical = 1 -text = "PLACEHOLDER" -vertical_alignment = 1 - -[connection signal="button_down" from="BackgroundButton" to="." method="_on_background_button_button_down"] -[connection signal="button_up" from="BackgroundButton" to="." method="_on_background_button_button_up"] -[connection signal="pressed" from="BackgroundButton" to="." method="_on_background_button_pressed"] -[connection signal="toggled" from="BackgroundButton" to="." method="_on_background_button_toggled"] |