Skip to content

Commit

Permalink
Clippy/fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
m00nwtchr committed Jul 31, 2024
1 parent 4a45a31 commit fe49ae1
Show file tree
Hide file tree
Showing 21 changed files with 164 additions and 154 deletions.
4 changes: 3 additions & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
hard_tabs = true
hard_tabs = true
imports_granularity = "Crate"
group_imports = "StdExternalCrate"
16 changes: 9 additions & 7 deletions src/component/attributes.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
use cofd::{
character::modifier::ModifierTarget,
prelude::{TraitCategory, *},
};
use iced::{
widget::{column, row, text, Column},
Alignment, Length,
};

use cofd::{character::modifier::ModifierTarget, prelude::TraitCategory, prelude::*};

use crate::i18n::Translate;
use crate::{
fl,
i18n::Translate,
widget::dots::{Shape, SheetDots},
Element, H2_SIZE, TITLE_SPACING,
};

#[derive(Debug, Clone)]
pub struct AttributeBar;

#[derive(Clone)]
#[derive(Clone, Copy)]
pub struct Message(u16, Attribute);

impl AttributeBar {
Expand All @@ -40,9 +42,9 @@ impl AttributeBar {
.spacing(3)
.width(Length::Fill)
.align_items(Alignment::End),
self.mk_attr_col(&character, TraitCategory::Mental),
self.mk_attr_col(&character, TraitCategory::Physical),
self.mk_attr_col(&character, TraitCategory::Social),
self.mk_attr_col(character, TraitCategory::Mental),
self.mk_attr_col(character, TraitCategory::Physical),
self.mk_attr_col(character, TraitCategory::Social),
column![].width(Length::Fill)
]
.spacing(10)
Expand Down
5 changes: 3 additions & 2 deletions src/component/forms.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::{fl, i18n::Translate, Element, INPUT_PADDING};
use cofd::{
character::modifier::ModifierTarget,
prelude::*,
Expand All @@ -14,6 +13,8 @@ use iced::{
Length,
};

use crate::{i18n::Translate, Element, INPUT_PADDING};

#[derive(Debug, Clone)]
pub struct FormsComponent;

Expand Down Expand Up @@ -46,7 +47,7 @@ impl FormsComponent {

if let Splat::Werewolf(..) = &character.splat {
for form in Form::all() {
row = row.push(self.mk_col(form, &character));
row = row.push(self.mk_col(form, character));
}
}

Expand Down
26 changes: 13 additions & 13 deletions src/component/info.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
use iced::widget::{component, container, scrollable, Component};
use cofd::{
character::InfoTrait,
prelude::*,
splat::{Splat, SplatTrait, XSplat, YSplat, ZSplat},
};
use iced::{
widget::{column, pick_list, row, text, text_input, Column},
Alignment, Length,
};
use std::{cell::RefCell, rc::Rc};

use crate::i18n::{Translate, Translated};
use crate::{fl, i18n, Element, INPUT_PADDING};
use cofd::{
character::InfoTrait,
prelude::*,
splat::{Splat, SplatTrait, XSplat, YSplat, ZSplat},
use crate::{
fl, i18n,
i18n::{Translate, Translated},
Element, INPUT_PADDING,
};
use iced::overlay::menu;

#[derive(Debug, Clone)]
pub struct InfoBar;
Expand Down Expand Up @@ -69,7 +69,7 @@ impl InfoBar {
let col3: Element<Message> = match character.splat {
Splat::Mortal(..) => self.mk_info_col(
vec![InfoTrait::Age, InfoTrait::Faction, InfoTrait::GroupName],
&character,
character,
),
_ => {
let mut xsplats = character.splat.xsplats();
Expand Down Expand Up @@ -208,15 +208,15 @@ impl InfoBar {
row![
self.mk_info_col(
vec![InfoTrait::Name, InfoTrait::Player, InfoTrait::Chronicle],
&character
character
),
self.mk_info_col(
vec![
InfoTrait::VirtueAnchor,
InfoTrait::ViceAnchor,
InfoTrait::Concept
],
&character
character
),
col3,
]
Expand All @@ -239,7 +239,7 @@ impl InfoBar {
_ => _trait.translated(),
};

col1 = col1.push(text(format!("{}:", str)));
col1 = col1.push(text(format!("{str}:")));
col2 = col2.push(
text_input("", character.info.get(_trait))
.on_input(move |val| Message::InfoTraitChanged(val, _trait))
Expand Down
14 changes: 7 additions & 7 deletions src/component/integrity.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
use cofd::{character::Wound, prelude::*, splat::Splat};
use iced::{
widget::{column, row, text, text_input, Column},
Alignment, Length,
};

use super::list;
use crate::i18n::Translate;
use crate::widget::{dots, track};
use crate::{
fl,
i18n::Translate,
widget::{
self,
dots::{Shape, SheetDots},
track::HealthTrack,
},
Element, COMPONENT_SPACING, H3_SIZE, INPUT_PADDING, MAX_INPUT_WIDTH, TITLE_SPACING,
};
use cofd::{character::Wound, prelude::*, splat::Splat};
use iced::{
widget::{column, row, text, text_input, Column},
Alignment, Length,
};

#[derive(Debug, Clone)]
pub struct IntegrityComponent;
Expand Down
3 changes: 1 addition & 2 deletions src/component/list.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use iced::widget::{component, Component};
use iced::{
widget::{text, Column},
widget::{component, text, Column, Component},
Alignment, Element, Pixels,
};

Expand Down
16 changes: 6 additions & 10 deletions src/component/merits.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
use cofd::{
prelude::*,
splat::{Merit, SplatTrait},
};
use iced::{
widget::{column, pick_list, row, text, text_input, Column},
Alignment, Length,
};
use std::{cell::RefCell, rc::Rc};

use crate::i18n::Translated;
use crate::widget::dots;
use crate::{
fl, i18n,
i18n::Translate,
i18n::Translated,
widget::dots::{Shape, SheetDots},
Element, H3_SIZE, INPUT_PADDING, TITLE_SPACING,
};
use cofd::{
prelude::*,
splat::{Merit, SplatTrait},
};
use iced::widget::{component, container, overlay, scrollable, Component};

#[derive(Debug, Clone)]
pub struct MeritComponent;
Expand Down Expand Up @@ -96,7 +92,7 @@ impl MeritComponent {
.merits
.iter()
.filter(|(merit, _)| *merit == *e)
.count() == 0 && e.is_available(&character, attributes, skills)
.count() == 0 && e.is_available(character, attributes, skills)
})
.cloned()
.map(Into::into)
Expand Down
1 change: 0 additions & 1 deletion src/component/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ mod traits;

pub use attributes::AttributeBar;
pub use forms::FormsComponent;
pub use info::InfoBar;
pub use integrity::IntegrityComponent;
pub use list::list;
pub use merits::MeritComponent;
Expand Down
25 changes: 14 additions & 11 deletions src/component/skills.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
use std::{cell::RefCell, rc::Rc};

use cofd::splat::mage::{Mage, Ministry, Order};
use cofd::{character::modifier::ModifierTarget, prelude::*, splat::Splat};
use iced::widget::{component, Component};
use cofd::{
character::modifier::ModifierTarget,
prelude::*,
splat::{
mage::{Mage, Ministry, Order},
Splat,
},
};
use iced::{
theme::{self},
widget::{button, checkbox, column, row, text, text_input, Column},
Alignment, Color, Element, Length,
};

use super::list;
use crate::i18n::Translate;
use crate::view::overview::vec_changed;
use crate::{
fl,
widget::dots::{self, Shape, SheetDots},
i18n::Translate,
view::overview::vec_changed,
widget::dots::{Shape, SheetDots},
H2_SIZE, H3_SIZE, TITLE_SPACING,
};

Expand Down Expand Up @@ -83,9 +86,9 @@ impl SkillsComponent {
pub fn view(&self, character: &Character) -> Element<Message> {
column![
text(fl!("skills").to_uppercase()).size(H2_SIZE),
self.mk_skill_col(&character, TraitCategory::Mental),
self.mk_skill_col(&character, TraitCategory::Physical),
self.mk_skill_col(&character, TraitCategory::Social),
self.mk_skill_col(character, TraitCategory::Mental),
self.mk_skill_col(character, TraitCategory::Physical),
self.mk_skill_col(character, TraitCategory::Social),
]
.spacing(10)
// .padding(15)
Expand Down
6 changes: 3 additions & 3 deletions src/component/traits.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::{fl, Element, INPUT_PADDING};
use cofd::{character::ArmorStruct, prelude::*};
use iced::widget::{component, Component};
use iced::{
widget::{column, row, text, text_input},
widget::{column, component, row, text, text_input, Component},
Length,
};

use crate::{fl, Element, INPUT_PADDING};

struct Traits {
size: u16,
speed: u16,
Expand Down
34 changes: 17 additions & 17 deletions src/i18n.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
use cofd::prelude::{Template, VariantName};
use cofd::splat::ability::Ability;
use cofd::splat::changeling::Regalia;
use cofd::splat::werewolf::{HuntersAspect, KuruthTriggers, MoonGift, Rite, ShadowGift, WolfGift};
use cofd::splat::{Merit, NameKey, Splat, SplatKind, XSplat, YSplat, ZSplat};
use cofd::template::mage::Arcanum;
use cofd::template::SupernaturalTolerance;
use cofd::traits::TraitCategory;
use std::{
fmt::{
Display, {self},
},
ops::Deref,
sync::Arc,
};

use cofd::{
character::InfoTrait,
splat::werewolf::Form,
template::{Anchor, Fuel, Integrity},
traits::{attribute::Attribute, skill::Skill, Trait},
prelude::{Template, VariantName},
splat::{
ability::Ability,
changeling::Regalia,
werewolf::{Form, HuntersAspect, KuruthTriggers, MoonGift, Rite, ShadowGift, WolfGift},
Merit, Splat, SplatKind, XSplat, YSplat, ZSplat,
},
template::{mage::Arcanum, Anchor, Fuel, Integrity, SupernaturalTolerance},
traits::{attribute::Attribute, skill::Skill, Trait, TraitCategory},
};
use i18n_embed::{
fluent::{fluent_language_loader, FluentLanguageLoader},
DefaultLocalizer, LanguageLoader, LanguageRequester, Localizer,
};
use once_cell::sync::Lazy;
use rust_embed::RustEmbed;
use std::fmt::Display;
use std::ops::Deref;
use std::{
fmt::{self},
sync::Arc,
};

#[derive(RustEmbed)]
#[folder = "i18n"] // path to the compiled localization resources
Expand Down
23 changes: 11 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,30 @@
clippy::default_trait_access
)]

use std::{
fmt::{Debug, Formatter},
mem,
};

use cofd::prelude::*;
use iced::{
executor,
widget::{button, column, row, Column},
Alignment, Application, Command, Element, Length, Settings, Size, Theme,
widget::{button, column},
Alignment, Application, Command, Element, Length, Settings, Theme,
};
#[cfg(target_arch = "wasm32")]
use log::Level;
use std::cell::{Ref, RefMut};
use std::fmt::{Debug, Formatter};
use std::{cell::RefCell, mem, rc::Rc};

mod component;
mod i18n;
mod store;
mod view;
mod widget;

use crate::view::character_list::CharacterList;
use crate::view::sheet::SheetView;
use crate::view::*;
use store::Store;

use crate::view::{character_list::CharacterList, sheet::SheetView, *};

const H2_SIZE: u16 = 25;
const H3_SIZE: u16 = 20;

Expand Down Expand Up @@ -188,8 +189,7 @@ impl Application for PlayerCompanionApp {

#[cfg(target_arch = "wasm32")]
{
use iced::window;
use iced::window::Id;
use iced::{window, window::Id};
let window = web_sys::window().unwrap();
let (width, height) = (
window.inner_width().unwrap().as_f64().unwrap() as f32,
Expand Down Expand Up @@ -238,7 +238,7 @@ mod demo {
use cofd::{
character::CharacterInfo,
prelude::*,
splat::{changeling::*, geist::*, mage::*, vampire::*, werewolf::*, Merit, Splat},
splat::{changeling::*, geist::*, mage::*, vampire::*, werewolf::*, Merit},
};

#[allow(unused_imports)]
Expand Down Expand Up @@ -569,7 +569,6 @@ mod demo {
presence: 2,
manipulation: 3,
composure: 2,
..Default::default()
})
.with_skills(Skills {
academics: 1,
Expand Down
Loading

0 comments on commit fe49ae1

Please sign in to comment.