mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Make rest of client platform flags configurage; fix speedometer confusing Americans
This commit is contained in:
@@ -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<GameplaySettings> for crate::data::client_config::GameplaySettings {
|
||||
@@ -31,3 +33,37 @@ impl std::convert::From<GameplaySettings> 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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,6 +277,19 @@ impl <C: Clone + Send> super::ConfigProvider<C> 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<C> {
|
||||
super::DevMessageProvider::new(self.settings.banners.iter().map(|msg| (msg.message.clone(), msg.duration as i32)).collect())
|
||||
}
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -16,6 +16,7 @@ pub trait ConfigProvider<C: Clone> {
|
||||
fn campaign_details(&self) -> super::CompleteCampaignProvider;
|
||||
fn campaigns(&self) -> super::CampaignResolver;
|
||||
fn client_config(&self) -> Typed<C>;
|
||||
fn platform(&self) -> PlatformConfig;
|
||||
fn login_messages(&self) -> DevMessageProvider<C>;
|
||||
fn public_channels(&self) -> Typed<C>;
|
||||
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,
|
||||
}
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,14 @@ pub(super) fn platform_config_provider<C: Send + 'static>(conf: &oj_rc_core::Con
|
||||
SimpleOpImpl::new(PlatformConfigProvider {
|
||||
chat_config: <oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::chat_system_config(conf),
|
||||
links: <oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::url_links(conf),
|
||||
platform_config: <oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::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 <C: Send + 'static> SimpleOperation<C> 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())),
|
||||
|
||||
Reference in New Issue
Block a user