modify chat visually, replace whitney with opensans, add to charcreation

Former-commit-id: 50ec03271ae5e9e7995144fd2d0701f62a68e5f7
This commit is contained in:
Imbris 2019-03-27 22:25:08 -04:00
parent f753a64018
commit 589110c2f5
43 changed files with 705 additions and 128 deletions

View File

@ -2,6 +2,7 @@ use crate::ui::Ui;
use conrod_core::{
input::Key,
position::Dimension,
text::font::Id as FontId,
widget::{Id, List, Rectangle, Text, TextEdit},
widget_ids, Color, Colorable, Positionable, Sizeable, UiCell, Widget,
};
@ -15,6 +16,12 @@ widget_ids! {
input_bg,
}
}
// Chat Behaviour:
// Input Window is only shown when the player presses Enter (graphical overlay to make it look better?)
// Instead of a Scrollbar it could have 3 Arrows at it's left side
// First two: Scroll the chat up and down
// Last one: Gets back to the bottom of the chat
// Consider making this a custom Widget
pub struct Chat {
ids: Ids,
@ -35,7 +42,7 @@ impl Chat {
id == self.ids.input
}
pub fn new_message(&mut self, msg: String) {
self.messages.push_back(msg);
self.messages.push_front(msg);
self.new_messages = true;
}
// Determine if the message box is scrolled to the bottom
@ -53,19 +60,20 @@ impl Chat {
}
}
}
pub fn update_layout(&mut self, ui_widgets: &mut UiCell) -> Option<String> {
pub fn update_layout(&mut self, ui_widgets: &mut UiCell, font: FontId) -> Option<String> {
// Maintain scrolling
if self.new_messages {
self.scroll_new_messages(ui_widgets);
//self.scroll_new_messages(ui_widgets);
self.new_messages = false;
}
// Chat input with rectangle as background
let text_edit = TextEdit::new(&self.input)
.w(500.0)
.w(470.0)
.restrict_to_height(false)
.font_size(30)
.bottom_left_with_margin_on(ui_widgets.window, 10.0);
.font_size(14)
.font_id(font)
.bottom_left_with_margins_on(ui_widgets.window, 10.0, 30.0);
let dims = match (
text_edit.get_x_dimension(ui_widgets),
text_edit.get_y_dimension(ui_widgets),
@ -84,21 +92,22 @@ impl Chat {
}
// Message box
Rectangle::fill([500.0, 300.0])
.rgba(0.0, 0.0, 0.0, 0.5)
Rectangle::fill([470.0, 180.0])
.rgba(0.0, 0.0, 0.0, 0.4)
.up_from(self.ids.input, 0.0)
.set(self.ids.message_box_bg, ui_widgets);
let (mut items, scrollbar) = List::flow_down(self.messages.len())
let (mut items, scrollbar) = List::flow_up(self.messages.len())
.middle_of(self.ids.message_box_bg)
.scrollbar_next_to()
.scrollbar_thickness(20.0)
.scrollbar_thickness(18.0)
.scrollbar_color(Color::Rgba(0.0, 0.0, 0.0, 1.0))
.set(self.ids.message_box, ui_widgets);
while let Some(item) = items.next(ui_widgets) {
item.set(
Text::new(&self.messages[item.i])
.font_size(30)
.rgba(1.0, 1.0, 1.0, 1.0),
.font_size(14)
.font_id(font)
.rgba(220.0, 220.0, 220.0, 1.0),
ui_widgets,
)
}

View File

@ -6,11 +6,12 @@ use crate::{
window::{Event as WinEvent, Window, Key},
};
use conrod_core::{
color,
event::Input,
image::Id as ImgId,
text::font::Id as FontId,
widget::{Button, Image, Text, TitleBar},
widget_ids, Borderable,
Colorable, Labelable, Positionable, Sizeable, Widget,
widget::{Button, Image, Text, Rectangle},
widget_ids, Colorable, Labelable, Positionable, Sizeable, Widget,
};
widget_ids! {
@ -20,8 +21,9 @@ widget_ids! {
bag_contents,
bag_close,
bag_map_open,
//Halp
halp,
//help
help,
help_bg,
//ESC-Menu
esc_bg,
fireplace,
@ -73,6 +75,7 @@ widget_ids! {
sound,
gameplay,
controls,
rectangle,
//1 Social
social_frame,
social_bg,
@ -160,6 +163,7 @@ struct Imgs {
//Missing: Buff Frame Animation
window_frame: ImgId,
window_frame_2: ImgId,
//Settings-Window
settings_bg: ImgId,
settings_icon: ImgId,
@ -190,8 +194,8 @@ struct Imgs {
//Quest-Log Window
questlog_bg: ImgId,
questlog_icon: ImgId,
//Halp
//halp: ImgId,
//help
//help: ImgId,
}
impl Imgs {
fn new(ui: &mut Ui, renderer: &mut Renderer) -> Imgs {
@ -250,8 +254,9 @@ impl Imgs {
//buff_frame_red: load("skill_bar/buff_frame_red.png"),
//buff_frame_green: load("skill_bar/buff_frame_green.png"),
//Missing: Buff Frame Animation (.gif ?!)
//Missing: Buff Frame Animation (.gif ?!) (we could do animation in ui.maintain(), or in shader?)
window_frame: load("window_frame.png"),
window_frame_2: load("window_frame_2.png"),
//Settings Window
settings_bg: load("settings/bg.png"),
@ -314,7 +319,7 @@ pub struct Hud {
typing: bool,
cursor_grabbed: bool,
font_metamorph: FontId,
font_whitney: FontId,
font_opensans: FontId,
show_help: bool,
bag_open: bool,
menu_open: bool,
@ -337,10 +342,10 @@ impl Hud {
// Load images
let imgs = Imgs::new(&mut ui, window.renderer_mut());
// Load fonts
let font_whitney = ui.new_font(
let font_opensans = ui.new_font(
conrod_core::text::font::from_file(concat!(
env!("CARGO_MANIFEST_DIR"),
"/test_assets/font/Whitney-Book.ttf"
"/test_assets/font/OpenSans-Regular.ttf"
))
.unwrap(),
);
@ -370,9 +375,8 @@ impl Hud {
mmap_button_3: false,
mmap_button_4: false,
mmap_button_5: false,
font_metamorph,
font_whitney,
font_opensans,
}
}
@ -381,13 +385,18 @@ impl Hud {
let ref mut ui_widgets = self.ui.set_widgets();
// Chat box
if let Some(msg) = self.chat.update_layout(ui_widgets) {
if let Some(msg) = self.chat.update_layout(ui_widgets, self.font_opensans) {
events.push(Event::SendMessage(msg));
}
//Help Text
// Help Text
if self.show_help {
TitleBar::new(
Image::new(self.imgs.window_frame_2)
.top_left_with_margins_on(ui_widgets.window, 5.0, 5.0)
.w_h(300.0, 300.0)
.set(self.ids.help_bg, ui_widgets);
Text::new(
"Tab = Free Cursor \n\
Esc = Open/Close Menus \n\
Q = Back to Login \n\
@ -401,21 +410,15 @@ impl Hud {
C = Character Window \n\
O = Social \n\
P = Spellbook \n\
N = Settings",
self.ids.halp,
)
.rgba(235.0, 170.0, 114.0, 0.3)
.border_rgba(235.0, 170.0, 114.0, 1.0)
.top_left_of(ui_widgets.window)
.w_h(300.0, 280.0)
.font_id(self.font_whitney)
.label_font_size(18)
.label_rgba(0.0, 0.0, 0.0, 1.0)
.left_justify_label()
.set(self.ids.halp, ui_widgets);
N = Settings")
.rgba(220.0, 220.0, 220.0, 0.8)
.top_left_with_margins_on(self.ids.help_bg, 20.0,20.0)
.font_id(self.font_opensans)
.font_size(18)
.set(self.ids.help, ui_widgets);
if Button::image(self.imgs.button_dark)
.w_h(50.0, 30.0)
.bottom_right_with_margin_on(self.ids.halp, 0.0)
.bottom_right_with_margins_on(self.ids.help_bg, 10.0, 10.0)
.hover_image(self.imgs.button_dark_hover)
.press_image(self.imgs.button_dark_press)
.label("Close")
@ -682,15 +685,20 @@ impl Hud {
.w_h(224.0 / 3.0, 224.0 / 3.0)
.top_left_with_margins_on(self.ids.settings_bg, -10.0, -10.0)
.set(self.ids.settings_icon, ui_widgets);
// TODO: Find out if we can remove this
// Alignment Rectangle
Rectangle::fill_with([1008.0/ 2.5, 1616.0 / 2.5], color::TRANSPARENT)
.top_left_with_margins_on(self.ids.settings_bg, 77.0, 205.0)
.set(self.ids.rectangle, ui_widgets);
//1 Interface////////////////////////////
if Button::image(self.imgs.button_blank)
if Button::image(if let SettingsTab::Interface = self.settings_tab {self.imgs.button_blue_mo} else {self.imgs.button_blank})
.w_h(304.0 / 2.5, 80.0 / 2.5)
.hover_image(self.imgs.button_blue_mo)
.press_image(self.imgs.button_blue_press)
.top_left_with_margins_on(self.ids.settings_bg, 10.0, 10.0)
.top_left_with_margins_on(self.ids.settings_bg, 78.0, 50.0)
.label("Interface")
.label_font_size(10)
.label_font_size(14)
.label_rgba(220.0, 220.0, 220.0, 0.8)
.set(self.ids.interface, ui_widgets)
.was_clicked()
@ -700,8 +708,8 @@ impl Hud {
//Toggle Help
if let SettingsTab::Interface = self.settings_tab {
self.show_help = ToggleButton::new(self.show_help, self.imgs.check, self.imgs.check_checked)
.w_h(288.0 / 10.0, 288.0 / 10.0)
.middle_of(self.ids.settings_bg)
.w_h(288.0 / 24.0, 288.0 / 24.0)
.top_left_with_margins_on(self.ids.rectangle, 15.0, 15.0)
.hover_images(self.imgs.check_checked_mo, self.imgs.check_mo)
.press_images(self.imgs.check_press, self.imgs.check_press)
.set(self.ids.button_help, ui_widgets);
@ -713,13 +721,13 @@ impl Hud {
.set(self.ids.show_help_label, ui_widgets);
}
//2 Gameplay////////////////
if Button::image(self.imgs.button_blank)
if Button::image(if let SettingsTab::Gameplay = self.settings_tab {self.imgs.button_blue_mo} else {self.imgs.button_blank})
.w_h(304.0 / 2.5, 80.0 / 2.5)
.hover_image(self.imgs.button_blue_mo)
.press_image(self.imgs.button_blue_press)
.down_from(self.ids.interface, 10.0)
.down_from(self.ids.interface, 1.0)
.label("Gameplay")
.label_font_size(10)
.label_font_size(14)
.label_rgba(220.0, 220.0, 220.0, 0.8)
.set(self.ids.gameplay, ui_widgets)
.was_clicked()
@ -728,13 +736,13 @@ impl Hud {
}
//3 Controls/////////////////////
if Button::image(self.imgs.button_blank)
if Button::image(if let SettingsTab::Controls = self.settings_tab {self.imgs.button_blue_mo} else {self.imgs.button_blank})
.w_h(304.0 / 2.5, 80.0 / 2.5)
.hover_image(self.imgs.button_blue_mo)
.press_image(self.imgs.button_blue_press)
.down_from(self.ids.interface, 52.0)
.down_from(self.ids.gameplay, 1.0)
.label("Controls")
.label_font_size(10)
.label_font_size(14)
.label_rgba(220.0, 220.0, 220.0, 0.8)
.set(self.ids.controls, ui_widgets)
.was_clicked()
@ -743,13 +751,13 @@ impl Hud {
}
//4 Video////////////////////////////////
if Button::image(self.imgs.button_blank)
if Button::image(if let SettingsTab::Video = self.settings_tab {self.imgs.button_blue_mo} else {self.imgs.button_blank})
.w_h(304.0 / 2.5, 80.0 / 2.5)
.hover_image(self.imgs.button_blue_mo)
.press_image(self.imgs.button_blue_press)
.down_from(self.ids.interface, 94.0)
.down_from(self.ids.controls, 1.0)
.label("Video")
.label_font_size(10)
.label_font_size(14)
.label_rgba(220.0, 220.0, 220.0, 0.8)
.set(self.ids.video, ui_widgets)
.was_clicked()
@ -758,13 +766,13 @@ impl Hud {
}
//5 Sound///////////////////////////////
if Button::image(self.imgs.button_blank)
if Button::image(if let SettingsTab::Sound = self.settings_tab {self.imgs.button_blue_mo} else {self.imgs.button_blank})
.w_h(304.0 / 2.5, 80.0 / 2.5)
.hover_image(self.imgs.button_blue_mo)
.press_image(self.imgs.button_blue_press)
.down_from(self.ids.interface, 136.0)
.down_from(self.ids.video, 1.0)
.label("Sound")
.label_font_size(10)
.label_font_size(14)
.label_rgba(220.0, 220.0, 220.0, 0.8)
.set(self.ids.sound, ui_widgets)
.was_clicked()

View File

@ -5,6 +5,7 @@ use crate::{
};
use conrod_core::{
color,
event::Input,
image::Id as ImgId,
text::font::Id as FontId,
widget::{text_box::Event as TextBoxEvent, Button, Image, Rectangle, Text, TextBox, TitleBar},
@ -30,6 +31,21 @@ widget_ids! {
races_bg,
gender_bg,
desc_bg,
skin_eyes_window,
hair_window,
accessories_window,
skin_eyes_button,
hair_button,
accessories_button,
skin_rect,
eyes_rect,
human_skin_bg,
orc_skin_bg,
dwarf_skin_bg,
undead_skin_bg,
elf_skin_bg,
danari_skin_bg,
// Buttons
enter_world_button,
@ -38,8 +54,7 @@ widget_ids! {
create_character_button,
delete_button,
create_button,
character_name_input,
name_input_bg,
name_input,
name_field,
race_1,
race_2,
@ -85,6 +100,32 @@ widget_ids! {
// Arrows
arrow_left,
arrow_right,
// Body Features
window_skin_eyes,
window_skin_eyes_mid,
window_skin_eyes_bot,
window_hair,
window_hair_mid,
window_hair_bot,
window_acessories,
window_acessories_mid,
window_acessories_bot,
skin_color_picker,
skin_color_slider,
skin_color_text,
skin_color_slider_text,
eye_color_picker,
eye_color_slider,
eye_color_text,
eye_color_slider_text,
skin_color_slider_range,
skin_color_slider_indicator,
eye_color_slider_range,
eye_color_slider_indicator,
}
}
@ -102,9 +143,22 @@ struct Imgs {
selection_window: ImgId,
test_char_l_button: ImgId,
test_char_l_big: ImgId,
name_input_bg: ImgId,
name_input: ImgId,
creation_window: ImgId,
desc_bg: 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,
//test_char_m_button: ImgId,
//test_char_r_button: ImgId,
// Race Icons
@ -172,9 +226,22 @@ impl Imgs {
button_dark_red_press: load("buttons/button_dark_red_press.png"),
test_char_l_button: load("test_char_l.png"),
test_char_l_big: load("test_char_l_big.png"),
name_input: load("input_bg.png"),
creation_window: load("creation_window.png"),
name_input_bg: load("input_bg.png"),
desc_bg: load("desc_bg.png"),
creation_window_body: load("creation_window_body.png"),
frame_closed: load("frame_closed_button.png"),
frame_closed_mo: load("frame_closed_mo_button.png"),
frame_closed_press: load("frame_closed_press_button.png"),
frame_open: load("frame_open_button.png"),
frame_open_mo: load("frame_open_mo_button.png"),
frame_open_press: load("frame_open_press_button.png"),
skin_eyes_window: load("frame_skin_eyes.png"),
hair_window: load("frame_skin_eyes.png"),
accessories_window: load("frame_skin_eyes.png"),
color_picker_bg: load("color_picker_blank.png"),
slider_range: load("slider_range.png"),
slider_indicator: load("slider_indicator.png"),
// Weapon Icons
daggers: load("icons/daggers_icon.png"),
sword_shield: load("icons/swordshield_icon.png"),
@ -221,7 +288,7 @@ impl Imgs {
enum CreationState {
Race,
Weapon,
Body,
Body(BodyPart),
}
enum Races {
Human,
@ -231,6 +298,12 @@ enum Races {
Undead,
Danari,
}
#[derive(Clone, Copy)]
enum BodyPart {
SkinEyes,
Hair,
Accessories,
}
enum Sex {
Male,
Female,
@ -256,7 +329,7 @@ pub struct CharSelectionUi {
ids: Ids,
imgs: Imgs,
font_metamorph: FontId,
font_whitney: FontId,
font_opensans: FontId,
character_creation: bool,
selected_char_no: Option<i32>,
race: Races,
@ -276,10 +349,10 @@ impl CharSelectionUi {
// Load images
let imgs = Imgs::new(&mut ui, window.renderer_mut());
// Load fonts
let font_whitney = ui.new_font(
let font_opensans = ui.new_font(
conrod_core::text::font::from_file(concat!(
env!("CARGO_MANIFEST_DIR"),
"/test_assets/font/Whitney-Book.ttf"
"/test_assets/font/OpenSans-Regular.ttf"
))
.unwrap(),
);
@ -295,7 +368,7 @@ impl CharSelectionUi {
imgs,
ids,
font_metamorph,
font_whitney,
font_opensans,
character_creation: false,
selected_char_no: None,
character_name: "Character Name".to_string(),
@ -306,6 +379,7 @@ impl CharSelectionUi {
}
}
// TODO: split this up into multiple modules or functions
fn update_layout(&mut self) -> Vec<Event> {
let mut events = Vec::new();
let ref mut ui_widgets = self.ui.set_widgets();
@ -338,10 +412,10 @@ impl CharSelectionUi {
.set(self.ids.logout_button, ui_widgets)
.was_clicked()
{
events.push(Event::Logout)
};
events.push(Event::Logout);
}
// Create_Character_Button
// Create Character Button
if Button::image(self.imgs.button_dark)
.mid_bottom_with_margin_on(self.ids.bg_selection, 10.0)
.w_h(270.0, 50.0)
@ -356,8 +430,8 @@ impl CharSelectionUi {
{
self.character_creation = true;
self.selected_char_no = None;
};
//Test_Characters
}
// Test Characters
if Button::image(self.imgs.test_char_l_button)
.bottom_left_with_margins_on(self.ids.bg_selection, 395.0, 716.0)
.w_h(95.0, 130.0)
@ -368,7 +442,7 @@ impl CharSelectionUi {
{
self.selected_char_no = Some(1);
self.creation_state = CreationState::Race;
};
}
// Veloren Logo and Alpha Version
Button::image(self.imgs.v_logo)
@ -464,31 +538,33 @@ impl CharSelectionUi {
self.character_creation = false;
}
// Character Name Input
Image::new(self.imgs.name_input_bg)
Button::image(self.imgs.name_input)
.w_h(337.0, 67.0)
.label("Character Name")
.label_rgba(220.0, 220.0, 220.0, 0.8)
.label_font_size(20)
.label_y(conrod_core::position::Relative::Scalar(50.0))
.mid_bottom_with_margin_on(self.ids.bg_creation, 10.0)
.set(self.ids.name_input_bg, ui_widgets);
.set(self.ids.name_input, ui_widgets);
for event in TextBox::new(&self.character_name)
.w_h(580.0 / 2.0, 60.0 / 2.0)
.mid_bottom_with_margin_on(self.ids.name_input_bg, 44.0 / 2.0)
.font_size(20)
.w_h(300.0, 60.0)
.middle_of(self.ids.name_input)
.font_size(22)
.font_id(self.font_metamorph)
.text_color(Color::Rgba(220.0, 220.0, 220.0, 0.8))
.rgba(220.0, 220.0, 220.0, 0.8)
.center_justify()
.color(color::TRANSPARENT)
.border_color(color::TRANSPARENT)
.set(self.ids.name_field, ui_widgets) {
match event {
TextBoxEvent::Update(new_str) => {
// Note: TextBox limits the input string length to what fits in it
self.character_name = new_str.to_string();
}
TextBoxEvent::Enter => {}
.set(self.ids.name_field, ui_widgets)
{
match event {
TextBoxEvent::Update(name) => {
self.character_name = name;
}
TextBoxEvent::Enter => {}
}
}
// Window(s)
Image::new(self.imgs.creation_window)
Image::new(if let CreationState::Body(_) = self.creation_state {self.imgs.creation_window_body} else {self.imgs.creation_window})
.w_h(628.0, 814.0)
.top_left_with_margins_on(self.ids.bg_creation, 60.0, 30.0)
.set(self.ids.creation_window, ui_widgets);
@ -511,8 +587,8 @@ impl CharSelectionUi {
.set(self.ids.arrow_right, ui_widgets)
.was_clicked()
{
self.creation_state = CreationState::Weapon
};
self.creation_state = CreationState::Weapon;
}
}
CreationState::Weapon => {
if Button::image(self.imgs.arrow_left)
@ -523,8 +599,8 @@ impl CharSelectionUi {
.set(self.ids.arrow_left, ui_widgets)
.was_clicked()
{
self.creation_state = CreationState::Race
};
self.creation_state = CreationState::Race;
}
if Button::image(self.imgs.arrow_right)
.wh(ARROW_WH)
@ -534,10 +610,10 @@ impl CharSelectionUi {
.set(self.ids.arrow_right, ui_widgets)
.was_clicked()
{
self.creation_state = CreationState::Body
};
self.creation_state = CreationState::Body(BodyPart::SkinEyes);
}
}
CreationState::Body => {
CreationState::Body(_) => {
if Button::image(self.imgs.arrow_left)
.wh(ARROW_WH)
.hover_image(self.imgs.arrow_left_mo)
@ -546,8 +622,8 @@ impl CharSelectionUi {
.set(self.ids.arrow_left, ui_widgets)
.was_clicked()
{
self.creation_state = CreationState::Weapon
};
self.creation_state = CreationState::Weapon;
}
Button::image(self.imgs.arrow_right_grey)
.wh(ARROW_WH)
.top_right_with_margins_on(self.ids.creation_window, 74.0, 55.0)
@ -592,11 +668,11 @@ impl CharSelectionUi {
.was_clicked()
{
self.sex = Sex::Male;
};
}
// Female
Image::new(self.imgs.female)
.w_h(68.0, 68.0)
.right_from(self.ids.male, 15.0)
.right_from(self.ids.male, 16.0)
.set(self.ids.female, ui_widgets);
if Button::image(if let Sex::Female = self.sex {
self.imgs.icon_border_pressed
@ -610,7 +686,7 @@ impl CharSelectionUi {
.was_clicked()
{
self.sex = Sex::Female;
};
}
// for alignment
Rectangle::fill_with([458.0, 68.0], color::TRANSPARENT)
.mid_top_with_margin_on(self.ids.creation_window, 120.0)
@ -637,7 +713,7 @@ impl CharSelectionUi {
.was_clicked()
{
self.race = Races::Human;
};
}
// Orc
Image::new(if let Sex::Male = self.sex {
@ -660,7 +736,7 @@ impl CharSelectionUi {
.was_clicked()
{
self.race = Races::Orc;
};
}
// Dwarf
Image::new(if let Sex::Male = self.sex {
self.imgs.dwarf_m
@ -682,7 +758,7 @@ impl CharSelectionUi {
.was_clicked()
{
self.race = Races::Dwarf;
};
}
// Elf
Image::new(if let Sex::Male = self.sex {
self.imgs.elf_m
@ -704,7 +780,7 @@ impl CharSelectionUi {
.was_clicked()
{
self.race = Races::Elf;
};
}
// Undead
Image::new(if let Sex::Male = self.sex {
self.imgs.undead_m
@ -726,7 +802,7 @@ impl CharSelectionUi {
.was_clicked()
{
self.race = Races::Undead;
};
}
// Danari
Image::new(if let Sex::Male = self.sex {
self.imgs.danari_m
@ -748,16 +824,16 @@ impl CharSelectionUi {
.was_clicked()
{
self.race = Races::Danari;
};
}
// Description Headline and Text
// TODO: Load these from files (or from the server???)
const HUMAN_DESC: &str = "The former nomads were only recently \
able to take in the world of Veloren. \
able to gain a foothold in the world of Veloren. \
Their greatest strengths are their \
adaptability and intelligence, \
which makes them all-rounders in all fields.";
which makes them allrounders in many fields.";
const ORC_DESC: &str = "They are considered brutal, rude and combative. \
But once you got their trust they will be loyal friends \
following a strict code of honor in all of their actions. \
@ -789,7 +865,7 @@ impl CharSelectionUi {
.mid_top_with_margin_on(self.ids.creation_window, 410.0)
.w(500.0)
.font_size(20)
.font_id(self.font_whitney)
.font_id(self.font_opensans)
.rgba(220.0, 220.0, 220.0, 0.8)
.wrap_by_word()
.set(self.ids.race_description, ui_widgets);
@ -824,7 +900,7 @@ impl CharSelectionUi {
.was_clicked()
{
self.weapon = Weapons::SwordShield;
};
}
// Daggers
Image::new(self.imgs.daggers)
@ -843,7 +919,7 @@ impl CharSelectionUi {
.was_clicked()
{
self.weapon = Weapons::Daggers;
};
}
// Sword
Image::new(self.imgs.sword)
@ -862,7 +938,7 @@ impl CharSelectionUi {
.was_clicked()
{
self.weapon = Weapons::Sword;
};
}
// Axe
Image::new(self.imgs.axe)
.w_h(60.0, 60.0)
@ -880,7 +956,7 @@ impl CharSelectionUi {
.was_clicked()
{
self.weapon = Weapons::Axe;
};
}
// Hammer
Image::new(self.imgs.hammer)
.w_h(60.0, 60.0)
@ -898,7 +974,7 @@ impl CharSelectionUi {
.was_clicked()
{
self.weapon = Weapons::Hammer;
};
}
// Bow
Image::new(self.imgs.bow)
.w_h(60.0, 60.0)
@ -916,7 +992,7 @@ impl CharSelectionUi {
.was_clicked()
{
self.weapon = Weapons::Bow;
};
}
// Staff
Image::new(self.imgs.staff)
.w_h(60.0, 60.0)
@ -934,7 +1010,7 @@ impl CharSelectionUi {
.was_clicked()
{
self.weapon = Weapons::Staff;
};
}
// TODO: Load these from files (or from the server???)
const SWORDSHIELD_DESC: &str = " MISSING ";
@ -963,7 +1039,7 @@ impl CharSelectionUi {
.mid_top_with_margin_on(self.ids.creation_window, 410.0)
.w(500.0)
.font_size(20)
.font_id(self.font_whitney)
.font_id(self.font_opensans)
.rgba(220.0, 220.0, 220.0, 0.8)
.wrap_by_word()
.set(self.ids.race_description, ui_widgets);
@ -972,9 +1048,264 @@ impl CharSelectionUi {
}
// 3 states/windows: 1.Skin & Eyes 2.Hair 3.Accessories
// If one state is activated the other ones collapse
// The title bar is the button to unfold/collapse the windows
// The BG Frame can be stretched to the needed size
if let CreationState::Body = self.creation_state {}
}
// Window BG
if let CreationState::Body(state) = self.creation_state {
Text::new("Body Customization")
.mid_top_with_margin_on(self.ids.creation_window, 74.0)
.font_size(28)
.rgba(220.0, 220.0, 220.0, 0.8)
.set(self.ids.select_window_title, ui_widgets);
match state {
// Skin Eyes Open
BodyPart::SkinEyes => {
Image::new(self.imgs.skin_eyes_window)
.w_h(511.0, 333.0)
.mid_top_with_margin_on(self.ids.select_window_title, 60.0)
.set(self.ids.skin_eyes_window, ui_widgets);
// Open Window: Skin & Eyes
if Button::image(self.imgs.frame_open_mo)
.mid_top_with_margin_on(self.ids.skin_eyes_window, 0.0)
.w_h(511.0, 37.0)
//.hover_image(self.imgs.frame_open_mo)
//.press_image(self.imgs.frame_open_press)
.label("Skin & Eyes")
.label_rgba(220.0, 220.0, 220.0, 0.8)
.label_y(conrod_core::position::Relative::Scalar(4.0))
.label_font_size(16)
.set(self.ids.skin_eyes_button, ui_widgets)
.was_clicked() {
self.creation_state = CreationState::Body(BodyPart::SkinEyes);
}
// Closed: Hair
if Button::image(self.imgs.frame_closed)
.down_from(self.ids.skin_eyes_window, 5.0)
.w_h(511.0, 31.0)
.hover_image(self.imgs.frame_closed_mo)
.press_image(self.imgs.frame_closed_press)
.label("Hair")
.label_rgba(220.0, 220.0, 220.0, 0.8)
.label_font_size(16)
.set(self.ids.hair_button, ui_widgets)
.was_clicked() {
self.creation_state = CreationState::Body(BodyPart::Hair);
}
// Closed: Accessories
if Button::image(self.imgs.frame_closed)
.down_from(self.ids.hair_button, 5.0)
.w_h(511.0, 31.0)
.hover_image(self.imgs.frame_closed_mo)
.press_image(self.imgs.frame_closed_press)
.label("Accessories")
.label_rgba(220.0, 220.0, 220.0, 0.8)
.label_font_size(16)
.set(self.ids.accessories_button, ui_widgets)
.was_clicked() {
self.creation_state = CreationState::Body(BodyPart::Accessories);
}
} // State 1 fin
// Hair Open
BodyPart::Hair => {
Image::new(self.imgs.hair_window)
.w_h(511.0, 500.0) //333.0
.down_from(self.ids.skin_eyes_button, 5.0)
.set(self.ids.hair_window, ui_widgets);
// Closed Window: Skin & Eyes
if Button::image(self.imgs.frame_closed)
.mid_top_with_margin_on(self.ids.select_window_title, 60.0)
.w_h(511.0, 31.0)
.hover_image(self.imgs.frame_closed_mo)
.press_image(self.imgs.frame_closed_press)
.label("Skin & Eyes")
.label_rgba(220.0, 220.0, 220.0, 0.8)
.label_font_size(16)
.set(self.ids.skin_eyes_button, ui_widgets)
.was_clicked() {
self.creation_state = CreationState::Body(BodyPart::SkinEyes);
}
// Open Window: Hair
if Button::image(self.imgs.frame_open_mo)
.mid_top_with_margin_on(self.ids.hair_window, 0.0)
.w_h(511.0, 37.0)
//.hover_image(self.imgs.frame_closed_mo)
//.press_image(self.imgs.frame_closed_press)
.label("Hair")
.label_rgba(220.0, 220.0, 220.0, 0.8)
.label_y(conrod_core::position::Relative::Scalar(4.0))
.label_font_size(16)
.set(self.ids.hair_button, ui_widgets)
.was_clicked() {
self.creation_state = CreationState::Body(BodyPart::Hair);
}
// Closed: Accessories
if Button::image(self.imgs.frame_closed)
.down_from(self.ids.hair_window, 5.0)
.w_h(511.0, 31.0)
.hover_image(self.imgs.frame_closed_mo)
.press_image(self.imgs.frame_closed_press)
.label("Accessories")
.label_rgba(220.0, 220.0, 220.0, 0.8)
.label_font_size(16)
.set(self.ids.accessories_button, ui_widgets)
.was_clicked() {
self.creation_state = CreationState::Body(BodyPart::Accessories);
}
} // State 2 fin
// Open: Accessories
BodyPart::Accessories => {
Image::new(self.imgs.hair_window)
.w_h(511.0, 333.0)
.down_from(self.ids.hair_button, 5.0)
.set(self.ids.accessories_window, ui_widgets);
// Closed Window: Skin & Eyes
if Button::image(self.imgs.frame_closed)
.mid_top_with_margin_on(self.ids.select_window_title, 60.0)
.w_h(511.0, 31.0)
.hover_image(self.imgs.frame_closed_mo)
.press_image(self.imgs.frame_closed_press)
.label("Skin & Eyes")
.label_rgba(220.0, 220.0, 220.0, 0.8)
.label_font_size(16)
.set(self.ids.skin_eyes_button, ui_widgets)
.was_clicked() {
self.creation_state = CreationState::Body(BodyPart::SkinEyes);
}
// Closed: Hair
if Button::image(self.imgs.frame_closed)
.down_from(self.ids.skin_eyes_button, 5.0)
.w_h(511.0, 31.0)
.hover_image(self.imgs.frame_closed_mo)
.press_image(self.imgs.frame_closed_press)
.label("Hair")
.label_rgba(220.0, 220.0, 220.0, 0.8)
.label_font_size(16)
.set(self.ids.hair_button, ui_widgets)
.was_clicked() {
self.creation_state = CreationState::Body(BodyPart::Hair);
}
// Open: Accessories
if Button::image(self.imgs.frame_open_mo)
.down_from(self.ids.hair_button, 5.0)
.w_h(511.0, 37.0)
//.hover_image(self.imgs.frame_closed_mo)
//.press_image(self.imgs.frame_closed_press)
.label("Accessories")
.label_y(conrod_core::position::Relative::Scalar(4.0))
.label_rgba(220.0, 220.0, 220.0, 0.8)
.label_font_size(16)
.set(self.ids.accessories_button, ui_widgets)
.was_clicked() {
self.creation_state = CreationState::Body(BodyPart::Accessories);
}
} // State 3 fin
} // match fin
// Body Customization Window Contents ////////////////////////
match state {
BodyPart::SkinEyes => {
// Skin Color: Text, Brightness Slider, Picker
Text::new("Skin Color")
.top_left_with_margins_on(self.ids.skin_rect, 0.0, -250.0)
.font_size(25)
.rgba(220.0, 220.0, 220.0, 0.8)
.set(self.ids.skin_color_text, ui_widgets);
// TODO: Align Buttons here
// They set an i32 to a value from 0-14
// Depending on the race another color will be chosen
// Here only the BG image changes depending on the race.
Rectangle::fill_with([192.0, 116.0], color::WHITE)
.top_right_with_margins_on(self.ids.skin_eyes_window, 60.0, 30.0)
.rgba(220.0, 220.0, 220.0, 0.8)
.set(self.ids.skin_rect, ui_widgets);
// TODO:Slider
// Sliders actually change the Alpha-Level of the main colour chosen above
// -> They will appear "brighter", therefore the sliders are labeled "Brightness"
Image::new(self.imgs.slider_range)
.w_h(208.0, 12.0)
.bottom_left_with_margins_on(self.ids.skin_rect, 10.0, -255.0)
.set(self.ids.skin_color_slider_range, ui_widgets);
Image::new(self.imgs.slider_indicator)
.w_h(10.0, 22.0)
.middle_of(self.ids.skin_color_slider_range)
.set(self.ids.skin_color_slider_indicator, ui_widgets);
Text::new("Brightness")
.top_left_with_margins_on(self.ids.skin_color_slider_range, -27.0, 0.0)
.rgba(220.0, 220.0, 220.0, 0.8)
.font_size(14)
.set(self.ids.skin_color_slider_text, ui_widgets);
// Eye Color: Text, Brightness Slider, Picker
Text::new("Eye Color")
.top_left_with_margins_on(self.ids.eyes_rect, 0.0, -250.0)
.font_size(25)
.rgba(220.0, 220.0, 220.0, 0.8)
.set(self.ids.eye_color_text, ui_widgets);
// TODO: Align 16 Buttons here
//
// They set a variable to a value from 0-14
// Depending on the race another color will be chosen
// Only the BG image (190x114 -> 2px border!) changes depending on the race.
Rectangle::fill_with([192.0, 116.0], color::WHITE)
.top_right_with_margins_on(self.ids.skin_eyes_window, 186.0, 30.0)
.rgba(220.0, 220.0, 220.0, 0.8)
.set(self.ids.eyes_rect, ui_widgets);
// TODO:Slider
Image::new(self.imgs.slider_range)
.w_h(208.0, 12.0)
.bottom_left_with_margins_on(self.ids.eyes_rect, 10.0, -255.0)
.set(self.ids.eye_color_slider_range, ui_widgets);
Image::new(self.imgs.slider_indicator)
.w_h(10.0, 22.0)
.middle_of(self.ids.eye_color_slider_range)
.set(self.ids.eye_color_slider_indicator, ui_widgets);
Text::new("Brightness")
.top_left_with_margins_on(self.ids.eye_color_slider_range, -27.0, 0.0)
.rgba(220.0, 220.0, 220.0, 0.8)
.font_size(14)
.set(self.ids.eye_color_slider_text, ui_widgets);
}
// Hair ///////////////////////////////////////////////////////
// Hair Styles -> Arrows
// Hair Color -> Picker
// Eye Brow Style -> Arrow
// Facial Hair -> Picker (Only active for males!)
BodyPart::Hair => {}
// Accessories ///////////////////////////////
// Accessory Picker -> Arrows (Name Changes with race!)
// Color -> Picker
// Brightness -> Slider
BodyPart::Accessories => {}
// Accessories fin
}; // Body Customization Fin
} // CreationState::Body Fin
} // Char Creation fin
events
}

View File

@ -97,7 +97,7 @@ pub struct MainMenuUi {
ids: Ids,
imgs: Imgs,
font_metamorph: FontId,
font_whitney: FontId,
font_opensans: FontId,
username: String,
server_address: String,
}
@ -112,10 +112,10 @@ impl MainMenuUi {
// Load images
let imgs = Imgs::new(&mut ui, window.renderer_mut());
// Load fonts
let font_whitney = ui.new_font(
let font_opensans = ui.new_font(
conrod_core::text::font::from_file(concat!(
env!("CARGO_MANIFEST_DIR"),
"/test_assets/font/Whitney-Book.ttf"
"/test_assets/font/OpenSans-Regular.ttf"
))
.unwrap(),
);
@ -131,7 +131,7 @@ impl MainMenuUi {
imgs,
ids,
font_metamorph,
font_whitney,
font_opensans,
username: "Username".to_string(),
server_address: "Server Address".to_string(),
}
@ -174,7 +174,7 @@ impl MainMenuUi {
.w_h(580.0 / 2.0, 60.0 / 2.0)
.mid_bottom_with_margin_on(self.ids.username_bg, 44.0 / 2.0)
.font_size(20)
.font_id(self.font_whitney)
.font_id(self.font_opensans)
.text_color(Color::Rgba(220.0, 220.0, 220.0, 0.8))
// transparent background
.color(TRANSPARENT)
@ -198,7 +198,7 @@ impl MainMenuUi {
.w_h(580.0 / 2.0, 60.0 / 2.0)
.mid_bottom_with_margin_on(self.ids.address_bg, 44.0 / 2.0)
.font_size(20)
.font_id(self.font_whitney)
.font_id(self.font_opensans)
.text_color(Color::Rgba(220.0, 220.0, 220.0, 0.8))
// transparent background
.color(TRANSPARENT)

View File

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
voxygen/test_assets/ui/char_selection/frame_open_button.png (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
voxygen/test_assets/ui/char_selection/frame_skin_eyes.png (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

BIN
voxygen/test_assets/ui/hud/window_frame_2.png (Stored with Git LFS) Normal file

Binary file not shown.