Character stats displayed in char window, pulsating active slot in inventory

This commit is contained in:
Monty Marz 2020-01-23 17:14:02 +00:00
parent b8135408a5
commit bfee0a6f9e
5 changed files with 29 additions and 42 deletions

View File

@ -65,6 +65,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Made clouds bigger, more performant and prettier
- Terrain meshing optimized further
- Tree leaves no longer color blended
- Actual character stats displayed in character window
### Removed

View File

@ -317,13 +317,12 @@ Chat commands:
/// Start character window section
"character_window.character_name": "Character Name",
// Charater stats
"character_window.character_stats": r#"Stamina
"character_window.character_stats": r#"Endurance
Strength
Fitness
Dexterity
Intelligence"#,
Willpower
"#,
/// Start character window section

View File

@ -40,6 +40,7 @@ pub struct Bag<'a> {
common: widget::CommonBuilder,
rot_imgs: &'a ImgsRot,
tooltip_manager: &'a mut TooltipManager,
pulse: f32,
}
impl<'a> Bag<'a> {
@ -50,6 +51,7 @@ impl<'a> Bag<'a> {
fonts: &'a Fonts,
rot_imgs: &'a ImgsRot,
tooltip_manager: &'a mut TooltipManager,
pulse: f32,
) -> Self {
Self {
client,
@ -59,6 +61,7 @@ impl<'a> Bag<'a> {
common: widget::CommonBuilder::default(),
rot_imgs,
tooltip_manager,
pulse,
}
}
}
@ -103,6 +106,7 @@ impl<'a> Widget for Bag<'a> {
Some(inv) => inv,
None => return None,
};
// Tooltips
let item_tooltip = Tooltip::new({
// Edge images [t, b, r, l]
@ -173,6 +177,7 @@ impl<'a> Widget for Bag<'a> {
let is_selected = Some(i) == state.selected_slot;
// Slot
let slot_widget = Button::image(if !is_selected {
self.imgs.inv_slot
} else {
@ -182,9 +187,8 @@ impl<'a> Widget for Bag<'a> {
state.ids.inv_alignment,
0.0 + y as f64 * (40.0 + 2.0),
0.0 + x as f64 * (40.0 + 2.0),
) // conrod uses a (y,x) format for placing...
// (the margin placement functions do this because that is the same order as "top left")
.w_h(40.0, 40.0)
)
.wh(if is_selected { [40.0; 2] } else { [40.0; 2] })
.image_color(if is_selected {
color::WHITE
} else {
@ -223,6 +227,9 @@ impl<'a> Widget for Bag<'a> {
}
// Item
if let Some(kind) = item.as_ref().map(|i| ItemKey::from(i)) {
let slot_anim: f64 =
((self.pulse as f64 * 4.0/*speed factor*/).cos() * 0.5 + 0.5) * 2.0; //Animation timer
println!("{}", slot_anim);
Button::image(match &state.img_id_cache[i] {
Some((cached_kind, id)) if cached_kind == &kind => *id,
_ => {
@ -234,7 +241,11 @@ impl<'a> Widget for Bag<'a> {
id
}
})
.w_h(30.0, 30.0)
.wh(if is_selected {
[30.0 + slot_anim.abs(); 2]
} else {
[30.0; 2]
})
.middle_of(state.ids.inv_slots[i]) // TODO: Items need to be assigned to a certain slot and then placed like in this example
//.label("5x") // TODO: Quantity goes here...
//.label_font_id(self.fonts.opensans)

View File

@ -405,15 +405,14 @@ impl<'a> Widget for CharacterWindow<'a> {
.set(state.charwindow_tab1_statnames, ui);
// TODO: Shows actual stat points.
Text::new(
"1234\n\
\n\
12312\n\
\n\
12414\n\
\n\
124124",
)
Text::new(&format!(
"{}\n\
\n\
{}\n\
\n\
{}",
self.stats.endurance, self.stats.fitness, self.stats.willpower
))
.top_right_with_margins_on(state.charwindow_rectangle, 140.0, 5.0)
.font_id(self.fonts.cyri)
.font_size(16)

View File

@ -280,7 +280,6 @@ pub struct Show {
esc_menu: bool,
open_windows: Windows,
map: bool,
inventory_test_button: bool,
mini_map: bool,
ingame: bool,
settings_tab: SettingsTab,
@ -432,7 +431,6 @@ pub struct Hud {
fonts: Fonts,
rot_imgs: ImgsRot,
new_messages: VecDeque<ClientEvent>,
inventory_space: usize,
show: Show,
never_show: bool,
intro: bool,
@ -475,7 +473,6 @@ impl Hud {
fonts,
ids,
new_messages: VecDeque::new(),
inventory_space: 8,
intro: false,
intro_2: false,
show: Show {
@ -491,7 +488,6 @@ impl Hud {
quest: false,
spell: false,
character_window: false,
inventory_test_button: false,
mini_map: false,
settings_tab: SettingsTab::Interface,
social_tab: SocialTab::Online,
@ -1519,26 +1515,6 @@ impl Hud {
.set(self.ids.debug_info, ui_widgets);
}
// Add Bag-Space Button.
if self.show.inventory_test_button {
if Button::image(self.imgs.button)
.w_h(100.0, 100.0)
.middle_of(ui_widgets.window)
.label("Add 1 Space")
.label_font_size(20)
.label_color(TEXT_COLOR)
.hover_image(self.imgs.button_hover)
.press_image(self.imgs.button_press)
.set(self.ids.bag_space_add, ui_widgets)
.was_clicked()
{
if self.inventory_space < 100 {
self.inventory_space += 1;
} else {
}
};
}
// Help Text
if self.show.help && !self.show.map && !self.show.esc_menu {
Image::new(self.imgs.help)
@ -1621,6 +1597,7 @@ impl Hud {
&self.fonts,
&self.rot_imgs,
tooltip_manager,
self.pulse,
)
.set(self.ids.bag, ui_widgets)
{