From 80f25098fe6fa8484c51c03d445006871cfce34a Mon Sep 17 00:00:00 2001 From: PixelQz Date: Wed, 27 Sep 2023 11:38:27 +0800 Subject: [PATCH 1/4] chat_window --- src/client/state_manager/game.rs | 49 +++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/src/client/state_manager/game.rs b/src/client/state_manager/game.rs index 17a741d..59f7923 100644 --- a/src/client/state_manager/game.rs +++ b/src/client/state_manager/game.rs @@ -6,7 +6,7 @@ use bevy::{ prelude::{ in_state, AmbientLight, Commands, DespawnRecursiveExt, Entity, EventReader, EventWriter, Input, IntoSystemConfigs, KeyCode, Local, NextState, OnEnter, OnExit, Plugin, Query, Res, - ResMut, State, States, Update, Vec2, With, + ResMut, State, States, Update, Vec2, With,Resource, }, window::{CursorGrabMode, PrimaryWindow, Window, WindowCloseRequested}, }; @@ -44,6 +44,13 @@ use crate::{ use super::{new_renet_client, notification::Notification, ConnectionAddr, GameState}; + +#[derive(Default,Resource)] +pub struct TextEditDemo { + pub input: String, +} + + #[derive(Clone, Copy, Default, Eq, PartialEq, Debug, Hash, States)] pub enum PlayState { Main, @@ -62,6 +69,7 @@ impl Plugin for GamePlugin { app.add_systems(OnEnter(GameState::Game), setup); // app.insert_resource(); + app.insert_resource(TextEditDemo::default()); app.insert_resource(RenetClientVisualizer::<200>::new( RenetVisualizerStyle::default(), )); @@ -411,3 +419,42 @@ fn disconnect_on_close( exit.send(AppExit); } } + +fn chat_window( + mut contexts:EguiContexts, + mut input:ResMut, + + ) { + let ctx=contexts.ctx_mut(); + egui::Window::new("Chat") + .title_bar(false) + .vscroll(true) + .resizable(false) + .frame(egui::Frame::none().fill( egui::Color32::BLACK.gamma_multiply(0.8))) + .default_height(200.0) + .default_width(360.0) + .anchor(egui::Align2::LEFT_BOTTOM, [0.0,0.0]) + .collapsible(false) + .show(ctx, |ui|{ + + egui::CentralPanel::default() + .show_inside(ui, |ui|{ + ui.horizontal(|ui|{ + ui.label("Player"); + ui.label("time"); + ui.colored_label(egui::Color32::RED, "text"); + }); + }); + + egui::TopBottomPanel::bottom("bottom") + .show_inside(ui, |ui|{ + ui.horizontal(|ui|{ + ui.text_edit_singleline(&mut input.input); + + if ui.button("Send").clicked(){ + //todo + }; + }); + }) + }); + } \ No newline at end of file From 660fb69c443ab9aacdd4091c019f690bd0bfaebc Mon Sep 17 00:00:00 2001 From: PixelQz Date: Wed, 27 Sep 2023 11:45:10 +0800 Subject: [PATCH 2/4] feat:chat --- src/client/state_manager/game.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/state_manager/game.rs b/src/client/state_manager/game.rs index 59f7923..b1835f7 100644 --- a/src/client/state_manager/game.rs +++ b/src/client/state_manager/game.rs @@ -83,7 +83,7 @@ impl Plugin for GamePlugin { ); app.add_systems( Update, - (egui_center_cursor_system, mian_ui, controller_tool_bar) + (egui_center_cursor_system, mian_ui, controller_tool_bar,chat_window) .run_if(in_state(PlayState::Main)) .after(EguiSet::InitContexts), ); From 232eb8c30188ec689c36eeceea91afccff550a7a Mon Sep 17 00:00:00 2001 From: weykon <635883092@qq.com> Date: Fri, 29 Sep 2023 14:18:29 +0800 Subject: [PATCH 3/4] merge from Fan --- src/bin/client.rs | 6 ++- src/client/state_manager/game.rs | 85 +++++++++++++++----------------- 2 files changed, 46 insertions(+), 45 deletions(-) diff --git a/src/bin/client.rs b/src/bin/client.rs index a61b1e0..66f1c29 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -4,7 +4,7 @@ use bevy::{ asset::ChangeWatcher, diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}, prelude::{App, AssetPlugin, PluginGroup, Update}, - window::{ExitCondition, WindowPlugin}, + window::{ExitCondition, WindowPlugin, WindowMode, Window}, DefaultPlugins, }; use bevy_easy_localize::{Localize, LocalizePlugin}; @@ -32,6 +32,10 @@ fn main() { app.add_plugins(WindowPlugin { exit_condition: ExitCondition::OnAllClosed, close_when_requested: false, + primary_window: Some(Window { + mode: WindowMode::BorderlessFullscreen, + ..Default::default() + }), ..Default::default() }); app.add_plugins( diff --git a/src/client/state_manager/game.rs b/src/client/state_manager/game.rs index b1835f7..8d8e04d 100644 --- a/src/client/state_manager/game.rs +++ b/src/client/state_manager/game.rs @@ -6,7 +6,7 @@ use bevy::{ prelude::{ in_state, AmbientLight, Commands, DespawnRecursiveExt, Entity, EventReader, EventWriter, Input, IntoSystemConfigs, KeyCode, Local, NextState, OnEnter, OnExit, Plugin, Query, Res, - ResMut, State, States, Update, Vec2, With,Resource, + ResMut, Resource, State, States, Update, Vec2, With, }, window::{CursorGrabMode, PrimaryWindow, Window, WindowCloseRequested}, }; @@ -31,12 +31,13 @@ use crate::{ ClientLobby, }, ray_cast::MeshRayCastPlugin, + sp_mesh_display::SpMeshManagerPlugin, tool_bar_manager::ToolBarSyncPlugin, ui::{ staff_rules::staff_rules_ui, tool_bar::{tool_bar, ToolBar}, UiPicResourceManager, - }, sp_mesh_display::SpMeshManagerPlugin, + }, }, common::ClientClipSpheresPlugin, sky::ClientSkyPlugins, @@ -44,13 +45,11 @@ use crate::{ use super::{new_renet_client, notification::Notification, ConnectionAddr, GameState}; - -#[derive(Default,Resource)] +#[derive(Default, Resource)] pub struct TextEditDemo { - pub input: String, + pub input: String, } - #[derive(Clone, Copy, Default, Eq, PartialEq, Debug, Hash, States)] pub enum PlayState { Main, @@ -83,7 +82,12 @@ impl Plugin for GamePlugin { ); app.add_systems( Update, - (egui_center_cursor_system, mian_ui, controller_tool_bar,chat_window) + ( + egui_center_cursor_system, + mian_ui, + controller_tool_bar, + chat_window, + ) .run_if(in_state(PlayState::Main)) .after(EguiSet::InitContexts), ); @@ -420,41 +424,34 @@ fn disconnect_on_close( } } -fn chat_window( - mut contexts:EguiContexts, - mut input:ResMut, - - ) { - let ctx=contexts.ctx_mut(); +fn chat_window(mut contexts: EguiContexts, mut input: ResMut) { + let ctx = contexts.ctx_mut(); egui::Window::new("Chat") - .title_bar(false) - .vscroll(true) - .resizable(false) - .frame(egui::Frame::none().fill( egui::Color32::BLACK.gamma_multiply(0.8))) - .default_height(200.0) - .default_width(360.0) - .anchor(egui::Align2::LEFT_BOTTOM, [0.0,0.0]) - .collapsible(false) - .show(ctx, |ui|{ - - egui::CentralPanel::default() - .show_inside(ui, |ui|{ - ui.horizontal(|ui|{ - ui.label("Player"); - ui.label("time"); - ui.colored_label(egui::Color32::RED, "text"); - }); - }); - - egui::TopBottomPanel::bottom("bottom") - .show_inside(ui, |ui|{ - ui.horizontal(|ui|{ - ui.text_edit_singleline(&mut input.input); - - if ui.button("Send").clicked(){ - //todo - }; - }); - }) - }); - } \ No newline at end of file + .title_bar(false) + .vscroll(true) + .resizable(false) + .frame(egui::Frame::none().fill(egui::Color32::BLACK.gamma_multiply(0.8))) + .default_height(200.0) + .default_width(360.0) + .anchor(egui::Align2::LEFT_BOTTOM, [0.0, 0.0]) + .collapsible(false) + .show(ctx, |ui| { + egui::CentralPanel::default().show_inside(ui, |ui| { + ui.horizontal(|ui| { + ui.label("Player"); + ui.label("time"); + ui.colored_label(egui::Color32::RED, "text"); + }); + }); + + egui::TopBottomPanel::bottom("bottom").show_inside(ui, |ui| { + ui.horizontal(|ui| { + ui.text_edit_singleline(&mut input.input); + + if ui.button("Send").clicked() { + //todo + }; + }); + }) + }); +} From d8e7968f51ecb057b6944ae4188f2ad0cded51c9 Mon Sep 17 00:00:00 2001 From: weykon <635883092@qq.com> Date: Fri, 29 Sep 2023 14:39:07 +0800 Subject: [PATCH 4/4] fix: spell mistake. CossTroughCheckPlugin -> CrossTroughCheckPlugin --- src/bin/server.rs | 4 ++-- src/server/cross_through_check.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bin/server.rs b/src/bin/server.rs index 68fdd3f..f3b51c4 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -17,7 +17,7 @@ use just_join::{ connection_config, server::{ async_chunk::ChunkDataPlugin, chunk::ServerChunkPlugin, - cross_through_check::CossTroughCheckPlugin, deal_message_system, + cross_through_check::CrossTroughCheckPlugin, deal_message_system, object_filing::ObjectFilingPlugin, player::ServerLobby, server_connect_system, sp_physics::SpPhysicsPlugin, staff_rule_sync::ServerStaffRulePlugin, sync_body_and_head, terrain_physics::TerrainPhysicsPlugin, @@ -125,7 +125,7 @@ fn main() { ServerSkyPlugins, ObjectFilingPlugin, ServerStaffRulePlugin, - CossTroughCheckPlugin, + CrossTroughCheckPlugin, OtherTreePlugin, VoxelMeshPlugin, SpPhysicsPlugin, diff --git a/src/server/cross_through_check.rs b/src/server/cross_through_check.rs index 9478f9a..ea896ee 100644 --- a/src/server/cross_through_check.rs +++ b/src/server/cross_through_check.rs @@ -20,9 +20,9 @@ pub struct CossTroughCheck; #[derive(Debug, Clone, Copy, Component)] pub struct CossTroughFixed(Vec3); -pub struct CossTroughCheckPlugin; +pub struct CrossTroughCheckPlugin; -impl Plugin for CossTroughCheckPlugin { +impl Plugin for CrossTroughCheckPlugin { fn build(&self, app: &mut bevy::prelude::App) { app.add_systems(PreUpdate, cross_through_check); app.add_systems(Update, cross_through_fixed);