Add pause menu
This commit is contained in:
parent
a98c9d2e55
commit
6cf5828d43
@ -107,3 +107,6 @@ text = "Exit to Lobby"
|
|||||||
[node name="exit" type="Button" parent="pause_menu/v_box_container" unique_id=641638697]
|
[node name="exit" type="Button" parent="pause_menu/v_box_container" unique_id=641638697]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Exit"
|
text = "Exit"
|
||||||
|
|
||||||
|
[connection signal="pressed" from="pause_menu/v_box_container/exit_to_lobby" to="." method="exit_to_lobby"]
|
||||||
|
[connection signal="pressed" from="pause_menu/v_box_container/exit" to="." method="exit"]
|
||||||
|
|||||||
@ -96,11 +96,13 @@ impl GameManager {
|
|||||||
|
|
||||||
pub fn exit_game(&mut self) {
|
pub fn exit_game(&mut self) {
|
||||||
self.exiting = true;
|
self.exiting = true;
|
||||||
if let Some(mut game) = self.game.take() {
|
self.run_deferred(|s| {
|
||||||
game.bind_mut().finish_game();
|
if let Some(mut game) = s.game.take() {
|
||||||
game.queue_free();
|
game.bind_mut().finish_game();
|
||||||
self.go_to_main_menu();
|
game.queue_free();
|
||||||
}
|
s.go_to_main_menu();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn go_to_finish_screen(&self) {
|
pub fn go_to_finish_screen(&self) {
|
||||||
|
|||||||
@ -11,7 +11,7 @@ use godot::{
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
game_manager::{Game, GameOption},
|
game_manager::{Game, GameManager, GameOption},
|
||||||
net::{
|
net::{
|
||||||
network_manager::{
|
network_manager::{
|
||||||
NetworkManager,
|
NetworkManager,
|
||||||
@ -483,7 +483,6 @@ impl ICharacterBody3D for LocalPlayer {
|
|||||||
|
|
||||||
fn input(&mut self, event: Gd<InputEvent>) {
|
fn input(&mut self, event: Gd<InputEvent>) {
|
||||||
if event.is_action_pressed("pause") {
|
if event.is_action_pressed("pause") {
|
||||||
godot_print!("pause");
|
|
||||||
if let Some(pause_panel) = &mut self.pause_panel {
|
if let Some(pause_panel) = &mut self.pause_panel {
|
||||||
let is_visible = pause_panel.is_visible();
|
let is_visible = pause_panel.is_visible();
|
||||||
pause_panel.set_visible(!is_visible);
|
pause_panel.set_visible(!is_visible);
|
||||||
@ -599,6 +598,19 @@ impl LocalPlayer {
|
|||||||
self.weapon = Some(weapon);
|
self.weapon = Some(weapon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[func]
|
||||||
|
pub fn exit_to_lobby(&mut self) {
|
||||||
|
if let Some(game) = &mut Game::singleton() {
|
||||||
|
game.bind_mut().finish_game();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[func]
|
||||||
|
pub fn exit(&mut self) {
|
||||||
|
GameManager::singleton().bind_mut().exit_game();
|
||||||
|
NetworkManager::singleton().bind_mut().disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(GodotClass)]
|
#[derive(GodotClass)]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user