From 04863e37ddb7451ba98c337775d0a7bc6bbd2105 Mon Sep 17 00:00:00 2001 From: atlinx Date: Thu, 27 Jul 2023 10:46:37 -0400 Subject: [PATCH] Improve ui, fix bugs with launcher --- CogsPartyLauncher/assets/icon_add.svg | 1 + CogsPartyLauncher/assets/icon_add.svg.import | 37 +++++++++++++++ CogsPartyLauncher/assets/icon_close.svg | 1 + .../assets/icon_close.svg.import | 37 +++++++++++++++ CogsPartyLauncher/assets/theme.tres | 1 - CogsPartyLauncher/prefabs/game_entry.tscn | 45 ++++++++++++------- .../prefabs/game_library_display.tscn | 6 ++- CogsPartyLauncher/prefabs/player_setting.tscn | 6 ++- CogsPartyLauncher/project.godot | 2 +- CogsPartyLauncher/scenes/main.tscn | 12 +++-- CogsPartyLauncher/scripts/crossout.gd | 17 +++++++ CogsPartyLauncher/scripts/game_entry.gd | 3 ++ CogsPartyLauncher/scripts/game_library.gd | 4 +- .../scripts/game_library_display.gd | 10 ++++- .../scripts/player_select_menu.gd | 43 +++++++++++++----- 15 files changed, 185 insertions(+), 40 deletions(-) create mode 100644 CogsPartyLauncher/assets/icon_add.svg create mode 100644 CogsPartyLauncher/assets/icon_add.svg.import create mode 100644 CogsPartyLauncher/assets/icon_close.svg create mode 100644 CogsPartyLauncher/assets/icon_close.svg.import create mode 100644 CogsPartyLauncher/scripts/crossout.gd diff --git a/CogsPartyLauncher/assets/icon_add.svg b/CogsPartyLauncher/assets/icon_add.svg new file mode 100644 index 0000000..afad08a --- /dev/null +++ b/CogsPartyLauncher/assets/icon_add.svg @@ -0,0 +1 @@ + diff --git a/CogsPartyLauncher/assets/icon_add.svg.import b/CogsPartyLauncher/assets/icon_add.svg.import new file mode 100644 index 0000000..2e8fa70 --- /dev/null +++ b/CogsPartyLauncher/assets/icon_add.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c27ucuw3vtgn6" +path="res://.godot/imported/icon_add.svg-c7fda2bfb8ff6d6baa27b09a81576c16.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/icon_add.svg" +dest_files=["res://.godot/imported/icon_add.svg-c7fda2bfb8ff6d6baa27b09a81576c16.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/CogsPartyLauncher/assets/icon_close.svg b/CogsPartyLauncher/assets/icon_close.svg new file mode 100644 index 0000000..331727a --- /dev/null +++ b/CogsPartyLauncher/assets/icon_close.svg @@ -0,0 +1 @@ + diff --git a/CogsPartyLauncher/assets/icon_close.svg.import b/CogsPartyLauncher/assets/icon_close.svg.import new file mode 100644 index 0000000..298d55b --- /dev/null +++ b/CogsPartyLauncher/assets/icon_close.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bnna1b7hu12k" +path="res://.godot/imported/icon_close.svg-f6a0d84d2b71f33aa20260176384f21b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/icon_close.svg" +dest_files=["res://.godot/imported/icon_close.svg-f6a0d84d2b71f33aa20260176384f21b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/CogsPartyLauncher/assets/theme.tres b/CogsPartyLauncher/assets/theme.tres index 126f9c3..b9f8055 100644 --- a/CogsPartyLauncher/assets/theme.tres +++ b/CogsPartyLauncher/assets/theme.tres @@ -5,5 +5,4 @@ [resource] default_font = ExtResource("2_of4dy") -default_font_size = 18 RichTextLabel/fonts/bold_font = ExtResource("1_4qjdl") diff --git a/CogsPartyLauncher/prefabs/game_entry.tscn b/CogsPartyLauncher/prefabs/game_entry.tscn index c641484..368c583 100644 --- a/CogsPartyLauncher/prefabs/game_entry.tscn +++ b/CogsPartyLauncher/prefabs/game_entry.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=6 format=3 uid="uid://b3fh8hsqlpcp2"] +[gd_scene load_steps=7 format=3 uid="uid://b3fh8hsqlpcp2"] [ext_resource type="Texture2D" uid="uid://86474c6ugxyg" path="res://assets/sgj_poster.png" id="1_asex0"] [ext_resource type="Theme" uid="uid://036n6qd3ik2g" path="res://assets/theme.tres" id="1_lafwr"] [ext_resource type="Script" path="res://scripts/game_entry.gd" id="1_y8fwy"] [ext_resource type="FontFile" uid="uid://bg4kldgugtb2r" path="res://assets/urbanist/static/Urbanist-Black.ttf" id="2_o3hcj"] +[ext_resource type="Script" path="res://scripts/crossout.gd" id="5_a1qsc"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_km0gx"] content_margin_left = 8.0 @@ -14,45 +15,49 @@ bg_color = Color(0.996078, 0.372549, 0.372549, 1) corner_radius_bottom_right = 8 corner_radius_bottom_left = 8 -[node name="GameEntry" type="VBoxContainer" node_paths=PackedStringArray("banner_rect", "title_label", "description_label", "error_panel", "error_panel_label", "content_container", "enabled_checkbox", "player_count_label")] +[node name="GameEntry" type="VBoxContainer" node_paths=PackedStringArray("banner_rect", "title_label", "description_label", "error_panel", "error_panel_label", "content_container", "enabled_checkbox", "player_count_label", "crossout")] offset_right = 410.0 offset_bottom = 146.0 size_flags_horizontal = 3 theme = ExtResource("1_lafwr") theme_override_constants/separation = 0 script = ExtResource("1_y8fwy") -banner_rect = NodePath("ContentContainer/BannerRect") -title_label = NodePath("ContentContainer/VBoxContainer/TitleLabel") -description_label = NodePath("ContentContainer/VBoxContainer/DescriptionLabel") +banner_rect = NodePath("MarginContainer/ContentContainer/BannerRect") +title_label = NodePath("MarginContainer/ContentContainer/VBoxContainer/TitleLabel") +description_label = NodePath("MarginContainer/ContentContainer/VBoxContainer/DescriptionLabel") error_panel = NodePath("ErrorPanel") error_panel_label = NodePath("ErrorPanel/ErrorPanelLabel") -content_container = NodePath("ContentContainer") -enabled_checkbox = NodePath("ContentContainer/VBoxContainer2/EnabledCheckbox") -player_count_label = NodePath("ContentContainer/VBoxContainer/PlayerCountLabel") +content_container = NodePath("MarginContainer/ContentContainer") +enabled_checkbox = NodePath("MarginContainer/ContentContainer/VBoxContainer2/EnabledCheckbox") +player_count_label = NodePath("MarginContainer/ContentContainer/VBoxContainer/PlayerCountLabel") +crossout = NodePath("MarginContainer/Crossout") -[node name="ContentContainer" type="HBoxContainer" parent="."] +[node name="MarginContainer" type="MarginContainer" parent="."] +layout_mode = 2 + +[node name="ContentContainer" type="HBoxContainer" parent="MarginContainer"] layout_mode = 2 size_flags_vertical = 3 theme_override_constants/separation = 18 -[node name="BannerRect" type="TextureRect" parent="ContentContainer"] +[node name="BannerRect" type="TextureRect" parent="MarginContainer/ContentContainer"] custom_minimum_size = Vector2(105, 140) layout_mode = 2 texture = ExtResource("1_asex0") expand_mode = 1 stretch_mode = 6 -[node name="VBoxContainer" type="VBoxContainer" parent="ContentContainer"] +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/ContentContainer"] layout_mode = 2 size_flags_horizontal = 3 -[node name="TitleLabel" type="Label" parent="ContentContainer/VBoxContainer"] +[node name="TitleLabel" type="Label" parent="MarginContainer/ContentContainer/VBoxContainer"] layout_mode = 2 size_flags_vertical = 1 theme_override_fonts/font = ExtResource("2_o3hcj") text = "Cool Game" -[node name="DescriptionLabel" type="Label" parent="ContentContainer/VBoxContainer"] +[node name="DescriptionLabel" type="Label" parent="MarginContainer/ContentContainer/VBoxContainer"] layout_mode = 2 size_flags_vertical = 3 theme_override_colors/font_color = Color(1, 1, 1, 0.784314) @@ -60,18 +65,24 @@ text = "the quick brown fox jumps over the lazy dog. the quick brown fox jumps o autowrap_mode = 2 text_overrun_behavior = 3 -[node name="PlayerCountLabel" type="Label" parent="ContentContainer/VBoxContainer"] +[node name="PlayerCountLabel" type="Label" parent="MarginContainer/ContentContainer/VBoxContainer"] layout_mode = 2 text = "4 - 8 Players" -[node name="Control" type="Control" parent="ContentContainer/VBoxContainer"] +[node name="Control" type="Control" parent="MarginContainer/ContentContainer/VBoxContainer"] +layout_mode = 2 + +[node name="VBoxContainer2" type="VBoxContainer" parent="MarginContainer/ContentContainer"] layout_mode = 2 -[node name="VBoxContainer2" type="VBoxContainer" parent="ContentContainer"] +[node name="EnabledCheckbox" type="CheckBox" parent="MarginContainer/ContentContainer/VBoxContainer2"] layout_mode = 2 -[node name="EnabledCheckbox" type="CheckBox" parent="ContentContainer/VBoxContainer2"] +[node name="Crossout" type="Control" parent="MarginContainer"] +visible = false +self_modulate = Color(1, 0.34902, 0.34902, 1) layout_mode = 2 +script = ExtResource("5_a1qsc") [node name="ErrorPanel" type="PanelContainer" parent="."] layout_mode = 2 diff --git a/CogsPartyLauncher/prefabs/game_library_display.tscn b/CogsPartyLauncher/prefabs/game_library_display.tscn index cd441b1..6428b31 100644 --- a/CogsPartyLauncher/prefabs/game_library_display.tscn +++ b/CogsPartyLauncher/prefabs/game_library_display.tscn @@ -1,10 +1,13 @@ -[gd_scene load_steps=5 format=3 uid="uid://bp0606lonchki"] +[gd_scene load_steps=6 format=3 uid="uid://bp0606lonchki"] [ext_resource type="Theme" uid="uid://036n6qd3ik2g" path="res://assets/theme.tres" id="1_7e4nq"] [ext_resource type="Script" path="res://scripts/game_library_display.gd" id="1_y4w2o"] [ext_resource type="PackedScene" uid="uid://b3fh8hsqlpcp2" path="res://prefabs/game_entry.tscn" id="2_vypkx"] [ext_resource type="FontFile" uid="uid://bg4kldgugtb2r" path="res://assets/urbanist/static/Urbanist-Black.ttf" id="3_jyrsh"] +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_t3e3d"] +content_margin_right = 8.0 + [node name="GameLibraryDisplay" type="VBoxContainer" node_paths=PackedStringArray("game_entry_container", "games_label")] theme = ExtResource("1_7e4nq") script = ExtResource("1_y4w2o") @@ -37,6 +40,7 @@ text = "G A M E S (1/2)" [node name="ScrollContainer" type="ScrollContainer" parent="PanelContainer/MarginContainer/VBoxContainer"] layout_mode = 2 size_flags_vertical = 3 +theme_override_styles/panel = SubResource("StyleBoxEmpty_t3e3d") horizontal_scroll_mode = 0 [node name="GameEntryContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer/VBoxContainer/ScrollContainer"] diff --git a/CogsPartyLauncher/prefabs/player_setting.tscn b/CogsPartyLauncher/prefabs/player_setting.tscn index 1b876b5..172e09a 100644 --- a/CogsPartyLauncher/prefabs/player_setting.tscn +++ b/CogsPartyLauncher/prefabs/player_setting.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=6 format=3 uid="uid://c24hlo57mf44p"] +[gd_scene load_steps=7 format=3 uid="uid://c24hlo57mf44p"] [ext_resource type="Script" path="res://scripts/player_setting.gd" id="1_6lld3"] [ext_resource type="Theme" uid="uid://036n6qd3ik2g" path="res://assets/theme.tres" id="1_cghqm"] [ext_resource type="Texture2D" uid="uid://cvnj8l4lspw3d" path="res://assets/icon_arrow_left.svg" id="2_ajqs2"] [ext_resource type="Texture2D" uid="uid://dt0bslhmu3sfq" path="res://assets/icon_arrow_right.svg" id="3_pocyf"] +[ext_resource type="Texture2D" uid="uid://bnna1b7hu12k" path="res://assets/icon_close.svg" id="5_5fgrl"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_tcaly"] content_margin_left = 16.0 @@ -60,4 +61,5 @@ icon = ExtResource("3_pocyf") [node name="RemoveButton" type="Button" parent="VBoxContainer"] layout_mode = 2 size_flags_vertical = 3 -text = "Remove" +icon = ExtResource("5_5fgrl") +icon_alignment = 1 diff --git a/CogsPartyLauncher/project.godot b/CogsPartyLauncher/project.godot index 4adcadc..142d252 100644 --- a/CogsPartyLauncher/project.godot +++ b/CogsPartyLauncher/project.godot @@ -29,7 +29,7 @@ project/assembly_name="CogsPartyLauncher" [editor_plugins] -enabled=PackedStringArray("res://addons/max_size_container/plugin.cfg") +enabled=PackedStringArray("res://addons/editor_icon_previewer/plugin.cfg", "res://addons/max_size_container/plugin.cfg") [rendering] diff --git a/CogsPartyLauncher/scenes/main.tscn b/CogsPartyLauncher/scenes/main.tscn index c9e0d0f..7a96f06 100644 --- a/CogsPartyLauncher/scenes/main.tscn +++ b/CogsPartyLauncher/scenes/main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=21 format=3 uid="uid://k31chn02rvs2"] +[gd_scene load_steps=22 format=3 uid="uid://k31chn02rvs2"] [ext_resource type="Theme" uid="uid://036n6qd3ik2g" path="res://assets/theme.tres" id="1_erdau"] [ext_resource type="Script" path="res://scripts/main_menu.gd" id="2_6njpl"] @@ -11,6 +11,7 @@ [ext_resource type="Script" path="res://scripts/game_library.gd" id="7_afary"] [ext_resource type="Texture2D" uid="uid://uc8pxnfjvsmj" path="res://assets/icon_reload.svg" id="7_ywnar"] [ext_resource type="PackedScene" uid="uid://c24hlo57mf44p" path="res://prefabs/player_setting.tscn" id="8_g7i7g"] +[ext_resource type="Texture2D" uid="uid://c27ucuw3vtgn6" path="res://assets/icon_add.svg" id="9_f0lwm"] [ext_resource type="Script" path="res://scripts/lobby_menu.gd" id="9_iaqec"] [ext_resource type="PackedScene" uid="uid://ccybwxdqx3qi7" path="res://prefabs/lobby_player.tscn" id="10_ewmxw"] [ext_resource type="PackedScene" uid="uid://bp0606lonchki" path="res://prefabs/game_library_display.tscn" id="11_gn2ub"] @@ -132,7 +133,6 @@ theme_override_constants/margin_right = 30 theme_override_constants/margin_bottom = 30 [node name="PlayerSelectMenu" type="VBoxContainer" parent="Menus" node_paths=PackedStringArray("player_setting_container", "add_player_button", "play_button", "back_button", "game_library", "menu_navigator", "game_library_display")] -visible = false layout_mode = 2 theme_override_constants/separation = 32 alignment = 1 @@ -150,6 +150,7 @@ game_library_display = NodePath("HBoxContainer2/GameLibraryDisplay") [node name="HBoxContainer2" type="HBoxContainer" parent="Menus/PlayerSelectMenu"] layout_mode = 2 size_flags_vertical = 3 +theme_override_constants/separation = 16 [node name="PanelContainer" type="PanelContainer" parent="Menus/PlayerSelectMenu/HBoxContainer2"] layout_mode = 2 @@ -194,7 +195,8 @@ theme_override_fonts/font = ExtResource("4_jhk8j") theme_override_styles/normal = SubResource("StyleBoxFlat_5ytcv") theme_override_styles/hover = SubResource("StyleBoxFlat_5cgwq") theme_override_styles/pressed = SubResource("StyleBoxFlat_5ytcv") -text = "A D D" +icon = ExtResource("9_f0lwm") +icon_alignment = 1 [node name="GameLibraryDisplay" parent="Menus/PlayerSelectMenu/HBoxContainer2" instance=ExtResource("11_gn2ub")] layout_mode = 2 @@ -225,6 +227,7 @@ theme_override_styles/pressed = SubResource("StyleBoxFlat_55hvc") text = "P L A Y" [node name="LobbyMenu" type="MarginContainer" parent="Menus" node_paths=PackedStringArray("menu_navigator", "game_library", "game_library_display", "quit_button", "next_button", "lobby_player_container", "lobby_view", "running_game_playing_label", "running_view", "running_game_entry")] +visible = false layout_mode = 2 script = ExtResource("9_iaqec") menu_navigator = NodePath("../../MenuNavigator") @@ -240,12 +243,12 @@ running_view = NodePath("RunningView") running_game_entry = NodePath("RunningView/MarginContainer/VBoxContainer/RunningGameEntry") [node name="LobbyView" type="VBoxContainer" parent="Menus/LobbyMenu"] -visible = false layout_mode = 2 [node name="HBoxContainer2" type="HBoxContainer" parent="Menus/LobbyMenu/LobbyView"] layout_mode = 2 size_flags_vertical = 3 +theme_override_constants/separation = 16 [node name="PanelContainer" type="PanelContainer" parent="Menus/LobbyMenu/LobbyView/HBoxContainer2"] layout_mode = 2 @@ -437,3 +440,4 @@ fit_content = true [node name="GameLibraryDisplay" parent="Menus/MainMenu" instance=ExtResource("11_gn2ub")] layout_mode = 2 +display_mode = true diff --git a/CogsPartyLauncher/scripts/crossout.gd b/CogsPartyLauncher/scripts/crossout.gd new file mode 100644 index 0000000..2d83028 --- /dev/null +++ b/CogsPartyLauncher/scripts/crossout.gd @@ -0,0 +1,17 @@ +@tool +extends Control + + +func _draw(): + var rect = self.get_rect() + var width = 4; + var radius = width / 2.0 + var color = Color.WHITE + rect.position += Vector2.ONE * radius + rect.size -= 2 * Vector2.ONE * radius + draw_line(rect.position, rect.position + rect.size, color, width) + draw_line(rect.position + Vector2(rect.size.x, 0), rect.position + Vector2(0, rect.size.y), color, width) + draw_circle(rect.position, radius, color) + draw_circle(rect.position + Vector2(rect.size.x, 0), radius, color) + draw_circle(rect.position + Vector2(0, rect.size.y), radius, color) + draw_circle(rect.position + rect.size, radius, color) diff --git a/CogsPartyLauncher/scripts/game_entry.gd b/CogsPartyLauncher/scripts/game_entry.gd index aed38e7..9cb3eaa 100644 --- a/CogsPartyLauncher/scripts/game_entry.gd +++ b/CogsPartyLauncher/scripts/game_entry.gd @@ -14,6 +14,7 @@ signal changed() @export var content_container: Control @export var enabled_checkbox: CheckBox @export var player_count_label: Label +@export var crossout: Control const SUPPORTED_BUILDS = [ @@ -106,6 +107,8 @@ func _update_ui(): else: error_panel.visible = false + crossout.visible = not allowed + crossout.queue_redraw() if not allowed: content_container.modulate = Color("#b4b4b4") enabled_checkbox.disabled = true diff --git a/CogsPartyLauncher/scripts/game_library.gd b/CogsPartyLauncher/scripts/game_library.gd index ed0d553..3cab6cf 100644 --- a/CogsPartyLauncher/scripts/game_library.gd +++ b/CogsPartyLauncher/scripts/game_library.gd @@ -95,9 +95,9 @@ func get_playable_games(player_count: int = save_data.players.size()) -> Array[D return playable_games -func get_enabled_playable_games() -> Array[Dictionary]: +func get_enabled_playable_games(player_count: int = save_data.players.size()) -> Array[Dictionary]: var playable_games: Array[Dictionary] = [] - for game in get_playable_games(): + for game in get_playable_games(player_count): if game.enabled: playable_games.append(game) return playable_games diff --git a/CogsPartyLauncher/scripts/game_library_display.gd b/CogsPartyLauncher/scripts/game_library_display.gd index 45ca5f8..42dd4aa 100644 --- a/CogsPartyLauncher/scripts/game_library_display.gd +++ b/CogsPartyLauncher/scripts/game_library_display.gd @@ -2,6 +2,9 @@ extends VBoxContainer class_name GameLibraryDisplay +signal changed() + + @export var game_entry_prefab: PackedScene @export var game_entry_container: VBoxContainer @export var games_label: Label @@ -23,7 +26,7 @@ func update(_games: Array[Dictionary], _allowed_games = null,): for entry in _games: var inst = game_entry_prefab.instantiate() as GameEntry game_entry_container.add_child(inst) - inst.changed.connect(_update_games_label) + inst.changed.connect(_on_entry_changed) inst.construct(entry) if allowed_games != null and not entry in allowed_games: inst.allowed = false @@ -75,3 +78,8 @@ func _update_games_label(): games_label.text = "G A M E S ( %d / %d )" % [allowed_and_enabled_game_count, allowed_game_count] else: games_label.text = "G A M E S ( %d )" % allowed_and_enabled_game_count + + +func _on_entry_changed(): + _update_games_label() + changed.emit() diff --git a/CogsPartyLauncher/scripts/player_select_menu.gd b/CogsPartyLauncher/scripts/player_select_menu.gd index ccc9426..1dd6705 100644 --- a/CogsPartyLauncher/scripts/player_select_menu.gd +++ b/CogsPartyLauncher/scripts/player_select_menu.gd @@ -20,6 +20,7 @@ func _ready(): add_player_button.pressed.connect(_on_add_player_button_pressed) play_button.pressed.connect(_on_play_button_pressed) back_button.pressed.connect(menu_navigator.load_menu.bind("MainMenu")) + game_library_display.changed.connect(_on_game_library_display_changed) self.visibility_changed.connect(_on_visible_changed) _update_add_player_button() @@ -74,6 +75,18 @@ func _update_add_player_button(): add_player_button.visible = taken_colors.size() < player_colors.size() +func _get_enabled_playable_games() -> Array[Dictionary]: + return game_library.get_enabled_playable_games(player_settings.size()) + + +func _get_playable_games() -> Array[Dictionary]: + return game_library.get_playable_games(player_settings.size()) + + +func _update_play_button(): + play_button.disabled = _get_enabled_playable_games().size() == 0 + + func _update_player_settings(): _update_taken_colors_set() # Update color options and numbers @@ -84,7 +97,7 @@ func _update_player_settings(): func _update_game_library_display(): - game_library_display.update(game_library.games, game_library.get_playable_games(player_settings.size())) + game_library_display.update(game_library.games, _get_playable_games()) func _on_visible_changed(): @@ -93,6 +106,18 @@ func _on_visible_changed(): _update_game_library_display() +func _on_player_setting_updated(): + _update_player_settings() + + +func _on_player_count_changed(): + _update_player_settings() + _update_game_library_display() + _update_add_player_button() + _update_play_button() + + + func _on_add_player_button_pressed(): var inst = player_setting_prefab.instantiate() as PlayerSetting player_setting_container.add_child(inst) @@ -104,13 +129,7 @@ func _on_add_player_button_pressed(): _get_next_available_color_or_self() ) player_settings.append(inst) - _update_player_settings() - _update_game_library_display() - _update_add_player_button() - - -func _on_player_setting_updated(): - _update_player_settings() + _on_player_count_changed() func _on_player_setting_removed(player_setting: PlayerSetting): @@ -126,9 +145,11 @@ func _on_player_setting_removed(player_setting: PlayerSetting): player_setting_container.remove_child(player_setting) player_setting.queue_free() player_settings.erase(player_setting) - _update_player_settings() - _update_game_library_display() - _update_add_player_button() + _on_player_count_changed() + + +func _on_game_library_display_changed(): + _update_play_button() func _on_play_button_pressed():