-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
199 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,41 @@ | ||
//! Enum for attack indicator. | ||
|
||
use std::fmt::Display; | ||
|
||
use enum_iterator::Sequence; | ||
use rimecraft_text::{format_localization_key, Localizable}; | ||
|
||
use super::ByUSizeId; | ||
|
||
/// Represents the position of the attack indicator. | ||
/// | ||
/// # MCJE Reference | ||
/// | ||
/// This type represents `net.minecraft.client.option.AttackIndicator` (yarn). | ||
#[derive(Debug)] | ||
#[derive(Debug, Sequence)] | ||
pub enum AttackIndicator { | ||
/// No attack indicator. | ||
None, | ||
/// Attack indicator off. | ||
Off, | ||
/// Below crosshair. | ||
Crosshair, | ||
/// Next to hotbar. | ||
Hotbar | ||
} | ||
|
||
impl ByUSizeId for AttackIndicator {} | ||
|
||
impl Display for AttackIndicator { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "{}", match self { | ||
AttackIndicator::Off => "off", | ||
AttackIndicator::Crosshair => "crosshair", | ||
AttackIndicator::Hotbar => "hotbar", | ||
}) | ||
} | ||
} | ||
|
||
impl Localizable for AttackIndicator { | ||
fn localization_key(&self) -> String { | ||
format_localization_key!("options", "attack", format!("{}", self)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,34 @@ | ||
//! Enum for cloud render mode. | ||
|
||
use std::fmt::Display; | ||
|
||
use enum_iterator::Sequence; | ||
|
||
use super::ByUSizeId; | ||
|
||
/// Represents the rendering mode of clouds. | ||
/// | ||
/// # MCJE Reference | ||
/// | ||
/// This type represents `net.minecraft.client.option.CloudRenderMode` (yarn). | ||
#[derive(Debug)] | ||
#[derive(Debug, Sequence)] | ||
pub enum CloudRenderMode { | ||
/// Doesn't render clouds. | ||
Off, | ||
/// Render clouds faster. | ||
Fast, | ||
/// Render clouds fancier. | ||
Fancy | ||
} | ||
|
||
impl ByUSizeId for CloudRenderMode {} | ||
|
||
impl Display for CloudRenderMode { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "{}", match self { | ||
CloudRenderMode::Off => "off", | ||
CloudRenderMode::Fast => "fast", | ||
CloudRenderMode::Fancy => "fancy", | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,41 @@ | ||
//! Enum for graphics mode. | ||
|
||
use std::fmt::Display; | ||
|
||
use enum_iterator::Sequence; | ||
use rimecraft_text::{format_localization_key, Localizable}; | ||
|
||
use super::ByUSizeId; | ||
|
||
/// Represents the mode for graphics. | ||
/// | ||
/// # MCJE Reference | ||
/// | ||
/// This type represents `net.minecraft.client.option.GraphicsMode` (yarn). | ||
#[derive(Debug)] | ||
#[derive(Debug, Sequence)] | ||
pub enum GraphicsMode { | ||
/// The fastest rendering speed with the worst picture. | ||
Fast, | ||
/// Not that fast but with a better picture. | ||
Fancy, | ||
/// Maybe slow, but with the best picture. | ||
Fabulous | ||
} | ||
|
||
impl ByUSizeId for GraphicsMode {} | ||
|
||
impl Display for GraphicsMode { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "{}", match self { | ||
GraphicsMode::Fast => "fast", | ||
GraphicsMode::Fancy => "fancy", | ||
GraphicsMode::Fabulous => "fabulous", | ||
}) | ||
} | ||
} | ||
|
||
impl Localizable for GraphicsMode { | ||
fn localization_key(&self) -> String { | ||
format_localization_key!("options", "graphics", format!("{}", self)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//! Macro rules. | ||
|
||
/// Creates a new localization key with literals. | ||
/// | ||
/// # Examples | ||
/// | ||
/// ``` | ||
/// use rimecraft_identifier::format_localization_key; | ||
/// | ||
/// let key = format_localization_key!( | ||
/// "category", "id", "path" | ||
/// ); | ||
/// assert_eq!("category.id.path", key); | ||
/// ``` | ||
#[macro_export] | ||
macro_rules! format_localization_key { | ||
($($word:expr),*) => { | ||
{ | ||
let mut words: Vec<String> = Vec::new(); | ||
|
||
$( | ||
words.push($word.to_string()); | ||
)* | ||
|
||
words.into_iter().filter(|s| s.len() > 0).collect::<Vec<String>>().join(".") | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters