Skip to main content

LangPackRon

Struct LangPackRon 

Source
pub struct LangPackRon { /* private fields */ }
Expand description

A language pack (lang-pack, .ron), read from its lang.ron in its folder (lang/pt-BR/lang.ron), which is named by its tag as BCP 47 writes it: its ui.ron beside it, checked against the source’s (lang/en/ui.ron, or the folder of the source the game declares, LangPackRon::source_lang), and its data.ron and dialogue/*.ron, checked against the game’s data text when it gives it (LangPackRon::with_data; left out otherwise). Any other file in the folder is an error, and the source’s folder is no pack. Checked as pack_from_files says, with the game’s rules, its limits counting a character of the font atlas’s wide glyphs as two cells when the game gives the atlas (LangPackRon::widths_of), as the pack has them (LangInfo::widths); with the atlas, the wide set its wide_font names must be one the atlas has.

Implementations§

Source§

impl LangPackRon

Source

pub fn new(limits: DialogueLimits, tokens: &'static (dyn Tokens + Sync)) -> Self

Packs whose dialogue fits limits and may use the game’s tokens, with no rules of the game’s for its data text, no variants, no data text to check theirs against, and English as the source.

Source

pub fn source_lang(self, source: SourceLang) -> Self

These packs, of a game written in source: checked against its screen text (<languages>/<code>/ui.ron), its folder no pack.

Source

pub fn widths_of(self, atlas: &FontAtlasDef) -> Self

These packs, their limits counting a character with a wide glyph in atlas as two cells (CellWidths::of), as the screen prints it, and their wide_font naming one of its wide sets.

Source

pub fn data_problem( self, data_problem: fn(&str, &str) -> Option<String>, ) -> Self

These packs, their data text kept to data_problem (PackRules::data_problem).

Source

pub fn variants(self, variants: &'static [&'static str]) -> Self

These packs, whose dialogue entries may have variants (PackRules::variants).

Source

pub fn with_data(self, data: SourceText) -> Self

These packs, their data and dialogue text read and checked against the source text of the game’s data, data.

Trait Implementations§

Source§

impl Debug for LangPackRon

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Format for LangPackRon

Source§

type Asset = LangPack

The kind it reads.
Source§

fn id(&self) -> &'static str

Stable id, e.g. "png", "tiled-tmx", "yarn": one per format of a kind.
Source§

fn extensions(&self) -> &'static [&'static str]

File extensions this format claims, lowercase, without the dot. A format that only stands in another’s place (a one-bit picture at a PNG’s path) claims none and is found by sniff.
Source§

fn max_bytes(&self) -> usize

The most bytes it reads: a bigger file is refused before decode sees it. DEFAULT_MAX_BYTES unless the format says.
Source§

fn decode( &self, file: &AssetPath, bytes: &[u8], cx: &DecodeCx<'_>, ) -> Result<LangPack, Vec<ContentError>>

Every problem found, each with file and place; never a panic.
Source§

fn sniff(&self, bytes: &[u8]) -> bool

True if these bytes look like this format (magic bytes); false when the format has none.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.