diff options
author | metamuffin <metamuffin@disroot.org> | 2025-06-07 18:32:51 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-06-07 18:32:51 +0200 |
commit | f8882c85ae75f6a72c59768148e27ac103e6fedf (patch) | |
tree | 9ed7157f62f920f3182fa70131d8d1453a990aad | |
parent | ea1f60b0ba95a0f8b96e294c6aee608357306d20 (diff) | |
download | hurrycurry-f8882c85ae75f6a72c59768148e27ac103e6fedf.tar hurrycurry-f8882c85ae75f6a72c59768148e27ac103e6fedf.tar.bz2 hurrycurry-f8882c85ae75f6a72c59768148e27ac103e6fedf.tar.zst |
disable lobby menu bot add/remove buttons if unavailable
-rw-r--r-- | client/menu/lobby.gd | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/client/menu/lobby.gd b/client/menu/lobby.gd index f530862c..0cdabfdd 100644 --- a/client/menu/lobby.gd +++ b/client/menu/lobby.gd @@ -1,6 +1,7 @@ # Hurry Curry! - a game about cooking # Copyright 2024 tpart # Copyright 2024 nokoe +# Copyright 2025 metamuffin # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -17,7 +18,7 @@ extends Control class_name Lobby -const MAX_BOT_COUNT_PER_TYPE: int = 16 +const MAX_BOT_COUNT_PER_TYPE: int = 3 const PLAYER = preload("res://menu/lobby/player.tscn") var map_count @@ -27,6 +28,8 @@ var selected_map_name: String var bots_enabled := false var bot_counts := {} var bot_reset_buttons := {} +var bot_inc_buttons := {} +var bot_dec_buttons := {} @onready var game: Game = $"../Game" @onready var player_container = $PlayerList/VBoxContainer/Players @@ -86,17 +89,19 @@ func initialize(): var add := Button.new() add.text = "+" var reset := Button.new() - bot_reset_buttons[algo_id] = reset - update_bot_reset_text(algo_id) reset.size_flags_horizontal = SIZE_EXPAND_FILL var remove := Button.new() remove.text = "-" - h.add_child(remove) - h.add_child(reset) - h.add_child(add) + bot_reset_buttons[algo_id] = reset + bot_inc_buttons[algo_id] = add + bot_dec_buttons[algo_id] = remove + update_bot_reset_text(algo_id) add.pressed.connect(increase_bot_count.bind(algo_id)) reset.pressed.connect(reset_bot_count.bind(algo_id)) remove.pressed.connect(decrease_bot_count.bind(algo_id)) + h.add_child(remove) + h.add_child(reset) + h.add_child(add) bot_settings.add_child(h) func select_map(i: int): @@ -112,11 +117,11 @@ func select_map(i: int): map_list_container.get_child(i).grab_focus() func increase_bot_count(algo_id: String): - bot_counts[algo_id] = clampi(bot_counts[algo_id] + 1, 0, MAX_BOT_COUNT_PER_TYPE) + bot_counts[algo_id] += 1 update_bot_reset_text(algo_id) func decrease_bot_count(algo_id: String): - bot_counts[algo_id] = clampi(bot_counts[algo_id] - 1, 0, MAX_BOT_COUNT_PER_TYPE) + bot_counts[algo_id] -= 1 update_bot_reset_text(algo_id) func reset_bot_count(algo_id: String): @@ -126,6 +131,8 @@ func reset_bot_count(algo_id: String): func update_bot_reset_text(algo_id: String): var display_name: String = tr("s.bot.%s" % algo_id) bot_reset_buttons[algo_id].text = "%s (%d)" % [display_name, bot_counts[algo_id]] + bot_inc_buttons[algo_id].disabled = not bot_counts[algo_id] < MAX_BOT_COUNT_PER_TYPE + bot_dec_buttons[algo_id].disabled = not bot_counts[algo_id] > 0 func update_players(player_list: Dictionary): for i in player_container.get_children(): |