Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Grokmoo committed Jul 17, 2023
1 parent fba0fa5 commit 8c7b200
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 51 deletions.
9 changes: 2 additions & 7 deletions sulis_core/src/ui/layout_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,16 @@ use crate::config::Config;
use crate::ui::theme::Theme;
use crate::ui::{Cursor, Size, Widget};

#[derive(Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Deserialize, Default, Debug, Clone, Copy, PartialEq, Eq)]
pub enum LayoutKind {
#[default]
Normal,
BoxVertical,
BoxHorizontal,
GridRows,
GridColumns,
}

impl Default for LayoutKind {
fn default() -> Self {
LayoutKind::Normal
}
}

impl LayoutKind {
pub fn layout(self, widget: &Widget) {
let theme = Rc::clone(&widget.theme);
Expand Down
47 changes: 11 additions & 36 deletions sulis_core/src/ui/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,66 +25,46 @@ use crate::ui::color::Color;
use crate::ui::{Border, LayoutKind, WidgetState};
use crate::util::{Point, Size};

#[derive(Deserialize, Debug, Clone, Copy, Eq, Hash, PartialEq)]
#[derive(Deserialize, Default, Debug, Clone, Copy, Eq, Hash, PartialEq)]
#[serde(deny_unknown_fields)]
pub enum HorizontalAlignment {
Left,
#[default]
Center,
Right,
}

impl Default for HorizontalAlignment {
fn default() -> Self {
HorizontalAlignment::Center
}
}

#[derive(Deserialize, Debug, Clone, Copy, Eq, Hash, PartialEq)]
#[derive(Deserialize, Default, Debug, Clone, Copy, Eq, Hash, PartialEq)]
#[serde(deny_unknown_fields)]
pub enum VerticalAlignment {
Top,
#[default]
Center,
Bottom,
}

impl Default for VerticalAlignment {
fn default() -> Self {
VerticalAlignment::Center
}
}

#[derive(Deserialize, Debug, Clone, Copy, Eq, Hash, PartialEq)]
#[derive(Deserialize, Default, Debug, Clone, Copy, Eq, Hash, PartialEq)]
#[serde(deny_unknown_fields)]
pub enum SizeRelative {
#[default]
Zero,
Max,
ChildMax,
ChildSum,
Custom,
}

impl Default for SizeRelative {
fn default() -> Self {
SizeRelative::Zero
}
}

#[derive(Deserialize, Debug, Clone, Copy, Eq, Hash, PartialEq)]
#[derive(Deserialize, Default, Debug, Clone, Copy, Eq, Hash, PartialEq)]
#[serde(deny_unknown_fields)]
pub enum PositionRelative {
#[default]
Zero,
Center,
Max,
Custom,
Mouse,
}

impl Default for PositionRelative {
fn default() -> Self {
PositionRelative::Zero
}
}

#[derive(Debug, Clone, Copy)]
pub struct Relative {
pub x: PositionRelative,
Expand Down Expand Up @@ -128,20 +108,15 @@ impl Default for Relative {

pub const DEFAULT_THEME_ID: &str = "default";

#[derive(Deserialize, Debug, Copy, Clone)]
#[derive(Deserialize, Default, Debug, Copy, Clone)]
pub enum Kind {
#[default]
Ref, // a reference to a widget that will be added in rust code, or
// simply used as a building block for another theme item
// simply used as a building block for another theme item
Label, // a widget showing static text - defined purely in the theme
Container, // a widget holding other widgets - defined purely in the theme
}

impl Default for Kind {
fn default() -> Self {
Kind::Ref
}
}

#[derive(Debug)]
pub struct Theme {
pub id: String,
Expand Down
2 changes: 1 addition & 1 deletion sulis_module/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ fn expand_include_directives(scripts: &mut HashMap<String, String>) {
});
}

for mut expansion in &mut expansions {
for expansion in &mut expansions {
let substr = &script[(expansion.start_index + include_len)..];
let mut iter = substr.lines();
let id = match iter.next() {
Expand Down
9 changes: 2 additions & 7 deletions sulis_module/src/rules/bonus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ pub enum BonusKind {
ClassStat { id: String, amount: i32 },
}

#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Serialize, Deserialize, Default, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
#[serde(deny_unknown_fields)]
pub enum Contingent {
/// Bonuses that should always be applied
#[default]
Always,

/// Bonuses that should only be applied to the parent if they have the given
Expand Down Expand Up @@ -109,12 +110,6 @@ pub enum Contingent {
Threatened,
}

impl Default for Contingent {
fn default() -> Contingent {
Contingent::Always
}
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialOrd, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct Bonus {
Expand Down

0 comments on commit 8c7b200

Please sign in to comment.