mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
cargo fmt
This commit is contained in:
parent
d090eefb00
commit
7b4aa6d4cc
@ -4,11 +4,18 @@ use dot_vox::DotVoxData;
|
|||||||
use image::DynamicImage;
|
use image::DynamicImage;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::{borrow::Cow, fs, io, path::{Path, PathBuf}, sync::Arc};
|
use std::{
|
||||||
|
borrow::Cow,
|
||||||
|
fs, io,
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
sync::Arc,
|
||||||
|
};
|
||||||
|
|
||||||
pub use assets_manager::{
|
pub use assets_manager::{
|
||||||
Asset, AssetCache, BoxedError, Compound, Error, source,
|
loader::{
|
||||||
loader::{self, BytesLoader, BincodeLoader, Loader, JsonLoader, LoadFrom, RonLoader, StringLoader},
|
self, BincodeLoader, BytesLoader, JsonLoader, LoadFrom, Loader, RonLoader, StringLoader,
|
||||||
|
},
|
||||||
|
source, Asset, AssetCache, BoxedError, Compound, Error,
|
||||||
};
|
};
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
@ -16,9 +23,7 @@ lazy_static! {
|
|||||||
static ref ASSETS: AssetCache = AssetCache::new(&*ASSETS_PATH).unwrap();
|
static ref ASSETS: AssetCache = AssetCache::new(&*ASSETS_PATH).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_hot_reloading() {
|
pub fn start_hot_reloading() { ASSETS.enhance_hot_reloading(); }
|
||||||
ASSETS.enhance_hot_reloading();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type AssetHandle<T> = assets_manager::Handle<'static, T>;
|
pub type AssetHandle<T> = assets_manager::Handle<'static, T>;
|
||||||
pub type AssetDir<T> = assets_manager::DirReader<'static, T, source::FileSystem>;
|
pub type AssetDir<T> = assets_manager::DirReader<'static, T, source::FileSystem>;
|
||||||
@ -79,21 +84,15 @@ pub fn load_dir<T: Asset>(specifier: &str) -> Result<AssetDir<T>, Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Compound> AssetExt for T {
|
impl<T: Compound> AssetExt for T {
|
||||||
fn load(specifier: &str) -> Result<AssetHandle<Self>, Error> {
|
fn load(specifier: &str) -> Result<AssetHandle<Self>, Error> { ASSETS.load(specifier) }
|
||||||
ASSETS.load(specifier)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn load_owned(specifier: &str) -> Result<Self, Error> {
|
fn load_owned(specifier: &str) -> Result<Self, Error> { ASSETS.load_owned(specifier) }
|
||||||
ASSETS.load_owned(specifier)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Image(pub Arc<DynamicImage>);
|
pub struct Image(pub Arc<DynamicImage>);
|
||||||
|
|
||||||
impl Image {
|
impl Image {
|
||||||
pub fn to_image(&self) -> Arc<DynamicImage> {
|
pub fn to_image(&self) -> Arc<DynamicImage> { self.0.clone() }
|
||||||
self.0.clone()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ImageLoader;
|
pub struct ImageLoader;
|
||||||
@ -105,8 +104,9 @@ impl Loader<Image> for ImageLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Asset for Image {
|
impl Asset for Image {
|
||||||
const EXTENSIONS: &'static [&'static str] = &["png", "jpg"];
|
|
||||||
type Loader = ImageLoader;
|
type Loader = ImageLoader;
|
||||||
|
|
||||||
|
const EXTENSIONS: &'static [&'static str] = &["png", "jpg"];
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DotVoxAsset(pub DotVoxData);
|
pub struct DotVoxAsset(pub DotVoxData);
|
||||||
@ -128,14 +128,15 @@ impl<T> Asset for Ron<T>
|
|||||||
where
|
where
|
||||||
T: Send + Sync + for<'de> Deserialize<'de> + 'static,
|
T: Send + Sync + for<'de> Deserialize<'de> + 'static,
|
||||||
{
|
{
|
||||||
const EXTENSION: &'static str = "ron";
|
|
||||||
type Loader = RonLoader;
|
type Loader = RonLoader;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "ron";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl Asset for DotVoxAsset {
|
impl Asset for DotVoxAsset {
|
||||||
const EXTENSION: &'static str = "vox";
|
|
||||||
type Loader = DotVoxLoader;
|
type Loader = DotVoxLoader;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "vox";
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
@ -242,9 +243,7 @@ fn get_dir_files(files: &mut Vec<String>, path: &Path, specifier: &str) -> io::R
|
|||||||
pub struct Directory(Vec<String>);
|
pub struct Directory(Vec<String>);
|
||||||
|
|
||||||
impl Directory {
|
impl Directory {
|
||||||
pub fn iter(&self) -> impl Iterator<Item=&String> {
|
pub fn iter(&self) -> impl Iterator<Item = &String> { self.0.iter() }
|
||||||
self.0.iter()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Compound for Directory {
|
impl Compound for Directory {
|
||||||
|
@ -16,8 +16,8 @@ use arraygen::Arraygen;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use specs::{Component, FlaggedStorage};
|
use specs::{Component, FlaggedStorage};
|
||||||
use specs_idvs::IdvStorage;
|
use specs_idvs::IdvStorage;
|
||||||
use tracing::error;
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
use tracing::error;
|
||||||
use vek::Vec3;
|
use vek::Vec3;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Hash, Eq, PartialEq, Debug, Serialize, Deserialize)]
|
#[derive(Copy, Clone, Hash, Eq, PartialEq, Debug, Serialize, Deserialize)]
|
||||||
@ -239,14 +239,14 @@ impl Default for CharacterAbility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Asset for CharacterAbility {
|
impl Asset for CharacterAbility {
|
||||||
const EXTENSION: &'static str = "ron";
|
|
||||||
type Loader = assets::RonLoader;
|
type Loader = assets::RonLoader;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "ron";
|
||||||
|
|
||||||
fn default_value(specifier: &str, err: assets::Error) -> Result<Self, assets::Error> {
|
fn default_value(specifier: &str, err: assets::Error) -> Result<Self, assets::Error> {
|
||||||
error!(
|
error!(
|
||||||
?err,
|
?err,
|
||||||
"Error loading CharacterAbility: {} for the ability \
|
"Error loading CharacterAbility: {} for the ability map: replacing with default",
|
||||||
map: replacing with default",
|
|
||||||
specifier
|
specifier
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -126,8 +126,9 @@ impl<
|
|||||||
SpeciesMeta: Send + Sync + for<'de> serde::Deserialize<'de> + 'static,
|
SpeciesMeta: Send + Sync + for<'de> serde::Deserialize<'de> + 'static,
|
||||||
> Asset for AllBodies<BodyMeta, SpeciesMeta>
|
> Asset for AllBodies<BodyMeta, SpeciesMeta>
|
||||||
{
|
{
|
||||||
const EXTENSION: &'static str = "json";
|
|
||||||
type Loader = assets::JsonLoader;
|
type Loader = assets::JsonLoader;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "json";
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Body {
|
impl Body {
|
||||||
|
@ -159,13 +159,27 @@ impl PartialEq for Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl assets::Compound for ItemDef {
|
impl assets::Compound for ItemDef {
|
||||||
fn load<S: assets_manager::source::Source>(cache: &assets_manager::AssetCache<S>, specifier: &str) -> Result<Self, Error> {
|
fn load<S: assets_manager::source::Source>(
|
||||||
|
cache: &assets_manager::AssetCache<S>,
|
||||||
|
specifier: &str,
|
||||||
|
) -> Result<Self, Error> {
|
||||||
let raw = cache.load_owned::<RawItemDef>(specifier)?;
|
let raw = cache.load_owned::<RawItemDef>(specifier)?;
|
||||||
|
|
||||||
let RawItemDef { name, description, kind, quality} = raw;
|
let RawItemDef {
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
kind,
|
||||||
|
quality,
|
||||||
|
} = raw;
|
||||||
let item_definition_id = specifier.replace('\\', ".");
|
let item_definition_id = specifier.replace('\\', ".");
|
||||||
|
|
||||||
Ok(ItemDef { item_definition_id, name, description, kind, quality })
|
Ok(ItemDef {
|
||||||
|
item_definition_id,
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
kind,
|
||||||
|
quality,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,16 +193,15 @@ struct RawItemDef {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl assets::Asset for RawItemDef {
|
impl assets::Asset for RawItemDef {
|
||||||
const EXTENSION: &'static str = "ron";
|
|
||||||
type Loader = assets::RonLoader;
|
type Loader = assets::RonLoader;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "ron";
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Item {
|
impl Item {
|
||||||
// TODO: consider alternatives such as default abilities that can be added to a
|
// TODO: consider alternatives such as default abilities that can be added to a
|
||||||
// loadout when no weapon is present
|
// loadout when no weapon is present
|
||||||
pub fn empty() -> Self {
|
pub fn empty() -> Self { Item::new_from_asset_expect("common.items.weapons.empty.empty") }
|
||||||
Item::new_from_asset_expect("common.items.weapons.empty.empty")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new(inner_item: Arc<ItemDef>) -> Self {
|
pub fn new(inner_item: Arc<ItemDef>) -> Self {
|
||||||
Item {
|
Item {
|
||||||
@ -212,7 +225,8 @@ impl Item {
|
|||||||
|
|
||||||
let specifiers = assets::Directory::load(asset_glob)?;
|
let specifiers = assets::Directory::load(asset_glob)?;
|
||||||
|
|
||||||
specifiers.read()
|
specifiers
|
||||||
|
.read()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|spec| Self::new_from_asset(&spec))
|
.map(|spec| Self::new_from_asset(&spec))
|
||||||
.collect()
|
.collect()
|
||||||
@ -334,7 +348,8 @@ impl Item {
|
|||||||
3 => "common.loot_tables.loot_table_armor_cloth",
|
3 => "common.loot_tables.loot_table_armor_cloth",
|
||||||
4 => "common.loot_tables.loot_table_armor_heavy",
|
4 => "common.loot_tables.loot_table_armor_heavy",
|
||||||
_ => "common.loot_tables.loot_table_armor_misc",
|
_ => "common.loot_tables.loot_table_armor_misc",
|
||||||
}).read();
|
})
|
||||||
|
.read();
|
||||||
chosen.choose()
|
chosen.choose()
|
||||||
},
|
},
|
||||||
SpriteKind::ChestBurried => {
|
SpriteKind::ChestBurried => {
|
||||||
@ -343,7 +358,8 @@ impl Item {
|
|||||||
2 => "common.loot_tables.loot_table_armor_light",
|
2 => "common.loot_tables.loot_table_armor_light",
|
||||||
3 => "common.loot_tables.loot_table_armor_cloth",
|
3 => "common.loot_tables.loot_table_armor_cloth",
|
||||||
_ => "common.loot_tables.loot_table_armor_misc",
|
_ => "common.loot_tables.loot_table_armor_misc",
|
||||||
}).read();
|
})
|
||||||
|
.read();
|
||||||
chosen.choose()
|
chosen.choose()
|
||||||
},
|
},
|
||||||
SpriteKind::Mud => {
|
SpriteKind::Mud => {
|
||||||
@ -352,14 +368,16 @@ impl Item {
|
|||||||
1 => "common.loot_tables.loot_table_weapon_common",
|
1 => "common.loot_tables.loot_table_weapon_common",
|
||||||
2 => "common.loot_tables.loot_table_armor_misc",
|
2 => "common.loot_tables.loot_table_armor_misc",
|
||||||
_ => "common.loot_tables.loot_table_rocks",
|
_ => "common.loot_tables.loot_table_rocks",
|
||||||
}).read();
|
})
|
||||||
|
.read();
|
||||||
chosen.choose()
|
chosen.choose()
|
||||||
},
|
},
|
||||||
SpriteKind::Crate => {
|
SpriteKind::Crate => {
|
||||||
chosen = Lottery::<String>::load_expect(match rng.gen_range(0, 4) {
|
chosen = Lottery::<String>::load_expect(match rng.gen_range(0, 4) {
|
||||||
0 => "common.loot_tables.loot_table_crafting",
|
0 => "common.loot_tables.loot_table_crafting",
|
||||||
_ => "common.loot_tables.loot_table_food",
|
_ => "common.loot_tables.loot_table_food",
|
||||||
}).read();
|
})
|
||||||
|
.read();
|
||||||
chosen.choose()
|
chosen.choose()
|
||||||
},
|
},
|
||||||
SpriteKind::Beehive => "common.items.crafting_ing.honey",
|
SpriteKind::Beehive => "common.items.crafting_ing.honey",
|
||||||
|
@ -144,26 +144,31 @@ impl Default for AbilitySet<CharacterAbility> {
|
|||||||
pub struct AbilityMap<T = CharacterAbility>(HashMap<ToolKind, AbilitySet<T>>);
|
pub struct AbilityMap<T = CharacterAbility>(HashMap<ToolKind, AbilitySet<T>>);
|
||||||
|
|
||||||
impl Asset for AbilityMap<String> {
|
impl Asset for AbilityMap<String> {
|
||||||
const EXTENSION: &'static str = "ron";
|
|
||||||
type Loader = assets::RonLoader;
|
type Loader = assets::RonLoader;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "ron";
|
||||||
}
|
}
|
||||||
|
|
||||||
impl assets::Compound for AbilityMap {
|
impl assets::Compound for AbilityMap {
|
||||||
fn load<S: assets_manager::source::Source>(cache: &assets_manager::AssetCache<S>, specifier: &str) -> Result<Self, assets::Error> {
|
fn load<S: assets_manager::source::Source>(
|
||||||
|
cache: &assets_manager::AssetCache<S>,
|
||||||
|
specifier: &str,
|
||||||
|
) -> Result<Self, assets::Error> {
|
||||||
let manifest = cache.load::<AbilityMap<String>>(specifier)?.read();
|
let manifest = cache.load::<AbilityMap<String>>(specifier)?.read();
|
||||||
|
|
||||||
Ok(AbilityMap(
|
Ok(AbilityMap(
|
||||||
manifest.0
|
manifest
|
||||||
|
.0
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(kind, set)| {
|
.map(|(kind, set)| {
|
||||||
(
|
(
|
||||||
kind.clone(),
|
kind.clone(),
|
||||||
// expect cannot fail because CharacterAbility always
|
// expect cannot fail because CharacterAbility always
|
||||||
// provides a default value in case of failure
|
// provides a default value in case of failure
|
||||||
set.map_ref(|s| cache.load_expect(&s).cloned())
|
set.map_ref(|s| cache.load_expect(&s).cloned()),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect()
|
.collect(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,9 @@ pub struct Lottery<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T: DeserializeOwned + Send + Sync + 'static> assets::Asset for Lottery<T> {
|
impl<T: DeserializeOwned + Send + Sync + 'static> assets::Asset for Lottery<T> {
|
||||||
const EXTENSION: &'static str = "ron";
|
|
||||||
type Loader = assets::LoadFrom<Vec<(f32, T)>, assets::RonLoader>;
|
type Loader = assets::LoadFrom<Vec<(f32, T)>, assets::RonLoader>;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "ron";
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> From<Vec<(f32, T)>> for Lottery<T> {
|
impl<T> From<Vec<(f32, T)>> for Lottery<T> {
|
||||||
|
@ -88,7 +88,10 @@ pub fn get_npc_name(npc_type: NpcKind) -> String {
|
|||||||
let BodyNames { keyword, names } = &npc_names[npc_type];
|
let BodyNames { keyword, names } = &npc_names[npc_type];
|
||||||
|
|
||||||
// If no pretty name is found, fall back to the keyword.
|
// If no pretty name is found, fall back to the keyword.
|
||||||
names.choose(&mut rand::thread_rng()).unwrap_or(keyword).clone()
|
names
|
||||||
|
.choose(&mut rand::thread_rng())
|
||||||
|
.unwrap_or(keyword)
|
||||||
|
.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Randomly generates a body associated with this NPC kind.
|
/// Randomly generates a body associated with this NPC kind.
|
||||||
|
@ -70,13 +70,16 @@ impl RecipeBook {
|
|||||||
struct RawRecipeBook(HashMap<String, ((String, u32), Vec<(String, u32)>)>);
|
struct RawRecipeBook(HashMap<String, ((String, u32), Vec<(String, u32)>)>);
|
||||||
|
|
||||||
impl assets::Asset for RawRecipeBook {
|
impl assets::Asset for RawRecipeBook {
|
||||||
const EXTENSION: &'static str = "ron";
|
|
||||||
type Loader = assets::RonLoader;
|
type Loader = assets::RonLoader;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "ron";
|
||||||
}
|
}
|
||||||
|
|
||||||
impl assets::Compound for RecipeBook {
|
impl assets::Compound for RecipeBook {
|
||||||
|
fn load<S: assets_manager::source::Source>(
|
||||||
fn load<S: assets_manager::source::Source>(cache: &assets_manager::AssetCache<S>, specifier: &str) -> Result<Self, assets_manager::Error> {
|
cache: &assets_manager::AssetCache<S>,
|
||||||
|
specifier: &str,
|
||||||
|
) -> Result<Self, assets_manager::Error> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn load_item_def(spec: &(String, u32)) -> Result<(Arc<ItemDef>, u32), assets::Error> {
|
fn load_item_def(spec: &(String, u32)) -> Result<(Arc<ItemDef>, u32), assets::Error> {
|
||||||
let def = Arc::<ItemDef>::load_cloned(&spec.0)?;
|
let def = Arc::<ItemDef>::load_cloned(&spec.0)?;
|
||||||
@ -85,11 +88,11 @@ impl assets::Compound for RecipeBook {
|
|||||||
|
|
||||||
let raw = cache.load::<RawRecipeBook>(specifier)?.read();
|
let raw = cache.load::<RawRecipeBook>(specifier)?.read();
|
||||||
|
|
||||||
let recipes = raw.0.iter()
|
let recipes = raw
|
||||||
|
.0
|
||||||
|
.iter()
|
||||||
.map(|(name, (output, inputs))| {
|
.map(|(name, (output, inputs))| {
|
||||||
let inputs = inputs.iter()
|
let inputs = inputs.iter().map(load_item_def).collect::<Result<_, _>>()?;
|
||||||
.map(load_item_def)
|
|
||||||
.collect::<Result<_, _>>()?;
|
|
||||||
let output = load_item_def(output)?;
|
let output = load_item_def(output)?;
|
||||||
Ok((name.clone(), Recipe { inputs, output }))
|
Ok((name.clone(), Recipe { inputs, output }))
|
||||||
})
|
})
|
||||||
|
@ -53,17 +53,20 @@ pub struct StructuresGroup(Vec<Structure>);
|
|||||||
impl std::ops::Deref for StructuresGroup {
|
impl std::ops::Deref for StructuresGroup {
|
||||||
type Target = [Structure];
|
type Target = [Structure];
|
||||||
|
|
||||||
fn deref(&self) -> &[Structure] {
|
fn deref(&self) -> &[Structure] { &self.0 }
|
||||||
&self.0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl assets::Compound for StructuresGroup {
|
impl assets::Compound for StructuresGroup {
|
||||||
fn load<S: assets_manager::source::Source>(cache: &assets_manager::AssetCache<S>, specifier: &str) -> Result<Self, Error> {
|
fn load<S: assets_manager::source::Source>(
|
||||||
|
cache: &assets_manager::AssetCache<S>,
|
||||||
|
specifier: &str,
|
||||||
|
) -> Result<Self, Error> {
|
||||||
let specs = cache.load::<StructuresGroupSpec>(specifier)?.read();
|
let specs = cache.load::<StructuresGroupSpec>(specifier)?.read();
|
||||||
|
|
||||||
Ok(StructuresGroup(
|
Ok(StructuresGroup(
|
||||||
specs.0.iter()
|
specs
|
||||||
|
.0
|
||||||
|
.iter()
|
||||||
.map(|sp| {
|
.map(|sp| {
|
||||||
let base = cache.load::<Arc<BaseStructure>>(&sp.specifier)?.cloned();
|
let base = cache.load::<Arc<BaseStructure>>(&sp.specifier)?.cloned();
|
||||||
Ok(Structure {
|
Ok(Structure {
|
||||||
@ -71,7 +74,7 @@ impl assets::Compound for StructuresGroup {
|
|||||||
base,
|
base,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.collect::<Result<_, Error>>()?
|
.collect::<Result<_, Error>>()?,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,7 +115,10 @@ impl ReadVol for Structure {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl assets::Compound for BaseStructure {
|
impl assets::Compound for BaseStructure {
|
||||||
fn load<S: assets_manager::source::Source>(cache: &assets_manager::AssetCache<S>, specifier: &str) -> Result<Self, Error> {
|
fn load<S: assets_manager::source::Source>(
|
||||||
|
cache: &assets_manager::AssetCache<S>,
|
||||||
|
specifier: &str,
|
||||||
|
) -> Result<Self, Error> {
|
||||||
let dot_vox_data = cache.load::<DotVoxAsset>(specifier)?.read();
|
let dot_vox_data = cache.load::<DotVoxAsset>(specifier)?.read();
|
||||||
let dot_vox_data = &dot_vox_data.0;
|
let dot_vox_data = &dot_vox_data.0;
|
||||||
|
|
||||||
@ -182,6 +188,7 @@ struct StructureSpec {
|
|||||||
struct StructuresGroupSpec(Vec<StructureSpec>);
|
struct StructuresGroupSpec(Vec<StructureSpec>);
|
||||||
|
|
||||||
impl assets::Asset for StructuresGroupSpec {
|
impl assets::Asset for StructuresGroupSpec {
|
||||||
const EXTENSION: &'static str = "ron";
|
|
||||||
type Loader = assets::RonLoader;
|
type Loader = assets::RonLoader;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "ron";
|
||||||
}
|
}
|
@ -4,7 +4,10 @@ use crate::{
|
|||||||
scene::Camera,
|
scene::Camera,
|
||||||
};
|
};
|
||||||
use client::Client;
|
use client::Client;
|
||||||
use common::{assets::{self, AssetExt, AssetHandle}, vol::ReadVol};
|
use common::{
|
||||||
|
assets::{self, AssetExt, AssetHandle},
|
||||||
|
vol::ReadVol,
|
||||||
|
};
|
||||||
use common_sys::state::State;
|
use common_sys::state::State;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
@ -130,12 +133,14 @@ impl AmbientMgr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl assets::Asset for AmbientCollection {
|
impl assets::Asset for AmbientCollection {
|
||||||
const EXTENSION: &'static str = "ron";
|
|
||||||
type Loader = assets::RonLoader;
|
type Loader = assets::RonLoader;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "ron";
|
||||||
|
|
||||||
fn default_value(_: &str, error: assets::Error) -> Result<Self, assets::Error> {
|
fn default_value(_: &str, error: assets::Error) -> Result<Self, assets::Error> {
|
||||||
warn!(
|
warn!(
|
||||||
"Error reading music config file, music will not be available: {:#?}", error
|
"Error reading music config file, music will not be available: {:#?}",
|
||||||
|
error
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(AmbientCollection::default())
|
Ok(AmbientCollection::default())
|
||||||
|
@ -232,12 +232,14 @@ impl MusicMgr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl assets::Asset for SoundtrackCollection {
|
impl assets::Asset for SoundtrackCollection {
|
||||||
const EXTENSION: &'static str = "ron";
|
|
||||||
type Loader = assets::RonLoader;
|
type Loader = assets::RonLoader;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "ron";
|
||||||
|
|
||||||
fn default_value(_: &str, error: assets::Error) -> Result<Self, assets::Error> {
|
fn default_value(_: &str, error: assets::Error) -> Result<Self, assets::Error> {
|
||||||
warn!(
|
warn!(
|
||||||
"Error reading music config file, music will not be available: {:#?}", error
|
"Error reading music config file, music will not be available: {:#?}",
|
||||||
|
error
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(SoundtrackCollection::default())
|
Ok(SoundtrackCollection::default())
|
||||||
|
@ -368,12 +368,14 @@ impl SfxMgr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl assets::Asset for SfxTriggers {
|
impl assets::Asset for SfxTriggers {
|
||||||
const EXTENSION: &'static str = "ron";
|
|
||||||
type Loader = assets::RonLoader;
|
type Loader = assets::RonLoader;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "ron";
|
||||||
|
|
||||||
fn default_value(_: &str, error: assets::Error) -> Result<Self, assets::Error> {
|
fn default_value(_: &str, error: assets::Error) -> Result<Self, assets::Error> {
|
||||||
warn!(
|
warn!(
|
||||||
"Error reading sfx config file, sfx will not be available: {:#?}", error
|
"Error reading sfx config file, sfx will not be available: {:#?}",
|
||||||
|
error
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(SfxTriggers::default())
|
Ok(SfxTriggers::default())
|
||||||
|
@ -23,9 +23,10 @@ impl assets::Loader<WavSound> for SoundLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl assets::Asset for WavSound {
|
impl assets::Asset for WavSound {
|
||||||
const EXTENSION: &'static str = "wav";
|
|
||||||
type Loader = SoundLoader;
|
type Loader = SoundLoader;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "wav";
|
||||||
|
|
||||||
fn default_value(specifier: &str, error: assets::Error) -> Result<Self, assets::Error> {
|
fn default_value(specifier: &str, error: assets::Error) -> Result<Self, assets::Error> {
|
||||||
warn!(?specifier, ?error, "Failed to load sound");
|
warn!(?specifier, ?error, "Failed to load sound");
|
||||||
|
|
||||||
@ -40,9 +41,9 @@ impl WavSound {
|
|||||||
rodio::Decoder::new(cursor).unwrap()
|
rodio::Decoder::new(cursor).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a `WavSound` containing empty .wav data. This intentionally doesn't
|
/// Returns a `WavSound` containing empty .wav data. This intentionally
|
||||||
/// load from the filesystem so we have a reliable fallback when there
|
/// doesn't load from the filesystem so we have a reliable fallback when
|
||||||
/// is a failure to read a file.
|
/// there is a failure to read a file.
|
||||||
///
|
///
|
||||||
/// The data below is the result of passing a very short, silent .wav file
|
/// The data below is the result of passing a very short, silent .wav file
|
||||||
/// to `Sound::load()`.
|
/// to `Sound::load()`.
|
||||||
@ -69,8 +70,9 @@ impl assets::Loader<OggSound> for SoundLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl assets::Asset for OggSound {
|
impl assets::Asset for OggSound {
|
||||||
const EXTENSION: &'static str = "ogg";
|
|
||||||
type Loader = SoundLoader;
|
type Loader = SoundLoader;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "ogg";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wrapper for decoded audio data
|
/// Wrapper for decoded audio data
|
||||||
|
@ -84,8 +84,9 @@ impl ImageSpec {
|
|||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
struct ItemImagesSpec(HashMap<ItemKey, ImageSpec>);
|
struct ItemImagesSpec(HashMap<ItemKey, ImageSpec>);
|
||||||
impl assets::Asset for ItemImagesSpec {
|
impl assets::Asset for ItemImagesSpec {
|
||||||
const EXTENSION: &'static str = "ron";
|
|
||||||
type Loader = assets::RonLoader;
|
type Loader = assets::RonLoader;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "ron";
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: when there are more images don't load them all into memory
|
// TODO: when there are more images don't load them all into memory
|
||||||
@ -97,7 +98,7 @@ pub struct ItemImgs {
|
|||||||
|
|
||||||
impl ItemImgs {
|
impl ItemImgs {
|
||||||
pub fn new(ui: &mut Ui, not_found: Id) -> Self {
|
pub fn new(ui: &mut Ui, not_found: Id) -> Self {
|
||||||
let manifest = ItemImagesSpec::load_expect("voxygen.item_image_manifest");
|
let manifest = ItemImagesSpec::load_expect("voxygen.item_image_manifest");
|
||||||
let map = manifest
|
let map = manifest
|
||||||
.read()
|
.read()
|
||||||
.0
|
.0
|
||||||
|
@ -659,7 +659,8 @@ impl Hud {
|
|||||||
// Load item images.
|
// Load item images.
|
||||||
let item_imgs = ItemImgs::new(&mut ui, imgs.not_found);
|
let item_imgs = ItemImgs::new(&mut ui, imgs.not_found);
|
||||||
// Load fonts.
|
// Load fonts.
|
||||||
let fonts = Fonts::load(&global_state.i18n.read().fonts, &mut ui).expect("Impossible to load fonts!");
|
let fonts = Fonts::load(&global_state.i18n.read().fonts, &mut ui)
|
||||||
|
.expect("Impossible to load fonts!");
|
||||||
// Get the server name.
|
// Get the server name.
|
||||||
let server = &client.server_info().name;
|
let server = &client.server_info().name;
|
||||||
// Get the id, unwrap is safe because this CANNOT be None at this
|
// Get the id, unwrap is safe because this CANNOT be None at this
|
||||||
@ -2289,9 +2290,7 @@ impl Hud {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if self.show.esc_menu {
|
if self.show.esc_menu {
|
||||||
match EscMenu::new(&self.imgs, &self.fonts, i18n)
|
match EscMenu::new(&self.imgs, &self.fonts, i18n).set(self.ids.esc_menu, ui_widgets) {
|
||||||
.set(self.ids.esc_menu, ui_widgets)
|
|
||||||
{
|
|
||||||
Some(esc_menu::Event::OpenSettings(tab)) => {
|
Some(esc_menu::Event::OpenSettings(tab)) => {
|
||||||
self.show.open_setting_tab(tab);
|
self.show.open_setting_tab(tab);
|
||||||
},
|
},
|
||||||
|
@ -135,8 +135,9 @@ impl Localization {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl assets::Asset for Localization {
|
impl assets::Asset for Localization {
|
||||||
const EXTENSION: &'static str = "ron";
|
|
||||||
type Loader = LocalizationLoader;
|
type Loader = LocalizationLoader;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "ron";
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct LocalizationLoader;
|
pub struct LocalizationLoader;
|
||||||
@ -166,9 +167,7 @@ pub fn list_localizations() -> Vec<LanguageMetadata> {
|
|||||||
assets::load_dir::<Localization>("voxygen.i18n")
|
assets::load_dir::<Localization>("voxygen.i18n")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.iter_all()
|
.iter_all()
|
||||||
.filter_map(|(_, lang)| {
|
.filter_map(|(_, lang)| lang.ok().map(|e| e.read().metadata.clone()))
|
||||||
lang.ok().map(|e| e.read().metadata.clone())
|
|
||||||
})
|
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,19 +157,17 @@ fn main() {
|
|||||||
// Load the profile.
|
// Load the profile.
|
||||||
let profile = Profile::load();
|
let profile = Profile::load();
|
||||||
|
|
||||||
let i18n = Localization::load(
|
let i18n = Localization::load(&i18n_asset_key(&settings.language.selected_language))
|
||||||
&i18n_asset_key(&settings.language.selected_language),
|
.unwrap_or_else(|error| {
|
||||||
)
|
let selected_language = &settings.language.selected_language;
|
||||||
.unwrap_or_else(|error| {
|
warn!(
|
||||||
let selected_language = &settings.language.selected_language;
|
?error,
|
||||||
warn!(
|
?selected_language,
|
||||||
?error,
|
"Impossible to load language: change to the default language (English) instead.",
|
||||||
?selected_language,
|
);
|
||||||
"Impossible to load language: change to the default language (English) instead.",
|
settings.language.selected_language = i18n::REFERENCE_LANG.to_owned();
|
||||||
);
|
Localization::load_expect(&i18n_asset_key(&settings.language.selected_language))
|
||||||
settings.language.selected_language = i18n::REFERENCE_LANG.to_owned();
|
});
|
||||||
Localization::load_expect(&i18n_asset_key(&settings.language.selected_language))
|
|
||||||
});
|
|
||||||
i18n.read().log_missing_entries();
|
i18n.read().log_missing_entries();
|
||||||
|
|
||||||
// Create window
|
// Create window
|
||||||
|
@ -263,11 +263,7 @@ enum Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Controls {
|
impl Controls {
|
||||||
fn new(
|
fn new(fonts: Fonts, imgs: Imgs, selected: Option<CharacterId>) -> Self {
|
||||||
fonts: Fonts,
|
|
||||||
imgs: Imgs,
|
|
||||||
selected: Option<CharacterId>,
|
|
||||||
) -> Self {
|
|
||||||
let version = common::util::DISPLAY_VERSION_LONG.clone();
|
let version = common::util::DISPLAY_VERSION_LONG.clone();
|
||||||
let alpha = format!("Veloren {}", common::util::DISPLAY_VERSION.as_str());
|
let alpha = format!("Veloren {}", common::util::DISPLAY_VERSION.as_str());
|
||||||
|
|
||||||
@ -1467,8 +1463,8 @@ impl CharSelectionUi {
|
|||||||
let font = ui::ice::load_font(&i18n.fonts.get("cyri").unwrap().asset_key);
|
let font = ui::ice::load_font(&i18n.fonts.get("cyri").unwrap().asset_key);
|
||||||
|
|
||||||
self.ui.clear_fonts(font);
|
self.ui.clear_fonts(font);
|
||||||
self.controls.fonts = Fonts::load(&i18n.fonts, &mut self.ui)
|
self.controls.fonts =
|
||||||
.expect("Impossible to load fonts!");
|
Fonts::load(&i18n.fonts, &mut self.ui).expect("Impossible to load fonts!");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_scale_mode(&mut self, scale_mode: ui::ScaleMode) {
|
pub fn set_scale_mode(&mut self, scale_mode: ui::ScaleMode) {
|
||||||
|
@ -48,7 +48,8 @@ impl PlayState for MainMenuState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Updated localization in case the selected language was changed
|
// Updated localization in case the selected language was changed
|
||||||
self.main_menu_ui.update_language(global_state.i18n, &global_state.settings);
|
self.main_menu_ui
|
||||||
|
.update_language(global_state.i18n, &global_state.settings);
|
||||||
// Set scale mode in case it was change
|
// Set scale mode in case it was change
|
||||||
self.main_menu_ui
|
self.main_menu_ui
|
||||||
.set_scale_mode(global_state.settings.gameplay.ui_scale);
|
.set_scale_mode(global_state.settings.gameplay.ui_scale);
|
||||||
@ -264,10 +265,8 @@ impl PlayState for MainMenuState {
|
|||||||
&global_state.settings.language.selected_language,
|
&global_state.settings.language.selected_language,
|
||||||
));
|
));
|
||||||
global_state.i18n.read().log_missing_entries();
|
global_state.i18n.read().log_missing_entries();
|
||||||
self.main_menu_ui.update_language(
|
self.main_menu_ui
|
||||||
global_state.i18n,
|
.update_language(global_state.i18n, &global_state.settings);
|
||||||
&global_state.settings,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
#[cfg(feature = "singleplayer")]
|
#[cfg(feature = "singleplayer")]
|
||||||
MainMenuEvent::StartSingleplayer => {
|
MainMenuEvent::StartSingleplayer => {
|
||||||
|
@ -10,7 +10,7 @@ use crate::{
|
|||||||
ui::{
|
ui::{
|
||||||
self,
|
self,
|
||||||
fonts::IcedFonts as Fonts,
|
fonts::IcedFonts as Fonts,
|
||||||
ice::{style, widget, Element, IcedUi as Ui, load_font},
|
ice::{load_font, style, widget, Element, IcedUi as Ui},
|
||||||
img_ids::{ImageGraphic, VoxelGraphic},
|
img_ids::{ImageGraphic, VoxelGraphic},
|
||||||
Graphic,
|
Graphic,
|
||||||
},
|
},
|
||||||
@ -513,8 +513,8 @@ impl<'a> MainMenuUi {
|
|||||||
let i18n = &*i18n.read();
|
let i18n = &*i18n.read();
|
||||||
let font = load_font(&i18n.fonts.get("cyri").unwrap().asset_key);
|
let font = load_font(&i18n.fonts.get("cyri").unwrap().asset_key);
|
||||||
self.ui.clear_fonts(font);
|
self.ui.clear_fonts(font);
|
||||||
self.controls.fonts = Fonts::load(&i18n.fonts, &mut self.ui)
|
self.controls.fonts =
|
||||||
.expect("Impossible to load fonts!");
|
Fonts::load(&i18n.fonts, &mut self.ui).expect("Impossible to load fonts!");
|
||||||
let language_metadatas = crate::i18n::list_localizations();
|
let language_metadatas = crate::i18n::list_localizations();
|
||||||
self.controls.selected_language_index = language_metadatas
|
self.controls.selected_language_index = language_metadatas
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -102,14 +102,13 @@ pub type ColLightInfo = (
|
|||||||
pub struct Glsl(String);
|
pub struct Glsl(String);
|
||||||
|
|
||||||
impl From<String> for Glsl {
|
impl From<String> for Glsl {
|
||||||
fn from(s: String) -> Glsl {
|
fn from(s: String) -> Glsl { Glsl(s) }
|
||||||
Glsl(s)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl assets::Asset for Glsl {
|
impl assets::Asset for Glsl {
|
||||||
const EXTENSION: &'static str = "glsl";
|
|
||||||
type Loader = assets::LoadFrom<String, assets::StringLoader>;
|
type Loader = assets::LoadFrom<String, assets::StringLoader>;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "glsl";
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Shaders {
|
struct Shaders {
|
||||||
@ -164,7 +163,10 @@ struct Shaders {
|
|||||||
impl assets::Compound for Shaders {
|
impl assets::Compound for Shaders {
|
||||||
// TODO: Taking the specifier argument as a base for shaders specifiers
|
// TODO: Taking the specifier argument as a base for shaders specifiers
|
||||||
// would allow to use several shaders groups easily
|
// would allow to use several shaders groups easily
|
||||||
fn load<S: assets::source::Source>(_: &assets::AssetCache<S>, _: &str) -> Result<Shaders, assets::Error> {
|
fn load<S: assets::source::Source>(
|
||||||
|
_: &assets::AssetCache<S>,
|
||||||
|
_: &str,
|
||||||
|
) -> Result<Shaders, assets::Error> {
|
||||||
Ok(Shaders {
|
Ok(Shaders {
|
||||||
constants: AssetExt::load("voxygen.shaders.include.constants")?,
|
constants: AssetExt::load("voxygen.shaders.include.constants")?,
|
||||||
globals: AssetExt::load("voxygen.shaders.include.globals")?,
|
globals: AssetExt::load("voxygen.shaders.include.globals")?,
|
||||||
@ -185,8 +187,12 @@ impl assets::Compound for Shaders {
|
|||||||
figure_vert: AssetExt::load("voxygen.shaders.figure-vert")?,
|
figure_vert: AssetExt::load("voxygen.shaders.figure-vert")?,
|
||||||
|
|
||||||
terrain_point_shadow_vert: AssetExt::load("voxygen.shaders.light-shadows-vert")?,
|
terrain_point_shadow_vert: AssetExt::load("voxygen.shaders.light-shadows-vert")?,
|
||||||
terrain_directed_shadow_vert: AssetExt::load("voxygen.shaders.light-shadows-directed-vert")?,
|
terrain_directed_shadow_vert: AssetExt::load(
|
||||||
figure_directed_shadow_vert: AssetExt::load("voxygen.shaders.light-shadows-figure-vert")?,
|
"voxygen.shaders.light-shadows-directed-vert",
|
||||||
|
)?,
|
||||||
|
figure_directed_shadow_vert: AssetExt::load(
|
||||||
|
"voxygen.shaders.light-shadows-figure-vert",
|
||||||
|
)?,
|
||||||
directed_shadow_frag: AssetExt::load("voxygen.shaders.light-shadows-directed-frag")?,
|
directed_shadow_frag: AssetExt::load("voxygen.shaders.light-shadows-directed-frag")?,
|
||||||
|
|
||||||
skybox_vert: AssetExt::load("voxygen.shaders.skybox-vert")?,
|
skybox_vert: AssetExt::load("voxygen.shaders.skybox-vert")?,
|
||||||
@ -323,12 +329,7 @@ impl Renderer {
|
|||||||
point_shadow_pipeline,
|
point_shadow_pipeline,
|
||||||
terrain_directed_shadow_pipeline,
|
terrain_directed_shadow_pipeline,
|
||||||
figure_directed_shadow_pipeline,
|
figure_directed_shadow_pipeline,
|
||||||
) = create_pipelines(
|
) = create_pipelines(&mut factory, &shaders.read(), &mode, shadow_views.is_some())?;
|
||||||
&mut factory,
|
|
||||||
&shaders.read(),
|
|
||||||
&mode,
|
|
||||||
shadow_views.is_some(),
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let (
|
let (
|
||||||
tgt_color_view,
|
tgt_color_view,
|
||||||
@ -1994,7 +1995,9 @@ fn create_pipelines(
|
|||||||
&match mode.fluid {
|
&match mode.fluid {
|
||||||
FluidMode::Cheap => shaders.fluid_frag_cheap,
|
FluidMode::Cheap => shaders.fluid_frag_cheap,
|
||||||
FluidMode::Shiny => shaders.fluid_frag_shiny,
|
FluidMode::Shiny => shaders.fluid_frag_shiny,
|
||||||
}.read().0,
|
}
|
||||||
|
.read()
|
||||||
|
.0,
|
||||||
&include_ctx,
|
&include_ctx,
|
||||||
gfx::state::CullFace::Nothing,
|
gfx::state::CullFace::Nothing,
|
||||||
)?;
|
)?;
|
||||||
|
@ -128,8 +128,9 @@ struct SpriteConfig<Model> {
|
|||||||
struct SpriteSpec(sprite::sprite_kind::PureCases<Option<SpriteConfig<String>>>);
|
struct SpriteSpec(sprite::sprite_kind::PureCases<Option<SpriteConfig<String>>>);
|
||||||
|
|
||||||
impl assets::Asset for SpriteSpec {
|
impl assets::Asset for SpriteSpec {
|
||||||
const EXTENSION: &'static str = "ron";
|
|
||||||
type Loader = assets::RonLoader;
|
type Loader = assets::RonLoader;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "ron";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Function executed by worker threads dedicated to chunk meshing.
|
/// Function executed by worker threads dedicated to chunk meshing.
|
||||||
@ -276,7 +277,8 @@ impl<V: RectRasterableVol> Terrain<V> {
|
|||||||
#[allow(clippy::float_cmp)] // TODO: Pending review in #587
|
#[allow(clippy::float_cmp)] // TODO: Pending review in #587
|
||||||
pub fn new(renderer: &mut Renderer) -> Self {
|
pub fn new(renderer: &mut Renderer) -> Self {
|
||||||
// Load all the sprite config data.
|
// Load all the sprite config data.
|
||||||
let sprite_config = Arc::<SpriteSpec>::load_expect("voxygen.voxel.sprite_manifest").cloned();
|
let sprite_config =
|
||||||
|
Arc::<SpriteSpec>::load_expect("voxygen.voxel.sprite_manifest").cloned();
|
||||||
|
|
||||||
// Create a new mpsc (Multiple Produced, Single Consumer) pair for communicating
|
// Create a new mpsc (Multiple Produced, Single Consumer) pair for communicating
|
||||||
// with worker threads that are meshing chunks.
|
// with worker threads that are meshing chunks.
|
||||||
|
@ -119,11 +119,7 @@ impl SessionState {
|
|||||||
self.hud.new_message(m);
|
self.hud.new_message(m);
|
||||||
},
|
},
|
||||||
client::Event::InventoryUpdated(inv_event) => {
|
client::Event::InventoryUpdated(inv_event) => {
|
||||||
let sfx_triggers = self
|
let sfx_triggers = self.scene.sfx_mgr.triggers.read();
|
||||||
.scene
|
|
||||||
.sfx_mgr
|
|
||||||
.triggers
|
|
||||||
.read();
|
|
||||||
|
|
||||||
let sfx_trigger_item = sfx_triggers.get_key_value(&SfxEvent::from(&inv_event));
|
let sfx_trigger_item = sfx_triggers.get_key_value(&SfxEvent::from(&inv_event));
|
||||||
global_state.audio.emit_sfx_item(sfx_trigger_item);
|
global_state.audio.emit_sfx_item(sfx_trigger_item);
|
||||||
@ -167,7 +163,11 @@ impl SessionState {
|
|||||||
client::Event::Kicked(reason) => {
|
client::Event::Kicked(reason) => {
|
||||||
global_state.info_message = Some(format!(
|
global_state.info_message = Some(format!(
|
||||||
"{}: {}",
|
"{}: {}",
|
||||||
global_state.i18n.read().get("main.login.kicked").to_string(),
|
global_state
|
||||||
|
.i18n
|
||||||
|
.read()
|
||||||
|
.get("main.login.kicked")
|
||||||
|
.to_string(),
|
||||||
reason
|
reason
|
||||||
));
|
));
|
||||||
return Ok(TickAction::Disconnect);
|
return Ok(TickAction::Disconnect);
|
||||||
@ -674,8 +674,13 @@ impl PlayState for SessionState {
|
|||||||
Ok(TickAction::Continue) => {}, // Do nothing
|
Ok(TickAction::Continue) => {}, // Do nothing
|
||||||
Ok(TickAction::Disconnect) => return PlayStateResult::Pop, // Go to main menu
|
Ok(TickAction::Disconnect) => return PlayStateResult::Pop, // Go to main menu
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
global_state.info_message =
|
global_state.info_message = Some(
|
||||||
Some(global_state.i18n.read().get("common.connection_lost").to_owned());
|
global_state
|
||||||
|
.i18n
|
||||||
|
.read()
|
||||||
|
.get("common.connection_lost")
|
||||||
|
.to_owned(),
|
||||||
|
);
|
||||||
error!("[session] Failed to tick the scene: {:?}", err);
|
error!("[session] Failed to tick the scene: {:?}", err);
|
||||||
|
|
||||||
return PlayStateResult::Pop;
|
return PlayStateResult::Pop;
|
||||||
@ -1010,9 +1015,9 @@ impl PlayState for SessionState {
|
|||||||
HudEvent::ChangeLanguage(new_language) => {
|
HudEvent::ChangeLanguage(new_language) => {
|
||||||
global_state.settings.language.selected_language =
|
global_state.settings.language.selected_language =
|
||||||
new_language.language_identifier;
|
new_language.language_identifier;
|
||||||
global_state.i18n = Localization::load_expect(
|
global_state.i18n = Localization::load_expect(&i18n_asset_key(
|
||||||
&i18n_asset_key(&global_state.settings.language.selected_language),
|
&global_state.settings.language.selected_language,
|
||||||
);
|
));
|
||||||
global_state.i18n.read().log_missing_entries();
|
global_state.i18n.read().log_missing_entries();
|
||||||
self.hud.update_fonts(&global_state.i18n.read());
|
self.hud.update_fonts(&global_state.i18n.read());
|
||||||
},
|
},
|
||||||
|
@ -5,7 +5,10 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use common::assets::{self, AssetExt};
|
use common::assets::{self, AssetExt};
|
||||||
use glyph_brush::GlyphBrushBuilder;
|
use glyph_brush::GlyphBrushBuilder;
|
||||||
use std::{borrow::Cow, cell::{RefCell, RefMut}};
|
use std::{
|
||||||
|
borrow::Cow,
|
||||||
|
cell::{RefCell, RefMut},
|
||||||
|
};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
// Multiplied by current window size
|
// Multiplied by current window size
|
||||||
@ -31,13 +34,12 @@ impl assets::Loader<FontAsset> for FontLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl assets::Asset for FontAsset {
|
impl assets::Asset for FontAsset {
|
||||||
const EXTENSION: &'static str = "ttf";
|
|
||||||
type Loader = FontLoader;
|
type Loader = FontLoader;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "ttf";
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_font(specifier: &str) -> Font {
|
pub fn load_font(specifier: &str) -> Font { FontAsset::load_expect(specifier).read().0.clone() }
|
||||||
FontAsset::load_expect(specifier).read().0.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Default)]
|
#[derive(Clone, Copy, Default)]
|
||||||
pub struct FontId(pub(super) glyph_brush::FontId);
|
pub struct FontId(pub(super) glyph_brush::FontId);
|
||||||
@ -142,12 +144,11 @@ impl Cache {
|
|||||||
pub struct RawFont(pub Vec<u8>);
|
pub struct RawFont(pub Vec<u8>);
|
||||||
|
|
||||||
impl From<Vec<u8>> for RawFont {
|
impl From<Vec<u8>> for RawFont {
|
||||||
fn from(raw: Vec<u8>) -> RawFont {
|
fn from(raw: Vec<u8>) -> RawFont { RawFont(raw) }
|
||||||
RawFont(raw)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl assets::Asset for RawFont {
|
impl assets::Asset for RawFont {
|
||||||
const EXTENSION: &'static str = "ttf";
|
|
||||||
type Loader = assets::LoadFrom<Vec<u8>, assets::BytesLoader>;
|
type Loader = assets::LoadFrom<Vec<u8>, assets::BytesLoader>;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "ttf";
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ pub mod component;
|
|||||||
mod renderer;
|
mod renderer;
|
||||||
pub mod widget;
|
pub mod widget;
|
||||||
|
|
||||||
pub use cache::{Font, FontId, RawFont, load_font};
|
pub use cache::{load_font, Font, FontId, RawFont};
|
||||||
pub use graphic::{Id, Rotation};
|
pub use graphic::{Id, Rotation};
|
||||||
pub use iced::Event;
|
pub use iced::Event;
|
||||||
pub use iced_winit::conversion::window_event;
|
pub use iced_winit::conversion::window_event;
|
||||||
|
@ -26,8 +26,8 @@ pub struct IndexOwned {
|
|||||||
colors: Arc<Colors>,
|
colors: Arc<Colors>,
|
||||||
index: Arc<Index>,
|
index: Arc<Index>,
|
||||||
|
|
||||||
/// Stored separatly so `colors` is only updated when `reload_colors_if_changed`
|
/// Stored separatly so `colors` is only updated when
|
||||||
/// is called
|
/// `reload_colors_if_changed` is called
|
||||||
colors_handle: AssetHandle<Arc<Colors>>,
|
colors_handle: AssetHandle<Arc<Colors>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +183,8 @@ pub fn apply_caves_to(canvas: &mut Canvas) {
|
|||||||
&& cave_base < surface_z as i32 - 25
|
&& cave_base < surface_z as i32 - 25
|
||||||
{
|
{
|
||||||
let lottery = Lottery::<SpriteKind>::load_expect("common.cave_scatter").read();
|
let lottery = Lottery::<SpriteKind>::load_expect("common.cave_scatter").read();
|
||||||
let kind = *lottery.choose_seeded(RandomField::new(info.index().seed + 1).get(wpos2d.into()));
|
let kind = *lottery
|
||||||
|
.choose_seeded(RandomField::new(info.index().seed + 1).get(wpos2d.into()));
|
||||||
canvas.map(Vec3::new(wpos2d.x, wpos2d.y, cave_base), |block| {
|
canvas.map(Vec3::new(wpos2d.x, wpos2d.y, cave_base), |block| {
|
||||||
block.with_sprite(kind)
|
block.with_sprite(kind)
|
||||||
});
|
});
|
||||||
|
@ -7,7 +7,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use common::{
|
use common::{
|
||||||
assets::AssetHandle,
|
assets::AssetHandle,
|
||||||
terrain::{Structure, StructuresGroup, Block, BlockKind},
|
terrain::{Block, BlockKind, Structure, StructuresGroup},
|
||||||
vol::ReadVol,
|
vol::ReadVol,
|
||||||
};
|
};
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
@ -24,7 +24,8 @@ lazy_static! {
|
|||||||
static ref BAOBABS: AssetHandle<StructuresGroup> = Structure::load_group("baobabs");
|
static ref BAOBABS: AssetHandle<StructuresGroup> = Structure::load_group("baobabs");
|
||||||
static ref FRUIT_TREES: AssetHandle<StructuresGroup> = Structure::load_group("fruit_trees");
|
static ref FRUIT_TREES: AssetHandle<StructuresGroup> = Structure::load_group("fruit_trees");
|
||||||
static ref BIRCHES: AssetHandle<StructuresGroup> = Structure::load_group("birch");
|
static ref BIRCHES: AssetHandle<StructuresGroup> = Structure::load_group("birch");
|
||||||
static ref MANGROVE_TREES: AssetHandle<StructuresGroup> = Structure::load_group("mangrove_trees");
|
static ref MANGROVE_TREES: AssetHandle<StructuresGroup> =
|
||||||
|
Structure::load_group("mangrove_trees");
|
||||||
static ref QUIRKY: AssetHandle<StructuresGroup> = Structure::load_group("quirky");
|
static ref QUIRKY: AssetHandle<StructuresGroup> = Structure::load_group("quirky");
|
||||||
static ref QUIRKY_DRY: AssetHandle<StructuresGroup> = Structure::load_group("quirky_dry");
|
static ref QUIRKY_DRY: AssetHandle<StructuresGroup> = Structure::load_group("quirky_dry");
|
||||||
static ref SWAMP_TREES: AssetHandle<StructuresGroup> = Structure::load_group("swamp_trees");
|
static ref SWAMP_TREES: AssetHandle<StructuresGroup> = Structure::load_group("swamp_trees");
|
||||||
|
@ -72,8 +72,9 @@ pub struct Colors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl assets::Asset for Colors {
|
impl assets::Asset for Colors {
|
||||||
const EXTENSION: &'static str = "ron";
|
|
||||||
type Loader = assets::RonLoader;
|
type Loader = assets::RonLoader;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "ron";
|
||||||
}
|
}
|
||||||
|
|
||||||
impl World {
|
impl World {
|
||||||
|
@ -246,8 +246,9 @@ pub enum WorldFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl assets::Asset for WorldFile {
|
impl assets::Asset for WorldFile {
|
||||||
const EXTENSION: &'static str = "bin";
|
|
||||||
type Loader = assets::BincodeLoader;
|
type Loader = assets::BincodeLoader;
|
||||||
|
|
||||||
|
const EXTENSION: &'static str = "bin";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Data for the most recent map type. Update this when you add a new map
|
/// Data for the most recent map type. Update this when you add a new map
|
||||||
@ -413,22 +414,24 @@ impl WorldSim {
|
|||||||
|
|
||||||
map.into_modern()
|
map.into_modern()
|
||||||
},
|
},
|
||||||
FileOpts::LoadAsset(ref specifier) => {
|
FileOpts::LoadAsset(ref specifier) => match WorldFile::load_owned(&specifier) {
|
||||||
match WorldFile::load_owned(&specifier) {
|
Ok(map) => map.into_modern(),
|
||||||
Ok(map) => map.into_modern(),
|
Err(err) => {
|
||||||
Err(err) => {
|
match err {
|
||||||
match err {
|
assets::Error::Io(e) => {
|
||||||
assets::Error::Io(e) => {
|
warn!(?e, ?specifier, "Couldn't read asset specifier for maps");
|
||||||
warn!(?e, ?specifier, "Couldn't read asset specifier for maps");
|
},
|
||||||
}
|
assets::Error::Conversion(e) => {
|
||||||
assets::Error::Conversion(e) => {
|
warn!(
|
||||||
warn!(?e, "Couldn't parse modern map. Maybe you meant to try a legacy load?");
|
?e,
|
||||||
}
|
"Couldn't parse modern map. Maybe you meant to try a legacy \
|
||||||
assets::Error::NoDefaultValue => unreachable!(),
|
load?"
|
||||||
}
|
);
|
||||||
return None;
|
},
|
||||||
|
assets::Error::NoDefaultValue => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
return None;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
FileOpts::Generate | FileOpts::Save => return None,
|
FileOpts::Generate | FileOpts::Save => return None,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user