Fix sliders, remove uneeded method, fix aspect ratio in character creation

This commit is contained in:
Imbris 2019-08-24 20:42:43 -04:00
parent 7bebffb2af
commit fd251c4d3a
7 changed files with 33 additions and 40 deletions

Binary file not shown.

View File

@ -1,16 +1,16 @@
({ ({
(Human, Male): ( (Human, Male): (
offset: (-7.0, -5.0, -2.25), offset: (-7.0, -5.0, -1.25),
head: ("figure.head.human.male", (0, 0, 0)), head: ("figure.head.human.male", (0, 0, 0)),
eyes: ("figure.eyes.human.male", (10, 10, 3)), eyes: ("figure.eyes.human.male", (3, 7, 2)),
hair: { hair: {
None: None, None: None,
Temp1: Some(("figure.hair.human.male", (1, 2, 3))), Temp1: Some(("figure.hair.human.male", (1, 0, 1))),
Temp2: Some(("figure.hair.human.male", (1, 2, 3))), Temp2: Some(("figure.hair.human.male", (1, 0, 1))),
}, },
beard: { beard: {
None: None, None: None,
Some: Some(("figure.beard.human.1", (0, 0, -5))), Some: Some(("figure.beard.human.1", (1, 8, -7))),
}, },
accessory: { accessory: {
Nothing: None, Nothing: None,

View File

@ -47,35 +47,6 @@ impl From<&DotVoxData> for Segment {
} }
impl Segment { impl Segment {
// TODO: this is currenlty unused, remove?
/// Create a new `Segment` by combining two existing ones
pub fn union(&self, other: &Self, other_offset: Vec3<i32>) -> Self {
let size = self.get_size();
let other_size = other.get_size();
let new_size = other_offset
.map2(other_size, |oo, os| (oo, os))
.map2(size, |(oo, os), s| {
(oo + os as i32).max(s as i32) - oo.min(0)
})
.map(|e| e as u32);
let mut combined = Segment::filled(new_size, Cell::empty(), ());
// Copy self into combined
let offset = other_offset.map(|e| e.min(0).abs());
for pos in self.iter_positions() {
if let Cell::Filled(col) = *self.get(pos).unwrap() {
combined.set(pos + offset, Cell::Filled(col)).unwrap();
}
}
// Copy other into combined
let offset = other_offset.map(|e| e.max(0));
for pos in other.iter_positions() {
if let Cell::Filled(col) = *other.get(pos).unwrap() {
combined.set(pos + offset, Cell::Filled(col)).unwrap();
}
}
combined
}
/// Replaces one cell with another /// Replaces one cell with another
pub fn replace(mut self, old: Cell, new: Cell) -> Self { pub fn replace(mut self, old: Cell, new: Cell) -> Self {
for pos in self.iter_positions() { for pos in self.iter_positions() {

View File

@ -45,8 +45,10 @@ impl PlayState for CharSelectionState {
Event::Ui(event) => { Event::Ui(event) => {
self.char_selection_ui.handle_event(event); self.char_selection_ui.handle_event(event);
} }
// Ignore all other events. // Pass all other events to the scene
_ => {} event => {
self.scene.handle_input_event(event);
} // TODO: Do something if the event wasn't handled?
} }
} }

View File

@ -12,6 +12,7 @@ use crate::{
camera::{Camera, CameraMode}, camera::{Camera, CameraMode},
figure::{load_mesh, FigureModelCache, FigureState}, figure::{load_mesh, FigureModelCache, FigureState},
}, },
window::Event,
}; };
use client::Client; use client::Client;
use common::{ use common::{
@ -82,6 +83,21 @@ impl Scene {
&self.globals &self.globals
} }
/// Handle an incoming user input event (e.g.: cursor moved, key pressed, window closed).
///
/// If the event is handled, return true.
pub fn handle_input_event(&mut self, event: Event) -> bool {
match event {
// When the window is resized, change the camera's aspect ratio
Event::Resize(dims) => {
self.camera.set_aspect_ratio(dims.x as f32 / dims.y as f32);
true
}
// All other events are unhandled
_ => false,
}
}
pub fn maintain(&mut self, renderer: &mut Renderer, client: &Client, body: humanoid::Body) { pub fn maintain(&mut self, renderer: &mut Renderer, client: &Client, body: humanoid::Body) {
self.camera.set_focus_pos(Vec3::unit_z() * 2.0); self.camera.set_focus_pos(Vec3::unit_z() * 2.0);
self.camera.update(client.state().get_time()); self.camera.update(client.state().get_time());

View File

@ -852,7 +852,7 @@ impl CharSelectionUi {
ui_widgets: &mut UiCell| { ui_widgets: &mut UiCell| {
Text::new(text) Text::new(text)
.down_from(prev_id, 22.0) .down_from(prev_id, 22.0)
.align_middle_x() .align_middle_x_of(prev_id)
.font_size(18) .font_size(18)
.font_id(metamorph) .font_id(metamorph)
.color(TEXT_COLOR) .color(TEXT_COLOR)

View File

@ -199,7 +199,11 @@ pub fn mesh_chest(chest: Chest) -> Mesh<FigurePipeline> {
let bare_chest = load_segment("figure.body.chest"); let bare_chest = load_segment("figure.body.chest");
let chest_armor = load_segment("armor.chest.generic"); let chest_armor = load_segment("armor.chest.generic");
let chest = bare_chest.union(&chest_armor.chromify(Rgb::from(color)), Vec3::new(0, 0, 0)); let chest = SegmentUnionizer::new()
.add(bare_chest, Vec3::new(0, 0, 0))
.add(chest_armor.chromify(Rgb::from(color)), Vec3::new(0, 0, 0))
.unify()
.0;
Meshable::<FigurePipeline, FigurePipeline>::generate_mesh(&chest, Vec3::new(-6.0, -3.5, 0.0)).0 Meshable::<FigurePipeline, FigurePipeline>::generate_mesh(&chest, Vec3::new(-6.0, -3.5, 0.0)).0
} }