2019-05-08 20:25:15 +00:00
|
|
|
use super::{img_ids::Imgs, Fonts, TEXT_COLOR, XP_COLOR};
|
2019-04-26 20:24:05 +00:00
|
|
|
use conrod_core::{
|
2019-05-07 03:25:25 +00:00
|
|
|
color,
|
2019-04-28 04:44:13 +00:00
|
|
|
widget::{self, Button, Image, Rectangle, Text},
|
2019-05-07 03:25:25 +00:00
|
|
|
widget_ids, Colorable, Labelable, Positionable, Sizeable, Widget, WidgetCommon,
|
2019-04-26 20:24:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
widget_ids! {
|
2019-04-30 20:43:55 +00:00
|
|
|
pub struct Ids {
|
2019-04-26 20:24:05 +00:00
|
|
|
charwindow,
|
|
|
|
charwindow_bg,
|
|
|
|
charwindow_close,
|
|
|
|
charwindow_exp_progress_rectangle,
|
|
|
|
charwindow_exp_rectangle,
|
|
|
|
charwindow_frame,
|
2019-05-10 17:27:03 +00:00
|
|
|
content_align,
|
2019-05-10 12:43:14 +00:00
|
|
|
// charwindow_icon,
|
2019-04-26 20:24:05 +00:00
|
|
|
charwindow_rectangle,
|
|
|
|
charwindow_tab1,
|
|
|
|
charwindow_tab1_exp,
|
|
|
|
charwindow_tab1_expbar,
|
|
|
|
charwindow_tab1_level,
|
|
|
|
charwindow_tab1_statnames,
|
|
|
|
charwindow_tab1_stats,
|
|
|
|
charwindow_tab_bg,
|
|
|
|
charwindow_title,
|
2019-05-09 18:08:11 +00:00
|
|
|
window_3,
|
|
|
|
tab_bg,
|
|
|
|
tab_small_open,
|
|
|
|
tab_small_closed,
|
|
|
|
xp_charwindow,
|
2019-05-09 18:08:11 +00:00
|
|
|
divider,
|
2019-05-10 17:27:03 +00:00
|
|
|
head_bg,
|
|
|
|
shoulders_bg,
|
|
|
|
hands_bg,
|
|
|
|
belt_bg,
|
|
|
|
legs_bg,
|
|
|
|
feet_bg,
|
|
|
|
ring_r_bg,
|
|
|
|
ring_l_bg,
|
|
|
|
tabard_bg,
|
|
|
|
chest_bg,
|
|
|
|
back_bg,
|
|
|
|
gem_bg,
|
|
|
|
necklace_bg,
|
|
|
|
head_grid,
|
|
|
|
shoulders_grid,
|
|
|
|
hands_grid,
|
|
|
|
belt_grid,
|
|
|
|
legs_grid,
|
|
|
|
feet_grid,
|
|
|
|
ring_r_grid,
|
|
|
|
ring_l_grid,
|
|
|
|
tabard_grid,
|
|
|
|
chest_grid,
|
|
|
|
back_grid,
|
|
|
|
gem_grid,
|
|
|
|
necklace_grid,
|
|
|
|
|
2019-05-09 18:08:11 +00:00
|
|
|
|
2019-04-26 20:24:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(WidgetCommon)]
|
2019-04-28 04:44:13 +00:00
|
|
|
pub struct CharacterWindow<'a> {
|
|
|
|
imgs: &'a Imgs,
|
2019-04-30 20:43:55 +00:00
|
|
|
fonts: &'a Fonts,
|
2019-04-26 20:24:05 +00:00
|
|
|
|
|
|
|
#[conrod(common_builder)]
|
|
|
|
common: widget::CommonBuilder,
|
|
|
|
}
|
|
|
|
|
2019-04-28 04:44:13 +00:00
|
|
|
impl<'a> CharacterWindow<'a> {
|
2019-04-30 20:43:55 +00:00
|
|
|
pub fn new(imgs: &'a Imgs, fonts: &'a Fonts) -> Self {
|
2019-04-26 20:24:05 +00:00
|
|
|
Self {
|
2019-04-28 04:44:13 +00:00
|
|
|
imgs,
|
2019-04-30 20:43:55 +00:00
|
|
|
fonts,
|
2019-04-26 20:24:05 +00:00
|
|
|
common: widget::CommonBuilder::default(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-28 04:44:13 +00:00
|
|
|
pub enum Event {
|
2019-04-26 20:24:05 +00:00
|
|
|
Close,
|
|
|
|
}
|
|
|
|
|
2019-04-28 04:44:13 +00:00
|
|
|
impl<'a> Widget for CharacterWindow<'a> {
|
2019-04-30 20:43:55 +00:00
|
|
|
type State = Ids;
|
|
|
|
type Style = ();
|
2019-04-26 20:24:05 +00:00
|
|
|
type Event = Option<Event>;
|
|
|
|
|
|
|
|
fn init_state(&self, id_gen: widget::id::Generator) -> Self::State {
|
2019-04-30 20:43:55 +00:00
|
|
|
Ids::new(id_gen)
|
2019-04-26 20:24:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn style(&self) -> Self::Style {
|
2019-04-30 20:43:55 +00:00
|
|
|
()
|
2019-04-26 20:24:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
|
2019-05-07 05:40:03 +00:00
|
|
|
let widget::UpdateArgs { id, state, ui, .. } = args;
|
2019-04-28 04:44:13 +00:00
|
|
|
|
2019-05-03 16:56:18 +00:00
|
|
|
// TODO: Read from parameter / character struct
|
|
|
|
let xp_percentage = 0.4;
|
|
|
|
|
2019-04-26 20:24:05 +00:00
|
|
|
// Frame
|
2019-05-10 12:43:14 +00:00
|
|
|
Image::new(self.imgs.window_3)
|
2019-04-28 04:44:13 +00:00
|
|
|
.middle_of(id)
|
2019-05-10 12:43:14 +00:00
|
|
|
.top_left_with_margins_on(ui.window, 212.0, 215.0)
|
|
|
|
.w_h(103.0 * 4.0, 122.0 * 4.0)
|
2019-05-07 05:40:03 +00:00
|
|
|
.set(state.charwindow_frame, ui);
|
2019-04-26 20:24:05 +00:00
|
|
|
|
|
|
|
// Icon
|
2019-05-10 12:43:14 +00:00
|
|
|
//Image::new(self.imgs.charwindow_icon)
|
2019-05-10 17:27:03 +00:00
|
|
|
//.w_h(40.0, 40.0)
|
|
|
|
//.top_left_with_margins_on(state.charwindow_frame, 4.0, 4.0)
|
|
|
|
//.set(state.charwindow_icon, ui);
|
2019-04-26 20:24:05 +00:00
|
|
|
|
|
|
|
// X-Button
|
2019-04-30 14:39:19 +00:00
|
|
|
if Button::image(self.imgs.close_button)
|
2019-05-04 17:29:19 +00:00
|
|
|
.w_h(28.0, 28.0)
|
2019-04-28 16:44:44 +00:00
|
|
|
.hover_image(self.imgs.close_button_hover)
|
|
|
|
.press_image(self.imgs.close_button_press)
|
2019-05-10 12:43:14 +00:00
|
|
|
.top_right_with_margins_on(state.charwindow_frame, 0.0, 0.0)
|
2019-04-30 20:43:55 +00:00
|
|
|
.set(state.charwindow_close, ui)
|
2019-05-07 05:40:03 +00:00
|
|
|
.was_clicked()
|
|
|
|
{
|
|
|
|
return Some(Event::Close);
|
2019-04-30 14:39:19 +00:00
|
|
|
}
|
2019-04-26 20:24:05 +00:00
|
|
|
|
|
|
|
// Title
|
|
|
|
Text::new("Character Name") // Add in actual Character Name
|
2019-05-10 21:49:14 +00:00
|
|
|
.mid_top_with_margin_on(state.charwindow_frame, 6.0)
|
2019-05-06 18:49:12 +00:00
|
|
|
.font_id(self.fonts.metamorph)
|
|
|
|
.font_size(14)
|
2019-04-30 20:43:55 +00:00
|
|
|
.color(TEXT_COLOR)
|
|
|
|
.set(state.charwindow_title, ui);
|
2019-04-30 14:39:19 +00:00
|
|
|
|
2019-05-10 17:27:03 +00:00
|
|
|
// Content Alignment
|
|
|
|
Rectangle::fill_with([95.0 * 4.0, 108.0 * 4.0], color::TRANSPARENT)
|
|
|
|
.mid_top_with_margin_on(state.charwindow_frame, 40.0)
|
|
|
|
.set(state.content_align, ui);
|
|
|
|
|
|
|
|
// Contents
|
|
|
|
|
2019-05-10 21:49:14 +00:00
|
|
|
//Head
|
2019-05-10 17:27:03 +00:00
|
|
|
Image::new(self.imgs.head_bg)
|
2019-05-10 21:49:14 +00:00
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
2019-05-10 17:27:03 +00:00
|
|
|
.mid_top_with_margin_on(state.content_align, 5.0)
|
|
|
|
.set(state.head_bg, ui);
|
2019-05-10 21:49:14 +00:00
|
|
|
Button::image(self.imgs.grid)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
|
|
|
.middle_of(state.head_bg)
|
|
|
|
.set(state.head_grid, ui);
|
2019-05-10 21:49:14 +00:00
|
|
|
// Shoulders
|
2019-05-10 21:49:14 +00:00
|
|
|
Image::new(self.imgs.head_bg)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
2019-05-10 21:49:14 +00:00
|
|
|
.top_right_with_margins_on(state.content_align, 65.0, 40.0)
|
|
|
|
.set(state.shoulders_bg, ui);
|
2019-05-10 21:49:14 +00:00
|
|
|
Button::image(self.imgs.grid)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
2019-05-10 21:49:14 +00:00
|
|
|
.middle_of(state.shoulders_bg)
|
|
|
|
.set(state.shoulders_grid, ui);
|
|
|
|
// Hands
|
2019-05-10 21:49:14 +00:00
|
|
|
Image::new(self.imgs.head_bg)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
2019-05-10 21:49:14 +00:00
|
|
|
.up_from(state.belt_bg, 10.0)
|
|
|
|
.set(state.hands_bg, ui);
|
2019-05-10 21:49:14 +00:00
|
|
|
Button::image(self.imgs.grid)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
2019-05-10 21:49:14 +00:00
|
|
|
.middle_of(state.hands_bg)
|
|
|
|
.set(state.hands_grid, ui);
|
2019-05-10 22:11:16 +00:00
|
|
|
// Belt
|
2019-05-10 21:49:14 +00:00
|
|
|
Image::new(self.imgs.head_bg)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
2019-05-10 22:11:16 +00:00
|
|
|
.up_from(state.legs_bg, 10.0)
|
|
|
|
.set(state.belt_bg, ui);
|
2019-05-10 21:49:14 +00:00
|
|
|
Button::image(self.imgs.grid)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
2019-05-10 22:11:16 +00:00
|
|
|
.middle_of(state.belt_bg)
|
|
|
|
.set(state.belt_grid, ui);
|
2019-05-10 21:49:14 +00:00
|
|
|
// Legs
|
2019-05-10 21:49:14 +00:00
|
|
|
Image::new(self.imgs.head_bg)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
2019-05-10 21:49:14 +00:00
|
|
|
.up_from(state.feet_bg, 10.0)
|
|
|
|
.set(state.legs_bg, ui);
|
2019-05-10 21:49:14 +00:00
|
|
|
Button::image(self.imgs.grid)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
2019-05-10 21:49:14 +00:00
|
|
|
.middle_of(state.legs_bg)
|
|
|
|
.set(state.legs_grid, ui);
|
|
|
|
// Feet
|
2019-05-10 22:24:49 +00:00
|
|
|
Image::new(self.imgs.head_bg)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
2019-05-10 21:49:14 +00:00
|
|
|
.up_from(state.ring_r_bg, 10.0)
|
|
|
|
.set(state.feet_bg, ui);
|
2019-05-10 22:24:49 +00:00
|
|
|
Button::image(self.imgs.grid)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
2019-05-10 21:49:14 +00:00
|
|
|
.middle_of(state.feet_bg)
|
|
|
|
.set(state.feet_grid, ui);
|
|
|
|
// Ring R
|
|
|
|
Image::new(self.imgs.head_bg)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
|
|
|
.bottom_right_with_margins_on(state.content_align, 20.0, 20.0)
|
|
|
|
.set(state.ring_r_bg, ui);
|
|
|
|
Button::image(self.imgs.grid)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
|
|
|
.middle_of(state.ring_r_bg)
|
|
|
|
.set(state.ring_r_grid, ui);
|
2019-05-10 21:49:14 +00:00
|
|
|
// Ring L
|
|
|
|
Image::new(self.imgs.head_bg)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
|
|
|
.bottom_left_with_margins_on(state.content_align, 20.0, 20.0)
|
|
|
|
.set(state.ring_l_bg, ui);
|
|
|
|
Button::image(self.imgs.grid)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
|
|
|
.middle_of(state.ring_l_bg)
|
|
|
|
.set(state.ring_l_grid, ui);
|
|
|
|
// Tabard
|
|
|
|
Image::new(self.imgs.head_bg)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
|
|
|
.up_from(state.ring_l_bg, 10.0)
|
|
|
|
.set(state.tabard_bg, ui);
|
|
|
|
Button::image(self.imgs.grid)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
|
|
|
.middle_of(state.tabard_bg)
|
|
|
|
.set(state.tabard_grid, ui);
|
|
|
|
// Chest
|
|
|
|
Image::new(self.imgs.head_bg)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
|
|
|
.up_from(state.tabard_bg, 10.0)
|
|
|
|
.set(state.chest_bg, ui);
|
|
|
|
Button::image(self.imgs.grid)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
|
|
|
.middle_of(state.chest_bg)
|
|
|
|
.set(state.chest_grid, ui);
|
|
|
|
// Back
|
|
|
|
Image::new(self.imgs.head_bg)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
|
|
|
.up_from(state.chest_bg, 10.0)
|
|
|
|
.set(state.back_bg, ui);
|
|
|
|
Button::image(self.imgs.grid)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
|
|
|
.middle_of(state.back_bg)
|
|
|
|
.set(state.back_grid, ui);
|
|
|
|
// Gem
|
|
|
|
Image::new(self.imgs.head_bg)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
|
|
|
.up_from(state.back_bg, 10.0)
|
|
|
|
.set(state.gem_bg, ui);
|
|
|
|
Button::image(self.imgs.grid)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
|
|
|
.middle_of(state.gem_bg)
|
|
|
|
.set(state.gem_grid, ui);
|
|
|
|
//Necklace
|
|
|
|
Image::new(self.imgs.head_bg)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
2019-05-10 21:49:14 +00:00
|
|
|
.top_left_with_margins_on(state.content_align, 65.0, 40.0)
|
2019-05-10 21:49:14 +00:00
|
|
|
.set(state.necklace_bg, ui);
|
|
|
|
Button::image(self.imgs.grid)
|
|
|
|
.w_h(28.0 * 2.0, 28.0 * 2.0)
|
|
|
|
.middle_of(state.necklace_bg)
|
|
|
|
.set(state.necklace_grid, ui);
|
2019-05-10 17:27:03 +00:00
|
|
|
// Stats Tab
|
|
|
|
|
2019-04-26 20:24:05 +00:00
|
|
|
// Tab BG
|
2019-05-10 12:43:14 +00:00
|
|
|
Image::new(self.imgs.tab_bg)
|
2019-05-10 17:27:03 +00:00
|
|
|
.w_h(50.0 * 4.0, 115.0 * 4.0)
|
|
|
|
.top_left_with_margins_on(state.charwindow_frame, 28.0, -200.0)
|
2019-04-30 20:43:55 +00:00
|
|
|
.set(state.charwindow_tab_bg, ui);
|
2019-04-30 14:39:19 +00:00
|
|
|
|
2019-04-26 20:24:05 +00:00
|
|
|
// Tab Rectangle
|
2019-05-10 17:27:03 +00:00
|
|
|
Rectangle::fill_with([45.0 * 4.0, 104.0 * 4.0], color::TRANSPARENT)
|
|
|
|
.top_left_with_margins_on(state.charwindow_tab_bg, 7.0 * 4.0, 4.0 * 4.0)
|
2019-04-30 20:43:55 +00:00
|
|
|
.set(state.charwindow_rectangle, ui);
|
2019-04-30 14:39:19 +00:00
|
|
|
|
2019-05-10 17:27:03 +00:00
|
|
|
// Tab Button -> Add that back in when we have multiple tabs
|
|
|
|
// Button::image(self.imgs.charwindow_tab)
|
|
|
|
//.w_h(65.0, 23.0)
|
|
|
|
//.top_left_with_margins_on(state.charwindow_tab_bg, -18.0, 2.0)
|
|
|
|
//.label("Stats")
|
|
|
|
//.label_color(TEXT_COLOR)
|
|
|
|
//.label_font_size(14)
|
|
|
|
//.set(state.charwindow_tab1, ui);
|
2019-04-30 14:39:19 +00:00
|
|
|
|
2019-04-26 20:24:05 +00:00
|
|
|
Text::new("1") //Add in actual Character Level
|
2019-04-30 20:43:55 +00:00
|
|
|
.mid_top_with_margin_on(state.charwindow_rectangle, 10.0)
|
|
|
|
.font_id(self.fonts.opensans)
|
2019-04-26 20:24:05 +00:00
|
|
|
.font_size(30)
|
2019-04-30 20:43:55 +00:00
|
|
|
.color(TEXT_COLOR)
|
|
|
|
.set(state.charwindow_tab1_level, ui);
|
2019-04-30 14:39:19 +00:00
|
|
|
|
2019-04-26 20:24:05 +00:00
|
|
|
// Exp-Bar Background
|
|
|
|
Rectangle::fill_with([170.0, 10.0], color::BLACK)
|
2019-04-30 20:43:55 +00:00
|
|
|
.mid_top_with_margin_on(state.charwindow_rectangle, 50.0)
|
|
|
|
.set(state.charwindow_exp_rectangle, ui);
|
2019-04-30 14:39:19 +00:00
|
|
|
|
2019-04-26 20:24:05 +00:00
|
|
|
// Exp-Bar Progress
|
2019-05-03 16:56:18 +00:00
|
|
|
Rectangle::fill_with([170.0 * (xp_percentage), 6.0], XP_COLOR) // 0.8 = Experience percentage
|
2019-04-30 20:43:55 +00:00
|
|
|
.mid_left_with_margin_on(state.charwindow_tab1_expbar, 1.0)
|
|
|
|
.set(state.charwindow_exp_progress_rectangle, ui);
|
2019-04-30 14:39:19 +00:00
|
|
|
|
2019-04-26 20:24:05 +00:00
|
|
|
// Exp-Bar Foreground Frame
|
|
|
|
Image::new(self.imgs.progress_frame)
|
|
|
|
.w_h(170.0, 10.0)
|
2019-04-30 20:43:55 +00:00
|
|
|
.middle_of(state.charwindow_exp_rectangle)
|
|
|
|
.set(state.charwindow_tab1_expbar, ui);
|
2019-04-30 14:39:19 +00:00
|
|
|
|
2019-04-26 20:24:05 +00:00
|
|
|
// Exp-Text
|
|
|
|
Text::new("120/170") // Shows the Exp / Exp to reach the next level
|
2019-04-30 20:43:55 +00:00
|
|
|
.mid_top_with_margin_on(state.charwindow_tab1_expbar, 10.0)
|
|
|
|
.font_id(self.fonts.opensans)
|
2019-04-26 20:24:05 +00:00
|
|
|
.font_size(15)
|
2019-04-30 20:43:55 +00:00
|
|
|
.color(TEXT_COLOR)
|
|
|
|
.set(state.charwindow_tab1_exp, ui);
|
2019-04-26 20:24:05 +00:00
|
|
|
|
2019-05-10 17:27:03 +00:00
|
|
|
// Divider
|
|
|
|
|
|
|
|
Image::new(self.imgs.divider)
|
|
|
|
.w_h(38.0 * 4.0, 5.0 * 4.0)
|
|
|
|
.mid_top_with_margin_on(state.charwindow_tab1_exp, 30.0)
|
2019-05-09 18:08:11 +00:00
|
|
|
.set(state.divider, ui);
|
2019-05-10 17:27:03 +00:00
|
|
|
|
2019-04-26 20:24:05 +00:00
|
|
|
// Stats
|
|
|
|
Text::new(
|
|
|
|
"Stamina\n\
|
|
|
|
\n\
|
|
|
|
Strength\n\
|
|
|
|
\n\
|
|
|
|
Dexterity\n\
|
|
|
|
\n\
|
|
|
|
Intelligence",
|
|
|
|
)
|
2019-05-10 17:27:03 +00:00
|
|
|
.top_left_with_margins_on(state.charwindow_rectangle, 140.0, 5.0)
|
2019-05-07 05:40:03 +00:00
|
|
|
.font_id(self.fonts.opensans)
|
|
|
|
.font_size(16)
|
|
|
|
.color(TEXT_COLOR)
|
|
|
|
.set(state.charwindow_tab1_statnames, ui);
|
2019-04-26 20:24:05 +00:00
|
|
|
|
|
|
|
Text::new(
|
|
|
|
"1234\n\
|
|
|
|
\n\
|
|
|
|
12312\n\
|
|
|
|
\n\
|
|
|
|
12414\n\
|
|
|
|
\n\
|
|
|
|
124124",
|
|
|
|
)
|
2019-05-10 17:27:03 +00:00
|
|
|
.top_right_with_margins_on(state.charwindow_rectangle, 140.0, 5.0)
|
2019-05-07 05:40:03 +00:00
|
|
|
.font_id(self.fonts.opensans)
|
|
|
|
.font_size(16)
|
|
|
|
.color(TEXT_COLOR)
|
|
|
|
.set(state.charwindow_tab1_stats, ui);
|
2019-04-30 14:39:19 +00:00
|
|
|
|
|
|
|
None
|
2019-04-26 20:24:05 +00:00
|
|
|
}
|
|
|
|
}
|