diff options
| author | metamuffin <metamuffin@disroot.org> | 2024-07-08 18:54:22 +0200 | 
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2024-07-08 18:54:22 +0200 | 
| commit | b0d43c7e78e8cf706b257e3931c3fca126ef3814 (patch) | |
| tree | 573517f5d185e56371af992fd78260c3db67cc21 /client/menu | |
| parent | 5e50f6e05b4503be23fd17819ed612db1c45cf04 (diff) | |
| parent | fbf9286b3b4c7791a49d8546204ea5bf28e1b4db (diff) | |
| download | hurrycurry-b0d43c7e78e8cf706b257e3931c3fca126ef3814.tar hurrycurry-b0d43c7e78e8cf706b257e3931c3fca126ef3814.tar.bz2 hurrycurry-b0d43c7e78e8cf706b257e3931c3fca126ef3814.tar.zst | |
Merge branch 'master' of https://codeberg.org/metamuffin/hurrycurry
Diffstat (limited to 'client/menu')
| -rw-r--r-- | client/menu/ingame.gd | 23 | ||||
| -rw-r--r-- | client/menu/ingame.tscn | 15 | ||||
| -rw-r--r-- | client/menu/lobby.gd | 15 | 
3 files changed, 46 insertions, 7 deletions
| diff --git a/client/menu/ingame.gd b/client/menu/ingame.gd index 659528aa..f8653411 100644 --- a/client/menu/ingame.gd +++ b/client/menu/ingame.gd @@ -20,11 +20,14 @@ extends Menu  @onready var options = $Side/Margin/Options  @onready var game: Game = $"../Game"  @onready var lobby_button: Button = $Side/Margin/Options/Lobby +@onready var leave_button: Button = $Side/Margin/Options/Leave  var opened  func _ready():  	opened = Time.get_ticks_msec()  	lobby_button.disabled = game.in_lobby +	game.joined.connect(_on_game_joined) +	game.left.connect(_on_game_left)  	super()  func anim_setup(): pass @@ -57,3 +60,23 @@ func _on_quit_pressed():  func _on_lobby_pressed():  	game.mp.send_chat("/end")  	exit() + +func _on_leave_pressed(): +	if game.is_joined: +		game.mp.send_leave() +	elif not game.join_sent: +		leave_button.disabled = true +		game.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("Leave Game") +	else: +		leave_button.text = tr("Join Game") diff --git a/client/menu/ingame.tscn b/client/menu/ingame.tscn index 029a4d6a..75710d41 100644 --- a/client/menu/ingame.tscn +++ b/client/menu/ingame.tscn @@ -72,6 +72,7 @@ anchors_preset = 9  anchor_bottom = 1.0  offset_left = -400.0  offset_right = -90.0 +offset_bottom = 648.0  grow_vertical = 2  [node name="Margin" type="MarginContainer" parent="Side"] @@ -102,6 +103,11 @@ layout_mode = 2  text = "Resume"  alignment = 0 +[node name="Leave" type="Button" parent="Side/Margin/Options"] +layout_mode = 2 +text = "Join Game" +alignment = 0 +  [node name="Lobby" type="Button" parent="Side/Margin/Options"]  layout_mode = 2  text = "Cancel game" @@ -112,11 +118,19 @@ layout_mode = 2  text = "Reconnect"  alignment = 0 +[node name="Spacer2" type="Control" parent="Side/Margin/Options"] +custom_minimum_size = Vector2(0, 10) +layout_mode = 2 +  [node name="Settings" type="Button" parent="Side/Margin/Options"]  layout_mode = 2  text = "Settings"  alignment = 0 +[node name="Spacer3" type="Control" parent="Side/Margin/Options"] +custom_minimum_size = Vector2(0, 10) +layout_mode = 2 +  [node name="MainMenu" type="Button" parent="Side/Margin/Options"]  layout_mode = 2  text = "Main menu" @@ -128,6 +142,7 @@ text = "Quit game"  alignment = 0  [connection signal="pressed" from="Side/Margin/Options/Resume" to="." method="_on_resume_pressed"] +[connection signal="pressed" from="Side/Margin/Options/Leave" to="." method="_on_leave_pressed"]  [connection signal="pressed" from="Side/Margin/Options/Lobby" to="." method="_on_lobby_pressed"]  [connection signal="pressed" from="Side/Margin/Options/Reconnect" to="." method="_on_reconnect_pressed"]  [connection signal="pressed" from="Side/Margin/Options/Settings" to="." method="_on_settings_pressed"] diff --git a/client/menu/lobby.gd b/client/menu/lobby.gd index 6e315a19..a31b38e9 100644 --- a/client/menu/lobby.gd +++ b/client/menu/lobby.gd @@ -20,8 +20,6 @@ const PLAYER = preload("res://menu/lobby/player.tscn")  var selected_map := 0  var selected_map_name: String -var joined := false -var join_sent := false  @onready var game: Game = $"../Game"  @onready var map_count = game.map_names.size() @@ -38,6 +36,7 @@ func _ready():  	initialize()  	game.data_updated.connect(initialize)  	game.joined.connect(_on_game_joined) +	game.left.connect(_on_game_left)  func initialize():  	map_count = game.map_names.size() @@ -60,7 +59,7 @@ func update_players(player_list: Dictionary):  		player_container.add_child(p)  		p.setup(player_list[i].username) -func _input(event): +func _input(_event):  	if not visible:  		return @@ -73,7 +72,10 @@ func _on_game_joined():  	map_selector.show()  	start_button.text = tr("Start Game")  	start_button.disabled = false -	joined = true + +func _on_game_left(): +	map_selector.hide() +	start_button.text = tr("Join Game")  func _on_left_pressed():  	selected_map = (selected_map - 1) % map_count @@ -84,10 +86,9 @@ func _on_right_pressed():  	select_map(selected_map)  func _on_controller_button_pressed(): -	if joined: +	if game.is_joined:  		if selected_map_name != null:  			game.mp.send_chat("/start %s" % selected_map_name) -	elif not join_sent: -		join_sent = true +	elif not game.join_sent:  		start_button.disabled = true  		game.join() | 
