Clippy fixes

This commit is contained in:
Imbris 2020-11-01 01:13:36 -05:00
parent b84815cc0b
commit 64d885a192
10 changed files with 31 additions and 22 deletions

View File

@ -147,7 +147,7 @@ enum Mode {
Create {
name: String, // TODO: default to username
body: humanoid::Body,
loadout: comp::Loadout,
loadout: Box<comp::Loadout>,
tool: &'static str,
body_type_buttons: [button::State; 2],
@ -185,6 +185,8 @@ impl Mode {
.active_item(Some(LoadoutBuilder::default_item_config_from_str(tool)))
.build();
let loadout = Box::new(loadout);
Self::Create {
name,
body: humanoid::Body::random(),
@ -1127,7 +1129,7 @@ impl Controls {
})
.into()
} else {
create.into()
create
};
let bottom = Row::with_children(vec![

View File

@ -258,7 +258,8 @@ impl PlayState for MainMenuState {
&global_state.settings.language.selected_language,
));
localized_strings.log_missing_entries();
self.main_menu_ui.update_language(localized_strings.clone());
self.main_menu_ui
.update_language(std::sync::Arc::clone(&localized_strings));
},
#[cfg(feature = "singleplayer")]
MainMenuEvent::StartSingleplayer => {

View File

@ -139,7 +139,7 @@ impl Screen {
let content = Column::with_children(vec![
text.into(),
Container::new(
Row::with_children(vec![cancel.into(), add.into()])
Row::with_children(vec![cancel, add])
.spacing(20)
.height(Length::Units(25)),
)

View File

@ -51,6 +51,7 @@ impl Screen {
}
}
#[allow(clippy::too_many_arguments)]
pub(super) fn view(
&mut self,
fonts: &Fonts,
@ -155,20 +156,18 @@ impl Screen {
.height(Length::Units(180))
.padding(20)
.into()
} else if is_selecting_language {
self.language_selection.view(
fonts,
imgs,
i18n,
language_metadatas,
selected_language_index,
button_style,
)
} else {
if is_selecting_language {
self.language_selection.view(
fonts,
imgs,
i18n,
language_metadatas,
selected_language_index,
button_style,
)
} else {
self.banner
.view(fonts, imgs, login_info, i18n, button_style)
}
self.banner
.view(fonts, imgs, login_info, i18n, button_style)
};
let central_column = Container::new(central_content)

View File

@ -232,7 +232,7 @@ impl Controls {
}
fn view(&mut self, settings: &Settings, dt: f32) -> Element<Message> {
self.time = self.time + dt as f64;
self.time += dt as f64;
// TODO: consider setting this as the default in the renderer
let button_style = style::button::Style::new(self.imgs.button)

View File

@ -187,7 +187,7 @@ impl IcedUi {
&self.events,
cursor_position,
Some(&self.clipboard),
&mut self.renderer,
&self.renderer,
);
drop(guard);
// Clear events

View File

@ -799,6 +799,7 @@ impl iced::Renderer for IcedRenderer {
// TODO: use graph of primitives to enable diffing???
type Output = (Primitive, iced::mouse::Interaction);
#[allow(clippy::let_and_return)]
fn layout<'a, M>(
&mut self,
element: &iced::Element<'a, M, Self>,

View File

@ -77,6 +77,7 @@ impl slider::Renderer for IcedRenderer {
mouse::Interaction::Idle
};
#[allow(clippy::if_same_then_else)] // TODO: remove
let primitives = if style.labels {
// TODO text label on left and right ends
vec![bar, cursor]

View File

@ -31,9 +31,10 @@ impl text_input::Renderer for IcedRenderer {
};
let mut glyph_calculator = self.cache.glyph_calculator();
let width = glyph_calculator
/* let width = */
glyph_calculator
.glyph_bounds(section)
.map_or(0.0, |rect| rect.width() / p_scale);
.map_or(0.0, |rect| rect.width() / p_scale)
// glyph_brush ignores the exterior spaces
// or does it!!!
@ -75,7 +76,7 @@ impl text_input::Renderer for IcedRenderer {
width += exterior_spaces as f32 * space_width;
}*/
width
//width
}
fn offset(

View File

@ -63,6 +63,10 @@ impl Padding {
}
}
impl Default for Padding {
fn default() -> Self { Self::new() }
}
pub trait Background<R: iced::Renderer>: Sized {
// The intended implementors already store the state accessed in the three
// functions below