Removed redundant things

This commit is contained in:
Joshua Barretto 2023-04-02 01:09:12 +01:00
parent 33e643fbfd
commit ab5561df61
2 changed files with 20 additions and 23 deletions

Binary file not shown.

View File

@ -1140,18 +1140,18 @@ impl Controls {
// Height of interactable area // Height of interactable area
const SLIDER_HEIGHT: u16 = 30; const SLIDER_HEIGHT: u16 = 30;
fn starter_slider<'a, T: Copy + Into<u32>>( fn starter_slider<'a>(
text: String, text: String,
size: u16, size: u16,
state: &'a mut slider::State, state: &'a mut slider::State,
max: T, max: u32,
selected_val: T, selected_val: u32,
on_change: impl 'static + Fn(u32) -> Message, on_change: impl 'static + Fn(u32) -> Message,
imgs: &Imgs, imgs: &Imgs,
) -> Element<'a, Message> { ) -> Element<'a, Message> {
Column::with_children(vec![ Column::with_children(vec![
Text::new(text).size(size).into(), Text::new(text).size(size).into(),
Slider::new(state, 0..=max.into(), selected_val.into(), on_change) Slider::new(state, 0..=max, selected_val, on_change)
.height(SLIDER_HEIGHT) .height(SLIDER_HEIGHT)
.style(style::slider::Style::images( .style(style::slider::Style::images(
imgs.slider_indicator, imgs.slider_indicator,
@ -1165,19 +1165,19 @@ impl Controls {
.align_items(Align::Center) .align_items(Align::Center)
.into() .into()
} }
fn char_slider<'a, T: Copy + Into<u32>>( fn char_slider<'a>(
text: String, text: String,
state: &'a mut slider::State, state: &'a mut slider::State,
max: T, max: u8,
selected_val: T, selected_val: u8,
on_change: impl 'static + Fn(u32) -> Message, on_change: impl 'static + Fn(u8) -> Message,
(fonts, imgs): (&Fonts, &Imgs), (fonts, imgs): (&Fonts, &Imgs),
) -> Element<'a, Message> { ) -> Element<'a, Message> {
Column::with_children(vec![ Column::with_children(vec![
Text::new(text) Text::new(text)
.size(fonts.cyri.scale(SLIDER_TEXT_SIZE)) .size(fonts.cyri.scale(SLIDER_TEXT_SIZE))
.into(), .into(),
Slider::new(state, 0..=max.into(), selected_val.into(), on_change) Slider::new(state, 0..=max, selected_val, on_change)
.height(SLIDER_HEIGHT) .height(SLIDER_HEIGHT)
.style(style::slider::Style::images( .style(style::slider::Style::images(
imgs.slider_indicator, imgs.slider_indicator,
@ -1191,13 +1191,13 @@ impl Controls {
.align_items(Align::Center) .align_items(Align::Center)
.into() .into()
} }
fn char_slider_greyable<'a, T: Copy + Into<u32>>( fn char_slider_greyable<'a>(
active: bool, active: bool,
text: String, text: String,
state: &'a mut slider::State, state: &'a mut slider::State,
max: T, max: u8,
selected_val: T, selected_val: u8,
on_change: impl 'static + Fn(u32) -> Message, on_change: impl 'static + Fn(u8) -> Message,
(fonts, imgs): (&Fonts, &Imgs), (fonts, imgs): (&Fonts, &Imgs),
) -> Element<'a, Message> { ) -> Element<'a, Message> {
if active { if active {
@ -1237,7 +1237,7 @@ impl Controls {
&mut sliders.hair_style, &mut sliders.hair_style,
body.species.num_hair_styles(body.body_type) - 1, body.species.num_hair_styles(body.body_type) - 1,
body.hair_style, body.hair_style,
|x| Message::HairStyle(x as u8), Message::HairStyle,
(fonts, imgs), (fonts, imgs),
), ),
char_slider( char_slider(
@ -1245,7 +1245,7 @@ impl Controls {
&mut sliders.hair_color, &mut sliders.hair_color,
body.species.num_hair_colors() - 1, body.species.num_hair_colors() - 1,
body.hair_color, body.hair_color,
|x| Message::HairColor(x as u8), Message::HairColor,
(fonts, imgs), (fonts, imgs),
), ),
char_slider( char_slider(
@ -1253,7 +1253,7 @@ impl Controls {
&mut sliders.skin, &mut sliders.skin,
body.species.num_skin_colors() - 1, body.species.num_skin_colors() - 1,
body.skin, body.skin,
|x| Message::Skin(x as u8), Message::Skin,
(fonts, imgs), (fonts, imgs),
), ),
char_slider( char_slider(
@ -1261,7 +1261,7 @@ impl Controls {
&mut sliders.eyes, &mut sliders.eyes,
body.species.num_eyes(body.body_type) - 1, body.species.num_eyes(body.body_type) - 1,
body.eyes, body.eyes,
|x| Message::Eyes(x as u8), Message::Eyes,
(fonts, imgs), (fonts, imgs),
), ),
char_slider( char_slider(
@ -1269,7 +1269,7 @@ impl Controls {
&mut sliders.eye_color, &mut sliders.eye_color,
body.species.num_eye_colors() - 1, body.species.num_eye_colors() - 1,
body.eye_color, body.eye_color,
|x| Message::EyeColor(x as u8), Message::EyeColor,
(fonts, imgs), (fonts, imgs),
), ),
char_slider_greyable( char_slider_greyable(
@ -1278,7 +1278,7 @@ impl Controls {
&mut sliders.accessory, &mut sliders.accessory,
body.species.num_accessories(body.body_type) - 1, body.species.num_accessories(body.body_type) - 1,
body.accessory, body.accessory,
|x| Message::Accessory(x as u8), Message::Accessory,
(fonts, imgs), (fonts, imgs),
), ),
char_slider_greyable( char_slider_greyable(
@ -1287,7 +1287,7 @@ impl Controls {
&mut sliders.beard, &mut sliders.beard,
body.species.num_beards(body.body_type) - 1, body.species.num_beards(body.body_type) - 1,
body.beard, body.beard,
|x| Message::Beard(x as u8), Message::Beard,
(fonts, imgs), (fonts, imgs),
), ),
]) ])