Merge branch 'pfau/fix-char-creation' into 'master'

Fixed char select bugs, improved code quality

See merge request veloren/veloren!739
This commit is contained in:
Joshua Barretto 2020-01-20 23:20:22 +00:00
commit 2ddb6d362e
4 changed files with 972 additions and 929 deletions

View File

@ -65,12 +65,14 @@ impl PlayState for CharSelectionState {
return PlayStateResult::Pop;
}
ui::Event::Play => {
let char_data = self
.char_selection_ui
.get_character_data()
.expect("Character data is required to play");
self.client.borrow_mut().request_character(
self.char_selection_ui.character_name.clone(),
comp::Body::Humanoid(self.char_selection_ui.character_body),
self.char_selection_ui
.character_tool
.map(|specifier| specifier.to_owned()),
char_data.name,
char_data.body,
char_data.tool,
);
return PlayStateResult::Push(Box::new(SessionState::new(
global_state,
@ -83,23 +85,32 @@ impl PlayState for CharSelectionState {
// Maintain global state.
global_state.maintain(clock.get_last_delta().as_secs_f32());
let humanoid_body = self
.char_selection_ui
.get_character_data()
.and_then(|data| match data.body {
comp::Body::Humanoid(body) => Some(body),
_ => None,
});
// Maintain the scene.
self.scene.maintain(
global_state.window.renderer_mut(),
&self.client.borrow(),
self.char_selection_ui.character_body,
humanoid_body.clone(),
);
// Render the scene.
self.scene.render(
global_state.window.renderer_mut(),
&self.client.borrow(),
self.char_selection_ui.character_body,
humanoid_body.clone(),
&comp::Equipment {
main: self
.char_selection_ui
.character_tool
.and_then(|specifier| assets::load_cloned(&specifier).ok()),
.get_character_data()
.and_then(|data| data.tool)
.and_then(|tool| assets::load_cloned(&tool).ok()),
alt: None,
},
);

View File

@ -115,7 +115,12 @@ impl Scene {
}
}
pub fn maintain(&mut self, renderer: &mut Renderer, client: &Client, body: humanoid::Body) {
pub fn maintain(
&mut self,
renderer: &mut Renderer,
client: &Client,
body: Option<humanoid::Body>,
) {
self.camera.set_focus_pos(Vec3::unit_z() * 1.5);
self.camera.update(client.state().get_time());
self.camera.set_distance(3.0); // 4.2
@ -147,6 +152,7 @@ impl Scene {
self.figure_model_cache.clean(client.get_tick());
if let Some(body) = body {
let tgt_skeleton = IdleAnimation::update_skeleton(
self.figure_state.skeleton_mut(),
client.state().get_time(),
@ -158,6 +164,7 @@ impl Scene {
&tgt_skeleton,
client.state().ecs().read_resource::<DeltaTime>().0,
);
}
self.figure_state.update(
renderer,
@ -178,11 +185,12 @@ impl Scene {
&mut self,
renderer: &mut Renderer,
client: &Client,
body: humanoid::Body,
body: Option<humanoid::Body>,
equipment: &Equipment,
) {
renderer.render_skybox(&self.skybox.model, &self.globals, &self.skybox.locals);
if let Some(body) = body {
let model = &self
.figure_model_cache
.get_or_create_model(
@ -203,6 +211,7 @@ impl Scene {
&self.lights,
&self.shadows,
);
}
renderer.render_figure(
&self.backdrop_model,

View File

@ -250,19 +250,31 @@ enum InfoContent {
//Name,
}
pub enum Mode {
Select(Option<CharacterData>),
Create {
name: String,
body: humanoid::Body,
tool: Option<&'static str>,
},
}
pub struct CharSelectionUi {
ui: Ui,
ids: Ids,
imgs: Imgs,
rot_imgs: ImgsRot,
fonts: Fonts,
character_creation: bool,
//character_creation: bool,
info_content: InfoContent,
selected_language: String,
//deletion_confirmation: bool,
/*
pub character_name: String,
pub character_body: humanoid::Body,
pub character_tool: Option<&'static str>,
*/
pub mode: Mode,
}
impl CharSelectionUi {
@ -288,12 +300,27 @@ impl CharSelectionUi {
rot_imgs,
fonts,
info_content: InfoContent::None,
selected_language: global_state.settings.language.selected_language.clone(),
//deletion_confirmation: false,
/*
character_creation: false,
selected_language: global_state.settings.language.selected_language.clone(),
character_name: "Character Name".to_string(),
character_body: humanoid::Body::random(),
character_tool: Some(STARTER_SWORD),
*/
mode: Mode::Select(None),
}
}
pub fn get_character_data(&self) -> Option<CharacterData> {
match &self.mode {
Mode::Select(data) => data.clone(),
Mode::Create { name, body, tool } => Some(CharacterData {
name: name.clone(),
body: comp::Body::Humanoid(body.clone()),
tool: tool.map(|specifier| specifier.to_string()),
}),
}
}
@ -372,6 +399,7 @@ impl CharSelectionUi {
.press_image(self.imgs.button_press)
.label_y(Relative::Scalar(2.0))
.label(&localized_strings.get("common.yes"))
.label_font_id(self.fonts.cyri)
.label_font_size(18)
.label_color(TEXT_COLOR)
.set(self.ids.info_ok, ui_widgets)
@ -384,21 +412,18 @@ impl CharSelectionUi {
}
}
// Character Selection /////////////////
if !self.character_creation {
match &mut self.mode {
Mode::Select(data) => {
// Set active body
self.character_body = if let Some(character) = global_state
*data = if let Some(character) = global_state
.meta
.characters
.get(global_state.meta.selected_character)
{
match character.body {
comp::Body::Humanoid(body) => Some(body.clone()),
_ => None,
}
Some(character.clone())
} else {
None
}
.unwrap_or_else(|| humanoid::Body::random());
};
// Background for Server Frame
Rectangle::fill_with([386.0, 95.0], color::rgba(0.0, 0.0, 0.0, 0.9))
@ -492,7 +517,7 @@ impl CharSelectionUi {
.w_h(270.0, 50.0)
.hover_image(self.imgs.button_hover)
.press_image(self.imgs.button_press)
.label(&localized_strings.get("char_selection.create_charater"))
.label("Create Character")
.label_font_id(self.fonts.cyri)
.label_color(TEXT_COLOR)
.label_font_size(20)
@ -532,13 +557,18 @@ impl CharSelectionUi {
// Character selection
for (i, character) in global_state.meta.characters.iter().enumerate() {
let character_box = Button::image(if global_state.meta.selected_character == i {
let character_box =
Button::image(if global_state.meta.selected_character == i {
self.imgs.selection_hover
} else {
self.imgs.selection
});
let character_box = if i == 0 {
character_box.top_left_with_margins_on(self.ids.charlist_alignment, 0.0, 2.0)
character_box.top_left_with_margins_on(
self.ids.charlist_alignment,
0.0,
2.0,
)
} else {
character_box.down_from(self.ids.character_boxes[i - 1], 5.0)
};
@ -552,11 +582,6 @@ impl CharSelectionUi {
.set(self.ids.character_boxes[i], ui_widgets)
.was_clicked()
{
self.character_name = character.name.clone();
self.character_body = match &character.body {
comp::Body::Humanoid(body) => body.clone(),
_ => panic!("Unsupported body type!"),
};
global_state.meta.selected_character = i;
}
if Button::image(self.imgs.delete_button)
@ -564,7 +589,12 @@ impl CharSelectionUi {
.top_right_with_margins_on(self.ids.character_boxes[i], 15.0, 15.0)
.hover_image(self.imgs.delete_button_hover)
.press_image(self.imgs.delete_button_press)
.with_tooltip(tooltip_manager, "Delete Character", "", &tooltip_human)
.with_tooltip(
tooltip_manager,
&localized_strings.get("char_selection.delete_permanently"),
"",
&tooltip_human,
)
.set(self.ids.character_deletes[i], ui_widgets)
.was_clicked()
{
@ -598,7 +628,11 @@ impl CharSelectionUi {
let create_char_button = if character_count > 0 {
create_char_button.down_from(self.ids.character_boxes[character_count - 1], 5.0)
} else {
create_char_button.top_left_with_margins_on(self.ids.charlist_alignment, 0.0, 2.0)
create_char_button.top_left_with_margins_on(
self.ids.charlist_alignment,
0.0,
2.0,
)
};
if create_char_button
@ -612,13 +646,16 @@ impl CharSelectionUi {
.set(self.ids.character_box_2, ui_widgets)
.was_clicked()
{
self.character_creation = true;
self.character_tool = Some(STARTER_SWORD);
self.character_body = humanoid::Body::random();
self.mode = Mode::Create {
name: "Character Name".to_string(),
body: humanoid::Body::random(),
tool: Some(STARTER_SWORD),
};
}
}
// Character_Creation //////////////////////////////////////////////////////////////////////
else {
Mode::Create { name, body, tool } => {
let mut to_select = false;
// Back Button
if Button::image(self.imgs.button)
.bottom_left_with_margins_on(ui_widgets.window, 10.0, 10.0)
@ -633,7 +670,7 @@ impl CharSelectionUi {
.set(self.ids.back_button, ui_widgets)
.was_clicked()
{
self.character_creation = false;
to_select = true;
}
// Create Button
if Button::image(self.imgs.button)
@ -650,11 +687,12 @@ impl CharSelectionUi {
.was_clicked()
{
// TODO: Save character.
self.character_creation = false;
global_state.meta.add_character(CharacterData {
name: self.character_name.clone(),
body: comp::Body::Humanoid(self.character_body.clone()),
name: name.clone(),
body: comp::Body::Humanoid(body.clone()),
tool: tool.map(|tool| tool.to_string()),
});
to_select = true;
}
// Character Name Input
Rectangle::fill_with([320.0, 50.0], color::rgba(0.0, 0.0, 0.0, 0.97))
@ -665,7 +703,7 @@ impl CharSelectionUi {
.w_h(337.0, 67.0)
.middle_of(self.ids.name_input_bg)
.set(self.ids.name_input, ui_widgets);
for event in TextBox::new(&self.character_name)
for event in TextBox::new(name)
.w_h(300.0, 60.0)
.mid_top_with_margin_on(self.ids.name_input, 2.0)
.font_size(26)
@ -678,9 +716,7 @@ impl CharSelectionUi {
.set(self.ids.name_field, ui_widgets)
{
match event {
TextBoxEvent::Update(name) => {
self.character_name = name;
}
TextBoxEvent::Update(new_name) => *name = new_name,
TextBoxEvent::Enter => {}
}
}
@ -725,42 +761,38 @@ impl CharSelectionUi {
.w_h(70.0, 70.0)
.top_left_with_margins_on(self.ids.creation_buttons_alignment_1, 0.0, 0.0)
.set(self.ids.male, ui_widgets);
if Button::image(
if let humanoid::BodyType::Male = self.character_body.body_type {
if Button::image(if let humanoid::BodyType::Male = body.body_type {
self.imgs.icon_border_pressed
} else {
self.imgs.icon_border
},
)
})
.middle_of(self.ids.male)
.hover_image(self.imgs.icon_border_mo)
.press_image(self.imgs.icon_border_press)
.set(self.ids.body_type_1, ui_widgets)
.was_clicked()
{
self.character_body.body_type = humanoid::BodyType::Male;
self.character_body.validate();
body.body_type = humanoid::BodyType::Male;
body.validate();
}
// Female
Image::new(self.imgs.female)
.w_h(70.0, 70.0)
.top_right_with_margins_on(self.ids.creation_buttons_alignment_1, 0.0, 0.0)
.set(self.ids.female, ui_widgets);
if Button::image(
if let humanoid::BodyType::Female = self.character_body.body_type {
if Button::image(if let humanoid::BodyType::Female = body.body_type {
self.imgs.icon_border_pressed
} else {
self.imgs.icon_border
},
)
})
.middle_of(self.ids.female)
.hover_image(self.imgs.icon_border_mo)
.press_image(self.imgs.icon_border_press)
.set(self.ids.body_type_2, ui_widgets)
.was_clicked()
{
self.character_body.body_type = humanoid::BodyType::Female;
self.character_body.validate();
body.body_type = humanoid::BodyType::Female;
body.validate();
}
// Alignment for Races and Tools
@ -769,7 +801,7 @@ impl CharSelectionUi {
.set(self.ids.creation_buttons_alignment_2, ui_widgets);
let (human_icon, orc_icon, dwarf_icon, elf_icon, undead_icon, danari_icon) =
match self.character_body.body_type {
match body.body_type {
humanoid::BodyType::Male => (
self.imgs.human_m,
self.imgs.orc_m,
@ -792,7 +824,7 @@ impl CharSelectionUi {
.w_h(70.0, 70.0)
.top_left_with_margins_on(self.ids.creation_buttons_alignment_2, 0.0, 0.0)
.set(self.ids.human, ui_widgets);
if Button::image(if let humanoid::Race::Human = self.character_body.race {
if Button::image(if let humanoid::Race::Human = body.race {
self.imgs.icon_border_pressed
} else {
self.imgs.icon_border
@ -807,7 +839,7 @@ impl CharSelectionUi {
&tooltip_human,
)
/*.tooltip_image(
if let humanoid::BodyType::Male = self.character_body.body_type {
if let humanoid::BodyType::Male = body.body_type {
self.imgs.human_m
} else {
self.imgs.human_f
@ -816,8 +848,8 @@ impl CharSelectionUi {
.set(self.ids.race_1, ui_widgets)
.was_clicked()
{
self.character_body.race = humanoid::Race::Human;
self.character_body.validate();
body.race = humanoid::Race::Human;
body.validate();
}
// Orc
@ -825,7 +857,7 @@ impl CharSelectionUi {
.w_h(70.0, 70.0)
.right_from(self.ids.human, 2.0)
.set(self.ids.orc, ui_widgets);
if Button::image(if let humanoid::Race::Orc = self.character_body.race {
if Button::image(if let humanoid::Race::Orc = body.race {
self.imgs.icon_border_pressed
} else {
self.imgs.icon_border
@ -842,15 +874,15 @@ impl CharSelectionUi {
.set(self.ids.race_2, ui_widgets)
.was_clicked()
{
self.character_body.race = humanoid::Race::Orc;
self.character_body.validate();
body.race = humanoid::Race::Orc;
body.validate();
}
// Dwarf
Image::new(dwarf_icon)
.w_h(70.0, 70.0)
.right_from(self.ids.orc, 2.0)
.set(self.ids.dwarf, ui_widgets);
if Button::image(if let humanoid::Race::Dwarf = self.character_body.race {
if Button::image(if let humanoid::Race::Dwarf = body.race {
self.imgs.icon_border_pressed
} else {
self.imgs.icon_border
@ -867,15 +899,15 @@ impl CharSelectionUi {
.set(self.ids.race_3, ui_widgets)
.was_clicked()
{
self.character_body.race = humanoid::Race::Dwarf;
self.character_body.validate();
body.race = humanoid::Race::Dwarf;
body.validate();
}
// Elf
Image::new(elf_icon)
.w_h(70.0, 70.0)
.down_from(self.ids.human, 2.0)
.set(self.ids.elf, ui_widgets);
if Button::image(if let humanoid::Race::Elf = self.character_body.race {
if Button::image(if let humanoid::Race::Elf = body.race {
self.imgs.icon_border_pressed
} else {
self.imgs.icon_border
@ -892,15 +924,16 @@ impl CharSelectionUi {
.set(self.ids.race_4, ui_widgets)
.was_clicked()
{
self.character_body.race = humanoid::Race::Elf;
self.character_body.validate();
body.race = humanoid::Race::Elf;
body.validate();
}
// Undead
Image::new(undead_icon)
.w_h(70.0, 70.0)
.right_from(self.ids.elf, 2.0)
.set(self.ids.undead, ui_widgets);
if Button::image(if let humanoid::Race::Undead = self.character_body.race {
if Button::image(if let humanoid::Race::Undead = body.race {
self.imgs.icon_border_pressed
} else {
self.imgs.icon_border
@ -917,15 +950,15 @@ impl CharSelectionUi {
.set(self.ids.race_5, ui_widgets)
.was_clicked()
{
self.character_body.race = humanoid::Race::Undead;
self.character_body.validate();
body.race = humanoid::Race::Undead;
body.validate();
}
// Danari
Image::new(danari_icon)
.w_h(70.0, 70.0)
.right_from(self.ids.undead, 2.0)
.set(self.ids.danari, ui_widgets);
if Button::image(if let humanoid::Race::Danari = self.character_body.race {
if Button::image(if let humanoid::Race::Danari = body.race {
self.imgs.icon_border_pressed
} else {
self.imgs.icon_border
@ -942,17 +975,16 @@ impl CharSelectionUi {
.set(self.ids.race_6, ui_widgets)
.was_clicked()
{
self.character_body.race = humanoid::Race::Danari;
self.character_body.validate();
body.race = humanoid::Race::Danari;
body.validate();
}
// Hammer
Image::new(self.imgs.hammer)
.w_h(70.0, 70.0)
.bottom_left_with_margins_on(self.ids.creation_buttons_alignment_2, 0.0, 0.0)
.set(self.ids.hammer, ui_widgets);
if Button::image(if let Some(STARTER_HAMMER) = self.character_tool {
if Button::image(if let Some(STARTER_HAMMER) = tool {
self.imgs.icon_border_pressed
} else {
self.imgs.icon_border
@ -969,7 +1001,7 @@ impl CharSelectionUi {
.set(self.ids.hammer_button, ui_widgets)
.was_clicked()
{
self.character_tool = Some(STARTER_HAMMER);
*tool = Some(STARTER_HAMMER);
}
// REMOVE THIS AFTER IMPLEMENTATION
/*Rectangle::fill_with([67.0, 67.0], color::rgba(0.0, 0.0, 0.0, 0.8))
@ -977,12 +1009,11 @@ impl CharSelectionUi {
.set(self.ids.hammer_grey, ui_widgets);*/
// Bow
Image::new(self.imgs.bow)
.w_h(70.0, 70.0)
.right_from(self.ids.hammer, 2.0)
.set(self.ids.bow, ui_widgets);
if Button::image(if let Some(STARTER_BOW) = self.character_tool {
if Button::image(if let Some(STARTER_BOW) = tool {
self.imgs.icon_border_pressed
} else {
self.imgs.icon_border
@ -999,7 +1030,7 @@ impl CharSelectionUi {
.set(self.ids.bow_button, ui_widgets)
.was_clicked()
{
self.character_tool = Some(STARTER_BOW);
*tool = Some(STARTER_BOW);
}
// REMOVE THIS AFTER IMPLEMENTATION
/*Rectangle::fill_with([67.0, 67.0], color::rgba(0.0, 0.0, 0.0, 0.8))
@ -1010,7 +1041,7 @@ impl CharSelectionUi {
.w_h(70.0, 70.0)
.right_from(self.ids.bow, 2.0)
.set(self.ids.staff, ui_widgets);
if Button::image(if let Some(STARTER_STAFF) = self.character_tool {
if Button::image(if let Some(STARTER_STAFF) = tool {
self.imgs.icon_border_pressed
} else {
self.imgs.icon_border
@ -1027,7 +1058,7 @@ impl CharSelectionUi {
.set(self.ids.staff_button, ui_widgets)
.was_clicked()
{
self.character_tool = Some(STARTER_STAFF);
*tool = Some(STARTER_STAFF);
}
// REMOVE THIS AFTER IMPLEMENTATION
/*Rectangle::fill_with([67.0, 67.0], color::rgba(0.0, 0.0, 0.0, 0.8))
@ -1038,7 +1069,7 @@ impl CharSelectionUi {
.w_h(70.0, 70.0)
.up_from(self.ids.hammer, 2.0)
.set(self.ids.sword, ui_widgets);
if Button::image(if let Some(STARTER_SWORD) = self.character_tool {
if Button::image(if let Some(STARTER_SWORD) = tool {
self.imgs.icon_border_pressed
} else {
self.imgs.icon_border
@ -1055,7 +1086,7 @@ impl CharSelectionUi {
.set(self.ids.sword_button, ui_widgets)
.was_clicked()
{
self.character_tool = Some(STARTER_SWORD);
*tool = Some(STARTER_SWORD);
}
// Daggers
@ -1063,7 +1094,7 @@ impl CharSelectionUi {
.w_h(70.0, 70.0)
.right_from(self.ids.sword, 2.0)
.set(self.ids.daggers, ui_widgets);
if Button::image(if let Some(STARTER_DAGGER) = self.character_tool {
if Button::image(if let Some(STARTER_DAGGER) = tool {
self.imgs.icon_border_pressed
} else {
self.imgs.icon_border
@ -1086,7 +1117,7 @@ impl CharSelectionUi {
.w_h(70.0, 70.0)
.right_from(self.ids.daggers, 2.0)
.set(self.ids.axe, ui_widgets);
if Button::image(if let Some(STARTER_AXE) = self.character_tool {
if Button::image(if let Some(STARTER_AXE) = tool {
self.imgs.icon_border_pressed
} else {
self.imgs.icon_border
@ -1103,7 +1134,7 @@ impl CharSelectionUi {
.set(self.ids.axe_button, ui_widgets)
.was_clicked()
{
self.character_tool = Some(STARTER_AXE);
*tool = Some(STARTER_AXE);
}
// REMOVE THIS AFTER IMPLEMENTATION
/*Rectangle::fill_with([67.0, 67.0], color::rgba(0.0, 0.0, 0.0, 0.8))
@ -1123,7 +1154,7 @@ impl CharSelectionUi {
selected_val,
slider_id,
ui_widgets: &mut UiCell| {
Text::new(&text.clone())
Text::new(&text)
.down_from(prev_id, 22.0)
.align_middle_x_of(prev_id)
.font_size(18)
@ -1144,42 +1175,39 @@ impl CharSelectionUi {
self.ids.creation_buttons_alignment_2,
localized_strings.get("char_selection.hair_style"),
self.ids.hairstyle_text,
self.character_body
.race
.num_hair_styles(self.character_body.body_type) as usize
- 1,
self.character_body.hair_style as usize,
body.race.num_hair_styles(body.body_type) as usize - 1,
body.hair_style as usize,
self.ids.hairstyle_slider,
ui_widgets,
) {
self.character_body.hair_style = new_val as u8;
body.hair_style = new_val as u8;
}
// Hair Color
if let Some(new_val) = char_slider(
self.ids.hairstyle_slider,
localized_strings.get("char_selection.hair_color"),
self.ids.haircolor_text,
self.character_body.race.num_hair_colors() as usize - 1,
self.character_body.hair_color as usize,
body.race.num_hair_colors() as usize - 1,
body.hair_color as usize,
self.ids.haircolor_slider,
ui_widgets,
) {
self.character_body.hair_color = new_val as u8;
body.hair_color = new_val as u8;
}
// Skin
if let Some(new_val) = char_slider(
self.ids.haircolor_slider,
localized_strings.get("char_selection.skin"),
self.ids.skin_text,
self.character_body.race.num_skin_colors() as usize - 1,
self.character_body.skin as usize,
body.race.num_skin_colors() as usize - 1,
body.skin as usize,
self.ids.skin_slider,
ui_widgets,
) {
self.character_body.skin = new_val as u8;
body.skin = new_val as u8;
}
// Eyebrows
let current_eyebrows = self.character_body.eyebrows;
let current_eyebrows = body.eyebrows;
if let Some(new_val) = char_slider(
self.ids.skin_slider,
localized_strings.get("char_selection.eyebrows"),
@ -1192,56 +1220,45 @@ impl CharSelectionUi {
self.ids.eyebrows_slider,
ui_widgets,
) {
self.character_body.eyebrows = humanoid::ALL_EYEBROWS[new_val];
body.eyebrows = humanoid::ALL_EYEBROWS[new_val];
}
// EyeColor
if let Some(new_val) = char_slider(
self.ids.eyebrows_slider,
localized_strings.get("char_selection.eye_color"),
self.ids.eyecolor_text,
self.character_body.race.num_eye_colors() as usize - 1,
self.character_body.eye_color as usize,
body.race.num_eye_colors() as usize - 1,
body.eye_color as usize,
self.ids.eyecolor_slider,
ui_widgets,
) {
self.character_body.eye_color = new_val as u8;
body.eye_color = new_val as u8;
}
// Accessories
let _current_accessory = self.character_body.accessory;
let _current_accessory = body.accessory;
if let Some(new_val) = char_slider(
self.ids.eyecolor_slider,
localized_strings.get("char_selection.accessories"),
self.ids.accessories_text,
self.character_body
.race
.num_accessories(self.character_body.body_type) as usize
- 1,
self.character_body.accessory as usize,
body.race.num_accessories(body.body_type) as usize - 1,
body.accessory as usize,
self.ids.accessories_slider,
ui_widgets,
) {
self.character_body.accessory = new_val as u8;
body.accessory = new_val as u8;
}
// Beard
if self
.character_body
.race
.num_beards(self.character_body.body_type)
> 1
{
if body.race.num_beards(body.body_type) > 1 {
if let Some(new_val) = char_slider(
self.ids.accessories_slider,
localized_strings.get("char_selection.beard"),
self.ids.beard_text,
self.character_body
.race
.num_beards(self.character_body.body_type) as usize
- 1,
self.character_body.beard as usize,
body.race.num_beards(body.body_type) as usize - 1,
body.beard as usize,
self.ids.beard_slider,
ui_widgets,
) {
self.character_body.beard = new_val as u8;
body.beard = new_val as u8;
}
} else {
Text::new(&localized_strings.get("char_selection.beard"))
@ -1261,7 +1278,7 @@ impl CharSelectionUi {
.set(self.ids.beard_slider, ui_widgets);
}
// Chest
let current_chest = self.character_body.chest;
let current_chest = body.chest;
if let Some(new_val) = char_slider(
self.ids.beard_slider,
localized_strings.get("char_selection.chest_color"),
@ -1274,10 +1291,10 @@ impl CharSelectionUi {
self.ids.chest_slider,
ui_widgets,
) {
self.character_body.chest = humanoid::ALL_CHESTS[new_val];
body.chest = humanoid::ALL_CHESTS[new_val];
}
// Pants
/*let current_pants = self.character_body.pants;
/*let current_pants = body.pants;
if let Some(new_val) = char_slider(
self.ids.chest_slider,
"Pants",
@ -1290,12 +1307,17 @@ impl CharSelectionUi {
self.ids.pants_slider,
ui_widgets,
) {
self.character_body.pants = humanoid::ALL_PANTS[new_val];
body.pants = humanoid::ALL_PANTS[new_val];
}*/
Rectangle::fill_with([20.0, 20.0], color::TRANSPARENT)
.down_from(self.ids.chest_slider, 15.0)
.set(self.ids.space, ui_widgets);
if to_select {
self.mode = Mode::Select(None);
}
} // Char Creation fin
}
events
}

View File

@ -9,6 +9,7 @@ use std::{fs, io, path::PathBuf};
pub struct CharacterData {
pub name: String,
pub body: comp::Body,
pub tool: Option<String>,
}
#[derive(Clone, Debug, Default, Serialize, Deserialize)]