mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
rustfmt
Former-commit-id: 7e2cdb284c670b5991c69b6aab042194c806171f
This commit is contained in:
@ -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,
|
||||
@ -46,7 +46,8 @@ lazy_static! {
|
||||
/// ```
|
||||
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()
|
||||
@ -64,8 +65,7 @@ pub fn load<A: Asset + 'static>(specifier: &str) -> Result<Arc<A>, Error> {
|
||||
/// 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())),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
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! {
|
||||
struct 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)
|
||||
@ -99,7 +92,6 @@ impl<'a> Widget for Bag<'a> {
|
||||
.rgba(0.33, 0.33, 0.33, 1.0)
|
||||
.set(state.ids.inv_scrollbar, ui);
|
||||
|
||||
|
||||
if self.inventory_space > 0 {
|
||||
// First Slot
|
||||
Button::image(self.imgs.inv_slot)
|
||||
|
@ -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,20 +84,18 @@ 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)
|
||||
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) {
|
||||
.set(state.ids.bag, ui)
|
||||
{
|
||||
return Some(Event::ToggleBag);
|
||||
}
|
||||
|
||||
|
@ -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,7 +72,7 @@ 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)
|
||||
.w_h(107.0 * 4.0, 125.0 * 4.0)
|
||||
.set(state.charwindow_frame, ui);
|
||||
|
||||
// Icon
|
||||
@ -98,7 +88,8 @@ 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() {
|
||||
.was_clicked()
|
||||
{
|
||||
return Some(Event::Close);
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
.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);
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::ui::{ImageGraphic, VoxelGraphic, BlankGraphic};
|
||||
use crate::ui::{BlankGraphic, ImageGraphic, VoxelGraphic};
|
||||
|
||||
image_ids! {
|
||||
pub struct Imgs {
|
||||
|
@ -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,11 +63,7 @@ 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)
|
||||
@ -102,7 +95,6 @@ impl<'a> Widget for Map<'a> {
|
||||
.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)
|
||||
.w_h(224.0 / 3.0, 224.0 / 3.0)
|
||||
|
@ -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;
|
||||
|
||||
@ -293,7 +295,13 @@ impl Hud {
|
||||
};
|
||||
}
|
||||
|
||||
match Buttons::new(&self.show.open_windows, self.show.map, self.show.bag, &self.imgs, &self.fonts)
|
||||
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(),
|
||||
@ -363,8 +371,7 @@ impl Hud {
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
@ -403,11 +410,13 @@ impl Hud {
|
||||
match SmallWindow::new(small, &self.show, &self.imgs, &self.fonts)
|
||||
.set(self.ids.small_window, ui_widgets)
|
||||
{
|
||||
Some(small_window::Event::Close) => self.show.open_windows = match self.show.open_windows {
|
||||
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 => {}
|
||||
}
|
||||
}
|
||||
@ -417,19 +426,19 @@ impl Hud {
|
||||
match CharacterWindow::new(&self.imgs, &self.fonts)
|
||||
.set(self.ids.character_window, ui_widgets)
|
||||
{
|
||||
Some(character_window::Event::Close) => self.show.open_windows = match small {
|
||||
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,7 +454,7 @@ 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 => {}
|
||||
}
|
||||
}
|
||||
|
||||
@ -466,7 +473,6 @@ impl Hud {
|
||||
.widget(id)
|
||||
.and_then(graph::Container::unique_widget_state::<widget::TextEdit>)
|
||||
.is_some()
|
||||
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
@ -1,17 +1,10 @@
|
||||
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 {
|
||||
@ -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)
|
||||
@ -150,8 +139,6 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.settings_title, ui);
|
||||
|
||||
|
||||
|
||||
// Interface
|
||||
if Button::image(if let SettingsTab::Interface = state.settings_tab {
|
||||
self.imgs.settings_button_pressed
|
||||
@ -226,11 +213,8 @@ 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
|
||||
)
|
||||
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)
|
||||
@ -248,7 +232,6 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.graphics_for(state.ids.debug_button)
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.debug_button_label, ui);
|
||||
|
||||
}
|
||||
|
||||
// 2 Gameplay////////////////
|
||||
|
@ -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;
|
||||
|
@ -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),
|
||||
@ -93,12 +84,12 @@ impl<'a> Widget for SmallWindow<'a> {
|
||||
if let Windows::CharacterAnd(_) = self.show.open_windows {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
use std::sync::Arc;
|
||||
use crate::{
|
||||
render::Renderer,
|
||||
ui::{self, Graphic, ScaleMode, Ui},
|
||||
@ -6,18 +5,7 @@ use crate::{
|
||||
};
|
||||
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);
|
||||
|
@ -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")
|
||||
)
|
||||
.unwrap()),
|
||||
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);
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user