fix UI issues & cleanup

This commit is contained in:
Maxicarlos08 2023-09-29 23:28:29 +02:00
parent 66f6b81575
commit 9ababec625
No known key found for this signature in database
16 changed files with 45 additions and 48 deletions

View File

@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Portals that spawn in place of the last staircase at old style dungeons to prevent stair cheesing - Portals that spawn in place of the last staircase at old style dungeons to prevent stair cheesing
- Mutliple singleplayer worlds and map generation UI. - Mutliple singleplayer worlds and map generation UI.
- New arena building in desert cities, suitable for PVP, also NPCs like to watch the fights too - New arena building in desert cities, suitable for PVP, also NPCs like to watch the fights too
- The loading screen now displays status updates for singleplayer server and client initialization progress
### Changed ### Changed

1
Cargo.lock generated
View File

@ -6785,7 +6785,6 @@ dependencies = [
"authc", "authc",
"byteorder", "byteorder",
"clap", "clap",
"crossbeam-channel",
"hashbrown 0.13.2", "hashbrown 0.13.2",
"image", "image",
"num 0.4.1", "num 0.4.1",

View File

@ -61,18 +61,18 @@ hud-sit = Sit
hud-steer = Steer hud-steer = Steer
hud-portal = Portal hud-portal = Portal
hud-init-stage-singleplayer = Starting singleplayer server... hud-init-stage-singleplayer = Starting singleplayer server...
hud-init-stage-server-db-migrations = [{ common-server }]: Applying database migrations hud-init-stage-server-db-migrations = [{ common-server }]: Applying database migrations...
hud-init-stage-server-db-vacuum = [{ common-server }]: Cleaning up database hud-init-stage-server-db-vacuum = [{ common-server }]: Cleaning up database...
hud-init-stage-server-worldsim-erosion = [{ common-server }]: Erosion { $percentage }% hud-init-stage-server-worldsim-erosion = [{ common-server }]: Erosion { $percentage }%
hud-init-stage-server-worldciv-civcreate = [{ common-server }]: Generated { $generated } out of { $total } civilizations hud-init-stage-server-worldciv-civcreate = [{ common-server }]: Generated { $generated } out of { $total } civilizations
hud-init-stage-server-worldciv-site = [{ common-server }]: Generating sites hud-init-stage-server-worldciv-site = [{ common-server }]: Generating sites...
hud-init-stage-server-economysim = [{ common-server }]: Simulating economy hud-init-stage-server-economysim = [{ common-server }]: Simulating economy...
hud-init-stage-server-spotgen = [{ common-server }]: Generating spots hud-init-stage-server-spotgen = [{ common-server }]: Generating spots...
hud-init-stage-server-starting = [{ common-server }]: Starting server... hud-init-stage-server-starting = [{ common-server }]: Starting server...
hud-init-stage-multiplayer = Starting multiplayer hud-init-stage-multiplayer = Starting multiplayer
hud-init-stage-client-connection-establish = [{ common-client }]: Establishing connection to server hud-init-stage-client-connection-establish = [{ common-client }]: Establishing connection to server...
hud-init-stage-client-request-server-version = [{ common-client }]: Wating for server version hud-init-stage-client-request-server-version = [{ common-client }]: Waiting for server version...
hud-init-stage-client-authentication = [{ common-client }]: Authenticating hud-init-stage-client-authentication = [{ common-client }]: Authenticating...
hud-init-stage-client-load-init-data = [{ common-client }]: Loading initialization data from server hud-init-stage-client-load-init-data = [{ common-client }]: Loading initialization data from server...
hud-init-stage-client-starting-client = [{ common-client }]: Preparing Client... hud-init-stage-client-starting-client = [{ common-client }]: Preparing Client...
hud-init-stage-render-pipeline = Creating render pipeline ({ $done }/{ $total }) hud-init-stage-render-pipeline = Creating render pipeline ({ $done }/{ $total })

View File

@ -30,7 +30,6 @@ tracing = { workspace = true }
rayon = { workspace = true } rayon = { workspace = true }
specs = { workspace = true, features = ["serde", "storage-event-control", "derive"] } specs = { workspace = true, features = ["serde", "storage-event-control", "derive"] }
vek = { workspace = true } vek = { workspace = true }
crossbeam-channel = { workspace = true }
hashbrown = { workspace = true } hashbrown = { workspace = true }
authc = { git = "https://gitlab.com/veloren/auth.git", rev = "abb1a705827984e11706d7bb97fb7a459e1e6533" } # xMAC94x/current_master_till_refactored branch authc = { git = "https://gitlab.com/veloren/auth.git", rev = "abb1a705827984e11706d7bb97fb7a459e1e6533" } # xMAC94x/current_master_till_refactored branch

View File

@ -72,6 +72,7 @@ pub fn make_client(
username, username,
password, password,
|_| true, |_| true,
Arc::new(|_| {})
)) ))
.ok() .ok()
} }

View File

@ -66,7 +66,6 @@ use common_net::{
use common_state::State; use common_state::State;
use common_systems::add_local_systems; use common_systems::add_local_systems;
use comp::BuffKind; use comp::BuffKind;
use crossbeam_channel::Sender;
use hashbrown::{HashMap, HashSet}; use hashbrown::{HashMap, HashSet};
use image::DynamicImage; use image::DynamicImage;
use network::{ConnectAddr, Network, Participant, Pid, Stream}; use network::{ConnectAddr, Network, Participant, Pid, Stream};
@ -307,17 +306,11 @@ impl Client {
username: &str, username: &str,
password: &str, password: &str,
auth_trusted: impl FnMut(&str) -> bool, auth_trusted: impl FnMut(&str) -> bool,
init_stage_update: Option<Sender<ClientInitStage>>, init_stage_update: Arc<dyn Fn(ClientInitStage) + Send + Sync>,
) -> Result<Self, Error> { ) -> Result<Self, Error> {
let update_stage = |stage: ClientInitStage| {
if let Some(updater) = &init_stage_update {
let _ = updater.send(stage);
}
};
let network = Network::new(Pid::new(), &runtime); let network = Network::new(Pid::new(), &runtime);
update_stage(ClientInitStage::ConnectionEstablish); init_stage_update(ClientInitStage::ConnectionEstablish);
let mut participant = match addr { let mut participant = match addr {
ConnectionArgs::Tcp { ConnectionArgs::Tcp {
hostname, hostname,
@ -347,7 +340,7 @@ impl Client {
let in_game_stream = participant.opened().await?; let in_game_stream = participant.opened().await?;
let terrain_stream = participant.opened().await?; let terrain_stream = participant.opened().await?;
update_stage(ClientInitStage::WatingForServerVersion); init_stage_update(ClientInitStage::WatingForServerVersion);
register_stream.send(ClientType::Game)?; register_stream.send(ClientType::Game)?;
let server_info: ServerInfo = register_stream.recv().await?; let server_info: ServerInfo = register_stream.recv().await?;
if server_info.git_hash != *common::util::GIT_HASH { if server_info.git_hash != *common::util::GIT_HASH {
@ -366,7 +359,7 @@ impl Client {
ping_stream.send(PingMsg::Ping)?; ping_stream.send(PingMsg::Ping)?;
update_stage(ClientInitStage::Authentication); init_stage_update(ClientInitStage::Authentication);
// Register client // Register client
Self::register( Self::register(
username, username,
@ -377,7 +370,7 @@ impl Client {
) )
.await?; .await?;
update_stage(ClientInitStage::LoadingInitData); init_stage_update(ClientInitStage::LoadingInitData);
// Wait for initial sync // Wait for initial sync
let mut ping_interval = tokio::time::interval(Duration::from_secs(1)); let mut ping_interval = tokio::time::interval(Duration::from_secs(1));
let ServerInit::GameSync { let ServerInit::GameSync {
@ -401,7 +394,7 @@ impl Client {
} }
}; };
update_stage(ClientInitStage::StartingClient); init_stage_update(ClientInitStage::StartingClient);
// Spawn in a blocking thread (leaving the network thread free). This is mostly // Spawn in a blocking thread (leaving the network thread free). This is mostly
// useful for bots. // useful for bots.
let mut task = tokio::task::spawn_blocking(move || { let mut task = tokio::task::spawn_blocking(move || {
@ -3007,7 +3000,7 @@ mod tests {
username, username,
password, password,
|suggestion: &str| suggestion == auth_server, |suggestion: &str| suggestion == auth_server,
None, Arc::new(|_| {}),
)); ));
let localisation = LocalizationHandle::load_expect("en"); let localisation = LocalizationHandle::load_expect("en");

View File

@ -192,7 +192,7 @@ fn main() -> io::Result<()> {
editable_settings, editable_settings,
database_settings, database_settings,
&server_data_dir, &server_data_dir,
None, Arc::new(|_| {}),
runtime, runtime,
) )
.expect("Failed to create server instance!"); .expect("Failed to create server instance!");

View File

@ -118,7 +118,6 @@ use crate::{
persistence::{DatabaseSettings, SqlLogMode}, persistence::{DatabaseSettings, SqlLogMode},
sys::terrain, sys::terrain,
}; };
use crossbeam_channel::Sender;
use hashbrown::HashMap; use hashbrown::HashMap;
use std::sync::RwLock; use std::sync::RwLock;
@ -200,6 +199,7 @@ pub struct ChunkRequest {
key: Vec2<i32>, key: Vec2<i32>,
} }
#[derive(Debug)]
pub enum ServerInitStage { pub enum ServerInitStage {
DbMigrations, DbMigrations,
DbVacuum, DbVacuum,
@ -230,7 +230,7 @@ impl Server {
editable_settings: EditableSettings, editable_settings: EditableSettings,
database_settings: DatabaseSettings, database_settings: DatabaseSettings,
data_dir: &std::path::Path, data_dir: &std::path::Path,
stage_report_tx: Option<Sender<ServerInitStage>>, report_stage: Arc<dyn Fn(ServerInitStage) + Send + Sync>,
runtime: Arc<Runtime>, runtime: Arc<Runtime>,
) -> Result<Self, Error> { ) -> Result<Self, Error> {
prof_span!("Server::new"); prof_span!("Server::new");
@ -239,12 +239,6 @@ impl Server {
info!("Authentication is disabled"); info!("Authentication is disabled");
} }
let report_stage = |stage: ServerInitStage| {
if let Some(stage_report_tx) = &stage_report_tx {
let _ = stage_report_tx.send(stage);
}
};
report_stage(ServerInitStage::DbMigrations); report_stage(ServerInitStage::DbMigrations);
// Run pending DB migrations (if any) // Run pending DB migrations (if any)
debug!("Running DB migrations..."); debug!("Running DB migrations...");
@ -271,7 +265,6 @@ impl Server {
let pools = State::pools(GameMode::Server); let pools = State::pools(GameMode::Server);
let world_generate_status_tx = stage_report_tx.clone();
#[cfg(feature = "worldgen")] #[cfg(feature = "worldgen")]
let (world, index) = World::generate( let (world, index) = World::generate(
settings.world_seed, settings.world_seed,
@ -286,11 +279,12 @@ impl Server {
calendar: Some(settings.calendar_mode.calendar_now()), calendar: Some(settings.calendar_mode.calendar_now()),
}, },
&pools, &pools,
{
let report_stage = Arc::clone(&report_stage);
Arc::new(move |stage| { Arc::new(move |stage| {
if let Some(stage_report_tx) = &world_generate_status_tx { report_stage(ServerInitStage::WorldGen(stage));
let _ = stage_report_tx.send(ServerInitStage::WorldGen(stage)); })
} },
}),
); );
#[cfg(not(feature = "worldgen"))] #[cfg(not(feature = "worldgen"))]
let (world, index) = World::generate(settings.world_seed); let (world, index) = World::generate(settings.world_seed);

View File

@ -52,7 +52,7 @@ impl ClientInit {
) -> Self { ) -> Self {
let (tx, rx) = unbounded(); let (tx, rx) = unbounded();
let (trust_tx, trust_rx) = unbounded(); let (trust_tx, trust_rx) = unbounded();
let (init_stage_tx, init_stare_rx) = unbounded(); let (init_stage_tx, init_stage_rx) = unbounded();
let cancel = Arc::new(AtomicBool::new(false)); let cancel = Arc::new(AtomicBool::new(false));
let cancel2 = Arc::clone(&cancel); let cancel2 = Arc::clone(&cancel);
@ -69,13 +69,17 @@ impl ClientInit {
let mut last_err = None; let mut last_err = None;
let client_stage_reporter: Arc<dyn Fn(ClientInitStage) + Send + Sync> =
Arc::new(move |stage| {
let _ = init_stage_tx.send(stage);
});
const FOUR_MINUTES_RETRIES: u64 = 48; const FOUR_MINUTES_RETRIES: u64 = 48;
'tries: for _ in 0..FOUR_MINUTES_RETRIES { 'tries: for _ in 0..FOUR_MINUTES_RETRIES {
if cancel2.load(Ordering::Relaxed) { if cancel2.load(Ordering::Relaxed) {
break; break;
} }
let mut mismatched_server_info = None; let mut mismatched_server_info = None;
let new_init_tx = init_stage_tx.clone();
match Client::new( match Client::new(
connection_args.clone(), connection_args.clone(),
Arc::clone(&runtime2), Arc::clone(&runtime2),
@ -83,7 +87,7 @@ impl ClientInit {
&username, &username,
&password, &password,
trust_fn, trust_fn,
Some(new_init_tx), Arc::clone(&client_stage_reporter),
) )
.await .await
{ {
@ -120,7 +124,7 @@ impl ClientInit {
ClientInit { ClientInit {
rx, rx,
stage_rx: init_stare_rx, stage_rx: init_stage_rx,
trust_tx, trust_tx,
cancel, cancel,
} }

View File

@ -27,8 +27,8 @@ use tokio::runtime;
use tracing::error; use tracing::error;
use ui::{Event as MainMenuEvent, MainMenuUi}; use ui::{Event as MainMenuEvent, MainMenuUi};
#[derive(Debug)]
pub enum DetailedInitializationStage { pub enum DetailedInitializationStage {
// TODO: Map generation and server startup progress
Singleplayer, Singleplayer,
SingleplayerServer(ServerInitStage), SingleplayerServer(ServerInitStage),
StartingMultiplayer, StartingMultiplayer,

View File

@ -206,11 +206,11 @@ impl Screen {
), ),
}; };
Container::new(Text::new(stage_message).size(fonts.cyri.scale(25))) Container::new(Text::new(stage_message).size(fonts.cyri.scale(20)))
.width(Length::Fill) .width(Length::Fill)
.height(Length::Fill) .height(Length::Fill)
.padding(10) .padding(10)
.align_y(Align::End) .align_x(Align::Start)
.into() .into()
}; };

View File

@ -728,6 +728,7 @@ impl MainMenuUi {
pub fn show_info(&mut self, msg: String) { self.controls.connection_error(msg); } pub fn show_info(&mut self, msg: String) { self.controls.connection_error(msg); }
pub fn update_stage(&mut self, stage: DetailedInitializationStage) { pub fn update_stage(&mut self, stage: DetailedInitializationStage) {
tracing::trace!(?stage, "Updating stage");
self.controls.init_stage(stage); self.controls.init_stage(stage);
} }

View File

@ -122,7 +122,9 @@ impl SingleplayerState {
editable_settings, editable_settings,
database_settings, database_settings,
&server_data_dir, &server_data_dir,
Some(server_stage_tx), Arc::new(move |init_stage| {
let _ = server_stage_tx.send(init_stage);
}),
runtime, runtime,
) { ) {
Ok(server) => (Some(server), Ok(())), Ok(server) => (Some(server), Ok(())),

View File

@ -224,6 +224,7 @@ impl<'a, R: Rng> GenCtx<'a, R> {
} }
} }
#[derive(Debug)]
pub enum WorldCivStage { pub enum WorldCivStage {
/// Civilization creation, how many out of how many civilizations have been /// Civilization creation, how many out of how many civilizations have been
/// generated yet /// generated yet

View File

@ -87,6 +87,7 @@ pub enum Error {
Other(String), Other(String),
} }
#[derive(Debug)]
pub enum WorldGenerateStage { pub enum WorldGenerateStage {
WorldSimGenerate(WorldSimStage), WorldSimGenerate(WorldSimStage),
WorldCivGenerate(WorldCivStage), WorldCivGenerate(WorldCivStage),

View File

@ -646,6 +646,7 @@ impl WorldFile {
} }
} }
#[derive(Debug)]
pub enum WorldSimStage { pub enum WorldSimStage {
// TODO: Add more stages // TODO: Add more stages
Erosion(f64), Erosion(f64),