diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index 54fe67b811..367cdf32ed 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -7,12 +7,14 @@ pub use self::run::RunAnimation; use crate::render::FigureBoneData; // Local -use super::{Bone, Skeleton}; +use super::{ + Skeleton, + Bone, +}; pub struct CharacterSkeleton { head: Bone, chest: Bone, - shoulders: Bone, belt: Bone, shorts: Bone, l_hand: Bone, @@ -20,8 +22,6 @@ pub struct CharacterSkeleton { l_foot: Bone, r_foot: Bone, back: Bone, - eyes: Bone, - hair: Bone, } impl CharacterSkeleton { @@ -29,7 +29,6 @@ impl CharacterSkeleton { Self { head: Bone::default(), chest: Bone::default(), - shoulders: Bone::default(), belt: Bone::default(), shorts: Bone::default(), l_hand: Bone::default(), @@ -37,8 +36,6 @@ impl CharacterSkeleton { l_foot: Bone::default(), r_foot: Bone::default(), back: Bone::default(), - eyes: Bone::default(), - hair: Bone::default(), } } } @@ -57,9 +54,9 @@ impl Skeleton for CharacterSkeleton { FigureBoneData::new(self.l_foot.compute_base_matrix()), FigureBoneData::new(self.r_foot.compute_base_matrix()), FigureBoneData::new(chest_mat * self.back.compute_base_matrix()), - FigureBoneData::new(self.shoulders.compute_base_matrix()), - FigureBoneData::new(self.eyes.compute_base_matrix()), - FigureBoneData::new(self.hair.compute_base_matrix()), + FigureBoneData::default(), + FigureBoneData::default(), + FigureBoneData::default(), FigureBoneData::default(), FigureBoneData::default(), FigureBoneData::default(), diff --git a/voxygen/src/anim/character/run.rs b/voxygen/src/anim/character/run.rs index 1b7cc14bf6..015feb8d89 100644 --- a/voxygen/src/anim/character/run.rs +++ b/voxygen/src/anim/character/run.rs @@ -5,7 +5,10 @@ use std::f32::consts::PI; use vek::*; // Local -use super::{super::Animation, CharacterSkeleton}; +use super::{ + CharacterSkeleton, + super::Animation, +}; pub struct RunAnimation; @@ -13,8 +16,11 @@ impl Animation for RunAnimation { type Skeleton = CharacterSkeleton; type Dependency = f64; - fn update_skeleton(skeleton: &mut Self::Skeleton, time: f64) { - /*let wave = (time as f32 * 12.0).sin(); + fn update_skeleton( + skeleton: &mut Self::Skeleton, + time: f64, + ) { + let wave = (time as f32 * 12.0).sin(); let wave_slow = (time as f32 * 6.0 + PI).sin(); let wave_dip = (wave_slow.abs() - 0.5).abs(); @@ -38,7 +44,7 @@ impl Animation for RunAnimation { skeleton.r_foot.offset = Vec3::new(3.5, 1.0 + wave * 8.0, 3.5 - wave_dip * 4.0); skeleton.r_foot.ori = Quaternion::rotation_x(wave + 1.0); - skeleton.back.offset = Vec3::new(-9.0, 5.0, 18.0);*/ + skeleton.back.offset = Vec3::new(-9.0, 5.0, 18.0); skeleton.back.ori = Quaternion::rotation_y(2.5); } } diff --git a/voxygen/src/hud/chat.rs b/voxygen/src/hud/chat.rs index 400d42ddf6..9f4eb67a8b 100644 --- a/voxygen/src/hud/chat.rs +++ b/voxygen/src/hud/chat.rs @@ -3,7 +3,7 @@ use conrod_core::{ input::Key, position::Dimension, text::font::Id as FontId, - widget::{Id, Button, List, Rectangle, Text, TextEdit}, + widget::{Button, Id, List, Rectangle, Text, TextEdit}, widget_ids, Color, Colorable, Positionable, Sizeable, UiCell, Widget, }; use std::collections::VecDeque; @@ -70,7 +70,12 @@ impl Chat { fn scroll_to_bottom(&self, ui_widgets: &mut UiCell) { ui_widgets.scroll_widget(self.ids.message_box, [0.0, std::f64::MAX]); } - pub(super) fn update_layout(&mut self, ui_widgets: &mut UiCell, font: FontId, imgs: &super::Imgs) -> Option { + pub(super) fn update_layout( + &mut self, + ui_widgets: &mut UiCell, + font: FontId, + imgs: &super::Imgs, + ) -> Option { // Maintain scrolling if self.new_messages { self.scroll_new_messages(ui_widgets); @@ -102,20 +107,23 @@ impl Chat { } // Message box - Rectangle::fill([470.0, 180.0]) + Rectangle::fill([470.0, 160.0]) .rgba(0.0, 0.0, 0.0, 0.4) .up_from(self.ids.input, 0.0) .set(self.ids.message_box_bg, ui_widgets); - let (mut items, _scrollbar) = List::flow_down(self.messages.len()) - .middle_of(self.ids.message_box_bg) - .scroll_kids_vertically() + let (mut items, scrollbar) = List::flow_down(self.messages.len()) + .top_left_with_margins_on(self.ids.message_box_bg, 0.0, 5.0) + .w_h(460.0, 160.0) + .scrollbar_next_to() + .scrollbar_thickness(18.0) + .scrollbar_color(Color::Rgba(0.0, 0.0, 0.0, 1.0)) .set(self.ids.message_box, ui_widgets); while let Some(item) = items.next(ui_widgets) { item.set( Text::new(&self.messages[item.i]) .font_size(14) .font_id(font) - .rgba(0.86 , 0.86, 0.86, 1.0), + .rgba(1.0, 1.0, 1.0, 1.0), ui_widgets, ) } @@ -123,12 +131,12 @@ impl Chat { // Chat Arrow if !self.scrolled_to_bottom(ui_widgets) { if Button::image(imgs.chat_arrow) - .w_h(22.0, 22.0) - .hover_image(imgs.chat_arrow_mo) - .press_image(imgs.chat_arrow_press) - .bottom_right_with_margins_on(self.ids.message_box_bg, 2.0, 2.0) - .set(self.ids.chat_arrow, ui_widgets) - .was_clicked() + .w_h(22.0, 22.0) + .hover_image(imgs.chat_arrow_mo) + .press_image(imgs.chat_arrow_press) + .bottom_right_with_margins_on(self.ids.message_box_bg, 2.0, 2.0) + .set(self.ids.chat_arrow, ui_widgets) + .was_clicked() { self.scroll_to_bottom(ui_widgets); } diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 0241142a92..b92d6dcd06 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -7,7 +7,7 @@ use crate::{ }; use common::assets; use conrod_core::{ - color, Color, + color, image::Id as ImgId, text::font::Id as FontId, widget::{Button, Image, Rectangle, Scrollbar, Text}, @@ -459,7 +459,7 @@ impl Hud { typing: false, cursor_grabbed: true, settings_tab: SettingsTab::Interface, - show_help: false, + show_help: true, bag_open: false, menu_open: false, map_open: false, @@ -511,7 +511,7 @@ impl Hud { if self.show_help { Image::new(self.imgs.window_frame_2) .top_left_with_margins_on(ui_widgets.window, 5.0, 5.0) - .w_h(300.0, 300.0) + .w_h(300.0, 370.0) .set(self.ids.help_bg, ui_widgets); Text::new( @@ -522,6 +522,9 @@ impl Hud { F1 = Toggle this Window \n\ F2 = Toggle Interface \n\ \n\ + Enter = Open Chat \n\ + Mouse Wheel= Scroll Chat\n\ + \n\ M = Map \n\ B = Bag \n\ L = Quest-Log \n\ @@ -775,14 +778,14 @@ impl Hud { // Insert actual Level here Text::new("1") .left_from(self.ids.xp_bar, -15.0) - .font_size(14) + .font_size(10) .color(TEXT_COLOR) .set(self.ids.level_text, ui_widgets); // Insert next Level here Text::new("2") .right_from(self.ids.xp_bar, -15.0) - .font_size(14) + .font_size(10) .color(TEXT_COLOR) .set(self.ids.next_level_text, ui_widgets); diff --git a/voxygen/src/menu/main/ui.rs b/voxygen/src/menu/main/ui.rs index 2f92fd4fa8..c63794a1fb 100644 --- a/voxygen/src/menu/main/ui.rs +++ b/voxygen/src/menu/main/ui.rs @@ -249,7 +249,7 @@ impl MainMenuUi { .align_middle_x_of(self.ids.address_bg) .label("Login") .label_color(TEXT_COLOR) - .label_font_size(28) + .label_font_size(26) .label_y(conrod_core::position::Relative::Scalar(5.0)) .set(self.ids.login_button, ui_widgets) .was_clicked() diff --git a/voxygen/src/scene/figure.rs b/voxygen/src/scene/figure.rs index 7da880f683..8418ab5850 100644 --- a/voxygen/src/scene/figure.rs +++ b/voxygen/src/scene/figure.rs @@ -1,12 +1,19 @@ -use crate::{ - anim::Skeleton, - render::{ - Consts, FigureBoneData, FigureLocals, FigurePipeline, Globals, Mesh, Model, Renderer, - }, - Error, -}; use specs::{Component, VecStorage}; use vek::*; +use crate::{ + Error, + render::{ + Consts, + Globals, + Mesh, + Model, + Renderer, + FigurePipeline, + FigureBoneData, + FigureLocals, + }, + anim::Skeleton, +}; pub struct Figure { // GPU data @@ -57,17 +64,18 @@ impl Figure { Ok(()) } - pub fn update_locals( - &mut self, - renderer: &mut Renderer, - locals: FigureLocals, - ) -> Result<(), Error> { + pub fn update_locals(&mut self, renderer: &mut Renderer, locals: FigureLocals) -> Result<(), Error> { renderer.update_consts(&mut self.locals, &[locals])?; Ok(()) } pub fn render(&self, renderer: &mut Renderer, globals: &Consts) { - renderer.render_figure(&self.model, globals, &self.locals, &self.bone_consts); + renderer.render_figure( + &self.model, + globals, + &self.locals, + &self.bone_consts, + ); } } diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index 1f15c8575c..9513b6f602 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -2,23 +2,36 @@ pub mod camera; pub mod figure; pub mod terrain; -use self::{camera::Camera, figure::Figure, terrain::Terrain}; -use crate::{ - anim::{ - character::{CharacterSkeleton, RunAnimation}, - Animation, - }, - mesh::Meshable, - render::{ - create_skybox_mesh, Consts, FigureLocals, Globals, Model, Renderer, SkyboxLocals, - SkyboxPipeline, - }, - window::Event, +use vek::*; +use dot_vox; +use common::{ + comp, + figure::Segment, }; use client::Client; -use common::{comp, figure::Segment}; -use dot_vox; -use vek::*; +use crate::{ + render::{ + Consts, + Globals, + Model, + Renderer, + SkyboxPipeline, + SkyboxLocals, + FigureLocals, + create_skybox_mesh, + }, + window::Event, + mesh::Meshable, + anim::{ + Animation, + character::{CharacterSkeleton, RunAnimation}, + }, +}; +use self::{ + camera::Camera, + figure::Figure, + terrain::Terrain, +}; // TODO: Don't hard-code this const CURSOR_PAN_SCALE: f32 = 0.005; @@ -40,25 +53,25 @@ pub struct Scene { // TODO: Make a proper asset loading system fn load_segment(filename: &'static str) -> Segment { - Segment::from( - dot_vox::load( - &(concat!(env!("CARGO_MANIFEST_DIR"), "/../assets/voxygen/voxel/").to_string() - + filename), - ) - .unwrap(), - ) + Segment::from(dot_vox::load(&(concat!(env!("CARGO_MANIFEST_DIR"), "/../assets/voxygen/voxel/").to_string() + filename)).unwrap()) } impl Scene { /// Create a new `Scene` with default parameters. pub fn new(renderer: &mut Renderer, client: &Client) -> Self { Self { - globals: renderer.create_consts(&[Globals::default()]).unwrap(), + globals: renderer + .create_consts(&[Globals::default()]) + .unwrap(), camera: Camera::new(), skybox: Skybox { - model: renderer.create_model(&create_skybox_mesh()).unwrap(), - locals: renderer.create_consts(&[SkyboxLocals::default()]).unwrap(), + model: renderer + .create_model(&create_skybox_mesh()) + .unwrap(), + locals: renderer + .create_consts(&[SkyboxLocals::default()]) + .unwrap(), }, terrain: Terrain::new(), @@ -84,19 +97,15 @@ impl Scene { ], CharacterSkeleton::new(), ) - .unwrap(), + .unwrap(), } } /// Get a reference to the scene's camera. - pub fn camera(&self) -> &Camera { - &self.camera - } + pub fn camera(&self) -> &Camera { &self.camera } /// Get a mutable reference to the scene's camera. - pub fn camera_mut(&mut self) -> &mut Camera { - &mut self.camera - } + pub fn camera_mut(&mut self) -> &mut Camera { &mut self.camera } /// Handle an incoming user input event (i.e: cursor moved, key pressed, window closed, etc.). /// @@ -107,17 +116,17 @@ impl Scene { Event::Resize(dims) => { self.camera.set_aspect_ratio(dims.x as f32 / dims.y as f32); true - } + }, // Panning the cursor makes the camera rotate Event::CursorPan(delta) => { self.camera.rotate_by(Vec3::from(delta) * CURSOR_PAN_SCALE); true - } + }, // Zoom the camera when a zoom event occurs Event::Zoom(delta) => { self.camera.zoom_by(-delta); true - } + }, // All other events are unhandled _ => false, } @@ -128,14 +137,13 @@ impl Scene { // Get player position let player_pos = client .player() - .and_then(|ent| { - client - .state() - .ecs_world() - .read_storage::() - .get(ent) - .map(|pos| pos.0) - }) + .and_then(|ent| client + .state() + .ecs_world() + .read_storage::() + .get(ent) + .map(|pos| pos.0) + ) .unwrap_or(Vec3::zero()); // Alter camera position to match player @@ -145,40 +153,41 @@ impl Scene { let (view_mat, proj_mat, cam_pos) = self.camera.compute_dependents(); // Update global constants - renderer - .update_consts( - &mut self.globals, - &[Globals::new( - view_mat, - proj_mat, - cam_pos, - self.camera.get_focus_pos(), - 10.0, - client.state().get_time_of_day(), - client.state().get_time(), - )], - ) + renderer.update_consts(&mut self.globals, &[Globals::new( + view_mat, + proj_mat, + cam_pos, + self.camera.get_focus_pos(), + 10.0, + client.state().get_time_of_day(), + client.state().get_time(), + )]) .expect("Failed to update global constants"); // Maintain the terrain self.terrain.maintain(renderer, client); // TODO: Don't do this here - RunAnimation::update_skeleton(&mut self.test_figure.skeleton, client.state().get_time()); + RunAnimation::update_skeleton( + &mut self.test_figure.skeleton, + client.state().get_time(), + ); // Calculate player model matrix let model_mat = Mat4::::translation_3d(player_pos); - self.test_figure - .update_locals(renderer, FigureLocals::new(model_mat)) - .unwrap(); + self.test_figure.update_locals(renderer, FigureLocals::new(model_mat)).unwrap(); self.test_figure.update_skeleton(renderer).unwrap(); } /// Render the scene using the provided `Renderer` pub fn render_to(&self, renderer: &mut Renderer) { // Render the skybox first (it appears over everything else so must be rendered first) - renderer.render_skybox(&self.skybox.model, &self.globals, &self.skybox.locals); + renderer.render_skybox( + &self.skybox.model, + &self.globals, + &self.skybox.locals, + ); // Render terrain self.terrain.render(renderer, &self.globals);