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 | |
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
29 files changed, 98 insertions, 28 deletions
diff --git a/client/game.gd b/client/game.gd index a31109cb..b6646407 100644 --- a/client/game.gd +++ b/client/game.gd @@ -22,6 +22,7 @@ signal update_players(players: Dictionary) signal data_updated() signal player_set_input_enabled(b: bool) signal joined() +signal left() var player_id: int = -1 var item_names: Array = [] @@ -33,6 +34,8 @@ var tile_interact: Array = [] var map_names: Array = [] var in_lobby := false var is_replay := false +var is_joined := false +var join_sent := false var marker_target = Vector3(0,0,0) var players := {} @@ -92,6 +95,7 @@ func _ready(): player_instance = ControllablePlayer.new(player, player_name, pos, character, self) camera.target = player_instance player_set_input_enabled.connect(player_instance.set_input_enabled) + is_joined = true joined.emit() else: player_instance = Player.new(player, player_name, pos, character, self) @@ -111,7 +115,10 @@ func _ready(): mp.remove_player.connect(func(id: int): var player: Player = players.get(id) if id == player_id: - camera.target = self + is_joined = false + join_sent = false + left.emit() + camera.target = $Center if player != null: if player.hand != null: player.hand.queue_free() @@ -237,6 +244,7 @@ func _ready(): ) func join(): + join_sent = true mp.send_join(Global.profile["username"], Global.profile["character"]) func _process(delta): diff --git a/client/map/item_factory.gd b/client/map/item_factory.gd index 833e61af..d4d0b054 100644 --- a/client/map/item_factory.gd +++ b/client/map/item_factory.gd @@ -1,6 +1,5 @@ # Hurry Curry! - a game about cooking # Copyright 2024 nokoe -# Copyright 2024 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 diff --git a/client/map/tile_factory.gd b/client/map/tile_factory.gd index a5e7bf05..b8f70200 100644 --- a/client/map/tile_factory.gd +++ b/client/map/tile_factory.gd @@ -62,6 +62,8 @@ static func produce(tile_name: String, node_name: String, neighbors: Array) -> T return Path.new(node_name, neighbors) "fence": return Fence.new(node_name, neighbors) + "book": + return Book.new(node_name, neighbors) var t: push_warning("tile %s unknown" % t) return GenericTile.new(node_name, neighbors, t) diff --git a/client/map/tiles/book.gd b/client/map/tiles/book.gd new file mode 100644 index 00000000..11bd6592 --- /dev/null +++ b/client/map/tiles/book.gd @@ -0,0 +1,25 @@ +# Hurry Curry! - a game about cooking +# Copyright 2024 nokoe +# +# 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 +# the Free Software Foundation, version 3 of the License only. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# +class_name Book +extends CounterBase + +func _init(rename: String, neighbors: Array): + super(rename, neighbors) + base.add_child(load("res://map/tiles/book.tscn").instantiate()) + +func interact(): + # the book is supposed to be opened here + pass diff --git a/client/map/tiles/book.res b/client/map/tiles/book.res Binary files differnew file mode 100644 index 00000000..9caf89f1 --- /dev/null +++ b/client/map/tiles/book.res diff --git a/client/map/tiles/book.tscn b/client/map/tiles/book.tscn new file mode 100644 index 00000000..d5f6e0d3 --- /dev/null +++ b/client/map/tiles/book.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=2 format=3 uid="uid://c7fjfp5ygxsjc"] + +[ext_resource type="ArrayMesh" uid="uid://cgvow28wkwesp" path="res://map/tiles/book.res" id="1_vxs3d"] + +[node name="Book" type="Node3D"] + +[node name="Mesh" type="MeshInstance3D" parent="."] +transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0.5, 0) +mesh = ExtResource("1_vxs3d") +skeleton = NodePath("") diff --git a/client/map/tiles/chair.gd b/client/map/tiles/chair.gd index bf2fce16..65b0f91e 100644 --- a/client/map/tiles/chair.gd +++ b/client/map/tiles/chair.gd @@ -1,5 +1,4 @@ # Hurry Curry! - a game about cooking -# Copyright 2024 metamuffin # Copyright 2024 nokoe # # This program is free software: you can redistribute it and/or modify diff --git a/client/map/tiles/counter.gd b/client/map/tiles/counter.gd index 45be5525..c07407ae 100644 --- a/client/map/tiles/counter.gd +++ b/client/map/tiles/counter.gd @@ -1,5 +1,4 @@ # Hurry Curry! - a game about cooking -# Copyright 2024 metamuffin # Copyright 2024 nokoe # # This program is free software: you can redistribute it and/or modify diff --git a/client/map/tiles/counter_base.gd b/client/map/tiles/counter_base.gd index 0235268e..649347a3 100644 --- a/client/map/tiles/counter_base.gd +++ b/client/map/tiles/counter_base.gd @@ -1,6 +1,5 @@ # Hurry Curry! - a game about cooking # Copyright 2024 nokoe -# Copyright 2024 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 diff --git a/client/map/tiles/crate.gd b/client/map/tiles/crate.gd index 63ceed75..7f6ccd3b 100644 --- a/client/map/tiles/crate.gd +++ b/client/map/tiles/crate.gd @@ -1,5 +1,5 @@ # Hurry Curry! - a game about cooking -# Copyright 2024 metamuffin +# Copyright 2024 nokoe # # 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 diff --git a/client/map/tiles/cutting_board.gd b/client/map/tiles/cutting_board.gd index 66968313..3e1b4018 100644 --- a/client/map/tiles/cutting_board.gd +++ b/client/map/tiles/cutting_board.gd @@ -1,6 +1,5 @@ # Hurry Curry! - a game about cooking # Copyright 2024 nokoe -# Copyright 2024 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 diff --git a/client/map/tiles/door.gd b/client/map/tiles/door.gd index 28506852..b84c224e 100644 --- a/client/map/tiles/door.gd +++ b/client/map/tiles/door.gd @@ -1,6 +1,5 @@ # Hurry Curry! - a game about cooking # Copyright 2024 nokoe -# Copyright 2024 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 diff --git a/client/map/tiles/floor.gd b/client/map/tiles/floor.gd index a8b9e8f7..666a6699 100644 --- a/client/map/tiles/floor.gd +++ b/client/map/tiles/floor.gd @@ -1,6 +1,5 @@ # Hurry Curry! - a game about cooking # Copyright 2024 nokoe -# Copyright 2024 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 diff --git a/client/map/tiles/flour_counter.gd b/client/map/tiles/flour_counter.gd index fa8a1bbc..03bb7742 100644 --- a/client/map/tiles/flour_counter.gd +++ b/client/map/tiles/flour_counter.gd @@ -1,6 +1,5 @@ # Hurry Curry! - a game about cooking # Copyright 2024 nokoe -# Copyright 2024 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 diff --git a/client/map/tiles/full_tile.gd b/client/map/tiles/full_tile.gd index f83ba2b5..99f12296 100644 --- a/client/map/tiles/full_tile.gd +++ b/client/map/tiles/full_tile.gd @@ -1,5 +1,4 @@ # Hurry Curry! - a game about cooking -# Copyright 2024 metamuffin # Copyright 2024 nokoe # # This program is free software: you can redistribute it and/or modify diff --git a/client/map/tiles/generic_tile.gd b/client/map/tiles/generic_tile.gd index 5cbc7820..87d7aab4 100644 --- a/client/map/tiles/generic_tile.gd +++ b/client/map/tiles/generic_tile.gd @@ -1,6 +1,5 @@ # Hurry Curry! - a game about cooking # Copyright 2024 nokoe -# Copyright 2024 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 diff --git a/client/map/tiles/oven.gd b/client/map/tiles/oven.gd index c0cf7196..598e0c7e 100644 --- a/client/map/tiles/oven.gd +++ b/client/map/tiles/oven.gd @@ -1,6 +1,5 @@ # Hurry Curry! - a game about cooking # Copyright 2024 nokoe -# Copyright 2024 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 diff --git a/client/map/tiles/raw_steak_crate.gd b/client/map/tiles/raw_steak_crate.gd index 07a2acdf..4c1240ff 100644 --- a/client/map/tiles/raw_steak_crate.gd +++ b/client/map/tiles/raw_steak_crate.gd @@ -1,6 +1,5 @@ # Hurry Curry! - a game about cooking # Copyright 2024 nokoe -# Copyright 2024 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 diff --git a/client/map/tiles/sink.gd b/client/map/tiles/sink.gd index adf1a971..e98a25d0 100644 --- a/client/map/tiles/sink.gd +++ b/client/map/tiles/sink.gd @@ -1,6 +1,5 @@ # Hurry Curry! - a game about cooking # Copyright 2024 nokoe -# Copyright 2024 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 diff --git a/client/map/tiles/stove.gd b/client/map/tiles/stove.gd index 65bc9502..9792041f 100644 --- a/client/map/tiles/stove.gd +++ b/client/map/tiles/stove.gd @@ -1,6 +1,5 @@ # Hurry Curry! - a game about cooking # Copyright 2024 nokoe -# Copyright 2024 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 diff --git a/client/map/tiles/table.gd b/client/map/tiles/table.gd index 6d1b1862..8d04b60a 100644 --- a/client/map/tiles/table.gd +++ b/client/map/tiles/table.gd @@ -1,6 +1,5 @@ # Hurry Curry! - a game about cooking # Copyright 2024 nokoe -# Copyright 2024 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 diff --git a/client/map/tiles/trash.gd b/client/map/tiles/trash.gd index a8ba3e6d..ad93a1d9 100644 --- a/client/map/tiles/trash.gd +++ b/client/map/tiles/trash.gd @@ -1,6 +1,5 @@ # Hurry Curry! - a game about cooking # Copyright 2024 nokoe -# Copyright 2024 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 diff --git a/client/map/tiles/wall.gd b/client/map/tiles/wall.gd index 0a00752d..a6d650da 100644 --- a/client/map/tiles/wall.gd +++ b/client/map/tiles/wall.gd @@ -1,6 +1,5 @@ # Hurry Curry! - a game about cooking # Copyright 2024 nokoe -# Copyright 2024 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 diff --git a/client/map/tiles/wall_tile.gd b/client/map/tiles/wall_tile.gd index d0d9a422..94248c03 100644 --- a/client/map/tiles/wall_tile.gd +++ b/client/map/tiles/wall_tile.gd @@ -1,6 +1,5 @@ # Hurry Curry! - a game about cooking # Copyright 2024 nokoe -# Copyright 2024 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 diff --git a/client/map/tiles/window.gd b/client/map/tiles/window.gd index 7c46fa56..0a3c9eba 100644 --- a/client/map/tiles/window.gd +++ b/client/map/tiles/window.gd @@ -1,6 +1,5 @@ # Hurry Curry! - a game about cooking # Copyright 2024 nokoe -# Copyright 2024 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 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() diff --git a/client/multiplayer.gd b/client/multiplayer.gd index 709a4502..aa895b69 100644 --- a/client/multiplayer.gd +++ b/client/multiplayer.gd @@ -287,6 +287,11 @@ func send_replay_tick(dt: float): "dt": dt }) +func send_leave(): + send_packet({ + "type": "leave", + }) + func send_packet(packet): var json = JSON.stringify(packet) socket.send_text(json) |