diff --git a/Cargo.lock b/Cargo.lock index 9fed945..c0806d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5055,7 +5055,7 @@ dependencies = [ [[package]] name = "turtle_time" -version = "0.8.0" +version = "0.9.0" dependencies = [ "bevy", "bevy-inspector-egui", diff --git a/Cargo.toml b/Cargo.toml index d54b23a..c06e660 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "turtle_time" -version = "0.8.0" +version = "0.9.0" publish = false authors = ["Mike Eder "] edition = "2021" diff --git a/README.md b/README.md index 9ddf365..31e879a 100644 --- a/README.md +++ b/README.md @@ -26,5 +26,3 @@ Try it out here: https://mikeder.net/turtletime 2. Scoreboard and Leaderboard for game stats, pickups, wins, loses, etc. 3. More game modes, COOP survival, PVE. 4. Controller support. - - diff --git a/src/menu/connect.rs b/src/menu/connect.rs index f06f66b..deb96e4 100644 --- a/src/menu/connect.rs +++ b/src/menu/connect.rs @@ -41,7 +41,7 @@ pub fn create_matchbox_socket(mut commands: Commands, connect_data: Res>(); // insert new socket resource for next session commands.insert_resource(MatchboxSocket::new_reliable(room_url)); - commands.remove_resource::(); + // commands.remove_resource::(); } pub fn lobby_system( diff --git a/src/menu/main.rs b/src/menu/main.rs index 35e9ee8..de7d663 100644 --- a/src/menu/main.rs +++ b/src/menu/main.rs @@ -1,4 +1,4 @@ -use super::connect::LocalHandle; +use super::connect::{ConnectData, LocalHandle}; use super::online::PlayerCount; use super::plugin::{BUTTON_TEXT, HOVERED_BUTTON, NORMAL_BUTTON, PRESSED_BUTTON, VERSION}; use crate::loading::{FontAssets, TextureAssets}; @@ -244,6 +244,9 @@ pub fn btn_listeners( app_state.set(AppState::MenuOnline); } MainMenuBtn::LocalMatch => { + // remove any lingering online connect data + commands.remove_resource::(); + create_synctest_session(&mut commands, player_count.0); app_state.set(AppState::RoundLocal); game_state.set(GameState::Playing); diff --git a/src/menu/win.rs b/src/menu/win.rs index 8c3c006..138f07e 100644 --- a/src/menu/win.rs +++ b/src/menu/win.rs @@ -1,3 +1,4 @@ +use super::connect::ConnectData; use super::plugin::{BUTTON_TEXT, HOVERED_BUTTON, NORMAL_BUTTON, PRESSED_BUTTON}; use crate::loading::FontAssets; use crate::AppState; @@ -9,6 +10,7 @@ pub struct WinUI; #[derive(Component)] pub enum MenuWinBtn { Back, + Rematch, } #[derive(Resource)] @@ -16,7 +18,17 @@ pub struct MatchData { pub result: String, } -pub fn setup_ui(mut commands: Commands, match_data: Res, font_assets: Res) { +pub fn setup_ui( + mut commands: Commands, + match_data: Res, + font_assets: Res, + connect_data: Option>, +) { + let mut rematch_vis = Visibility::Hidden; + if connect_data.is_some() { + rematch_vis = Visibility::Visible; + } + // ui camera commands.spawn(Camera2dBundle::default()).insert(WinUI); @@ -54,6 +66,36 @@ pub fn setup_ui(mut commands: Commands, match_data: Res, font_assets: ), ..Default::default() }); + // rematch button + parent + .spawn(ButtonBundle { + style: Style { + size: Size::new(Val::Px(250.0), Val::Px(65.0)), + justify_content: JustifyContent::Center, + align_items: AlignItems::Center, + margin: UiRect::all(Val::Px(16.)), + padding: UiRect::all(Val::Px(16.)), + + ..Default::default() + }, + visibility: rematch_vis, + background_color: NORMAL_BUTTON.into(), + ..Default::default() + }) + .with_children(|parent| { + parent.spawn(TextBundle { + text: Text::from_section( + "Rematch", + TextStyle { + font: font_assets.fira_sans.clone(), + font_size: 40.0, + color: BUTTON_TEXT, + }, + ), + ..Default::default() + }); + }) + .insert(MenuWinBtn::Rematch); // back to menu button parent .spawn(ButtonBundle { @@ -82,17 +124,6 @@ pub fn setup_ui(mut commands: Commands, match_data: Res, font_assets: }); }) .insert(MenuWinBtn::Back); - parent.spawn(TextBundle { - text: Text::from_section( - "This state is bugged...\nIf the button doesn't work, refresh the page.", - TextStyle { - font: font_assets.fira_sans.clone(), - font_size: 20.0, - color: Color::BLACK, - }, - ), - ..Default::default() - }); }) .insert(WinUI); @@ -130,6 +161,9 @@ pub fn btn_listeners( MenuWinBtn::Back => { app_state.set(AppState::MenuMain); } + MenuWinBtn::Rematch => { + app_state.set(AppState::MenuConnect); + } } } }