Skip to content

Commit

Permalink
Merge #486
Browse files Browse the repository at this point in the history
486: Fix Editor Not Displaying Map Elements r=zicklag a=zicklag

bors r+

Co-authored-by: Zicklag <zicklag@katharostech.com>
  • Loading branch information
bors[bot] and zicklag committed Nov 23, 2022
2 parents 4cc8d0c + f28aff2 commit e530274
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ pub struct EngineConfig {
#[arg(short = 'R', long)]
pub hot_reload: bool,

/// Sets the sync test distance during local play.
///
/// This is useful for developers for testing game rollback determinism without having to start
/// a network game.
#[arg(short = 'C', long, default_value = "0")]
pub sync_test_check_distance: usize,

/// The directory to load assets from
#[arg(short, long, env = ASSET_DIR_ENV_VAR)]
pub asset_dir: Option<String>,
Expand Down
5 changes: 2 additions & 3 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use bevy_ggrs::{
use jumpy_matchmaker_proto::TargetClient;

use crate::{
config::ENGINE_CONFIG,
networking::{client::NetClient, proto::ClientMatchInfo},
player,
prelude::*,
Expand Down Expand Up @@ -103,9 +104,7 @@ impl<'w, 's> SessionManager<'w, 's> {
builder = builder
.with_input_delay(INPUT_DELAY)
.with_num_players(player::MAX_PLAYERS)
// TODO: Add some flag to enable the non-zero check distance, instead of wasting
// processing power for local games.
.with_check_distance(7);
.with_check_distance(ENGINE_CONFIG.sync_test_check_distance);

for i in 0..player::MAX_PLAYERS {
builder = builder.add_player(ggrs::PlayerType::Local, i).unwrap();
Expand Down
5 changes: 5 additions & 0 deletions src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::{
metadata::{GameMeta, MapLayerKind, MapLayerMeta, MapMeta},
player::input::PlayerInputs,
prelude::*,
session::SessionManager,
utils::ResetManager,
};

Expand Down Expand Up @@ -154,6 +155,7 @@ struct EditorTopBar<'w, 's> {
map_meta: Query<'w, 's, &'static MapMeta>,
map_handle: Query<'w, 's, &'static AssetHandle<MapMeta>>,
settings: ResMut<'w, EditorState>,
session_manager: SessionManager<'w, 's>,
}

impl<'w, 's> WidgetSystem for EditorTopBar<'w, 's> {
Expand Down Expand Up @@ -248,6 +250,7 @@ impl<'w, 's> WidgetSystem for EditorTopBar<'w, 's> {
.spawn()
.insert(handle)
.insert(Rollback::new(params.rids.next_id()));
params.session_manager.start_session();
}
}
});
Expand Down Expand Up @@ -668,6 +671,7 @@ struct EditorCentralPanel<'w, 's> {
With<EditorCamera>,
>,
localization: Res<'w, Localization>,
session_manager: SessionManager<'w, 's>,
}

struct MapCreateInfo {
Expand Down Expand Up @@ -827,6 +831,7 @@ fn map_open_dialog(ui: &mut egui::Ui, params: &mut EditorCentralPanel) {
) {
if ui.button(&map_name).clicked() {
params.commands.spawn().insert(map_handle);
params.session_manager.start_session();
*params.show_map_open = false;
}
}
Expand Down

0 comments on commit e530274

Please sign in to comment.