2020-01-26 19:29:46 +00:00
|
|
|
use super::{img_ids::Imgs, Show, TEXT_COLOR};
|
|
|
|
use crate::ui::fonts::ConrodVoxygenFonts;
|
2019-08-07 13:14:26 +00:00
|
|
|
use conrod_core::{
|
|
|
|
color,
|
|
|
|
widget::{self, Button, Image, Rectangle, Text},
|
2020-02-01 20:39:39 +00:00
|
|
|
widget_ids, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
|
2019-08-07 13:14:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
use client::{self, Client};
|
|
|
|
|
2020-01-17 23:43:18 +00:00
|
|
|
use crate::i18n::VoxygenLocalization;
|
|
|
|
|
2019-08-07 13:14:26 +00:00
|
|
|
widget_ids! {
|
|
|
|
pub struct Ids {
|
|
|
|
spell_frame,
|
|
|
|
spell_close,
|
|
|
|
spell_title,
|
|
|
|
frame,
|
|
|
|
content_align,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(WidgetCommon)]
|
|
|
|
pub struct Spell<'a> {
|
|
|
|
_show: &'a Show,
|
|
|
|
_client: &'a Client,
|
|
|
|
|
|
|
|
imgs: &'a Imgs,
|
2020-01-26 19:29:46 +00:00
|
|
|
fonts: &'a ConrodVoxygenFonts,
|
2020-01-17 23:43:18 +00:00
|
|
|
localized_strings: &'a std::sync::Arc<VoxygenLocalization>,
|
|
|
|
|
2019-08-07 13:14:26 +00:00
|
|
|
#[conrod(common_builder)]
|
|
|
|
common: widget::CommonBuilder,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Spell<'a> {
|
2020-01-17 23:43:18 +00:00
|
|
|
pub fn new(
|
|
|
|
show: &'a Show,
|
|
|
|
_client: &'a Client,
|
|
|
|
imgs: &'a Imgs,
|
2020-01-26 19:29:46 +00:00
|
|
|
fonts: &'a ConrodVoxygenFonts,
|
2020-01-17 23:43:18 +00:00
|
|
|
localized_strings: &'a std::sync::Arc<VoxygenLocalization>,
|
|
|
|
) -> Self {
|
2019-08-07 13:14:26 +00:00
|
|
|
Self {
|
|
|
|
_show: show,
|
|
|
|
_client,
|
2020-01-17 23:43:18 +00:00
|
|
|
imgs,
|
|
|
|
fonts,
|
|
|
|
localized_strings,
|
2019-08-07 13:14:26 +00:00
|
|
|
common: widget::CommonBuilder::default(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*pub struct State {
|
|
|
|
ids: Ids,
|
|
|
|
}*/
|
|
|
|
|
|
|
|
pub enum Event {
|
|
|
|
Close,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Widget for Spell<'a> {
|
2020-02-01 20:39:39 +00:00
|
|
|
type Event = Option<Event>;
|
2019-08-07 13:14:26 +00:00
|
|
|
type State = Ids;
|
|
|
|
type Style = ();
|
|
|
|
|
2020-02-01 20:39:39 +00:00
|
|
|
fn init_state(&self, id_gen: widget::id::Generator) -> Self::State { Ids::new(id_gen) }
|
2019-08-07 13:14:26 +00:00
|
|
|
|
2020-02-01 20:39:39 +00:00
|
|
|
fn style(&self) -> Self::Style { () }
|
2019-08-07 13:14:26 +00:00
|
|
|
|
|
|
|
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
|
|
|
|
let widget::UpdateArgs {
|
|
|
|
id: _, state, ui, ..
|
|
|
|
} = args;
|
|
|
|
|
2020-03-16 18:56:15 +00:00
|
|
|
Image::new(self.imgs.window_3)
|
|
|
|
.top_left_with_margins_on(ui.window, 200.0, 25.0)
|
|
|
|
.w_h(103.0 * 4.0, 122.0 * 4.0)
|
|
|
|
.set(state.spell_frame, ui);
|
2019-08-07 13:14:26 +00:00
|
|
|
|
|
|
|
// X-Button
|
|
|
|
if Button::image(self.imgs.close_button)
|
|
|
|
.w_h(28.0, 28.0)
|
|
|
|
.hover_image(self.imgs.close_button_hover)
|
|
|
|
.press_image(self.imgs.close_button_press)
|
|
|
|
.top_right_with_margins_on(state.spell_frame, 0.0, 0.0)
|
|
|
|
.set(state.spell_close, ui)
|
|
|
|
.was_clicked()
|
|
|
|
{
|
|
|
|
return Some(Event::Close);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Title
|
|
|
|
// TODO: Use an actual character name.
|
2020-01-17 23:43:18 +00:00
|
|
|
Text::new(&self.localized_strings.get("hud.spell"))
|
2019-08-07 13:14:26 +00:00
|
|
|
.mid_top_with_margin_on(state.spell_frame, 6.0)
|
2020-01-26 19:29:46 +00:00
|
|
|
.font_id(self.fonts.cyri.conrod_id)
|
|
|
|
.font_size(self.fonts.cyri.scale(14))
|
2019-08-07 13:14:26 +00:00
|
|
|
.color(TEXT_COLOR)
|
|
|
|
.set(state.spell_title, ui);
|
|
|
|
|
|
|
|
// Content Alignment
|
|
|
|
Rectangle::fill_with([95.0 * 4.0, 108.0 * 4.0], color::TRANSPARENT)
|
|
|
|
.mid_top_with_margin_on(state.spell_frame, 40.0)
|
|
|
|
.set(state.content_align, ui);
|
|
|
|
|
|
|
|
// Contents
|
|
|
|
|
|
|
|
// Frame
|
|
|
|
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|