Skip to content

Commit

Permalink
[#72] Add example
Browse files Browse the repository at this point in the history
  • Loading branch information
Orchaldir committed Sep 17, 2023
1 parent 6ef4d84 commit d60ec4d
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 6 deletions.
2 changes: 2 additions & 0 deletions rpg_tools_core/src/model/equipment/appearance/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::model::equipment::appearance::pants::Pants;
use crate::model::equipment::appearance::shirt::Shirt;
use macro_ui::ui;
use serde::{Deserialize, Serialize};

Expand All @@ -12,5 +13,6 @@ pub enum Clothing {
None,
Simple {
pants: Pants,
shirt: Shirt,
},
}
4 changes: 2 additions & 2 deletions rpg_tools_core/src/model/equipment/appearance/shirt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
/// The shirt of the [`character`](crate::model::character::Character).
#[derive(ui, Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct Shirt {
pub sleeves: Sleeves,
pub sleeve_style: SleeveStyle,
pub neckline: Neckline,
pub color: Color,
}
Expand All @@ -24,7 +24,7 @@ pub enum Neckline {

/// What style of sleeves?
#[derive(Convert, ui, Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum Sleeves {
pub enum SleeveStyle {
#[default]
Long,
None,
Expand Down
8 changes: 5 additions & 3 deletions rpg_tools_rendering/examples/pants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ extern crate rpg_tools_rendering;

use crate::utils::render::render_2_sets;
use rpg_tools_core::model::character::appearance::body::{Body, BodyShape};
use rpg_tools_core::model::character::appearance::head::Head;
use rpg_tools_core::model::character::appearance::Appearance;
use rpg_tools_core::model::color::Color;
use rpg_tools_core::model::equipment::appearance::pants::{Pants, PantsStyle};
Expand Down Expand Up @@ -42,9 +41,12 @@ fn create_appearance(height: Length, pants: &Pants, shape: &BodyShape) -> Appear
shape: *shape,
width: Width::default(),
skin: Default::default(),
clothing: Clothing::Simple { pants: *pants },
clothing: Clothing::Simple {
pants: *pants,
shirt: Default::default(),
},
},
Head::default(),
Default::default(),
height,
)
}
50 changes: 50 additions & 0 deletions rpg_tools_rendering/examples/shirts.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
extern crate rpg_tools_core;
extern crate rpg_tools_rendering;

use crate::utils::render::render_2_sets;
use rpg_tools_core::model::character::appearance::body::{Body, BodyShape};
use rpg_tools_core::model::character::appearance::Appearance;
use rpg_tools_core::model::equipment::appearance::shirt::{Neckline, Shirt, SleeveStyle};
use rpg_tools_core::model::equipment::appearance::Clothing;
use rpg_tools_core::model::length::Length;
use rpg_tools_core::model::width::Width;

pub mod utils;

fn main() {
let mut shirts = vec![];

for neckline in Neckline::get_all() {
for sleeve_style in SleeveStyle::get_all() {
shirts.push(Shirt {
sleeve_style,
neckline,
color: Default::default(),
})
}
}

render_2_sets(
"shirts.svg",
shirts,
BodyShape::get_all(),
create_appearance,
false,
);
}

fn create_appearance(height: Length, shirt: &Shirt, shape: &BodyShape) -> Appearance {
Appearance::humanoid(
Body {
shape: *shape,
width: Width::default(),
skin: Default::default(),
clothing: Clothing::Simple {
pants: Default::default(),
shirt: *shirt,
},
},
Default::default(),
height,
)
}
2 changes: 1 addition & 1 deletion rpg_tools_rendering/src/rendering/equipment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn render_clothing(
aabb: &AABB,
body: &Body,
) {
if let Clothing::Simple { pants } = &body.clothing {
if let Clothing::Simple { pants, .. } = &body.clothing {
render_pants(renderer, config, aabb, body, pants)
}
}

0 comments on commit d60ec4d

Please sign in to comment.