diff --git a/assets/translation.csv b/assets/translation.csv index 8227266..28fb0bf 100644 --- a/assets/translation.csv +++ b/assets/translation.csv @@ -1,16 +1,20 @@ Keyword,Comment,Chinese,English 连接异常,none,连接异常,connection_exception 用户名已存在,none,用户名已存在,Username has exits -开始,none,开始,Start_game +开始,none,开始,Start game 端口,none,端口,Port 服务器,none,服务器,Server 多人游戏,none,多人游戏,Mutiplayer -进入服务器,none,进入服务器,Enter_Server +进入服务器,none,进入服务器,Enter Server 昵称,none,昵称,Nickname 返回,none,返回,Back -设置,none,设置,setting +设置,none,设置,Setting 退出,none,退出,Exit -关于,none,关于,about +关于,none,关于,Sbout 合成列表,none,合成列表,Craft 切换英语,none,切换英语,English -切换中文,none,切换中文,Chinese \ No newline at end of file +切换中文,none,切换中文,Chinese +依赖,none,依赖,Base on +规则,none,规则,Formula +输出,none,输出,Output +操作,none,操作,Actions \ No newline at end of file diff --git a/src/client/state_manager/game.rs b/src/client/state_manager/game.rs index 14a7737..c73be8c 100644 --- a/src/client/state_manager/game.rs +++ b/src/client/state_manager/game.rs @@ -10,6 +10,7 @@ use bevy::{ }, window::{CursorGrabMode, PrimaryWindow, Window, WindowCloseRequested}, }; +use bevy_easy_localize::Localize; use bevy_egui::{ egui::{self, epaint::Shadow, Color32}, EguiContext, EguiContexts, EguiSet, EguiUserTextures, @@ -211,6 +212,7 @@ fn panic_on_error_system(mut renet_error: EventReader) { } fn client_do_disconnected( + localize: Res, client: Res, mut play_state: ResMut>, mut game_state: ResMut>, @@ -225,7 +227,7 @@ fn client_do_disconnected( } notification .toasts - .error(message) + .error(localize.get(message)) .set_duration(Some(Duration::from_secs(5))); play_state.set(PlayState::Disabled); game_state.set(GameState::Menu); diff --git a/src/client/state_manager/menu.rs b/src/client/state_manager/menu.rs index 26566c7..ea65dd1 100644 --- a/src/client/state_manager/menu.rs +++ b/src/client/state_manager/menu.rs @@ -10,8 +10,8 @@ use bevy_easy_localize::Localize; use bevy_egui::{egui, EguiContext, EguiContexts, EguiUserTextures}; use std::time::Duration; -use super::{ENGLISH, CHINESE}; use super::{notification::Notification, ConnectionAddr, GameState}; +use super::{CHINESE, ENGLISH}; use crate::{ client::{ player::controller::back_grab_cursor, @@ -31,6 +31,7 @@ use crate::{ pub enum MenuState { Main, Test, + Settings, Multiplayer, #[default] Disabled, @@ -46,6 +47,7 @@ impl Plugin for MenuPlugin { app.add_systems(OnEnter(GameState::Menu), (setup, back_grab_cursor)); app.add_systems(Update, menu_main.run_if(in_state(MenuState::Main))); app.add_systems(Update, test.run_if(in_state(MenuState::Test))); + app.add_systems(Update, menu_settings.run_if(in_state(MenuState::Settings))); app.add_systems( Update, menu_multiplayer.run_if(in_state(MenuState::Multiplayer)), @@ -58,10 +60,30 @@ impl Plugin for MenuPlugin { } } -fn menu_multiplayer( +fn menu_settings( mut localize: ResMut, mut contexts: EguiContexts, mut menu_state: ResMut>, +) { + egui::CentralPanel::default().show(contexts.ctx_mut(), |ui| { + ui.heading(localize.get("设置")); + if ui.button(localize.get("切换英语")).clicked() { + localize.set_language(ENGLISH); + } + if ui.button(localize.get("切换中文")).clicked() { + localize.set_language(CHINESE); + } + if ui.button(localize.get("返回")).clicked() { + // 状态转移到 多人游戏的设置 + menu_state.set(MenuState::Main); + } + }); +} + +fn menu_multiplayer( + localize: Res, + mut contexts: EguiContexts, + mut menu_state: ResMut>, mut connection_addr: ResMut, mut notification: ResMut, mut game_state: ResMut>, @@ -77,12 +99,6 @@ fn menu_multiplayer( ui.label(localize.get("昵称")); ui.text_edit_singleline(&mut connection_addr.nickname); - if ui.button(localize.get("切换英语")).clicked() { - localize.set_language(ENGLISH); - } - if ui.button(localize.get("切换中文")).clicked() { - localize.set_language(CHINESE); - } if ui.button(localize.get("开始")).clicked() { // 这开始游戏相关数据 if connection_addr.server.is_empty() { @@ -139,6 +155,7 @@ fn menu_main( } if ui.button(localize.get("设置")).clicked() { // 转到设计游戏的地方 + menu_state.set(MenuState::Settings); } if ui.button(localize.get("退出")).clicked() { // 退出游戏 diff --git a/src/client/ui/staff_rules.rs b/src/client/ui/staff_rules.rs index 0159b49..7e716d1 100644 --- a/src/client/ui/staff_rules.rs +++ b/src/client/ui/staff_rules.rs @@ -70,16 +70,16 @@ pub fn staff_rules_ui( table .header(20.0, |mut header| { header.col(|ui| { - ui.strong("Base On"); + ui.strong(localize.get("依赖")); }); header.col(|ui| { - ui.strong("Rule"); + ui.strong(localize.get("规则")); }); header.col(|ui| { - ui.strong("Output"); + ui.strong(localize.get("输出")); }); header.col(|ui| { - ui.strong("Action"); + ui.strong(localize.get("操作")); }); }) .body(|mut body| { diff --git a/src/lib.rs b/src/lib.rs index 73f307f..1439e6f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,7 +33,7 @@ pub const TOUCH_RADIUS: f32 = 5.; pub const CLIENT_DEBUG: bool = false; pub const CLIENT_FPS: bool = false; // 是否每次都重新生成地形 -pub const CLIENT_MAP_GEN: bool = true; +pub const CLIENT_MAP_GEN: bool = false; // 最大物品堆放 pub const MAX_STAFF_FIXED: usize = 999;