diff --git a/src/assets.rs b/src/assets.rs index 352b9a1..d5e3b93 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -1,8 +1,5 @@ //! This module groups all the async loading stuff. -// TODO: https://github.com/rust-lang/rust-clippy/issues/4637 -#![allow(clippy::eval_order_dependence)] - use std::{collections::HashMap, hash::Hash}; use mq::{ diff --git a/src/core/battle.rs b/src/core/battle.rs index 568a476..dc3de3a 100644 --- a/src/core/battle.rs +++ b/src/core/battle.rs @@ -84,17 +84,14 @@ pub struct Id(i32); #[derive(Serialize, Deserialize, Default, Clone, Copy, Debug, PartialEq, PartialOrd)] pub struct Strength(pub i32); -#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, PartialOrd)] +#[derive(Serialize, Deserialize, Default, Clone, Copy, Debug, PartialEq, PartialOrd)] pub enum Weight { + #[default] Normal = 0, + Heavy = 1, - Immovable = 2, -} -impl Default for Weight { - fn default() -> Self { - Weight::Normal - } + Immovable = 2, } impl fmt::Display for Weight { @@ -132,14 +129,10 @@ pub struct Accuracy(pub i32); #[derive(Serialize, Deserialize, Default, Clone, Copy, Debug, PartialEq, PartialOrd)] pub struct Dodge(pub i32); -#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Eq)] +#[derive(Serialize, Deserialize, Default, Debug, Clone, Copy, PartialEq, Eq)] pub enum TileType { + #[default] Plain, - Rocks, -} -impl Default for TileType { - fn default() -> Self { - TileType::Plain - } + Rocks, } diff --git a/src/error.rs b/src/error.rs index 3cb57bf..c5596ae 100644 --- a/src/error.rs +++ b/src/error.rs @@ -2,35 +2,35 @@ use std::{error, fmt, io, path::PathBuf}; #[derive(Debug, derive_more::From)] pub enum ZError { - UiError(ui::Error), - SceneError(zscene::Error), - RonDeserializeError { + Ui(ui::Error), + Scene(zscene::Error), + RonDeserialize { error: ron::de::Error, path: PathBuf, }, - IOError(io::Error), - MqFileError(mq::file::FileError), - MqFontError(mq::text::FontError), + IO(io::Error), + MqFile(mq::file::FileError), + MqFont(mq::text::FontError), } impl ZError { pub fn from_ron_de_error(error: ron::de::Error, path: PathBuf) -> Self { - ZError::RonDeserializeError { error, path } + ZError::RonDeserialize { error, path } } } impl fmt::Display for ZError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - ZError::UiError(ref e) => write!(f, "ZGUI Error: {}", e), - ZError::SceneError(ref e) => write!(f, "ZScene Error: {}", e), - ZError::RonDeserializeError { error, path } => { + ZError::Ui(ref e) => write!(f, "ZGUI Error: {}", e), + ZError::Scene(ref e) => write!(f, "ZScene Error: {}", e), + ZError::RonDeserialize { error, path } => { let s = path.to_str().unwrap_or(""); write!(f, "Can't deserialize '{}': {}", s, error) } - ZError::IOError(ref e) => write!(f, "IO Error: {}", e), - ZError::MqFileError(ref e) => write!(f, "Macroquad File error: {}", e), - ZError::MqFontError(ref e) => write!(f, "Macroquad Font error: {}", e), + ZError::IO(ref e) => write!(f, "IO Error: {}", e), + ZError::MqFile(ref e) => write!(f, "Macroquad File error: {}", e), + ZError::MqFont(ref e) => write!(f, "Macroquad Font error: {}", e), } } } @@ -38,12 +38,12 @@ impl fmt::Display for ZError { impl error::Error for ZError { fn source(&self) -> Option<&(dyn error::Error + 'static)> { match self { - ZError::UiError(ref e) => Some(e), - ZError::SceneError(ref e) => Some(e), - ZError::RonDeserializeError { error, .. } => Some(error), - ZError::IOError(ref e) => Some(e), - ZError::MqFileError(ref e) => Some(e), - ZError::MqFontError(ref e) => Some(e), + ZError::Ui(ref e) => Some(e), + ZError::Scene(ref e) => Some(e), + ZError::RonDeserialize { error, .. } => Some(error), + ZError::IO(ref e) => Some(e), + ZError::MqFile(ref e) => Some(e), + ZError::MqFont(ref e) => Some(e), } } } diff --git a/src/screen/main_menu.rs b/src/screen/main_menu.rs index 7def0b9..1b005cd 100644 --- a/src/screen/main_menu.rs +++ b/src/screen/main_menu.rs @@ -5,7 +5,7 @@ use std::{ use log::trace; use mq::math::Vec2; -use ui::{self, Gui, Widget}; +use ui::{self, Widget}; use crate::{ assets, @@ -16,8 +16,11 @@ use crate::{ #[derive(Copy, Clone, Debug)] enum Message { + #[cfg_attr(target_arch = "wasm32", allow(unused))] // can't quit WASM so it's not used there Exit, + StartInstant, + StartCampaign, } @@ -49,7 +52,7 @@ fn make_gui() -> ZResult> { #[derive(Debug)] pub struct MainMenu { - gui: Gui, + gui: ui::Gui, receiver_battle_result: Option>>, } diff --git a/zgui/src/lib.rs b/zgui/src/lib.rs index 0f2647b..f2b1923 100644 --- a/zgui/src/lib.rs +++ b/zgui/src/lib.rs @@ -116,7 +116,6 @@ impl Drawable { struct Sprite { drawable: Drawable, dimensions: Rect, - basic_scale: f32, pos: Vec2, scale: Vec2, color: Color, @@ -129,7 +128,6 @@ impl Sprite { Self { drawable, dimensions, - basic_scale, pos: Vec2::new(0.0, 0.0), scale: Vec2::new(basic_scale, basic_scale), color: SPRITE_COLOR,