From 3077c002cc6b24287e8e33b493adb20f38b4b2ba Mon Sep 17 00:00:00 2001 From: Imbris Date: Tue, 7 May 2019 02:25:26 -0400 Subject: [PATCH] move conrod font out of common Former-commit-id: 1e7cbce00eddff6c765326671d04d9494639773e --- Cargo.lock | 1 - common/Cargo.toml | 1 - common/src/assets/mod.rs | 7 ------- voxygen/src/menu/char_selection/ui.rs | 7 +------ voxygen/src/menu/main/ui.rs | 7 +------ voxygen/src/ui/mod.rs | 25 ++++++++++++++++++------- 6 files changed, 20 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 730a6a9362..323b04845d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2284,7 +2284,6 @@ name = "veloren-common" version = "0.2.0" dependencies = [ "bincode 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "conrod_core 0.63.0 (git+https://gitlab.com/veloren/conrod.git)", "dot_vox 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/common/Cargo.toml b/common/Cargo.toml index 963a517395..7cbb23e2d8 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -9,7 +9,6 @@ sphynx = { git = "https://gitlab.com/veloren/sphynx.git", features = ["serde1"] specs = { version = "0.14", features = ["serde", "nightly"] } vek = { version = "0.9", features = ["serde"] } -conrod_core = { git = "https://gitlab.com/veloren/conrod.git" } dot_vox = "4.0" image = "0.21" threadpool = "1.7" diff --git a/common/src/assets/mod.rs b/common/src/assets/mod.rs index c2fbe8cb9c..cce075aeed 100644 --- a/common/src/assets/mod.rs +++ b/common/src/assets/mod.rs @@ -1,4 +1,3 @@ -use conrod_core::text::Font; use dot_vox::DotVoxData; use image::DynamicImage; use lazy_static::lazy_static; @@ -85,12 +84,6 @@ impl Asset for DotVoxData { } } -impl Asset for Font { - fn load(specifier: &str) -> Result { - Ok(Font::from_bytes(load_from_path(specifier)?).unwrap()) - } -} - // TODO: System to load file from specifiers (eg "core.ui.backgrounds.city") fn try_open_with_path(name: &str) -> Option { debug!("Trying to access \"{}\"", name); diff --git a/voxygen/src/menu/char_selection/ui.rs b/voxygen/src/menu/char_selection/ui.rs index 4952b05f35..815d5fb040 100644 --- a/voxygen/src/menu/char_selection/ui.rs +++ b/voxygen/src/menu/char_selection/ui.rs @@ -361,12 +361,7 @@ 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(assets::load(fullpath.as_str()).expect("Error loading file")) }; let font_opensans = load_font("/OpenSans-Regular.ttf", &mut ui); let font_metamorph = load_font("/Metamorphous-Regular.ttf", &mut ui); diff --git a/voxygen/src/menu/main/ui.rs b/voxygen/src/menu/main/ui.rs index 6d3cc429ae..a644c579b5 100644 --- a/voxygen/src/menu/main/ui.rs +++ b/voxygen/src/menu/main/ui.rs @@ -125,12 +125,7 @@ impl MainMenuUi { // 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(assets::load(fullpath.as_str()).expect("Error loading file")) }; let font_opensans = load_font("/OpenSans-Regular.ttf", &mut ui); let font_metamorph = load_font("/Metamorphous-Regular.ttf", &mut ui); diff --git a/voxygen/src/ui/mod.rs b/voxygen/src/ui/mod.rs index fc3c24e044..71c2d2db64 100644 --- a/voxygen/src/ui/mod.rs +++ b/voxygen/src/ui/mod.rs @@ -6,6 +6,11 @@ mod img_ids; #[macro_use] mod font_ids; +pub use graphic::Graphic; +pub use img_ids::{BlankGraphic, GraphicCreator, ImageGraphic, VoxelGraphic}; +pub(self) use util::{linear_to_srgb, srgb_to_linear}; +pub use widgets::toggle_button::ToggleButton; + use crate::{ render::{ create_ui_quad, create_ui_tri, Mesh, Model, RenderError, Renderer, Texture, UiMode, @@ -14,23 +19,20 @@ use crate::{ window::Window, Error, }; +use common::assets; use conrod_core::{ event::Input, graph::Graph, image::{Id as ImgId, Map}, input::{touch::Touch, Button, Motion, Widget}, render::Primitive, - text::{font::Id as FontId, Font, GlyphCache}, + text::{self, 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 { @@ -218,6 +220,15 @@ impl Scale { } } +pub struct Font(text::Font); +impl assets::Asset for Font { + fn load(specifier: &str) -> Result { + Ok(Font( + text::Font::from_bytes(assets::load_from_path(specifier)?).unwrap(), + )) + } +} + pub struct Ui { ui: CrUi, image_map: Map, @@ -257,8 +268,8 @@ impl Ui { self.image_map.insert(self.cache.add_graphic(graphic)) } - pub fn new_font(&mut self, mut font: Arc) -> FontId { - self.ui.fonts.insert(Arc::make_mut(&mut font).clone()) + pub fn new_font(&mut self, mut font: Arc) -> text::font::Id { + self.ui.fonts.insert(font.as_ref().0.clone()) } pub fn id_generator(&mut self) -> Generator {