diff --git a/noita-proxy/assets/lang/en-US/main.ftl b/noita-proxy/assets/lang/en-US/main.ftl index 82f211b9..bcdf65bb 100644 --- a/noita-proxy/assets/lang/en-US/main.ftl +++ b/noita-proxy/assets/lang/en-US/main.ftl @@ -13,6 +13,7 @@ connect_settings_debug_en = Debug/cheat mode connect_settings_debug_fixed_seed = Use fixed seed connect_settings_seed = Seed: connect_settings_wsv = World sync version to use: +connect_settings_player_tether = Player tether lang_picker = Choose a language diff --git a/noita-proxy/assets/lang/ru-RU/main.ftl b/noita-proxy/assets/lang/ru-RU/main.ftl index 1008ebc9..954dc068 100644 --- a/noita-proxy/assets/lang/ru-RU/main.ftl +++ b/noita-proxy/assets/lang/ru-RU/main.ftl @@ -11,6 +11,7 @@ connect_settings_debug_en = Подрубить читы connect_settings_debug_fixed_seed = Фиксированный сид мира connect_settings_seed = Сид: connect_settings_wsv = Версия синхронизатора мира: +connect_settings_player_tether = Предел расстояния до хоста lang_picker = Выберите язык diff --git a/noita-proxy/src/lib.rs b/noita-proxy/src/lib.rs index bcdfd3c5..d7d28c75 100644 --- a/noita-proxy/src/lib.rs +++ b/noita-proxy/src/lib.rs @@ -29,11 +29,23 @@ pub mod releases; mod self_update; pub mod steam_helper; -#[derive(Debug, Decode, Encode, Clone)] +#[derive(Debug, Decode, Encode, Clone, Serialize, Deserialize)] pub struct GameSettings { seed: u64, debug_mode: bool, world_sync_version: u32, + player_tether: bool, +} + +impl Default for GameSettings { + fn default() -> Self { + GameSettings { + seed: 0, + debug_mode: false, + world_sync_version: 2, + player_tether: false, + } + } } enum AppState { @@ -48,26 +60,24 @@ enum AppState { #[derive(Debug, Serialize, Deserialize)] struct AppSavedState { addr: String, - debug_mode: bool, use_constant_seed: bool, nickname: Option, times_started: u32, - world_sync_version: u32, lang_id: Option, constant_seed: u64, + game_settings: GameSettings, } impl Default for AppSavedState { fn default() -> Self { Self { addr: "127.0.0.1:5123".to_string(), - debug_mode: false, use_constant_seed: false, nickname: None, times_started: 0, - world_sync_version: 2, lang_id: None, constant_seed: 0, + game_settings: GameSettings::default(), } } } @@ -163,8 +173,7 @@ impl App { fn set_netman_settings(&mut self, netman: &Arc) { let mut settings = netman.settings.lock().unwrap(); - settings.debug_mode = self.saved_state.debug_mode; - settings.world_sync_version = self.saved_state.world_sync_version; + *settings = self.saved_state.game_settings.clone(); if !self.saved_state.use_constant_seed { settings.seed = rand::random(); } else { @@ -273,7 +282,7 @@ impl App { ui.label(tr("connect_settings_debug")); ui.checkbox( - &mut self.saved_state.debug_mode, + &mut self.saved_state.game_settings.debug_mode, tr("connect_settings_debug_en"), ); ui.checkbox( @@ -290,9 +299,22 @@ impl App { ui.label(tr("connect_settings_wsv")); ui.horizontal(|ui| { - ui.radio_value(&mut self.saved_state.world_sync_version, 1, "v1"); - ui.radio_value(&mut self.saved_state.world_sync_version, 2, "v2"); + ui.radio_value( + &mut self.saved_state.game_settings.world_sync_version, + 1, + "v1", + ); + ui.radio_value( + &mut self.saved_state.game_settings.world_sync_version, + 2, + "v2", + ); }); + + ui.checkbox( + &mut self.saved_state.game_settings.player_tether, + tr("connect_settings_player_tether"), + ) }); }); ui.allocate_ui_at_rect(steam_connect_rect.shrink(group_shrink), |ui| { diff --git a/noita-proxy/src/net.rs b/noita-proxy/src/net.rs index 6c84f150..90314826 100644 --- a/noita-proxy/src/net.rs +++ b/noita-proxy/src/net.rs @@ -91,12 +91,7 @@ impl NetManager { pub fn new(peer: omni::PeerVariant, init: NetManagerInit) -> Arc { Self { peer, - settings: Mutex::new(GameSettings { - // seed: 1663107061, - seed: 1663107066, - debug_mode: false, - world_sync_version: 1, - }), + settings: Mutex::new(GameSettings::default()), continue_running: AtomicBool::new(true), accept_local: AtomicBool::new(false), local_connected: AtomicBool::new(false), @@ -291,6 +286,7 @@ impl NetManager { "world_sync_version", settings.world_sync_version, )); + state.try_ws_write(ws_encode_proxy_opt("player_tether", settings.player_tether)); state.try_ws_write(ws_encode_proxy("ready", "")); // TODO? those are currently ignored by mod