mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Chat padding, Font Colours to white, Help Window
Former-commit-id: d36a878971f92fbf16eb44d3102b4328832e6563
This commit is contained in:
parent
2e14f7d559
commit
822901b08b
@ -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(),
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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<String> {
|
||||
pub(super) fn update_layout(
|
||||
&mut self,
|
||||
ui_widgets: &mut UiCell,
|
||||
font: FontId,
|
||||
imgs: &super::Imgs,
|
||||
) -> Option<String> {
|
||||
// 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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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<S: Skeleton> {
|
||||
// GPU data
|
||||
@ -57,17 +64,18 @@ impl<S: Skeleton> Figure<S> {
|
||||
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<Globals>) {
|
||||
renderer.render_figure(&self.model, globals, &self.locals, &self.bone_consts);
|
||||
renderer.render_figure(
|
||||
&self.model,
|
||||
globals,
|
||||
&self.locals,
|
||||
&self.bone_consts,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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::<comp::phys::Pos>()
|
||||
.get(ent)
|
||||
.map(|pos| pos.0)
|
||||
})
|
||||
.and_then(|ent| client
|
||||
.state()
|
||||
.ecs_world()
|
||||
.read_storage::<comp::phys::Pos>()
|
||||
.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::<f32>::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);
|
||||
|
Loading…
Reference in New Issue
Block a user