mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'mainmenu-assets' into 'master'
Use image_ids! and font_ids! in main menu and char selection menu See merge request veloren/veloren!114 Former-commit-id: 06087f38f1646bcad9e029529932afe932e0bee2
This commit is contained in:
commit
cd00bcdfa4
@ -1,4 +1,4 @@
|
|||||||
use super::{font_ids::Fonts, img_ids::Imgs};
|
use super::{img_ids::Imgs, Fonts};
|
||||||
use conrod_core::{
|
use conrod_core::{
|
||||||
color,
|
color,
|
||||||
widget::{self, Button, Image, Rectangle, Scrollbar},
|
widget::{self, Button, Image, Rectangle, Scrollbar},
|
||||||
|
@ -3,7 +3,7 @@ use conrod_core::{
|
|||||||
widget_ids, Colorable, Labelable, Positionable, Sizeable, Widget, WidgetCommon,
|
widget_ids, Colorable, Labelable, Positionable, Sizeable, Widget, WidgetCommon,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{font_ids::Fonts, img_ids::Imgs, small_window::SmallWindowType, Windows, TEXT_COLOR};
|
use super::{img_ids::Imgs, small_window::SmallWindowType, Fonts, Windows, TEXT_COLOR};
|
||||||
use crate::ui::ToggleButton;
|
use crate::ui::ToggleButton;
|
||||||
|
|
||||||
widget_ids! {
|
widget_ids! {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use super::{font_ids::Fonts, img_ids::Imgs, TEXT_COLOR, XP_COLOR};
|
use super::{img_ids::Imgs, Fonts, TEXT_COLOR, XP_COLOR};
|
||||||
use conrod_core::{
|
use conrod_core::{
|
||||||
color,
|
color,
|
||||||
widget::{self, Button, Image, Rectangle, Text},
|
widget::{self, Button, Image, Rectangle, Text},
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use super::{font_ids::Fonts, img_ids::Imgs, TEXT_COLOR};
|
use super::{img_ids::Imgs, Fonts, TEXT_COLOR};
|
||||||
use conrod_core::{
|
use conrod_core::{
|
||||||
input::Key,
|
input::Key,
|
||||||
position::Dimension,
|
position::Dimension,
|
||||||
|
@ -3,7 +3,7 @@ use conrod_core::{
|
|||||||
widget_ids, Labelable, Positionable, Sizeable, Widget, WidgetCommon,
|
widget_ids, Labelable, Positionable, Sizeable, Widget, WidgetCommon,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{font_ids::Fonts, img_ids::Imgs, TEXT_COLOR};
|
use super::{img_ids::Imgs, Fonts, TEXT_COLOR};
|
||||||
|
|
||||||
widget_ids! {
|
widget_ids! {
|
||||||
struct Ids {
|
struct Ids {
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
font_ids! {
|
|
||||||
pub struct Fonts {
|
|
||||||
opensans: "/voxygen/font/OpenSans-Regular.ttf",
|
|
||||||
metamorph: "/voxygen/font/Metamorphous-Regular.ttf",
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,7 +4,7 @@ use conrod_core::{
|
|||||||
widget_ids, Positionable, Sizeable, Widget, WidgetCommon,
|
widget_ids, Positionable, Sizeable, Widget, WidgetCommon,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{font_ids::Fonts, img_ids::Imgs};
|
use super::{img_ids::Imgs, Fonts};
|
||||||
|
|
||||||
widget_ids! {
|
widget_ids! {
|
||||||
struct Ids {
|
struct Ids {
|
||||||
|
@ -4,7 +4,7 @@ use conrod_core::{
|
|||||||
widget_ids, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
|
widget_ids, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{font_ids::Fonts, img_ids::Imgs, Show, TEXT_COLOR};
|
use super::{img_ids::Imgs, Fonts, Show, TEXT_COLOR};
|
||||||
|
|
||||||
widget_ids! {
|
widget_ids! {
|
||||||
struct Ids {
|
struct Ids {
|
||||||
|
@ -3,7 +3,6 @@ mod buttons;
|
|||||||
mod character_window;
|
mod character_window;
|
||||||
mod chat;
|
mod chat;
|
||||||
mod esc_menu;
|
mod esc_menu;
|
||||||
mod font_ids;
|
|
||||||
mod img_ids;
|
mod img_ids;
|
||||||
mod map;
|
mod map;
|
||||||
mod minimap;
|
mod minimap;
|
||||||
@ -16,7 +15,6 @@ use buttons::Buttons;
|
|||||||
use character_window::CharacterWindow;
|
use character_window::CharacterWindow;
|
||||||
use chat::Chat;
|
use chat::Chat;
|
||||||
use esc_menu::EscMenu;
|
use esc_menu::EscMenu;
|
||||||
use font_ids::Fonts;
|
|
||||||
use img_ids::Imgs;
|
use img_ids::Imgs;
|
||||||
use map::Map;
|
use map::Map;
|
||||||
use minimap::MiniMap;
|
use minimap::MiniMap;
|
||||||
@ -83,6 +81,13 @@ widget_ids! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
font_ids! {
|
||||||
|
pub struct Fonts {
|
||||||
|
opensans: "/voxygen/font/OpenSans-Regular.ttf",
|
||||||
|
metamorph: "/voxygen/font/Metamorphous-Regular.ttf",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
SendMessage(String),
|
SendMessage(String),
|
||||||
Logout,
|
Logout,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use super::{font_ids::Fonts, img_ids::Imgs, TEXT_COLOR};
|
use super::{img_ids::Imgs, Fonts, TEXT_COLOR};
|
||||||
use crate::{hud::Show, ui::ToggleButton};
|
use crate::{hud::Show, ui::ToggleButton};
|
||||||
use conrod_core::{
|
use conrod_core::{
|
||||||
color,
|
color,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use super::{font_ids::Fonts, img_ids::Imgs, HP_COLOR, MANA_COLOR, TEXT_COLOR, XP_COLOR};
|
use super::{img_ids::Imgs, Fonts, HP_COLOR, MANA_COLOR, TEXT_COLOR, XP_COLOR};
|
||||||
use conrod_core::{
|
use conrod_core::{
|
||||||
widget::{self, Image, Rectangle, Text},
|
widget::{self, Image, Rectangle, Text},
|
||||||
widget_ids, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
|
widget_ids, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use super::{font_ids::Fonts, img_ids::Imgs, Windows, TEXT_COLOR};
|
use super::{img_ids::Imgs, Fonts, Windows, TEXT_COLOR};
|
||||||
use crate::hud::Show;
|
use crate::hud::Show;
|
||||||
use conrod_core::{
|
use conrod_core::{
|
||||||
color,
|
color,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
render::Renderer,
|
render::Renderer,
|
||||||
ui::{self, Graphic, ScaleMode, Ui},
|
ui::{self, BlankGraphic, Graphic, ImageGraphic, ScaleMode, Ui, VoxelGraphic},
|
||||||
window::Window,
|
window::Window,
|
||||||
};
|
};
|
||||||
use common::{
|
use common::{
|
||||||
@ -85,8 +85,6 @@ widget_ids! {
|
|||||||
test_char_l_big,
|
test_char_l_big,
|
||||||
help_text_bg,
|
help_text_bg,
|
||||||
help_text,
|
help_text,
|
||||||
//test_char_m_button,
|
|
||||||
//test_char_r_button,
|
|
||||||
|
|
||||||
// Char Creation
|
// Char Creation
|
||||||
// Race Icons
|
// Race Icons
|
||||||
@ -160,158 +158,84 @@ widget_ids! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Imgs {
|
image_ids! {
|
||||||
v_logo: ImgId,
|
struct Imgs {
|
||||||
bg_selection: ImgId,
|
<VoxelGraphic>
|
||||||
bg_creation: ImgId,
|
v_logo: "/voxygen/element/v_logo.vox",
|
||||||
button: ImgId,
|
button: "/voxygen/element/buttons/button.vox",
|
||||||
button_hover: ImgId,
|
button_hover: "/voxygen/element/buttons/button_hover.vox",
|
||||||
button_press: ImgId,
|
button_press: "/voxygen/element/buttons/button_press.vox",
|
||||||
button_red: ImgId,
|
button_red: "/voxygen/element/buttons/button_red.vox",
|
||||||
button_red_hover: ImgId,
|
button_red_hover: "/voxygen/element/buttons/button_red_hover.vox",
|
||||||
button_red_press: ImgId,
|
button_red_press: "/voxygen/element/buttons/button_red_press.vox",
|
||||||
selection_window: ImgId,
|
name_input: "/voxygen/element/misc_bg/textbox.vox",
|
||||||
test_char_l_button: ImgId,
|
|
||||||
test_char_l_big: ImgId,
|
|
||||||
name_input: ImgId,
|
|
||||||
creation_window: ImgId,
|
|
||||||
creation_window_body: ImgId,
|
|
||||||
frame_closed: ImgId,
|
|
||||||
frame_closed_mo: ImgId,
|
|
||||||
frame_closed_press: ImgId,
|
|
||||||
frame_open: ImgId,
|
|
||||||
frame_open_mo: ImgId,
|
|
||||||
frame_open_press: ImgId,
|
|
||||||
skin_eyes_window: ImgId,
|
|
||||||
hair_window: ImgId,
|
|
||||||
accessories_window: ImgId,
|
|
||||||
color_picker_bg: ImgId,
|
|
||||||
slider_range: ImgId,
|
|
||||||
slider_indicator: ImgId,
|
|
||||||
window_frame_2: ImgId,
|
|
||||||
|
|
||||||
//test_char_m_button: ImgId,
|
<ImageGraphic>
|
||||||
//test_char_r_button: ImgId,
|
bg_selection: "/voxygen/background/bg_selection.png",
|
||||||
// Race Icons
|
bg_creation: "/voxygen/background/bg_creation.png",
|
||||||
male: ImgId,
|
selection_window: "/voxygen/element/frames/selection.png",
|
||||||
female: ImgId,
|
test_char_l_button: "/voxygen/element/misc_bg/test_char_l.png",
|
||||||
human_m: ImgId,
|
test_char_l_big: "/voxygen/element/misc_bg/test_char_l_big.png",
|
||||||
human_f: ImgId,
|
creation_window: "/voxygen/element/frames/char_creation.png",
|
||||||
orc_m: ImgId,
|
creation_window_body: "/voxygen/element/frames/body_creation.png",
|
||||||
orc_f: ImgId,
|
frame_closed: "/voxygen/element/buttons/frame/closed.png",
|
||||||
dwarf_m: ImgId,
|
frame_closed_mo: "/voxygen/element/buttons/frame/closed_mo.png",
|
||||||
dwarf_f: ImgId,
|
frame_closed_press: "/voxygen/element/buttons/frame/closed_press.png",
|
||||||
undead_m: ImgId,
|
frame_open: "/voxygen/element/buttons/frame/open.png",
|
||||||
undead_f: ImgId,
|
frame_open_mo: "/voxygen/element/buttons/frame/open_mo.png",
|
||||||
elf_m: ImgId,
|
frame_open_press: "/voxygen/element/buttons/frame/open_press.png",
|
||||||
elf_f: ImgId,
|
skin_eyes_window: "/voxygen/element/frames/skin_eyes.png",
|
||||||
danari_m: ImgId,
|
hair_window: "/voxygen/element/frames/skin_eyes.png",
|
||||||
danari_f: ImgId,
|
accessories_window: "/voxygen/element/frames/skin_eyes.png",
|
||||||
// Weapon Icons
|
color_picker_bg: "/voxygen/element/misc_bg/color_picker_blank.png",
|
||||||
daggers: ImgId,
|
slider_range: "/voxygen/element/slider/track.png",
|
||||||
sword_shield: ImgId,
|
slider_indicator: "/voxygen/element/slider/indicator.png",
|
||||||
sword: ImgId,
|
window_frame_2: "/voxygen/element/frames/window_2.png",
|
||||||
axe: ImgId,
|
|
||||||
hammer: ImgId,
|
|
||||||
bow: ImgId,
|
|
||||||
staff: ImgId,
|
|
||||||
// Arrows
|
|
||||||
arrow_left: ImgId,
|
|
||||||
arrow_left_mo: ImgId,
|
|
||||||
arrow_left_press: ImgId,
|
|
||||||
arrow_left_grey: ImgId,
|
|
||||||
arrow_right: ImgId,
|
|
||||||
arrow_right_mo: ImgId,
|
|
||||||
arrow_right_press: ImgId,
|
|
||||||
arrow_right_grey: ImgId,
|
|
||||||
// Icon Borders
|
|
||||||
icon_border: ImgId,
|
|
||||||
icon_border_mo: ImgId,
|
|
||||||
icon_border_press: ImgId,
|
|
||||||
icon_border_pressed: ImgId,
|
|
||||||
}
|
|
||||||
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();
|
|
||||||
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();
|
|
||||||
ui.add_graphic(Graphic::Voxel(dot_vox))
|
|
||||||
};
|
|
||||||
Imgs {
|
|
||||||
v_logo: load_vox("element/v_logo.vox", ui),
|
|
||||||
bg_selection: load_img("background/bg_selection.png", ui),
|
|
||||||
bg_creation: load_img("background/bg_creation.png", ui),
|
|
||||||
selection_window: load_img("element/frames/selection.png", ui),
|
|
||||||
button: load_vox("element/buttons/button.vox", ui),
|
|
||||||
button_hover: load_vox("element/buttons/button_hover.vox", ui),
|
|
||||||
button_press: load_vox("element/buttons/button_press.vox", ui),
|
|
||||||
button_red: load_vox("element/buttons/button_red.vox", ui),
|
|
||||||
button_red_hover: load_vox("element/buttons/button_red_hover.vox", ui),
|
|
||||||
button_red_press: load_vox("element/buttons/button_red_press.vox", ui),
|
|
||||||
test_char_l_button: load_img("element/misc_bg/test_char_l.png", ui),
|
|
||||||
test_char_l_big: load_img("element/misc_bg/test_char_l_big.png", ui),
|
|
||||||
name_input: load_vox("element/misc_bg/textbox.vox", ui),
|
|
||||||
creation_window: load_img("element/frames/char_creation.png", ui),
|
|
||||||
creation_window_body: load_img("element/frames/body_creation.png", ui),
|
|
||||||
frame_closed: load_img("element/buttons/frame/closed.png", ui),
|
|
||||||
frame_closed_mo: load_img("element/buttons/frame/closed_mo.png", ui),
|
|
||||||
frame_closed_press: load_img("element/buttons/frame/closed_press.png", ui),
|
|
||||||
frame_open: load_img("element/buttons/frame/open.png", ui),
|
|
||||||
frame_open_mo: load_img("element/buttons/frame/open_mo.png", ui),
|
|
||||||
frame_open_press: load_img("element/buttons/frame/open_press.png", ui),
|
|
||||||
skin_eyes_window: load_img("element/frames/skin_eyes.png", ui),
|
|
||||||
hair_window: load_img("element/frames/skin_eyes.png", ui),
|
|
||||||
accessories_window: load_img("element/frames/skin_eyes.png", ui),
|
|
||||||
color_picker_bg: load_img("element/misc_bg/color_picker_blank.png", ui),
|
|
||||||
slider_range: load_img("element/slider/track.png", ui),
|
|
||||||
slider_indicator: load_img("element/slider/indicator.png", ui),
|
|
||||||
window_frame_2: load_img("element/frames/window_2.png", ui),
|
|
||||||
|
|
||||||
// Weapon Icons
|
// Weapon Icons
|
||||||
daggers: load_img("element/icons/daggers.png", ui),
|
daggers: "/voxygen/element/icons/daggers.png",
|
||||||
sword_shield: load_img("element/icons/swordshield.png", ui),
|
sword_shield: "/voxygen/element/icons/swordshield.png",
|
||||||
sword: load_img("element/icons/sword.png", ui),
|
sword: "/voxygen/element/icons/sword.png",
|
||||||
axe: load_img("element/icons/axe.png", ui),
|
axe: "/voxygen/element/icons/axe.png",
|
||||||
hammer: load_img("element/icons/hammer.png", ui),
|
hammer: "/voxygen/element/icons/hammer.png",
|
||||||
bow: load_img("element/icons/bow.png", ui),
|
bow: "/voxygen/element/icons/bow.png",
|
||||||
staff: load_img("element/icons/staff.png", ui),
|
staff: "/voxygen/element/icons/staff.png",
|
||||||
//test_char_m_button: load_img("test_char_m_button"),
|
|
||||||
//test_char_r_button: load_img("test_char_r_button"),
|
|
||||||
// Race Icons
|
// Race Icons
|
||||||
male: load_img("element/icons/male.png", ui),
|
male: "/voxygen/element/icons/male.png",
|
||||||
female: load_img("element/icons/female.png", ui),
|
female: "/voxygen/element/icons/female.png",
|
||||||
human_m: load_img("element/icons/human_m.png", ui),
|
human_m: "/voxygen/element/icons/human_m.png",
|
||||||
human_f: load_img("element/icons/human_f.png", ui),
|
human_f: "/voxygen/element/icons/human_f.png",
|
||||||
orc_m: load_img("element/icons/orc_m.png", ui),
|
orc_m: "/voxygen/element/icons/orc_m.png",
|
||||||
orc_f: load_img("element/icons/orc_f.png", ui),
|
orc_f: "/voxygen/element/icons/orc_f.png",
|
||||||
dwarf_m: load_img("element/icons/dwarf_m.png", ui),
|
dwarf_m: "/voxygen/element/icons/dwarf_m.png",
|
||||||
dwarf_f: load_img("element/icons/dwarf_f.png", ui),
|
dwarf_f: "/voxygen/element/icons/dwarf_f.png",
|
||||||
undead_m: load_img("element/icons/ud_m.png", ui),
|
undead_m: "/voxygen/element/icons/ud_m.png",
|
||||||
undead_f: load_img("element/icons/ud_f.png", ui),
|
undead_f: "/voxygen/element/icons/ud_f.png",
|
||||||
elf_m: load_img("element/icons/elf_m.png", ui),
|
elf_m: "/voxygen/element/icons/elf_m.png",
|
||||||
elf_f: load_img("element/icons/elf_f.png", ui),
|
elf_f: "/voxygen/element/icons/elf_f.png",
|
||||||
danari_m: load_img("element/icons/danari_m.png", ui),
|
danari_m: "/voxygen/element/icons/danari_m.png",
|
||||||
danari_f: load_img("element/icons/danari_f.png", ui),
|
danari_f: "/voxygen/element/icons/danari_f.png",
|
||||||
// Arrows
|
// Arrows
|
||||||
arrow_left: load_img("element/buttons/arrow/left.png", ui),
|
arrow_left: "/voxygen/element/buttons/arrow/left.png",
|
||||||
arrow_left_mo: load_img("element/buttons/arrow/left_mo.png", ui),
|
arrow_left_mo: "/voxygen/element/buttons/arrow/left_mo.png",
|
||||||
arrow_left_press: load_img("element/buttons/arrow/left_press.png", ui),
|
arrow_left_press: "/voxygen/element/buttons/arrow/left_press.png",
|
||||||
arrow_left_grey: load_img("element/buttons/arrow/left_inactive.png", ui),
|
arrow_left_grey: "/voxygen/element/buttons/arrow/left_inactive.png",
|
||||||
arrow_right: load_img("element/buttons/arrow/right.png", ui),
|
arrow_right: "/voxygen/element/buttons/arrow/right.png",
|
||||||
arrow_right_mo: load_img("element/buttons/arrow/right_mo.png", ui),
|
arrow_right_mo: "/voxygen/element/buttons/arrow/right_mo.png",
|
||||||
arrow_right_press: load_img("element/buttons/arrow/right_press.png", ui),
|
arrow_right_press: "/voxygen/element/buttons/arrow/right_press.png",
|
||||||
arrow_right_grey: load_img("element/buttons/arrow/right_inactive.png", ui),
|
arrow_right_grey: "/voxygen/element/buttons/arrow/right_inactive.png",
|
||||||
// Icon Borders
|
// Icon Borders
|
||||||
icon_border: load_img("element/buttons/border.png", ui),
|
icon_border: "/voxygen/element/buttons/border.png",
|
||||||
icon_border_mo: load_img("element/buttons/border_mo.png", ui),
|
icon_border_mo: "/voxygen/element/buttons/border_mo.png",
|
||||||
icon_border_press: load_img("element/buttons/border_press.png", ui),
|
icon_border_press: "/voxygen/element/buttons/border_press.png",
|
||||||
icon_border_pressed: load_img("element/buttons/border_pressed.png", ui),
|
icon_border_pressed: "/voxygen/element/buttons/border_pressed.png",
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
font_ids! {
|
||||||
|
pub struct Fonts {
|
||||||
|
opensans: "/voxygen/font/OpenSans-Regular.ttf",
|
||||||
|
metamorph: "/voxygen/font/Metamorphous-Regular.ttf",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,8 +264,7 @@ pub struct CharSelectionUi {
|
|||||||
ui: Ui,
|
ui: Ui,
|
||||||
ids: Ids,
|
ids: Ids,
|
||||||
imgs: Imgs,
|
imgs: Imgs,
|
||||||
font_metamorph: FontId,
|
fonts: Fonts,
|
||||||
font_opensans: FontId,
|
|
||||||
character_creation: bool,
|
character_creation: bool,
|
||||||
selected_char_no: Option<i32>,
|
selected_char_no: Option<i32>,
|
||||||
character_name: String,
|
character_name: String,
|
||||||
@ -357,22 +280,16 @@ impl CharSelectionUi {
|
|||||||
// Generate ids
|
// Generate ids
|
||||||
let ids = Ids::new(ui.id_generator());
|
let ids = Ids::new(ui.id_generator());
|
||||||
// Load images
|
// Load images
|
||||||
let imgs = Imgs::new(&mut ui);
|
let imgs = Imgs::load(&mut ui).expect("Failed to load images");
|
||||||
// Load fonts
|
// Load fonts
|
||||||
let load_font = |filename, ui: &mut Ui| {
|
let fonts = Fonts::load(&mut ui).expect("Failed to load fonts");
|
||||||
let fullpath: String = ["/voxygen/font", filename].concat();
|
|
||||||
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);
|
|
||||||
|
|
||||||
// TODO: Randomize initial values
|
// TODO: Randomize initial values
|
||||||
Self {
|
Self {
|
||||||
ui,
|
ui,
|
||||||
imgs,
|
|
||||||
ids,
|
ids,
|
||||||
font_metamorph,
|
imgs,
|
||||||
font_opensans,
|
fonts,
|
||||||
character_creation: false,
|
character_creation: false,
|
||||||
selected_char_no: None,
|
selected_char_no: None,
|
||||||
character_name: "Character Name".to_string(),
|
character_name: "Character Name".to_string(),
|
||||||
@ -574,7 +491,7 @@ impl CharSelectionUi {
|
|||||||
.w_h(300.0, 60.0)
|
.w_h(300.0, 60.0)
|
||||||
.mid_top_with_margin_on(self.ids.name_input, 2.0)
|
.mid_top_with_margin_on(self.ids.name_input, 2.0)
|
||||||
.font_size(26)
|
.font_size(26)
|
||||||
.font_id(self.font_metamorph)
|
.font_id(self.fonts.metamorph)
|
||||||
.center_justify()
|
.center_justify()
|
||||||
.text_color(TEXT_COLOR)
|
.text_color(TEXT_COLOR)
|
||||||
.color(TRANSPARENT)
|
.color(TRANSPARENT)
|
||||||
@ -931,7 +848,7 @@ impl CharSelectionUi {
|
|||||||
.mid_top_with_margin_on(self.ids.creation_window, 410.0)
|
.mid_top_with_margin_on(self.ids.creation_window, 410.0)
|
||||||
.w(500.0)
|
.w(500.0)
|
||||||
.font_size(20)
|
.font_size(20)
|
||||||
.font_id(self.font_opensans)
|
.font_id(self.fonts.opensans)
|
||||||
.color(TEXT_COLOR)
|
.color(TEXT_COLOR)
|
||||||
.wrap_by_word()
|
.wrap_by_word()
|
||||||
.set(self.ids.race_description, ui_widgets);
|
.set(self.ids.race_description, ui_widgets);
|
||||||
@ -1105,7 +1022,7 @@ impl CharSelectionUi {
|
|||||||
.mid_top_with_margin_on(self.ids.creation_window, 410.0)
|
.mid_top_with_margin_on(self.ids.creation_window, 410.0)
|
||||||
.w(500.0)
|
.w(500.0)
|
||||||
.font_size(20)
|
.font_size(20)
|
||||||
.font_id(self.font_opensans)
|
.font_id(self.fonts.opensans)
|
||||||
.color(TEXT_COLOR)
|
.color(TEXT_COLOR)
|
||||||
.wrap_by_word()
|
.wrap_by_word()
|
||||||
.set(self.ids.race_description, ui_widgets);
|
.set(self.ids.race_description, ui_widgets);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
render::Renderer,
|
render::Renderer,
|
||||||
ui::{self, Graphic, ScaleMode, Ui},
|
ui::{self, BlankGraphic, Graphic, ImageGraphic, ScaleMode, Ui, VoxelGraphic},
|
||||||
GlobalState, DEFAULT_PUBLIC_SERVER,
|
GlobalState, DEFAULT_PUBLIC_SERVER,
|
||||||
};
|
};
|
||||||
use common::assets;
|
use common::assets;
|
||||||
@ -51,41 +51,25 @@ widget_ids! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Imgs {
|
image_ids! {
|
||||||
bg: ImgId,
|
struct Imgs {
|
||||||
v_logo: ImgId,
|
<VoxelGraphic>
|
||||||
|
v_logo: "/voxygen/element/v_logo.vox",
|
||||||
|
input_bg: "/voxygen/element/misc_bg/textbox.vox",
|
||||||
|
button: "/voxygen/element/buttons/button.vox",
|
||||||
|
button_hover: "/voxygen/element/buttons/button_hover.vox",
|
||||||
|
button_press: "/voxygen/element/buttons/button_press.vox",
|
||||||
|
|
||||||
input_bg: ImgId,
|
<ImageGraphic>
|
||||||
|
bg: "/voxygen/background/bg_main.png",
|
||||||
error_frame: ImgId,
|
error_frame: "/voxygen/element/frames/window_2.png",
|
||||||
button: ImgId,
|
|
||||||
button_hover: ImgId,
|
|
||||||
button_press: ImgId,
|
|
||||||
}
|
|
||||||
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();
|
|
||||||
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();
|
|
||||||
ui.add_graphic(Graphic::Voxel(dot_vox))
|
|
||||||
};
|
|
||||||
Imgs {
|
|
||||||
bg: load_img("background/bg_main.png", ui),
|
|
||||||
v_logo: load_vox("element/v_logo.vox", ui),
|
|
||||||
|
|
||||||
// Input fields
|
|
||||||
input_bg: load_vox("element/misc_bg/textbox.vox", ui),
|
|
||||||
|
|
||||||
error_frame: load_img("element/frames/window_2.png", ui),
|
|
||||||
button: load_vox("element/buttons/button.vox", ui),
|
|
||||||
button_hover: load_vox("element/buttons/button_hover.vox", ui),
|
|
||||||
button_press: load_vox("element/buttons/button_press.vox", ui),
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
font_ids! {
|
||||||
|
pub struct Fonts {
|
||||||
|
opensans: "/voxygen/font/OpenSans-Regular.ttf",
|
||||||
|
metamorph: "/voxygen/font/Metamorphous-Regular.ttf",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,8 +86,7 @@ pub struct MainMenuUi {
|
|||||||
ui: Ui,
|
ui: Ui,
|
||||||
ids: Ids,
|
ids: Ids,
|
||||||
imgs: Imgs,
|
imgs: Imgs,
|
||||||
font_metamorph: FontId,
|
fonts: Fonts,
|
||||||
font_opensans: FontId,
|
|
||||||
username: String,
|
username: String,
|
||||||
server_address: String,
|
server_address: String,
|
||||||
login_error: Option<String>,
|
login_error: Option<String>,
|
||||||
@ -121,21 +104,15 @@ impl MainMenuUi {
|
|||||||
// Generate ids
|
// Generate ids
|
||||||
let ids = Ids::new(ui.id_generator());
|
let ids = Ids::new(ui.id_generator());
|
||||||
// Load images
|
// Load images
|
||||||
let imgs = Imgs::new(&mut ui);
|
let imgs = Imgs::load(&mut ui).expect("Failed to load images");
|
||||||
// Load fonts
|
// Load fonts
|
||||||
let load_font = |filename, ui: &mut Ui| {
|
let fonts = Fonts::load(&mut ui).expect("Failed to load fonts");
|
||||||
let fullpath: String = ["/voxygen/font", filename].concat();
|
|
||||||
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);
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
ui,
|
ui,
|
||||||
imgs,
|
|
||||||
ids,
|
ids,
|
||||||
font_metamorph,
|
imgs,
|
||||||
font_opensans,
|
fonts,
|
||||||
username: networking.username.clone(),
|
username: networking.username.clone(),
|
||||||
server_address: networking.servers[networking.default_server].clone(),
|
server_address: networking.servers[networking.default_server].clone(),
|
||||||
login_error: None,
|
login_error: None,
|
||||||
@ -162,6 +139,7 @@ impl MainMenuUi {
|
|||||||
.color(TEXT_COLOR)
|
.color(TEXT_COLOR)
|
||||||
.set(self.ids.version, ui_widgets);
|
.set(self.ids.version, ui_widgets);
|
||||||
|
|
||||||
|
// TODO: Don't use macros for this?
|
||||||
// Input fields
|
// Input fields
|
||||||
// Used when the login button is pressed, or enter is pressed within input field
|
// Used when the login button is pressed, or enter is pressed within input field
|
||||||
macro_rules! login {
|
macro_rules! login {
|
||||||
@ -175,8 +153,8 @@ impl MainMenuUi {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//Singleplayer
|
// Singleplayer
|
||||||
//Used when the singleplayer button is pressed
|
// Used when the singleplayer button is pressed
|
||||||
macro_rules! singleplayer {
|
macro_rules! singleplayer {
|
||||||
() => {
|
() => {
|
||||||
self.login_error = None;
|
self.login_error = None;
|
||||||
@ -201,7 +179,7 @@ impl MainMenuUi {
|
|||||||
.w_h(290.0, 30.0)
|
.w_h(290.0, 30.0)
|
||||||
.mid_bottom_with_margin_on(self.ids.username_bg, 44.0 / 2.0)
|
.mid_bottom_with_margin_on(self.ids.username_bg, 44.0 / 2.0)
|
||||||
.font_size(22)
|
.font_size(22)
|
||||||
.font_id(self.font_opensans)
|
.font_id(self.fonts.opensans)
|
||||||
.text_color(TEXT_COLOR)
|
.text_color(TEXT_COLOR)
|
||||||
// transparent background
|
// transparent background
|
||||||
.color(TRANSPARENT)
|
.color(TRANSPARENT)
|
||||||
@ -223,7 +201,7 @@ impl MainMenuUi {
|
|||||||
let text = Text::new(&msg)
|
let text = Text::new(&msg)
|
||||||
.rgba(1.0, 1.0, 1.0, 1.0)
|
.rgba(1.0, 1.0, 1.0, 1.0)
|
||||||
.font_size(30)
|
.font_size(30)
|
||||||
.font_id(self.font_opensans);
|
.font_id(self.fonts.opensans);
|
||||||
Rectangle::fill_with([400.0, 100.0], color::TRANSPARENT)
|
Rectangle::fill_with([400.0, 100.0], color::TRANSPARENT)
|
||||||
.rgba(0.1, 0.1, 0.1, 1.0)
|
.rgba(0.1, 0.1, 0.1, 1.0)
|
||||||
.parent(ui_widgets.window)
|
.parent(ui_widgets.window)
|
||||||
@ -322,7 +300,7 @@ impl MainMenuUi {
|
|||||||
.w_h(290.0, 30.0)
|
.w_h(290.0, 30.0)
|
||||||
.mid_bottom_with_margin_on(self.ids.address_bg, 44.0 / 2.0)
|
.mid_bottom_with_margin_on(self.ids.address_bg, 44.0 / 2.0)
|
||||||
.font_size(22)
|
.font_size(22)
|
||||||
.font_id(self.font_opensans)
|
.font_id(self.fonts.opensans)
|
||||||
.text_color(TEXT_COLOR)
|
.text_color(TEXT_COLOR)
|
||||||
// transparent background
|
// transparent background
|
||||||
.color(TRANSPARENT)
|
.color(TRANSPARENT)
|
||||||
|
Loading…
Reference in New Issue
Block a user