diff options
| author | nokoe <nokoe@mailbox.org> | 2024-09-28 12:00:48 +0200 | 
|---|---|---|
| committer | nokoe <nokoe@mailbox.org> | 2024-09-28 12:02:43 +0200 | 
| commit | 04ddfc807a0e275d69e82222c7a7fcb39c979e02 (patch) | |
| tree | adbe8ce929bc2fb81914b8b90be4115ddfcef8cc /client/menu/ingame.gd | |
| parent | 045e34f78a498230f39101ce215424fcdcec9eb0 (diff) | |
| download | hurrycurry-04ddfc807a0e275d69e82222c7a7fcb39c979e02.tar hurrycurry-04ddfc807a0e275d69e82222c7a7fcb39c979e02.tar.bz2 hurrycurry-04ddfc807a0e275d69e82222c7a7fcb39c979e02.tar.zst | |
replace `is_joined` and `join_sent` with `join_state`
Diffstat (limited to 'client/menu/ingame.gd')
| -rw-r--r-- | client/menu/ingame.gd | 39 | 
1 files changed, 15 insertions, 24 deletions
| diff --git a/client/menu/ingame.gd b/client/menu/ingame.gd index 7052f237..ba365f8e 100644 --- a/client/menu/ingame.gd +++ b/client/menu/ingame.gd @@ -26,19 +26,16 @@ extends Menu  var opened  func _ready():  	opened = Time.get_ticks_msec() -	game.joined.connect(_on_game_joined) -	game.left.connect(_on_game_left) -	update_button_text() -	game.joined.connect(update_lobby_button) -	game.left.connect(update_lobby_button) +	game.join_state_updated.connect(_on_game_join_state_changed) +	_on_game_join_state_changed(game.join_state)  	update_lobby_button()  	super()  func update_lobby_button(): -	lobby_button.disabled = game.in_lobby or not game.is_joined +	lobby_button.disabled = game.in_lobby or game.join_state == Game.JoinState.SPECTATING  	if game.in_lobby:  		lobby_button.tooltip_text = "Cannot cancel game since no game is running." -	elif not game.is_joined: +	elif not game.join_state == Game.JoinState.JOINED:  		lobby_button.tooltip_text = "You must join in order to be able to cancel the current game."  	else:  		lobby_button.tooltip_text = "" @@ -71,21 +68,15 @@ func _on_lobby_pressed():  	exit()  func _on_leave_pressed(): -	if game.is_joined: -		game.mp.send_leave(game.player_id) -	elif not game.join_sent: -		leave_button.disabled = true -		game.join() +	game.toggle_join() -func _on_game_joined(): -	leave_button.disabled = false -	update_button_text() - -func _on_game_left(): -	update_button_text() - -func update_button_text(): -	if game.is_joined: -		leave_button.text = tr("c.menu.ingame.leave") -	else: -		leave_button.text = tr("c.menu.ingame.join") +func _on_game_join_state_changed(state: Game.JoinState): +	match state: +		Game.JoinState.JOINED: +			leave_button.disabled = false +			leave_button.text = tr("c.menu.ingame.leave") +		Game.JoinState.SPECTATING: +			leave_button.disabled = false +			leave_button.text = tr("c.menu.ingame.join") +		Game.JoinState.WAITING: +			leave_button.disabled = true | 
