Former-commit-id: 7e2cdb284c670b5991c69b6aab042194c806171f
This commit is contained in:
Imbris 2019-05-07 01:40:03 -04:00
parent 99d6c92c8d
commit eb3d8310f8
18 changed files with 432 additions and 528 deletions

View File

@ -1,6 +1,6 @@
use conrod_core::text::Font;
use dot_vox::DotVoxData;
use image::DynamicImage;
use conrod_core::text::Font;
use lazy_static::lazy_static;
use std::{
any::Any,
@ -41,12 +41,13 @@ lazy_static! {
/// ```
/// use image::DynamicImage;
/// use common::assets;
///
///
/// let my_image = Assets::load::<DynamicImage>("core.ui.backgrounds.city").unwrap();
/// ```
pub fn load<A: Asset + 'static>(specifier: &str) -> Result<Arc<A>, Error> {
Ok(ASSETS
.write().unwrap()
.write()
.unwrap()
.entry(specifier.to_string())
.or_insert(Arc::new(A::load(specifier)?))
.clone()
@ -60,12 +61,11 @@ pub fn load<A: Asset + 'static>(specifier: &str) -> Result<Arc<A>, Error> {
/// ```
/// use image::DynamicImage;
/// use common::assets;
///
///
/// let my_image = Assets::load_expect::<DynamicImage>("core.ui.backgrounds.city");
/// ```
pub fn load_expect<A: Asset + 'static>(specifier: &str) -> Arc<A> {
load(specifier)
.expect(&format!("Failed loading essential asset: {}", specifier))
load(specifier).expect(&format!("Failed loading essential asset: {}", specifier))
}
/// Asset Trait
@ -75,29 +75,19 @@ pub trait Asset: Send + Sync + Sized {
impl Asset for DynamicImage {
fn load(specifier: &str) -> Result<Self, Error> {
Ok(image::load_from_memory(
load_from_path(specifier)?.as_slice()
)
.unwrap()
)
Ok(image::load_from_memory(load_from_path(specifier)?.as_slice()).unwrap())
}
}
impl Asset for DotVoxData {
fn load(specifier: &str) -> Result<Self, Error> {
Ok(dot_vox::load_bytes(
load_from_path(specifier)?.as_slice()
)
.unwrap()
)
Ok(dot_vox::load_bytes(load_from_path(specifier)?.as_slice()).unwrap())
}
}
impl Asset for Font {
fn load(specifier: &str) -> Result<Self, Error> {
Ok(Font::from_bytes(
load_from_path(specifier)?).unwrap()
)
Ok(Font::from_bytes(load_from_path(specifier)?).unwrap())
}
}
@ -127,10 +117,8 @@ pub fn load_from_path(name: &str) -> Result<Vec<u8>, Error> {
let mut content = Vec::<u8>::new();
f.read_to_end(&mut content)?;
Ok(content)
},
None => {
Err(Error::NotFound(name.to_owned()))
}
None => Err(Error::NotFound(name.to_owned())),
}
}

View File

@ -1,11 +1,8 @@
use super::{font_ids::Fonts, img_ids::Imgs};
use conrod_core::{
color,
widget::{self, Button, Image, Rectangle, Scrollbar},
widget_ids, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
};
use super::{
img_ids::Imgs,
font_ids::Fonts,
widget_ids, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
};
widget_ids! {
@ -67,11 +64,7 @@ impl<'a> Widget for Bag<'a> {
}
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
let widget::UpdateArgs {
state,
ui,
..
} = args;
let widget::UpdateArgs { state, ui, .. } = args;
// Contents
Image::new(self.imgs.bag_contents)
@ -81,24 +74,23 @@ impl<'a> Widget for Bag<'a> {
// Alignment for Grid
Rectangle::fill_with([58.0 * 4.0 - 5.0, 100.0 * 4.0], color::TRANSPARENT)
.top_left_with_margins_on(state.ids.bag_contents, 11.0 * 4.0, 5.0 * 4.0)
.scroll_kids()
.scroll_kids_vertically()
.set(state.ids.inv_alignment, ui);
.top_left_with_margins_on(state.ids.bag_contents, 11.0 * 4.0, 5.0 * 4.0)
.scroll_kids()
.scroll_kids_vertically()
.set(state.ids.inv_alignment, ui);
// Grid
Image::new(self.imgs.inv_grid)
.w_h(58.0 * 4.0, 111.0 * 4.0)
.mid_top_with_margin_on(state.ids.inv_alignment, 0.0)
.set(state.ids.inv_grid_1, ui);
Image::new(self.imgs.inv_grid)
.w_h(58.0 * 4.0, 111.0 * 4.0)
.mid_top_with_margin_on(state.ids.inv_alignment, 110.0 * 4.0)
.set(state.ids.inv_grid_2, ui);
Scrollbar::y_axis(state.ids.inv_alignment)
.thickness(5.0)
.rgba(0.33, 0.33, 0.33, 1.0)
.set(state.ids.inv_scrollbar, ui);
.w_h(58.0 * 4.0, 111.0 * 4.0)
.mid_top_with_margin_on(state.ids.inv_alignment, 0.0)
.set(state.ids.inv_grid_1, ui);
Image::new(self.imgs.inv_grid)
.w_h(58.0 * 4.0, 111.0 * 4.0)
.mid_top_with_margin_on(state.ids.inv_alignment, 110.0 * 4.0)
.set(state.ids.inv_grid_2, ui);
Scrollbar::y_axis(state.ids.inv_alignment)
.thickness(5.0)
.rgba(0.33, 0.33, 0.33, 1.0)
.set(state.ids.inv_scrollbar, ui);
if self.inventory_space > 0 {
// First Slot

View File

@ -3,13 +3,7 @@ use conrod_core::{
widget_ids, Colorable, Labelable, Positionable, Sizeable, Widget, WidgetCommon,
};
use super::{
img_ids::Imgs,
font_ids::Fonts,
small_window::SmallWindowType,
Windows,
TEXT_COLOR,
};
use super::{font_ids::Fonts, img_ids::Imgs, small_window::SmallWindowType, Windows, TEXT_COLOR};
use crate::ui::ToggleButton;
widget_ids! {
@ -44,7 +38,13 @@ pub struct Buttons<'a> {
}
impl<'a> Buttons<'a> {
pub fn new(open_windows: &'a Windows, show_map: bool, show_bag: bool, imgs: &'a Imgs, fonts: &'a Fonts) -> Self {
pub fn new(
open_windows: &'a Windows,
show_map: bool,
show_bag: bool,
imgs: &'a Imgs,
fonts: &'a Fonts,
) -> Self {
Self {
open_windows,
show_map,
@ -84,21 +84,19 @@ impl<'a> Widget for Buttons<'a> {
}
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
let widget::UpdateArgs {
state,
ui,
..
} = args;
let widget::UpdateArgs { state, ui, .. } = args;
// Bag
if !self.show_map {
if self.show_bag != ToggleButton::new(self.show_bag, self.imgs.bag, self.imgs.bag_open)
.bottom_right_with_margins_on(ui.window, 5.0, 5.0)
.hover_images(self.imgs.bag_hover, self.imgs.bag_open_hover)
.press_images(self.imgs.bag_press, self.imgs.bag_open_press)
.w_h(420.0 / 10.0, 480.0 / 10.0)
.set(state.ids.bag, ui) {
return Some(Event::ToggleBag);
if self.show_bag
!= ToggleButton::new(self.show_bag, self.imgs.bag, self.imgs.bag_open)
.bottom_right_with_margins_on(ui.window, 5.0, 5.0)
.hover_images(self.imgs.bag_hover, self.imgs.bag_open_hover)
.press_images(self.imgs.bag_press, self.imgs.bag_open_press)
.w_h(420.0 / 10.0, 480.0 / 10.0)
.set(state.ids.bag, ui)
{
return Some(Event::ToggleBag);
}
Text::new("B")

View File

@ -1,14 +1,9 @@
use super::{font_ids::Fonts, img_ids::Imgs, TEXT_COLOR, XP_COLOR};
use conrod_core::{
color,
widget::{self, Button, Image, Rectangle, Text},
widget_ids, Colorable, Labelable, Positionable, Sizeable, Widget, WidgetCommon,
};
use super::{
img_ids::Imgs,
font_ids::Fonts,
TEXT_COLOR,
XP_COLOR,
};
widget_ids! {
pub struct Ids {
@ -68,12 +63,7 @@ impl<'a> Widget for CharacterWindow<'a> {
}
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
let widget::UpdateArgs {
id,
state,
ui,
..
} = args;
let widget::UpdateArgs { id, state, ui, .. } = args;
// TODO: Read from parameter / character struct
let xp_percentage = 0.4;
@ -82,8 +72,8 @@ impl<'a> Widget for CharacterWindow<'a> {
Image::new(self.imgs.window_frame)
.middle_of(id)
.top_left_with_margins_on(ui.window, 200.0, 215.0)
.w_h(107.0*4.0, 125.0*4.0)
.set(state.charwindow_frame, ui);
.w_h(107.0 * 4.0, 125.0 * 4.0)
.set(state.charwindow_frame, ui);
// Icon
//Image::new(self.imgs.charwindow_icon)
@ -98,8 +88,9 @@ impl<'a> Widget for CharacterWindow<'a> {
.press_image(self.imgs.close_button_press)
.top_right_with_margins_on(state.charwindow_frame, 12.0, 0.0)
.set(state.charwindow_close, ui)
.was_clicked() {
return Some(Event::Close);
.was_clicked()
{
return Some(Event::Close);
}
// Title
@ -171,11 +162,11 @@ impl<'a> Widget for CharacterWindow<'a> {
\n\
Intelligence",
)
.top_left_with_margins_on(state.charwindow_rectangle, 100.0, 20.0)
.font_id(self.fonts.opensans)
.font_size(16)
.color(TEXT_COLOR)
.set(state.charwindow_tab1_statnames, ui);
.top_left_with_margins_on(state.charwindow_rectangle, 100.0, 20.0)
.font_id(self.fonts.opensans)
.font_size(16)
.color(TEXT_COLOR)
.set(state.charwindow_tab1_statnames, ui);
Text::new(
"1234\n\
@ -186,11 +177,11 @@ impl<'a> Widget for CharacterWindow<'a> {
\n\
124124",
)
.right_from(state.charwindow_tab1_statnames, 10.0)
.font_id(self.fonts.opensans)
.font_size(16)
.color(TEXT_COLOR)
.set(state.charwindow_tab1_stats, ui);
.right_from(state.charwindow_tab1_statnames, 10.0)
.font_id(self.fonts.opensans)
.font_size(16)
.color(TEXT_COLOR)
.set(state.charwindow_tab1_stats, ui);
None
}

View File

@ -1,13 +1,9 @@
use super::{font_ids::Fonts, img_ids::Imgs, TEXT_COLOR};
use conrod_core::{
input::Key,
widget::{self, Button, Id, List, Rectangle, Text, TextEdit},
position::Dimension,
UiCell, widget_ids, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
};
use super::{
img_ids::Imgs,
font_ids::Fonts,
TEXT_COLOR,
widget::{self, Button, Id, List, Rectangle, Text, TextEdit},
widget_ids, Colorable, Positionable, Sizeable, UiCell, Widget, WidgetCommon,
};
use std::collections::VecDeque;
@ -86,12 +82,7 @@ impl<'a> Widget for Chat<'a> {
}
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
let widget::UpdateArgs {
id,
state,
ui,
..
} = args;
let widget::UpdateArgs { id, state, ui, .. } = args;
// Maintain scrolling
if !self.new_messages.is_empty() {
@ -134,10 +125,12 @@ impl<'a> Widget for Chat<'a> {
// Message box
Rectangle::fill([470.0, 174.0])
.rgba(0.0, 0.0, 0.0, 0.4)
.and(|r| if input_focused {
r.up_from(state.ids.input_bg, 0.0)
} else {
r.bottom_left_with_margins_on(ui.window, 10.0, 10.0)
.and(|r| {
if input_focused {
r.up_from(state.ids.input_bg, 0.0)
} else {
r.bottom_left_with_margins_on(ui.window, 10.0, 10.0)
}
})
.set(state.ids.message_box_bg, ui);
let (mut items, _) = List::flow_down(state.messages.len() + 1)
@ -165,7 +158,10 @@ impl<'a> Widget for Chat<'a> {
} else {
// Spacer at bottom of the last message so that it is not cut off
// Needs to be larger than the space above
Text::new("").font_size(6).font_id(self.fonts.opensans).w(470.0)
Text::new("")
.font_size(6)
.font_id(self.fonts.opensans)
.w(470.0)
};
item.set(widget, ui);
}
@ -190,7 +186,7 @@ impl<'a> Widget for Chat<'a> {
Some(Event::Focus(state.ids.input))
}
// If enter is pressed and the input box is not empty send the current message
else if ui
else if ui
.widget_input(state.ids.input)
.presses()
.key()

View File

@ -3,11 +3,7 @@ use conrod_core::{
widget_ids, Labelable, Positionable, Sizeable, Widget, WidgetCommon,
};
use super::{
img_ids::Imgs,
font_ids::Fonts,
TEXT_COLOR,
};
use super::{font_ids::Fonts, img_ids::Imgs, TEXT_COLOR};
widget_ids! {
struct Ids {
@ -23,7 +19,6 @@ widget_ids! {
#[derive(WidgetCommon)]
pub struct EscMenu<'a> {
imgs: &'a Imgs,
fonts: &'a Fonts,
@ -68,11 +63,7 @@ impl<'a> Widget for EscMenu<'a> {
}
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
let widget::UpdateArgs {
state,
ui,
..
} = args;
let widget::UpdateArgs { state, ui, .. } = args;
Image::new(self.imgs.esc_bg)
.w_h(228.0, 450.0)

View File

@ -1,4 +1,4 @@
use crate::ui::{ImageGraphic, VoxelGraphic, BlankGraphic};
use crate::ui::{BlankGraphic, ImageGraphic, VoxelGraphic};
image_ids! {
pub struct Imgs {
@ -39,14 +39,14 @@ image_ids! {
qlog_button: "/voxygen/element/buttons/qlog.vox",
qlog_hover: "/voxygen/element/buttons/qlog_hover.vox",
qlog_press: "/voxygen/element/buttons/qlog_press.vox",
// Close button
close_button: "/voxygen/element/buttons/x.vox",
close_button_hover: "/voxygen/element/buttons/x_hover.vox",
close_button_press: "/voxygen/element/buttons/x_press.vox",
// Esc-Menu
// Esc-Menu
fireplace: "/voxygen/element/misc_bg/fireplace.vox",
button: "/voxygen/element/buttons/button.vox",
button_hover: "/voxygen/element/buttons/button_hover.vox",
@ -55,10 +55,10 @@ image_ids! {
// MiniMap
mmap_frame: "/voxygen/element/frames/mmap.vox",
mmap_frame_closed: "/voxygen/element/frames/mmap_closed.vox",
// Missing: Buff Frame Animation .gif ?! we could do animation in ui.maintain, or in shader?
window_frame: "/voxygen/element/frames/window2.vox",
window_frame: "/voxygen/element/frames/window2.vox",
// Settings Window
settings_frame_r: "/voxygen/element/frames/settings_r.vox",
@ -66,23 +66,23 @@ image_ids! {
settings_button: "/voxygen/element/buttons/settings_button.vox",
settings_button_pressed: "/voxygen/element/buttons/settings_button_pressed.vox",
settings_button_hover: "/voxygen/element/buttons/settings_button_hover.vox",
settings_button_press: "/voxygen/element/buttons/settings_button_press.vox",
settings_button_press: "/voxygen/element/buttons/settings_button_press.vox",
check: "/voxygen/element/buttons/check/no.vox",
check_mo: "/voxygen/element/buttons/check/no_mo.vox",
check_press: "/voxygen/element/buttons/check/press.vox",
check_checked: "/voxygen/element/buttons/check/yes.vox",
check_checked_mo: "/voxygen/element/buttons/check/yes_mo.vox",
slider: "/voxygen/element/slider/track.vox",
slider_indicator: "/voxygen/element/slider/indicator.vox",
slider_indicator: "/voxygen/element/slider/indicator.vox",
// Map Window
// Map Window
map_frame_l: "/voxygen/element/frames/map_l.vox",
map_frame_r: "/voxygen/element/frames/map_r.vox",
map_frame_bl: "/voxygen/element/frames/map_bl.vox",
map_frame_br: "/voxygen/element/frames/map_br.vox",
map_frame_br: "/voxygen/element/frames/map_br.vox",
// Chat-Arrows
chat_arrow: "/voxygen/element/buttons/arrow_down.vox",
chat_arrow_mo: "/voxygen/element/buttons/arrow_down_hover.vox",

View File

@ -4,10 +4,7 @@ use conrod_core::{
widget_ids, Positionable, Sizeable, Widget, WidgetCommon,
};
use super::{
img_ids::Imgs,
font_ids::Fonts,
};
use super::{font_ids::Fonts, img_ids::Imgs};
widget_ids! {
struct Ids {
@ -66,42 +63,37 @@ impl<'a> Widget for Map<'a> {
}
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
let widget::UpdateArgs {
state,
ui,
..
} = args;
let widget::UpdateArgs { state, ui, .. } = args;
// BG
Rectangle::fill_with([824.0, 976.0], color::TRANSPARENT)
.mid_top_with_margin_on(ui.window, 15.0)
.scroll_kids()
.scroll_kids_vertically()
.set(state.ids.map_bg, ui);
// Frame
Image::new(self.imgs.map_frame_l)
.top_left_with_margins_on(state.ids.map_bg, 0.0, 0.0)
.w_h(412.0, 488.0)
.set(state.ids.map_frame_l, ui);
Image::new(self.imgs.map_frame_r)
.right_from(state.ids.map_frame_l, 0.0)
.w_h(412.0, 488.0)
.set(state.ids.map_frame_r, ui);
Image::new(self.imgs.map_frame_br)
.down_from(state.ids.map_frame_r, 0.0)
.w_h(412.0, 488.0)
.set(state.ids.map_frame_br, ui);
Image::new(self.imgs.map_frame_bl)
.down_from(state.ids.map_frame_l, 0.0)
.w_h(412.0, 488.0)
.set(state.ids.map_frame_bl, ui);
// Icon
Image::new(self.imgs.map_icon)
.w_h(224.0 / 3.0, 224.0 / 3.0)
.top_left_with_margins_on(state.ids.map_frame, -10.0, -10.0)
.set(state.ids.map_icon, ui);
Rectangle::fill_with([824.0, 976.0], color::TRANSPARENT)
.mid_top_with_margin_on(ui.window, 15.0)
.scroll_kids()
.scroll_kids_vertically()
.set(state.ids.map_bg, ui);
// Frame
Image::new(self.imgs.map_frame_l)
.top_left_with_margins_on(state.ids.map_bg, 0.0, 0.0)
.w_h(412.0, 488.0)
.set(state.ids.map_frame_l, ui);
Image::new(self.imgs.map_frame_r)
.right_from(state.ids.map_frame_l, 0.0)
.w_h(412.0, 488.0)
.set(state.ids.map_frame_r, ui);
Image::new(self.imgs.map_frame_br)
.down_from(state.ids.map_frame_r, 0.0)
.w_h(412.0, 488.0)
.set(state.ids.map_frame_br, ui);
Image::new(self.imgs.map_frame_bl)
.down_from(state.ids.map_frame_l, 0.0)
.w_h(412.0, 488.0)
.set(state.ids.map_frame_bl, ui);
// Icon
Image::new(self.imgs.map_icon)
.w_h(224.0 / 3.0, 224.0 / 3.0)
.top_left_with_margins_on(state.ids.map_frame, -10.0, -10.0)
.set(state.ids.map_icon, ui);
// Icon
Image::new(self.imgs.map_icon)
@ -110,16 +102,16 @@ impl<'a> Widget for Map<'a> {
.set(state.ids.map_icon, ui);
// X-Button
if Button::image(self.imgs.close_button)
.w_h(28.0, 28.0)
.hover_image(self.imgs.close_button_hover)
.press_image(self.imgs.close_button_press)
.top_right_with_margins_on(state.ids.map_frame_r, 0.0, 0.0)
.set(state.ids.map_close, ui)
.was_clicked()
if Button::image(self.imgs.close_button)
.w_h(28.0, 28.0)
.hover_image(self.imgs.close_button_hover)
.press_image(self.imgs.close_button_press)
.top_right_with_margins_on(state.ids.map_frame_r, 0.0, 0.0)
.set(state.ids.map_close, ui)
.was_clicked()
{
return Some(Event::Close);
}
}
None
}

View File

@ -1,26 +1,26 @@
mod chat;
mod character_window;
mod skillbar;
mod buttons;
mod map;
mod bag;
mod buttons;
mod character_window;
mod chat;
mod esc_menu;
mod small_window;
mod settings_window;
mod img_ids;
mod font_ids;
mod img_ids;
mod map;
mod settings_window;
mod skillbar;
mod small_window;
use chat::Chat;
use character_window::CharacterWindow;
use map::Map;
use bag::Bag;
use skillbar::Skillbar;
use buttons::Buttons;
use character_window::CharacterWindow;
use chat::Chat;
use esc_menu::EscMenu;
use small_window::{SmallWindow, SmallWindowType};
use settings_window::SettingsWindow;
use img_ids::Imgs;
use font_ids::Fonts;
use img_ids::Imgs;
use map::Map;
use settings_window::SettingsWindow;
use skillbar::Skillbar;
use small_window::{SmallWindow, SmallWindowType};
use crate::{
render::Renderer,
@ -30,7 +30,9 @@ use crate::{
GlobalState,
};
use conrod_core::{
widget::{self, Button, Image, Text, Rectangle}, widget_ids, Color, Colorable, Labelable, Positionable, Sizeable, Widget, color, graph
color, graph,
widget::{self, Button, Image, Rectangle, Text},
widget_ids, Color, Colorable, Labelable, Positionable, Sizeable, Widget,
};
use std::collections::VecDeque;
@ -46,7 +48,7 @@ widget_ids! {
// Debug
debug_bg,
fps_counter,
// Game Version
version,
@ -95,7 +97,7 @@ pub enum Event {
// map not here because it currently is displayed over the top of other open windows
#[derive(PartialEq)]
pub enum Windows {
Settings, // display settings window
Settings, // display settings window
CharacterAnd(Option<SmallWindowType>), // show character window + optionally another
Small(SmallWindowType),
None,
@ -110,7 +112,7 @@ pub struct Show {
open_windows: Windows,
map: bool,
inventory_test_button: bool,
mini_map: bool,
mini_map: bool,
}
impl Show {
fn toggle_bag(&mut self) {
@ -267,7 +269,7 @@ impl Hud {
{
self.inventory_space += 1;
};
}
}
// Help Text
if self.show.help {
Image::new(self.imgs.window_frame_2)
@ -293,8 +295,14 @@ impl Hud {
};
}
match Buttons::new(&self.show.open_windows, self.show.map, self.show.bag, &self.imgs, &self.fonts)
.set(self.ids.buttons, ui_widgets)
match Buttons::new(
&self.show.open_windows,
self.show.map,
self.show.bag,
&self.imgs,
&self.fonts,
)
.set(self.ids.buttons, ui_widgets)
{
Some(buttons::Event::ToggleBag) => self.show.toggle_bag(),
Some(buttons::Event::ToggleSettings) => self.show.toggle_settings(),
@ -356,15 +364,14 @@ impl Hud {
// Bag contents
if self.show.bag {
match Bag::new(self.inventory_space, &self.imgs, &self.fonts)
.set(self.ids.bag, ui_widgets)
.set(self.ids.bag, ui_widgets)
{
Some(bag::Event::Close) => self.show.bag = false,
None => {}
}
}
Skillbar::new(&self.imgs, &self.fonts)
.set(self.ids.skillbar, ui_widgets);
Skillbar::new(&self.imgs, &self.fonts).set(self.ids.skillbar, ui_widgets);
// Chat box
match Chat::new(&mut self.new_messages, &self.imgs, &self.fonts)
@ -389,7 +396,7 @@ impl Hud {
if let Windows::Settings = self.show.open_windows {
match SettingsWindow::new(&mut self.show, &self.imgs, &self.fonts)
.set(self.ids.settings_window, ui_widgets)
.set(self.ids.settings_window, ui_widgets)
{
Some(settings_window::Event::Close) => {
self.show.open_windows = Windows::None;
@ -401,13 +408,15 @@ impl Hud {
// Small Window
if let Windows::Small(small) | Windows::CharacterAnd(Some(small)) = self.show.open_windows {
match SmallWindow::new(small, &self.show, &self.imgs, &self.fonts)
.set(self.ids.small_window, ui_widgets)
.set(self.ids.small_window, ui_widgets)
{
Some(small_window::Event::Close) => self.show.open_windows = match self.show.open_windows {
Windows::Small(_) => Windows::None,
Windows::CharacterAnd(_) => Windows::CharacterAnd(None),
_ => Windows::Settings,
},
Some(small_window::Event::Close) => {
self.show.open_windows = match self.show.open_windows {
Windows::Small(_) => Windows::None,
Windows::CharacterAnd(_) => Windows::CharacterAnd(None),
_ => Windows::Settings,
}
}
None => {}
}
}
@ -415,21 +424,21 @@ impl Hud {
// Character Window
if let Windows::CharacterAnd(small) = self.show.open_windows {
match CharacterWindow::new(&self.imgs, &self.fonts)
.set(self.ids.character_window, ui_widgets)
.set(self.ids.character_window, ui_widgets)
{
Some(character_window::Event::Close) => self.show.open_windows = match small {
Some(small) => Windows::Small(small),
None => Windows::None,
},
Some(character_window::Event::Close) => {
self.show.open_windows = match small {
Some(small) => Windows::Small(small),
None => Windows::None,
}
}
None => {}
}
}
// Map
if self.show.map {
match Map::new(&self.imgs, &self.fonts)
.set(self.ids.map, ui_widgets)
{
match Map::new(&self.imgs, &self.fonts).set(self.ids.map, ui_widgets) {
Some(map::Event::Close) => self.show.map = false,
None => {}
}
@ -437,9 +446,7 @@ impl Hud {
// Esc-menu
if self.show.esc_menu {
match EscMenu::new(&self.imgs, &self.fonts)
.set(self.ids.esc_menu, ui_widgets)
{
match EscMenu::new(&self.imgs, &self.fonts).set(self.ids.esc_menu, ui_widgets) {
Some(esc_menu::Event::OpenSettings) => {
self.show.esc_menu = false;
self.show.open_windows = Windows::Settings;
@ -447,10 +454,10 @@ impl Hud {
Some(esc_menu::Event::Close) => self.show.esc_menu = false,
Some(esc_menu::Event::Logout) => events.push(Event::Logout),
Some(esc_menu::Event::Quit) => events.push(Event::Quit),
None => {},
None => {}
}
}
events
}
@ -466,7 +473,6 @@ impl Hud {
.widget(id)
.and_then(graph::Container::unique_widget_state::<widget::TextEdit>)
.is_some()
} else {
false
}

View File

@ -1,21 +1,14 @@
use super::{font_ids::Fonts, img_ids::Imgs, TEXT_COLOR};
use crate::{hud::Show, ui::ToggleButton};
use conrod_core::{
color,
widget::{self, Button, Image, Rectangle, Scrollbar, Text},
widget_ids, Colorable, Labelable, Positionable, Sizeable, Widget, WidgetCommon,
};
use super::{
img_ids::Imgs,
font_ids::Fonts,
TEXT_COLOR,
};
use crate::{
ui::ToggleButton,
hud::Show,
};
widget_ids! {
struct Ids {
settings_content,
settings_icon,
settings_button_mo,
@ -25,19 +18,19 @@ widget_ids! {
settings_l,
settings_scrollbar,
controls_text,
controls_controls,
controls_controls,
button_help,
button_help2,
show_help_label,
show_help_label,
gameplay,
controls,
rectangle,
rectangle,
debug_button,
debug_button_label,
debug_button_label,
interface,
inventory_test_button,
inventory_test_button_label,
settings_bg,
settings_bg,
sound,
test,
video,
@ -101,11 +94,7 @@ impl<'a> Widget for SettingsWindow<'a> {
}
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
let widget::UpdateArgs {
state,
ui,
..
} = args;
let widget::UpdateArgs { state, ui, .. } = args;
// Frame Alignment
Rectangle::fill_with([824.0, 488.0], color::TRANSPARENT)
@ -148,33 +137,31 @@ impl<'a> Widget for SettingsWindow<'a> {
.mid_top_with_margin_on(state.ids.settings_bg, 5.0)
.font_size(14)
.color(TEXT_COLOR)
.set(state.ids.settings_title, ui);
.set(state.ids.settings_title, ui);
// Interface
if Button::image(if let SettingsTab::Interface = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button
})
.w_h(31.0 * 4.0, 12.0 * 4.0)
.hover_image(if let SettingsTab::Interface = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button_hover
})
.press_image(if let SettingsTab::Interface = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button_press
})
.top_left_with_margins_on(state.ids.settings_l, 8.0 * 4.0, 2.0 * 4.0)
.label("Interface")
.label_font_size(14)
.label_color(TEXT_COLOR)
.set(state.ids.interface, ui)
.was_clicked()
if Button::image(if let SettingsTab::Interface = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button
})
.w_h(31.0 * 4.0, 12.0 * 4.0)
.hover_image(if let SettingsTab::Interface = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button_hover
})
.press_image(if let SettingsTab::Interface = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button_press
})
.top_left_with_margins_on(state.ids.settings_l, 8.0 * 4.0, 2.0 * 4.0)
.label("Interface")
.label_font_size(14)
.label_color(TEXT_COLOR)
.set(state.ids.interface, ui)
.was_clicked()
{
state.update(|s| s.settings_tab = SettingsTab::Interface);
}
@ -188,7 +175,7 @@ impl<'a> Widget for SettingsWindow<'a> {
.hover_images(self.imgs.check_checked_mo, self.imgs.check_mo)
.press_images(self.imgs.check_press, self.imgs.check_press)
.set(state.ids.button_help, ui);
if self.show.help != show_help {
self.show.toggle_help();
}
@ -207,11 +194,11 @@ impl<'a> Widget for SettingsWindow<'a> {
self.imgs.check,
self.imgs.check_checked,
)
.w_h(288.0 / 24.0, 288.0 / 24.0)
.down_from(state.ids.button_help, 7.0)
.hover_images(self.imgs.check_checked_mo, self.imgs.check_mo)
.press_images(self.imgs.check_press, self.imgs.check_press)
.set(state.ids.inventory_test_button, ui);
.w_h(288.0 / 24.0, 288.0 / 24.0)
.down_from(state.ids.button_help, 7.0)
.hover_images(self.imgs.check_checked_mo, self.imgs.check_mo)
.press_images(self.imgs.check_press, self.imgs.check_press)
.set(state.ids.inventory_test_button, ui);
if self.show.inventory_test_button != inventory_test_button {
self.show.inventory_test_button = inventory_test_button;
@ -226,16 +213,13 @@ impl<'a> Widget for SettingsWindow<'a> {
.set(state.ids.inventory_test_button_label, ui);
// Debug
let show_debug = ToggleButton::new(
self.show.debug,
self.imgs.check,
self.imgs.check_checked
)
.w_h(288.0 / 24.0, 288.0 / 24.0)
.down_from(state.ids.inventory_test_button, 7.0)
.hover_images(self.imgs.check_checked_mo, self.imgs.check_mo)
.press_images(self.imgs.check_press, self.imgs.check_press)
.set(state.ids.debug_button, ui);
let show_debug =
ToggleButton::new(self.show.debug, self.imgs.check, self.imgs.check_checked)
.w_h(288.0 / 24.0, 288.0 / 24.0)
.down_from(state.ids.inventory_test_button, 7.0)
.hover_images(self.imgs.check_checked_mo, self.imgs.check_mo)
.press_images(self.imgs.check_press, self.imgs.check_press)
.set(state.ids.debug_button, ui);
if self.show.debug != show_debug {
self.show.debug = show_debug;
@ -248,65 +232,64 @@ impl<'a> Widget for SettingsWindow<'a> {
.graphics_for(state.ids.debug_button)
.color(TEXT_COLOR)
.set(state.ids.debug_button_label, ui);
}
// 2 Gameplay////////////////
if Button::image(if let SettingsTab::Gameplay = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button
})
.w_h(31.0 * 4.0, 12.0 * 4.0)
.hover_image(if let SettingsTab::Gameplay = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button_hover
})
.press_image(if let SettingsTab::Gameplay = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button_press
})
.right_from(state.ids.interface, 0.0)
.label("Gameplay")
.label_font_size(14)
.label_color(TEXT_COLOR)
.set(state.ids.gameplay, ui)
.was_clicked()
if Button::image(if let SettingsTab::Gameplay = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button
})
.w_h(31.0 * 4.0, 12.0 * 4.0)
.hover_image(if let SettingsTab::Gameplay = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button_hover
})
.press_image(if let SettingsTab::Gameplay = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button_press
})
.right_from(state.ids.interface, 0.0)
.label("Gameplay")
.label_font_size(14)
.label_color(TEXT_COLOR)
.set(state.ids.gameplay, ui)
.was_clicked()
{
state.update(|s| s.settings_tab = SettingsTab::Gameplay);
}
// 3 Controls/////////////////////
if Button::image(if let SettingsTab::Controls = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button
})
.w_h(31.0 * 4.0, 12.0 * 4.0)
.hover_image(if let SettingsTab::Controls = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button_hover
})
.press_image(if let SettingsTab::Controls = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button_press
})
.right_from(state.ids.gameplay, 0.0)
.label("Controls")
.label_font_size(14)
.label_color(TEXT_COLOR)
.set(state.ids.controls, ui)
.was_clicked()
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button
})
.w_h(31.0 * 4.0, 12.0 * 4.0)
.hover_image(if let SettingsTab::Controls = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button_hover
})
.press_image(if let SettingsTab::Controls = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button_press
})
.right_from(state.ids.gameplay, 0.0)
.label("Controls")
.label_font_size(14)
.label_color(TEXT_COLOR)
.set(state.ids.controls, ui)
.was_clicked()
{
state.update(|s| s.settings_tab = SettingsTab::Controls);
}
if let SettingsTab::Controls = state.settings_tab {
Text::new(
"Free Cursor\n\
Text::new(
"Free Cursor\n\
Toggle Help Window\n\
Toggle Interface\n\
Toggle FPS and Debug Info\n\
@ -364,131 +347,131 @@ impl<'a> Widget for SettingsWindow<'a> {
/alias [Name] - Change your Chat Name \n\
/tp [Name] - Teleports you to another player
",
)
.color(TEXT_COLOR)
.top_left_with_margins_on(state.ids.settings_content, 5.0, 5.0)
.font_id(self.fonts.opensans)
.font_size(18)
.set(state.ids.controls_text, ui);
// TODO: Replace with buttons that show the actual keybind and allow the user to change it.
Text::new(
"TAB\n\
F1\n\
F2\n\
F3\n\
\n\
\n\
W\n\
A\n\
S\n\
D\n\
\n\
SPACE\n\
\n\
??\n\
\n\
??\n\
\n\
??\n\
\n\
??\n\
\n\
\n\
L-Click\n\
R-Click\n\
\n\
\n\
1\n\
2\n\
3\n\
4\n\
5\n\
6\n\
7\n\
8\n\
9\n\
0\n\
\n\
\n\
ESC\n\
N\n\
O\n\
M\n\
P\n\
C\n\
L\n\
B\n\
\n\
\n\
\n\
ENTER\n\
Mousewheel\n\
\n\
\n\
\n\
\n\
\n\
\n\
",
)
.color(TEXT_COLOR)
.right_from(state.ids.controls_text, 0.0)
.font_id(self.fonts.opensans)
.font_size(18)
.set(state.ids.controls_controls, ui);
}
)
.color(TEXT_COLOR)
.top_left_with_margins_on(state.ids.settings_content, 5.0, 5.0)
.font_id(self.fonts.opensans)
.font_size(18)
.set(state.ids.controls_text, ui);
// TODO: Replace with buttons that show the actual keybind and allow the user to change it.
Text::new(
"TAB\n\
F1\n\
F2\n\
F3\n\
\n\
\n\
W\n\
A\n\
S\n\
D\n\
\n\
SPACE\n\
\n\
??\n\
\n\
??\n\
\n\
??\n\
\n\
??\n\
\n\
\n\
L-Click\n\
R-Click\n\
\n\
\n\
1\n\
2\n\
3\n\
4\n\
5\n\
6\n\
7\n\
8\n\
9\n\
0\n\
\n\
\n\
ESC\n\
N\n\
O\n\
M\n\
P\n\
C\n\
L\n\
B\n\
\n\
\n\
\n\
ENTER\n\
Mousewheel\n\
\n\
\n\
\n\
\n\
\n\
\n\
",
)
.color(TEXT_COLOR)
.right_from(state.ids.controls_text, 0.0)
.font_id(self.fonts.opensans)
.font_size(18)
.set(state.ids.controls_controls, ui);
}
// 4 Video////////////////////////////////
if Button::image(if let SettingsTab::Video = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button
})
.w_h(31.0 * 4.0, 12.0 * 4.0)
.hover_image(if let SettingsTab::Video = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button_hover
})
.press_image(if let SettingsTab::Video = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button_press
})
.right_from(state.ids.controls, 0.0)
.label("Video")
.parent(state.ids.settings_r)
.label_font_size(14)
.label_color(TEXT_COLOR)
.set(state.ids.video, ui)
.was_clicked()
if Button::image(if let SettingsTab::Video = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button
})
.w_h(31.0 * 4.0, 12.0 * 4.0)
.hover_image(if let SettingsTab::Video = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button_hover
})
.press_image(if let SettingsTab::Video = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button_press
})
.right_from(state.ids.controls, 0.0)
.label("Video")
.parent(state.ids.settings_r)
.label_font_size(14)
.label_color(TEXT_COLOR)
.set(state.ids.video, ui)
.was_clicked()
{
state.update(|s| s.settings_tab = SettingsTab::Video);
}
// 5 Sound///////////////////////////////
if Button::image(if let SettingsTab::Sound = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button
})
.w_h(31.0 * 4.0, 12.0 * 4.0)
.hover_image(if let SettingsTab::Sound = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button_hover
})
.press_image(if let SettingsTab::Sound = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button_press
})
.right_from(state.ids.video, 0.0)
.parent(state.ids.settings_r)
.label("Sound")
.label_font_size(14)
.label_color(TEXT_COLOR)
.set(state.ids.sound, ui)
.was_clicked()
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button
})
.w_h(31.0 * 4.0, 12.0 * 4.0)
.hover_image(if let SettingsTab::Sound = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button_hover
})
.press_image(if let SettingsTab::Sound = state.settings_tab {
self.imgs.settings_button_pressed
} else {
self.imgs.settings_button_press
})
.right_from(state.ids.video, 0.0)
.parent(state.ids.settings_r)
.label("Sound")
.label_font_size(14)
.label_color(TEXT_COLOR)
.set(state.ids.sound, ui)
.was_clicked()
{
state.update(|s| s.settings_tab = SettingsTab::Sound);
}

View File

@ -1,12 +1,8 @@
use super::{font_ids::Fonts, img_ids::Imgs, HP_COLOR, MANA_COLOR, TEXT_COLOR, XP_COLOR};
use conrod_core::{
widget::{self, Image, Rectangle, Text},
widget_ids, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
};
use super::{
img_ids::Imgs,
font_ids::Fonts,
TEXT_COLOR, XP_COLOR, HP_COLOR, MANA_COLOR,
};
widget_ids! {
struct Ids {
@ -69,11 +65,7 @@ impl<'a> Widget for Skillbar<'a> {
}
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
let widget::UpdateArgs {
state,
ui,
..
} = args;
let widget::UpdateArgs { state, ui, .. } = args;
// TODO: Read from parameter / character struct
let xp_percentage = 0.4;

View File

@ -1,15 +1,10 @@
use super::{font_ids::Fonts, img_ids::Imgs, Windows, TEXT_COLOR};
use crate::hud::Show;
use conrod_core::{
color,
widget::{self, Button, Image, Rectangle, Text},
widget_ids, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
};
use crate::hud::Show;
use super::{
img_ids::Imgs,
font_ids::Fonts,
Windows,
TEXT_COLOR,
};
widget_ids! {
struct Ids {
@ -76,11 +71,7 @@ impl<'a> Widget for SmallWindow<'a> {
}
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
let widget::UpdateArgs {
state,
ui,
..
} = args;
let widget::UpdateArgs { state, ui, .. } = args;
let (title, icon) = match self.content {
SmallWindowType::Social => ("Social", self.imgs.social_icon),
@ -91,14 +82,14 @@ impl<'a> Widget for SmallWindow<'a> {
// Frame
// TODO: Relative to Char Window?
if let Windows::CharacterAnd(_) = self.show.open_windows {
Image::new(self.imgs.window_frame)
Image::new(self.imgs.window_frame)
.top_left_with_margins_on(ui.window, 200.0, 658.0)
.w_h(107.0*4.0, 125.0*4.0)
.w_h(107.0 * 4.0, 125.0 * 4.0)
.set(state.ids.frame, ui);
} else {
Image::new(self.imgs.window_frame)
.top_left_with_margins_on(ui.window, 200.0, 10.0)
.w_h(107.0*4.0, 125.0*4.0)
.w_h(107.0 * 4.0, 125.0 * 4.0)
.set(state.ids.frame, ui);
}
@ -143,4 +134,3 @@ impl<'a> Widget for SmallWindow<'a> {
None
}
}

View File

@ -1,23 +1,11 @@
use std::sync::Arc;
use crate::{
render::Renderer,
ui::{self, Graphic, ScaleMode, Ui},
window::Window,
window::Window,
};
use common::{
assets,
comp::character::{
Character,
Race,
Gender,
Head,
Chest,
Belt,
Pants,
Hand,
Foot,
Weapon,
}
comp::character::{Belt, Character, Chest, Foot, Gender, Hand, Head, Pants, Race, Weapon},
};
use conrod_core::{
color,
@ -27,6 +15,7 @@ use conrod_core::{
widget::{text_box::Event as TextBoxEvent, Button, Image, Rectangle, Text, TextBox},
widget_ids, Borderable, Color, Colorable, Labelable, Positionable, Sizeable, Widget,
};
use std::sync::Arc;
widget_ids! {
struct Ids {
@ -245,14 +234,12 @@ impl Imgs {
fn new(ui: &mut Ui) -> Imgs {
let load_img = |filename, ui: &mut Ui| {
let fullpath: String = ["/voxygen/", filename].concat();
let image = assets::load::<image::DynamicImage>(fullpath.as_str())
.unwrap();
let image = assets::load::<image::DynamicImage>(fullpath.as_str()).unwrap();
ui.add_graphic(Graphic::Image(image))
};
let load_vox = |filename, ui: &mut Ui| {
let fullpath: String = ["/voxygen/", filename].concat();
let dot_vox = assets::load::<dot_vox::DotVoxData>(fullpath.as_str())
.unwrap();
let dot_vox = assets::load::<dot_vox::DotVoxData>(fullpath.as_str()).unwrap();
ui.add_graphic(Graphic::Voxel(dot_vox))
};
Imgs {
@ -374,10 +361,12 @@ impl CharSelectionUi {
// Load fonts
let load_font = |filename, ui: &mut Ui| {
let fullpath: String = ["/voxygen/font", filename].concat();
ui.new_font(Arc::new(conrod_core::text::Font::from_bytes(
assets::load_from_path(fullpath.as_str())
.expect("Error loading file")
).unwrap()))
ui.new_font(Arc::new(
conrod_core::text::Font::from_bytes(
assets::load_from_path(fullpath.as_str()).expect("Error loading file"),
)
.unwrap(),
))
};
let font_opensans = load_font("/OpenSans-Regular.ttf", &mut ui);
let font_metamorph = load_font("/Metamorphous-Regular.ttf", &mut ui);

View File

@ -1,12 +1,9 @@
use std::sync::Arc;
use crate::{
render::Renderer,
ui::{self, Graphic, ScaleMode, Ui},
GlobalState, DEFAULT_PUBLIC_SERVER,
};
use common::{
assets,
};
use common::assets;
use conrod_core::{
color,
color::TRANSPARENT,
@ -16,6 +13,7 @@ use conrod_core::{
widget::{text_box::Event as TextBoxEvent, Button, Image, List, Rectangle, Text, TextBox},
widget_ids, Borderable, Color, Colorable, Labelable, Positionable, Sizeable, Widget,
};
use std::sync::Arc;
widget_ids! {
struct Ids {
@ -68,14 +66,12 @@ impl Imgs {
fn new(ui: &mut Ui) -> Imgs {
let load_img = |filename, ui: &mut Ui| {
let fullpath: String = ["/voxygen/", filename].concat();
let image = assets::load::<image::DynamicImage>(fullpath.as_str())
.unwrap();
let image = assets::load::<image::DynamicImage>(fullpath.as_str()).unwrap();
ui.add_graphic(Graphic::Image(image))
};
let load_vox = |filename, ui: &mut Ui| {
let fullpath: String = ["/voxygen/", filename].concat();
let dot_vox = assets::load::<dot_vox::DotVoxData>(fullpath.as_str())
.unwrap();
let dot_vox = assets::load::<dot_vox::DotVoxData>(fullpath.as_str()).unwrap();
ui.add_graphic(Graphic::Voxel(dot_vox))
};
Imgs {
@ -131,10 +127,10 @@ impl MainMenuUi {
let fullpath: String = ["/voxygen/font", filename].concat();
ui.new_font(Arc::new(
conrod_core::text::Font::from_bytes(
assets::load_from_path(fullpath.as_str()).expect("Error loading file")
assets::load_from_path(fullpath.as_str()).expect("Error loading file"),
)
.unwrap()),
)
.unwrap(),
))
};
let font_opensans = load_font("/OpenSans-Regular.ttf", &mut ui);
let font_metamorph = load_font("/Metamorphous-Regular.ttf", &mut ui);

View File

@ -19,9 +19,9 @@ use common::{
figure::Segment,
msg,
};
use dot_vox::DotVoxData;
use specs::{Component, Entity as EcsEntity, Join, VecStorage};
use std::{collections::HashMap, f32};
use dot_vox::DotVoxData;
use vek::*;
pub struct FigureCache {
@ -101,9 +101,7 @@ impl FigureCache {
fn load_mesh(filename: &str, position: Vec3<f32>) -> Mesh<FigurePipeline> {
let fullpath: String = ["/voxygen/voxel/", filename].concat();
Segment::from(
assets::load_expect::<DotVoxData>(fullpath.as_str()).as_ref()
)
Segment::from(assets::load_expect::<DotVoxData>(fullpath.as_str()).as_ref())
.generate_mesh(position)
}

View File

@ -1,8 +1,8 @@
use std::sync::Arc;
use dot_vox::DotVoxData;
use fnv::FnvHashMap;
use guillotiere::{size2, Allocation, AtlasAllocator};
use image::DynamicImage;
use dot_vox::DotVoxData;
use std::sync::Arc;
use vek::*;
pub enum Graphic {

View File

@ -1,7 +1,7 @@
use super::Graphic;
use common::assets::{load, Error};
use dot_vox::DotVoxData;
use image::DynamicImage;
use common::assets::{Error, load};
pub struct BlankGraphic;
pub struct ImageGraphic;
@ -20,13 +20,13 @@ impl<'a> GraphicCreator<'a> for BlankGraphic {
impl<'a> GraphicCreator<'a> for ImageGraphic {
type Specifier = &'a str;
fn new_graphic(specifier: Self::Specifier) -> Result<Graphic, Error> {
Ok(Graphic::Image(load::<DynamicImage>(specifier)?))
Ok(Graphic::Image(load::<DynamicImage>(specifier)?))
}
}
impl<'a> GraphicCreator<'a> for VoxelGraphic {
type Specifier = &'a str;
fn new_graphic(specifier: Self::Specifier) -> Result<Graphic, Error> {
Ok(Graphic::Voxel(load::<DotVoxData>(specifier)?))
Ok(Graphic::Voxel(load::<DotVoxData>(specifier)?))
}
}
@ -43,7 +43,7 @@ impl<'a> GraphicCreator<'a> for VoxelGraphic {
///
/// <ImageGraphic>
/// background: "background.png",
///
///
/// <BlankGraphic>
/// blank: (),
/// }

View File

@ -1,14 +1,11 @@
mod graphic;
mod util;
mod widgets;
#[macro_use] mod img_ids;
#[macro_use] mod font_ids;
#[macro_use]
mod img_ids;
#[macro_use]
mod font_ids;
use std::sync::Arc;
pub use graphic::Graphic;
pub use widgets::toggle_button::ToggleButton;
pub use img_ids::{BlankGraphic, ImageGraphic, VoxelGraphic, GraphicCreator};
pub(self) use util::{srgb_to_linear, linear_to_srgb};
use crate::{
render::{
create_ui_quad, create_ui_tri, Mesh, Model, RenderError, Renderer, Texture, UiMode,
@ -19,16 +16,21 @@ use crate::{
};
use conrod_core::{
event::Input,
graph::Graph,
image::{Id as ImgId, Map},
input::{touch::Touch, Button, Motion, Widget},
graph::Graph,
render::Primitive,
text::{font::Id as FontId, Font, GlyphCache},
widget::{id::Generator, Id as WidgId},
Ui as CrUi, UiBuilder, UiCell,
};
pub use graphic::Graphic;
use graphic::{GraphicCache, Id as GraphicId};
pub use img_ids::{BlankGraphic, GraphicCreator, ImageGraphic, VoxelGraphic};
use std::sync::Arc;
pub(self) use util::{linear_to_srgb, srgb_to_linear};
use vek::*;
pub use widgets::toggle_button::ToggleButton;
#[derive(Debug)]
pub enum UiError {