From 1d55e534c106e898bf7a6f9cb3a43ddb042fe433 Mon Sep 17 00:00:00 2001 From: "NG (Graham)" Date: Tue, 14 Apr 2026 22:01:05 -0400 Subject: [PATCH] Make rest of client platform flags configurage; fix speedometer confusing Americans --- rc_core/src/persist/client_config.rs | 36 +++++++++++++++++++ rc_core/src/persist/config/cubes_json.rs | 13 +++++++ rc_core/src/persist/config/mod.rs | 2 +- rc_core/src/persist/config/traits.rs | 11 ++++++ rc_core/src/persist/mod.rs | 2 +- rc_core/src/persist/settings.rs | 1 + .../src/operations/platform_config.rs | 16 +++++---- 7 files changed, 72 insertions(+), 9 deletions(-) diff --git a/rc_core/src/persist/client_config.rs b/rc_core/src/persist/client_config.rs index d2ceeaa..392301c 100644 --- a/rc_core/src/persist/client_config.rs +++ b/rc_core/src/persist/client_config.rs @@ -13,6 +13,8 @@ pub struct GameplaySettings { pub cross_promo_image: String, // url pub cross_promo_link: String, // url pub garages_limit: i32, + #[serde(default = "default_platform_conf", flatten)] + pub platform: PlatformSettings, } impl std::convert::From for crate::data::client_config::GameplaySettings { @@ -31,3 +33,37 @@ impl std::convert::From for crate::data::client_config::Gamepl } } } + +fn default_true() -> bool { + true +} + +#[derive(Serialize, Deserialize, Clone, Debug)] +pub struct PlatformSettings { + #[serde(default)] + pub can_buy_premium: bool, + #[serde(default = "default_true")] + pub can_shop: bool, + #[serde(default)] + pub can_pass: bool, + #[serde(default = "default_true")] + pub can_select_language: bool, + #[serde(default)] + pub can_voice: bool, + #[serde(default)] + pub can_analytics: bool, + #[serde(default = "default_true")] + pub can_si: bool, +} + +pub(super) fn default_platform_conf() -> PlatformSettings { + PlatformSettings { + can_buy_premium: false, + can_shop: true, + can_pass: false, + can_select_language: true, + can_voice: false, + can_analytics: false, + can_si: true, + } +} diff --git a/rc_core/src/persist/config/cubes_json.rs b/rc_core/src/persist/config/cubes_json.rs index bf1db79..ef4e423 100644 --- a/rc_core/src/persist/config/cubes_json.rs +++ b/rc_core/src/persist/config/cubes_json.rs @@ -277,6 +277,19 @@ impl super::ConfigProvider for CubeConfig { }) } + fn platform(&self) -> super::PlatformConfig { + super::PlatformConfig { + enable_buy_premium: self.settings.gameplay.platform.can_buy_premium, + enable_shop: self.settings.gameplay.platform.can_shop, + enable_robopass: self.settings.gameplay.platform.can_pass, + enable_select_language: self.settings.gameplay.platform.can_select_language, + enable_voice: self.settings.gameplay.platform.can_voice, + enable_analytics: self.settings.gameplay.platform.can_analytics, + enable_standard_units: self.settings.gameplay.platform.can_si, + } + + } + fn login_messages(&self) -> super::DevMessageProvider { super::DevMessageProvider::new(self.settings.banners.iter().map(|msg| (msg.message.clone(), msg.duration as i32)).collect()) } diff --git a/rc_core/src/persist/config/mod.rs b/rc_core/src/persist/config/mod.rs index ff7168c..a40dd52 100644 --- a/rc_core/src/persist/config/mod.rs +++ b/rc_core/src/persist/config/mod.rs @@ -2,7 +2,7 @@ mod cubes_json; pub use cubes_json::CubeConfig; mod traits; -pub use traits::{ConfigProvider, DevMessageProvider, ServerConfig, GarageUpgrades, GarageUpgradeIncrement, ChatSystemConfig, GameEventSequence, GameEvents, GameRotationStrategy, GameEvent, GameMap, GameVisibility, GameType, SingleplayerConfig, VehicleInfo, VehicleDescriptor, QueueChangeMode, Point, Sphere, MapConfig, LinksConfig, FakePlayer, ClientEmulator, EnergyConfig, BattleArenaResolver, PitSettings, PitWinCondition, TeamDeathMatchSettings, ShopEntriesResolver, ShopAction, ShopGain, PromoCode, MultiplayerSettings, BattleArenaCrystalParams, VehicleValidators, TeamChoosers, FactoryConfig}; +pub use traits::{ConfigProvider, DevMessageProvider, ServerConfig, GarageUpgrades, GarageUpgradeIncrement, ChatSystemConfig, GameEventSequence, GameEvents, GameRotationStrategy, GameEvent, GameMap, GameVisibility, GameType, SingleplayerConfig, VehicleInfo, VehicleDescriptor, QueueChangeMode, Point, Sphere, MapConfig, LinksConfig, FakePlayer, ClientEmulator, EnergyConfig, BattleArenaResolver, PitSettings, PitWinCondition, TeamDeathMatchSettings, ShopEntriesResolver, ShopAction, ShopGain, PromoCode, MultiplayerSettings, BattleArenaCrystalParams, VehicleValidators, TeamChoosers, FactoryConfig, PlatformConfig}; mod validation; pub use validation::{SelfValidator, ValidationInfo, ValidationMessage}; diff --git a/rc_core/src/persist/config/traits.rs b/rc_core/src/persist/config/traits.rs index ea2420b..b4ccd45 100644 --- a/rc_core/src/persist/config/traits.rs +++ b/rc_core/src/persist/config/traits.rs @@ -16,6 +16,7 @@ pub trait ConfigProvider { fn campaign_details(&self) -> super::CompleteCampaignProvider; fn campaigns(&self) -> super::CampaignResolver; fn client_config(&self) -> Typed; + fn platform(&self) -> PlatformConfig; fn login_messages(&self) -> DevMessageProvider; fn public_channels(&self) -> Typed; fn server_config(&self) -> ServerConfig; @@ -561,3 +562,13 @@ pub struct TeamChoosers { pub pit: crate::persist::TeamChooser, pub team_deathmatch: crate::persist::TeamChooser, } + +pub struct PlatformConfig { + pub enable_buy_premium: bool, + pub enable_shop: bool, + pub enable_robopass: bool, + pub enable_select_language: bool, + pub enable_voice: bool, + pub enable_analytics: bool, + pub enable_standard_units: bool, +} diff --git a/rc_core/src/persist/mod.rs b/rc_core/src/persist/mod.rs index 1b934b9..04cd70b 100644 --- a/rc_core/src/persist/mod.rs +++ b/rc_core/src/persist/mod.rs @@ -24,7 +24,7 @@ mod singleplayer; pub use singleplayer::{SingleplayerConfig, Campaign, CampaignDifficulty, CampaignCompletion, CampaignType, Wave, WaveRobot}; mod client_config; -pub use client_config::GameplaySettings; +pub use client_config::{GameplaySettings, PlatformSettings}; mod settings; pub use settings::{Settings, QueueMode}; diff --git a/rc_core/src/persist/settings.rs b/rc_core/src/persist/settings.rs index 5361489..e5383a5 100644 --- a/rc_core/src/persist/settings.rs +++ b/rc_core/src/persist/settings.rs @@ -33,6 +33,7 @@ fn default_gameplay_settings() -> super::GameplaySettings { cross_promo_image: "https://git.ngram.ca/OpenJam/rc-servers/raw/branch/main/assets/robocraft/default.png".to_owned(), cross_promo_link: "https://git.ngram.ca/OpenJam/rc-servers".to_owned(), garages_limit: 100, + platform: super::client_config::default_platform_conf(), } } diff --git a/rc_services_room/src/operations/platform_config.rs b/rc_services_room/src/operations/platform_config.rs index 0522d98..1cc48dc 100644 --- a/rc_services_room/src/operations/platform_config.rs +++ b/rc_services_room/src/operations/platform_config.rs @@ -9,12 +9,14 @@ pub(super) fn platform_config_provider(conf: &oj_rc_core::Con SimpleOpImpl::new(PlatformConfigProvider { chat_config: >::chat_system_config(conf), links: >::url_links(conf), + platform_config: >::platform(conf), }) } pub(super) struct PlatformConfigProvider { chat_config: oj_rc_core::persist::config::ChatSystemConfig, links: oj_rc_core::persist::config::LinksConfig, + platform_config: oj_rc_core::persist::config::PlatformConfig, } #[async_trait::async_trait] @@ -35,15 +37,15 @@ impl SimpleOperation for PlatformConfigProvider { key_ty: TypePrefix::Any, // obj val_ty: TypePrefix::Any, // obj items: vec![ - (Typed::Str("BuyPremiumAvailable".into()), Typed::Bool(false)), - (Typed::Str("MainShopButtonAvailable".into()), Typed::Bool(true)), - (Typed::Str("RoboPassButtonAvailable".into()), Typed::Bool(false)), - (Typed::Str("LanguageSelectionAvailable".into()), Typed::Bool(true)), + (Typed::Str("BuyPremiumAvailable".into()), Typed::Bool(self.platform_config.enable_buy_premium)), + (Typed::Str("MainShopButtonAvailable".into()), Typed::Bool(self.platform_config.enable_shop)), + (Typed::Str("RoboPassButtonAvailable".into()), Typed::Bool(self.platform_config.enable_robopass)), + (Typed::Str("LanguageSelectionAvailable".into()), Typed::Bool(self.platform_config.enable_select_language)), (Typed::Str("AutoJoinPublicChatRoom".into()), Typed::Str(client_selected_channel.into())), (Typed::Str("CanCreateChatRooms".into()), Typed::Bool(self.chat_config.can_create_channels)), - (Typed::Str("CurseVoiceEnabled".into()), Typed::Bool(false)), - (Typed::Str("DeltaDNAEnabled".into()), Typed::Bool(false)), - (Typed::Str("UseDecimalSystem".into()), Typed::Bool(true)), + (Typed::Str("CurseVoiceEnabled".into()), Typed::Bool(self.platform_config.enable_voice)), + (Typed::Str("DeltaDNAEnabled".into()), Typed::Bool(self.platform_config.enable_analytics)), + (Typed::Str("UseDecimalSystem".into()), Typed::Bool(self.platform_config.enable_standard_units)), (Typed::Str("FeedbackURL".into()), Typed::Str(self.links.feedback_url.clone().into())), (Typed::Str("SupportURL".into()), Typed::Str(self.links.support_url.clone().into())), (Typed::Str("WikiURL".into()), Typed::Str(self.links.wiki_url.clone().into())),