mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
hide entire hud when toggling interface
Former-commit-id: 969564ecfd85df0477db4216cd8974adf2df1921
This commit is contained in:
@ -487,378 +487,382 @@ impl Hud {
|
|||||||
const MANA_COLOR: Color = Color::Rgba(0.42, 0.41, 0.66, 1.0);
|
const MANA_COLOR: Color = Color::Rgba(0.42, 0.41, 0.66, 1.0);
|
||||||
const XP_COLOR: Color = Color::Rgba(0.59, 0.41, 0.67, 1.0);
|
const XP_COLOR: Color = Color::Rgba(0.59, 0.41, 0.67, 1.0);
|
||||||
|
|
||||||
if self.show_ui {
|
// Don't show anything if the ui is toggled off
|
||||||
// Add Bag-Space Button
|
if !self.show_ui {
|
||||||
if self.inventorytest_button {
|
return events;
|
||||||
if Button::image(self.imgs.mmap_button)
|
}
|
||||||
.w_h(100.0, 100.0)
|
|
||||||
.middle_of(ui_widgets.window)
|
// Add Bag-Space Button
|
||||||
.label("1 Up!")
|
if self.inventorytest_button {
|
||||||
.label_font_size(20)
|
|
||||||
.hover_image(self.imgs.mmap_button_hover)
|
|
||||||
.press_image(self.imgs.mmap_button_press)
|
|
||||||
.set(self.ids.bag_space_add, ui_widgets)
|
|
||||||
.was_clicked()
|
|
||||||
{
|
|
||||||
self.inventory_space = self.inventory_space + 1;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// Chat box
|
|
||||||
if let Some(msg) = self
|
|
||||||
.chat
|
|
||||||
.update_layout(ui_widgets, self.font_opensans, &self.imgs)
|
|
||||||
{
|
|
||||||
events.push(Event::SendMessage(msg));
|
|
||||||
}
|
|
||||||
// Alpha Version
|
|
||||||
Text::new(version)
|
|
||||||
.top_left_with_margins_on(ui_widgets.window, 5.0, 5.0)
|
|
||||||
.font_size(14)
|
|
||||||
.color(TEXT_COLOR)
|
|
||||||
.set(self.ids.v_logo, ui_widgets);
|
|
||||||
// Help Text
|
|
||||||
if self.show_help {
|
|
||||||
Image::new(self.imgs.window_frame_2)
|
|
||||||
.top_left_with_margins_on(ui_widgets.window, 3.0, 3.0)
|
|
||||||
.w_h(300.0, 350.0)
|
|
||||||
.set(self.ids.help_bg, ui_widgets);
|
|
||||||
|
|
||||||
Text::new(
|
|
||||||
"Tab = Free Cursor \n\
|
|
||||||
Esc = Open/Close Menus \n\
|
|
||||||
\n\
|
|
||||||
F1 = Toggle this Window \n\
|
|
||||||
F2 = Toggle Interface \n\
|
|
||||||
\n\
|
|
||||||
Enter = Open Chat \n\
|
|
||||||
Mouse Wheel = Scroll Chat\n\
|
|
||||||
\n\
|
|
||||||
M = Map \n\
|
|
||||||
B = Bag \n\
|
|
||||||
L = Quest-Log \n\
|
|
||||||
C = Character Window \n\
|
|
||||||
O = Social \n\
|
|
||||||
P = Spellbook \n\
|
|
||||||
N = Settings",
|
|
||||||
)
|
|
||||||
.color(TEXT_COLOR)
|
|
||||||
.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);
|
|
||||||
// X-button
|
|
||||||
if Button::image(self.imgs.close_button)
|
|
||||||
.w_h(244.0 * 0.22 / 3.0, 244.0 * 0.22 / 3.0)
|
|
||||||
.hover_image(self.imgs.close_button_hover)
|
|
||||||
.press_image(self.imgs.close_button_press)
|
|
||||||
.top_right_with_margins_on(self.ids.help_bg, 8.0, 3.0)
|
|
||||||
.set(self.ids.button_help2, ui_widgets)
|
|
||||||
.was_clicked()
|
|
||||||
{
|
|
||||||
self.show_help = false;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Minimap frame and bg
|
|
||||||
Image::new(self.imgs.mmap_frame_bg)
|
|
||||||
.w_h(1750.0 / 8.0, 1650.0 / 8.0)
|
|
||||||
.top_right_with_margins_on(ui_widgets.window, 5.0, 30.0)
|
|
||||||
.set(self.ids.mmap_frame_bg, ui_widgets);
|
|
||||||
|
|
||||||
Image::new(self.imgs.mmap_frame)
|
|
||||||
.w_h(1750.0 / 8.0, 1650.0 / 8.0)
|
|
||||||
.top_right_with_margins_on(ui_widgets.window, 5.0, 30.0)
|
|
||||||
.set(self.ids.mmap_frame, ui_widgets);
|
|
||||||
|
|
||||||
Image::new(self.imgs.mmap_icons)
|
|
||||||
.w_h(448.0 / 14.93, 2688.0 / 14.93)
|
|
||||||
.right_from(self.ids.mmap_frame, 0.0)
|
|
||||||
.align_bottom_of(self.ids.mmap_frame)
|
|
||||||
.set(self.ids.mmap_icons, ui_widgets);
|
|
||||||
// Title
|
|
||||||
// Make it display the actual location
|
|
||||||
Text::new("Uncanny Valley")
|
|
||||||
.mid_top_with_margin_on(self.ids.mmap_frame, 5.0)
|
|
||||||
.font_size(14)
|
|
||||||
.color(TEXT_COLOR)
|
|
||||||
.set(self.ids.mmap_location, ui_widgets);
|
|
||||||
|
|
||||||
// Minimap Buttons
|
|
||||||
|
|
||||||
//0 Settings
|
|
||||||
if Button::image(self.imgs.mmap_button)
|
if Button::image(self.imgs.mmap_button)
|
||||||
.w_h(448.0 / 15.0, 448.0 / 15.0)
|
.w_h(100.0, 100.0)
|
||||||
.top_right_with_margins_on(self.ids.mmap_icons, 0.0, 0.0)
|
.middle_of(ui_widgets.window)
|
||||||
|
.label("1 Up!")
|
||||||
|
.label_font_size(20)
|
||||||
.hover_image(self.imgs.mmap_button_hover)
|
.hover_image(self.imgs.mmap_button_hover)
|
||||||
.press_image(self.imgs.mmap_button_press)
|
.press_image(self.imgs.mmap_button_press)
|
||||||
.set(self.ids.mmap_button_0, ui_widgets)
|
.set(self.ids.bag_space_add, ui_widgets)
|
||||||
|
.was_clicked()
|
||||||
|
{
|
||||||
|
self.inventory_space = self.inventory_space + 1;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// Chat box
|
||||||
|
if let Some(msg) = self
|
||||||
|
.chat
|
||||||
|
.update_layout(ui_widgets, self.font_opensans, &self.imgs)
|
||||||
|
{
|
||||||
|
events.push(Event::SendMessage(msg));
|
||||||
|
}
|
||||||
|
// Alpha Version
|
||||||
|
Text::new(version)
|
||||||
|
.top_left_with_margins_on(ui_widgets.window, 5.0, 5.0)
|
||||||
|
.font_size(14)
|
||||||
|
.color(TEXT_COLOR)
|
||||||
|
.set(self.ids.v_logo, ui_widgets);
|
||||||
|
// Help Text
|
||||||
|
if self.show_help {
|
||||||
|
Image::new(self.imgs.window_frame_2)
|
||||||
|
.top_left_with_margins_on(ui_widgets.window, 3.0, 3.0)
|
||||||
|
.w_h(300.0, 350.0)
|
||||||
|
.set(self.ids.help_bg, ui_widgets);
|
||||||
|
|
||||||
|
Text::new(
|
||||||
|
"Tab = Free Cursor \n\
|
||||||
|
Esc = Open/Close Menus \n\
|
||||||
|
\n\
|
||||||
|
F1 = Toggle this Window \n\
|
||||||
|
F2 = Toggle Interface \n\
|
||||||
|
\n\
|
||||||
|
Enter = Open Chat \n\
|
||||||
|
Mouse Wheel = Scroll Chat\n\
|
||||||
|
\n\
|
||||||
|
M = Map \n\
|
||||||
|
B = Bag \n\
|
||||||
|
L = Quest-Log \n\
|
||||||
|
C = Character Window \n\
|
||||||
|
O = Social \n\
|
||||||
|
P = Spellbook \n\
|
||||||
|
N = Settings",
|
||||||
|
)
|
||||||
|
.color(TEXT_COLOR)
|
||||||
|
.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);
|
||||||
|
// X-button
|
||||||
|
if Button::image(self.imgs.close_button)
|
||||||
|
.w_h(244.0 * 0.22 / 3.0, 244.0 * 0.22 / 3.0)
|
||||||
|
.hover_image(self.imgs.close_button_hover)
|
||||||
|
.press_image(self.imgs.close_button_press)
|
||||||
|
.top_right_with_margins_on(self.ids.help_bg, 8.0, 3.0)
|
||||||
|
.set(self.ids.button_help2, ui_widgets)
|
||||||
|
.was_clicked()
|
||||||
|
{
|
||||||
|
self.show_help = false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minimap frame and bg
|
||||||
|
Image::new(self.imgs.mmap_frame_bg)
|
||||||
|
.w_h(1750.0 / 8.0, 1650.0 / 8.0)
|
||||||
|
.top_right_with_margins_on(ui_widgets.window, 5.0, 30.0)
|
||||||
|
.set(self.ids.mmap_frame_bg, ui_widgets);
|
||||||
|
|
||||||
|
Image::new(self.imgs.mmap_frame)
|
||||||
|
.w_h(1750.0 / 8.0, 1650.0 / 8.0)
|
||||||
|
.top_right_with_margins_on(ui_widgets.window, 5.0, 30.0)
|
||||||
|
.set(self.ids.mmap_frame, ui_widgets);
|
||||||
|
|
||||||
|
Image::new(self.imgs.mmap_icons)
|
||||||
|
.w_h(448.0 / 14.93, 2688.0 / 14.93)
|
||||||
|
.right_from(self.ids.mmap_frame, 0.0)
|
||||||
|
.align_bottom_of(self.ids.mmap_frame)
|
||||||
|
.set(self.ids.mmap_icons, ui_widgets);
|
||||||
|
// Title
|
||||||
|
// Make it display the actual location
|
||||||
|
Text::new("Uncanny Valley")
|
||||||
|
.mid_top_with_margin_on(self.ids.mmap_frame, 5.0)
|
||||||
|
.font_size(14)
|
||||||
|
.color(TEXT_COLOR)
|
||||||
|
.set(self.ids.mmap_location, ui_widgets);
|
||||||
|
|
||||||
|
// Minimap Buttons
|
||||||
|
|
||||||
|
//0 Settings
|
||||||
|
if Button::image(self.imgs.mmap_button)
|
||||||
|
.w_h(448.0 / 15.0, 448.0 / 15.0)
|
||||||
|
.top_right_with_margins_on(self.ids.mmap_icons, 0.0, 0.0)
|
||||||
|
.hover_image(self.imgs.mmap_button_hover)
|
||||||
|
.press_image(self.imgs.mmap_button_press)
|
||||||
|
.set(self.ids.mmap_button_0, ui_widgets)
|
||||||
|
.was_clicked()
|
||||||
|
{
|
||||||
|
self.open_windows = match self.open_windows {
|
||||||
|
Windows::Settings => Windows::None,
|
||||||
|
_ => Windows::Settings,
|
||||||
|
};
|
||||||
|
self.bag_open = false;
|
||||||
|
};
|
||||||
|
// 2 Map
|
||||||
|
if Button::image(self.imgs.mmap_button)
|
||||||
|
.w_h(448.0 / 15.0, 448.0 / 15.0)
|
||||||
|
.down_from(self.ids.mmap_button_1, 0.0)
|
||||||
|
.hover_image(self.imgs.mmap_button_hover)
|
||||||
|
.press_image(self.imgs.mmap_button_press)
|
||||||
|
.set(self.ids.mmap_button_2, ui_widgets)
|
||||||
|
.was_clicked()
|
||||||
|
{
|
||||||
|
self.map_open = !self.map_open;
|
||||||
|
self.bag_open = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Other Windows can only be accessed, when Settings are closed. Opening Settings will close all other Windows including the Bag.
|
||||||
|
// Opening the Map won't close the windows displayed before.
|
||||||
|
|
||||||
|
if match self.open_windows {
|
||||||
|
Windows::Settings => false,
|
||||||
|
_ => true,
|
||||||
|
} && self.map_open == false
|
||||||
|
{
|
||||||
|
//1 Social
|
||||||
|
if Button::image(self.imgs.mmap_button)
|
||||||
|
.w_h(448.0 / 15.0, 448.0 / 15.0)
|
||||||
|
.down_from(self.ids.mmap_button_0, 0.0)
|
||||||
|
.hover_image(self.imgs.mmap_button_hover)
|
||||||
|
.press_image(self.imgs.mmap_button_press)
|
||||||
|
.set(self.ids.mmap_button_1, ui_widgets)
|
||||||
.was_clicked()
|
.was_clicked()
|
||||||
{
|
{
|
||||||
self.open_windows = match self.open_windows {
|
self.open_windows = match self.open_windows {
|
||||||
Windows::Settings => Windows::None,
|
Windows::Small(Small::Social) => Windows::None,
|
||||||
_ => Windows::Settings,
|
Windows::None | Windows::Small(_) => Windows::Small(Small::Social),
|
||||||
|
Windows::CharacterAnd(small) => match small {
|
||||||
|
Some(Small::Social) => Windows::CharacterAnd(None),
|
||||||
|
_ => Windows::CharacterAnd(Some(Small::Social)),
|
||||||
|
},
|
||||||
|
Windows::Settings => Windows::Settings,
|
||||||
};
|
};
|
||||||
self.bag_open = false;
|
}
|
||||||
};
|
|
||||||
// 2 Map
|
//3 Spellbook
|
||||||
if Button::image(self.imgs.mmap_button)
|
if Button::image(self.imgs.mmap_button)
|
||||||
.w_h(448.0 / 15.0, 448.0 / 15.0)
|
.w_h(448.0 / 15.0, 448.0 / 15.0)
|
||||||
.down_from(self.ids.mmap_button_1, 0.0)
|
.down_from(self.ids.mmap_button_2, 0.0)
|
||||||
.hover_image(self.imgs.mmap_button_hover)
|
.hover_image(self.imgs.mmap_button_hover)
|
||||||
.press_image(self.imgs.mmap_button_press)
|
.press_image(self.imgs.mmap_button_press)
|
||||||
.set(self.ids.mmap_button_2, ui_widgets)
|
.set(self.ids.mmap_button_3, ui_widgets)
|
||||||
.was_clicked()
|
.was_clicked()
|
||||||
{
|
{
|
||||||
self.map_open = !self.map_open;
|
self.open_windows = match self.open_windows {
|
||||||
self.bag_open = false;
|
Windows::Small(Small::Spellbook) => Windows::None,
|
||||||
};
|
Windows::None | Windows::Small(_) => Windows::Small(Small::Spellbook),
|
||||||
|
Windows::CharacterAnd(small) => match small {
|
||||||
// Other Windows can only be accessed, when Settings are closed. Opening Settings will close all other Windows including the Bag.
|
Some(Small::Spellbook) => Windows::CharacterAnd(None),
|
||||||
// Opening the Map won't close the windows displayed before.
|
_ => Windows::CharacterAnd(Some(Small::Spellbook)),
|
||||||
|
},
|
||||||
if match self.open_windows {
|
Windows::Settings => Windows::Settings,
|
||||||
Windows::Settings => false,
|
};
|
||||||
_ => true,
|
}
|
||||||
} && self.map_open == false
|
//4 Char-Window
|
||||||
|
if Button::image(self.imgs.mmap_button)
|
||||||
|
.w_h(448.0 / 15.0, 448.0 / 15.0)
|
||||||
|
.down_from(self.ids.mmap_button_3, 0.0)
|
||||||
|
.hover_image(self.imgs.mmap_button_hover)
|
||||||
|
.press_image(self.imgs.mmap_button_press)
|
||||||
|
.set(self.ids.mmap_button_4, ui_widgets)
|
||||||
|
.was_clicked()
|
||||||
{
|
{
|
||||||
//1 Social
|
self.open_windows = match self.open_windows {
|
||||||
if Button::image(self.imgs.mmap_button)
|
Windows::CharacterAnd(small) => match small {
|
||||||
.w_h(448.0 / 15.0, 448.0 / 15.0)
|
Some(small) => Windows::Small(small),
|
||||||
.down_from(self.ids.mmap_button_0, 0.0)
|
None => Windows::None,
|
||||||
.hover_image(self.imgs.mmap_button_hover)
|
},
|
||||||
.press_image(self.imgs.mmap_button_press)
|
Windows::Small(small) => Windows::CharacterAnd(Some(small)),
|
||||||
.set(self.ids.mmap_button_1, ui_widgets)
|
Windows::None => Windows::CharacterAnd(None),
|
||||||
.was_clicked()
|
Windows::Settings => Windows::Settings,
|
||||||
{
|
|
||||||
self.open_windows = match self.open_windows {
|
|
||||||
Windows::Small(Small::Social) => Windows::None,
|
|
||||||
Windows::None | Windows::Small(_) => Windows::Small(Small::Social),
|
|
||||||
Windows::CharacterAnd(small) => match small {
|
|
||||||
Some(Small::Social) => Windows::CharacterAnd(None),
|
|
||||||
_ => Windows::CharacterAnd(Some(Small::Social)),
|
|
||||||
},
|
|
||||||
Windows::Settings => Windows::Settings,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
//3 Spellbook
|
|
||||||
if Button::image(self.imgs.mmap_button)
|
|
||||||
.w_h(448.0 / 15.0, 448.0 / 15.0)
|
|
||||||
.down_from(self.ids.mmap_button_2, 0.0)
|
|
||||||
.hover_image(self.imgs.mmap_button_hover)
|
|
||||||
.press_image(self.imgs.mmap_button_press)
|
|
||||||
.set(self.ids.mmap_button_3, ui_widgets)
|
|
||||||
.was_clicked()
|
|
||||||
{
|
|
||||||
self.open_windows = match self.open_windows {
|
|
||||||
Windows::Small(Small::Spellbook) => Windows::None,
|
|
||||||
Windows::None | Windows::Small(_) => Windows::Small(Small::Spellbook),
|
|
||||||
Windows::CharacterAnd(small) => match small {
|
|
||||||
Some(Small::Spellbook) => Windows::CharacterAnd(None),
|
|
||||||
_ => Windows::CharacterAnd(Some(Small::Spellbook)),
|
|
||||||
},
|
|
||||||
Windows::Settings => Windows::Settings,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
//4 Char-Window
|
|
||||||
if Button::image(self.imgs.mmap_button)
|
|
||||||
.w_h(448.0 / 15.0, 448.0 / 15.0)
|
|
||||||
.down_from(self.ids.mmap_button_3, 0.0)
|
|
||||||
.hover_image(self.imgs.mmap_button_hover)
|
|
||||||
.press_image(self.imgs.mmap_button_press)
|
|
||||||
.set(self.ids.mmap_button_4, ui_widgets)
|
|
||||||
.was_clicked()
|
|
||||||
{
|
|
||||||
self.open_windows = match self.open_windows {
|
|
||||||
Windows::CharacterAnd(small) => match small {
|
|
||||||
Some(small) => Windows::Small(small),
|
|
||||||
None => Windows::None,
|
|
||||||
},
|
|
||||||
Windows::Small(small) => Windows::CharacterAnd(Some(small)),
|
|
||||||
Windows::None => Windows::CharacterAnd(None),
|
|
||||||
Windows::Settings => Windows::Settings,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//5 Quest-Log
|
|
||||||
if Button::image(self.imgs.mmap_button)
|
|
||||||
.w_h(448.0 / 15.0, 448.0 / 15.0)
|
|
||||||
.down_from(self.ids.mmap_button_4, 0.0)
|
|
||||||
.hover_image(self.imgs.mmap_button_hover)
|
|
||||||
.press_image(self.imgs.mmap_button_press)
|
|
||||||
.set(self.ids.mmap_button_5, ui_widgets)
|
|
||||||
.was_clicked()
|
|
||||||
{
|
|
||||||
self.open_windows = match self.open_windows {
|
|
||||||
Windows::Small(Small::Questlog) => Windows::None,
|
|
||||||
Windows::None | Windows::Small(_) => Windows::Small(Small::Questlog),
|
|
||||||
Windows::CharacterAnd(small) => match small {
|
|
||||||
Some(Small::Questlog) => Windows::CharacterAnd(None),
|
|
||||||
_ => Windows::CharacterAnd(Some(Small::Questlog)),
|
|
||||||
},
|
|
||||||
Windows::Settings => Windows::Settings,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//5 Quest-Log
|
||||||
// Skillbar Module
|
if Button::image(self.imgs.mmap_button)
|
||||||
|
.w_h(448.0 / 15.0, 448.0 / 15.0)
|
||||||
// Experience-Bar
|
.down_from(self.ids.mmap_button_4, 0.0)
|
||||||
Image::new(self.imgs.xp_bar)
|
.hover_image(self.imgs.mmap_button_hover)
|
||||||
.w_h(2688.0 / 6.0, 116.0 / 6.0)
|
.press_image(self.imgs.mmap_button_press)
|
||||||
.mid_bottom_of(ui_widgets.window)
|
.set(self.ids.mmap_button_5, ui_widgets)
|
||||||
.set(self.ids.xp_bar, ui_widgets);
|
.was_clicked()
|
||||||
|
{
|
||||||
Rectangle::fill_with([406.0 * (self.xp_percentage), 5.0], XP_COLOR) // "W=406*[Exp. %]"
|
self.open_windows = match self.open_windows {
|
||||||
.top_left_with_margins_on(self.ids.xp_bar, 5.0, 21.0)
|
Windows::Small(Small::Questlog) => Windows::None,
|
||||||
.set(self.ids.xp_bar_progress, ui_widgets);
|
Windows::None | Windows::Small(_) => Windows::Small(Small::Questlog),
|
||||||
|
Windows::CharacterAnd(small) => match small {
|
||||||
// Left Grid
|
Some(Small::Questlog) => Windows::CharacterAnd(None),
|
||||||
Image::new(self.imgs.sb_grid)
|
_ => Windows::CharacterAnd(Some(Small::Questlog)),
|
||||||
.w_h(2240.0 / 12.0, 448.0 / 12.0)
|
},
|
||||||
.up_from(self.ids.xp_bar, 0.0)
|
Windows::Settings => Windows::Settings,
|
||||||
.align_left_of(self.ids.xp_bar)
|
};
|
||||||
.set(self.ids.sb_grid_l, ui_widgets);
|
|
||||||
|
|
||||||
Image::new(self.imgs.sb_grid_bg)
|
|
||||||
.w_h(2240.0 / 12.0, 448.0 / 12.0)
|
|
||||||
.middle_of(self.ids.sb_grid_l)
|
|
||||||
.set(self.ids.sb_grid_bg_l, ui_widgets);
|
|
||||||
|
|
||||||
// Right Grid
|
|
||||||
Image::new(self.imgs.sb_grid)
|
|
||||||
.w_h(2240.0 / 12.0, 448.0 / 12.0)
|
|
||||||
.up_from(self.ids.xp_bar, 0.0)
|
|
||||||
.align_right_of(self.ids.xp_bar)
|
|
||||||
.set(self.ids.sb_grid_r, ui_widgets);
|
|
||||||
|
|
||||||
Image::new(self.imgs.sb_grid_bg)
|
|
||||||
.w_h(2240.0 / 12.0, 448.0 / 12.0)
|
|
||||||
.middle_of(self.ids.sb_grid_r)
|
|
||||||
.set(self.ids.sb_grid_bg_r, ui_widgets);
|
|
||||||
|
|
||||||
// Right and Left Click
|
|
||||||
Image::new(self.imgs.l_click)
|
|
||||||
.w_h(224.0 / 6.0, 320.0 / 6.0)
|
|
||||||
.right_from(self.ids.sb_grid_bg_l, 0.0)
|
|
||||||
.align_bottom_of(self.ids.sb_grid_bg_l)
|
|
||||||
.set(self.ids.l_click, ui_widgets);
|
|
||||||
|
|
||||||
Image::new(self.imgs.r_click)
|
|
||||||
.w_h(224.0 / 6.0, 320.0 / 6.0)
|
|
||||||
.left_from(self.ids.sb_grid_bg_r, 0.0)
|
|
||||||
.align_bottom_of(self.ids.sb_grid_bg_r)
|
|
||||||
.set(self.ids.r_click, ui_widgets);
|
|
||||||
|
|
||||||
// Health Bar
|
|
||||||
Image::new(self.imgs.health_bar)
|
|
||||||
.w_h(1120.0 / 6.0, 96.0 / 6.0)
|
|
||||||
.left_from(self.ids.l_click, 0.0)
|
|
||||||
.align_top_of(self.ids.l_click)
|
|
||||||
.set(self.ids.health_bar, ui_widgets);
|
|
||||||
|
|
||||||
// Filling
|
|
||||||
Rectangle::fill_with([182.0 * (self.hp_percentage), 6.0], HP_COLOR) // "W=182.0 * [Health. %]"
|
|
||||||
.top_right_with_margins_on(self.ids.health_bar, 5.0, 0.0)
|
|
||||||
.set(self.ids.health_bar_color, ui_widgets);
|
|
||||||
|
|
||||||
// Mana Bar
|
|
||||||
Image::new(self.imgs.mana_bar)
|
|
||||||
.w_h(1120.0 / 6.0, 96.0 / 6.0)
|
|
||||||
.right_from(self.ids.r_click, 0.0)
|
|
||||||
.align_top_of(self.ids.r_click)
|
|
||||||
.set(self.ids.mana_bar, ui_widgets);
|
|
||||||
|
|
||||||
// Filling
|
|
||||||
Rectangle::fill_with([182.0 * (self.mana_percentage), 6.0], MANA_COLOR) // "W=182.0 * [Mana. %]"
|
|
||||||
.top_left_with_margins_on(self.ids.mana_bar, 5.0, 0.0)
|
|
||||||
.set(self.ids.mana_bar_color, ui_widgets);
|
|
||||||
|
|
||||||
// Buffs/Debuffs
|
|
||||||
|
|
||||||
// Buffs
|
|
||||||
|
|
||||||
// Debuffs
|
|
||||||
|
|
||||||
// Level Display
|
|
||||||
|
|
||||||
// Insert actual Level here
|
|
||||||
Text::new("1")
|
|
||||||
.left_from(self.ids.xp_bar, -15.0)
|
|
||||||
.font_size(10)
|
|
||||||
.color(TEXT_COLOR)
|
|
||||||
.set(self.ids.level_text, ui_widgets);
|
|
||||||
|
|
||||||
// Insert next Level here
|
|
||||||
Text::new("2")
|
|
||||||
.right_from(self.ids.xp_bar, -15.0)
|
|
||||||
.font_size(10)
|
|
||||||
.color(TEXT_COLOR)
|
|
||||||
.set(self.ids.next_level_text, ui_widgets);
|
|
||||||
|
|
||||||
// Bag contents
|
|
||||||
if self.bag_open {
|
|
||||||
// Contents
|
|
||||||
Image::new(self.imgs.bag_contents)
|
|
||||||
.w_h(307.0, 545.0)
|
|
||||||
.bottom_right_with_margins_on(ui_widgets.window, 90.0, 5.0)
|
|
||||||
.set(self.ids.bag_contents, ui_widgets);
|
|
||||||
|
|
||||||
// Alignment for Grid
|
|
||||||
Rectangle::fill_with([246.0, 465.0], color::TRANSPARENT)
|
|
||||||
.top_left_with_margins_on(self.ids.bag_contents, 27.0, 23.0)
|
|
||||||
.scroll_kids()
|
|
||||||
.scroll_kids_vertically()
|
|
||||||
.set(self.ids.inv_alignment, ui_widgets);
|
|
||||||
// Grid
|
|
||||||
Image::new(self.imgs.inv_grid)
|
|
||||||
.w_h(232.0, 1104.0)
|
|
||||||
.mid_top_with_margin_on(self.ids.inv_alignment, 0.0)
|
|
||||||
.set(self.ids.inv_grid, ui_widgets);
|
|
||||||
Scrollbar::y_axis(self.ids.inv_alignment)
|
|
||||||
.thickness(5.0)
|
|
||||||
.rgba(0.86, 0.86, 0.86, 0.1)
|
|
||||||
.set(self.ids.inv_scrollbar, ui_widgets);
|
|
||||||
|
|
||||||
// X-button
|
|
||||||
if Button::image(self.imgs.close_button)
|
|
||||||
.w_h(244.0 * 0.22 / 3.0, 244.0 * 0.22 / 3.0)
|
|
||||||
.hover_image(self.imgs.close_button_hover)
|
|
||||||
.press_image(self.imgs.close_button_press)
|
|
||||||
.top_right_with_margins_on(self.ids.bag_contents, 5.0, 17.0)
|
|
||||||
.set(self.ids.bag_close, ui_widgets)
|
|
||||||
.was_clicked()
|
|
||||||
{
|
|
||||||
self.bag_open = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.inventory_space > 0 {
|
|
||||||
// First Slot
|
|
||||||
Button::image(self.imgs.inv_slot)
|
|
||||||
.top_left_with_margins_on(self.ids.inv_grid, 5.0, 5.0)
|
|
||||||
.w_h(40.0, 40.0)
|
|
||||||
.set(self.ids.inv_slot_0, ui_widgets);
|
|
||||||
}
|
|
||||||
// if self.ids.inv_slot.len() < self.inventory_space {
|
|
||||||
// self.ids.inv_slot.resize(self.inventory_space, &mut ui_widgets.widget_id_generator());
|
|
||||||
//}
|
|
||||||
|
|
||||||
//let num = self.ids.inv_slot.len();
|
|
||||||
//println!("self.ids.inv_slot.len(): {:?}", num);
|
|
||||||
//if num > 0 {
|
|
||||||
//Button::image(self.imgs.inv_slot)
|
|
||||||
//.top_left_with_margins_on(self.ids.inv_grid, 5.0, 5.0)
|
|
||||||
//.w_h(40.0, 40.0)
|
|
||||||
//.set(self.ids.inv_slot[0], ui_widgets);
|
|
||||||
//}
|
|
||||||
//for i in 1..5 {
|
|
||||||
//Button::image(self.imgs.inv_slot)
|
|
||||||
//.right(10.0)
|
|
||||||
//.label(&format!("{}", i + 1))
|
|
||||||
//.label_color(TEXT_COLOR)
|
|
||||||
//.label_font_size(5)
|
|
||||||
//.set(self.ids.inv_slot[i], ui_widgets);}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skillbar Module
|
||||||
|
|
||||||
|
// Experience-Bar
|
||||||
|
Image::new(self.imgs.xp_bar)
|
||||||
|
.w_h(2688.0 / 6.0, 116.0 / 6.0)
|
||||||
|
.mid_bottom_of(ui_widgets.window)
|
||||||
|
.set(self.ids.xp_bar, ui_widgets);
|
||||||
|
|
||||||
|
Rectangle::fill_with([406.0 * (self.xp_percentage), 5.0], XP_COLOR) // "W=406*[Exp. %]"
|
||||||
|
.top_left_with_margins_on(self.ids.xp_bar, 5.0, 21.0)
|
||||||
|
.set(self.ids.xp_bar_progress, ui_widgets);
|
||||||
|
|
||||||
|
// Left Grid
|
||||||
|
Image::new(self.imgs.sb_grid)
|
||||||
|
.w_h(2240.0 / 12.0, 448.0 / 12.0)
|
||||||
|
.up_from(self.ids.xp_bar, 0.0)
|
||||||
|
.align_left_of(self.ids.xp_bar)
|
||||||
|
.set(self.ids.sb_grid_l, ui_widgets);
|
||||||
|
|
||||||
|
Image::new(self.imgs.sb_grid_bg)
|
||||||
|
.w_h(2240.0 / 12.0, 448.0 / 12.0)
|
||||||
|
.middle_of(self.ids.sb_grid_l)
|
||||||
|
.set(self.ids.sb_grid_bg_l, ui_widgets);
|
||||||
|
|
||||||
|
// Right Grid
|
||||||
|
Image::new(self.imgs.sb_grid)
|
||||||
|
.w_h(2240.0 / 12.0, 448.0 / 12.0)
|
||||||
|
.up_from(self.ids.xp_bar, 0.0)
|
||||||
|
.align_right_of(self.ids.xp_bar)
|
||||||
|
.set(self.ids.sb_grid_r, ui_widgets);
|
||||||
|
|
||||||
|
Image::new(self.imgs.sb_grid_bg)
|
||||||
|
.w_h(2240.0 / 12.0, 448.0 / 12.0)
|
||||||
|
.middle_of(self.ids.sb_grid_r)
|
||||||
|
.set(self.ids.sb_grid_bg_r, ui_widgets);
|
||||||
|
|
||||||
|
// Right and Left Click
|
||||||
|
Image::new(self.imgs.l_click)
|
||||||
|
.w_h(224.0 / 6.0, 320.0 / 6.0)
|
||||||
|
.right_from(self.ids.sb_grid_bg_l, 0.0)
|
||||||
|
.align_bottom_of(self.ids.sb_grid_bg_l)
|
||||||
|
.set(self.ids.l_click, ui_widgets);
|
||||||
|
|
||||||
|
Image::new(self.imgs.r_click)
|
||||||
|
.w_h(224.0 / 6.0, 320.0 / 6.0)
|
||||||
|
.left_from(self.ids.sb_grid_bg_r, 0.0)
|
||||||
|
.align_bottom_of(self.ids.sb_grid_bg_r)
|
||||||
|
.set(self.ids.r_click, ui_widgets);
|
||||||
|
|
||||||
|
// Health Bar
|
||||||
|
Image::new(self.imgs.health_bar)
|
||||||
|
.w_h(1120.0 / 6.0, 96.0 / 6.0)
|
||||||
|
.left_from(self.ids.l_click, 0.0)
|
||||||
|
.align_top_of(self.ids.l_click)
|
||||||
|
.set(self.ids.health_bar, ui_widgets);
|
||||||
|
|
||||||
|
// Filling
|
||||||
|
Rectangle::fill_with([182.0 * (self.hp_percentage), 6.0], HP_COLOR) // "W=182.0 * [Health. %]"
|
||||||
|
.top_right_with_margins_on(self.ids.health_bar, 5.0, 0.0)
|
||||||
|
.set(self.ids.health_bar_color, ui_widgets);
|
||||||
|
|
||||||
|
// Mana Bar
|
||||||
|
Image::new(self.imgs.mana_bar)
|
||||||
|
.w_h(1120.0 / 6.0, 96.0 / 6.0)
|
||||||
|
.right_from(self.ids.r_click, 0.0)
|
||||||
|
.align_top_of(self.ids.r_click)
|
||||||
|
.set(self.ids.mana_bar, ui_widgets);
|
||||||
|
|
||||||
|
// Filling
|
||||||
|
Rectangle::fill_with([182.0 * (self.mana_percentage), 6.0], MANA_COLOR) // "W=182.0 * [Mana. %]"
|
||||||
|
.top_left_with_margins_on(self.ids.mana_bar, 5.0, 0.0)
|
||||||
|
.set(self.ids.mana_bar_color, ui_widgets);
|
||||||
|
|
||||||
|
// Buffs/Debuffs
|
||||||
|
|
||||||
|
// Buffs
|
||||||
|
|
||||||
|
// Debuffs
|
||||||
|
|
||||||
|
// Level Display
|
||||||
|
|
||||||
|
// Insert actual Level here
|
||||||
|
Text::new("1")
|
||||||
|
.left_from(self.ids.xp_bar, -15.0)
|
||||||
|
.font_size(10)
|
||||||
|
.color(TEXT_COLOR)
|
||||||
|
.set(self.ids.level_text, ui_widgets);
|
||||||
|
|
||||||
|
// Insert next Level here
|
||||||
|
Text::new("2")
|
||||||
|
.right_from(self.ids.xp_bar, -15.0)
|
||||||
|
.font_size(10)
|
||||||
|
.color(TEXT_COLOR)
|
||||||
|
.set(self.ids.next_level_text, ui_widgets);
|
||||||
|
|
||||||
|
// Bag contents
|
||||||
|
if self.bag_open {
|
||||||
|
// Contents
|
||||||
|
Image::new(self.imgs.bag_contents)
|
||||||
|
.w_h(307.0, 545.0)
|
||||||
|
.bottom_right_with_margins_on(ui_widgets.window, 90.0, 5.0)
|
||||||
|
.set(self.ids.bag_contents, ui_widgets);
|
||||||
|
|
||||||
|
// Alignment for Grid
|
||||||
|
Rectangle::fill_with([246.0, 465.0], color::TRANSPARENT)
|
||||||
|
.top_left_with_margins_on(self.ids.bag_contents, 27.0, 23.0)
|
||||||
|
.scroll_kids()
|
||||||
|
.scroll_kids_vertically()
|
||||||
|
.set(self.ids.inv_alignment, ui_widgets);
|
||||||
|
// Grid
|
||||||
|
Image::new(self.imgs.inv_grid)
|
||||||
|
.w_h(232.0, 1104.0)
|
||||||
|
.mid_top_with_margin_on(self.ids.inv_alignment, 0.0)
|
||||||
|
.set(self.ids.inv_grid, ui_widgets);
|
||||||
|
Scrollbar::y_axis(self.ids.inv_alignment)
|
||||||
|
.thickness(5.0)
|
||||||
|
.rgba(0.86, 0.86, 0.86, 0.1)
|
||||||
|
.set(self.ids.inv_scrollbar, ui_widgets);
|
||||||
|
|
||||||
|
// X-button
|
||||||
|
if Button::image(self.imgs.close_button)
|
||||||
|
.w_h(244.0 * 0.22 / 3.0, 244.0 * 0.22 / 3.0)
|
||||||
|
.hover_image(self.imgs.close_button_hover)
|
||||||
|
.press_image(self.imgs.close_button_press)
|
||||||
|
.top_right_with_margins_on(self.ids.bag_contents, 5.0, 17.0)
|
||||||
|
.set(self.ids.bag_close, ui_widgets)
|
||||||
|
.was_clicked()
|
||||||
|
{
|
||||||
|
self.bag_open = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.inventory_space > 0 {
|
||||||
|
// First Slot
|
||||||
|
Button::image(self.imgs.inv_slot)
|
||||||
|
.top_left_with_margins_on(self.ids.inv_grid, 5.0, 5.0)
|
||||||
|
.w_h(40.0, 40.0)
|
||||||
|
.set(self.ids.inv_slot_0, ui_widgets);
|
||||||
|
}
|
||||||
|
// if self.ids.inv_slot.len() < self.inventory_space {
|
||||||
|
// self.ids.inv_slot.resize(self.inventory_space, &mut ui_widgets.widget_id_generator());
|
||||||
|
//}
|
||||||
|
|
||||||
|
//let num = self.ids.inv_slot.len();
|
||||||
|
//println!("self.ids.inv_slot.len(): {:?}", num);
|
||||||
|
//if num > 0 {
|
||||||
|
//Button::image(self.imgs.inv_slot)
|
||||||
|
//.top_left_with_margins_on(self.ids.inv_grid, 5.0, 5.0)
|
||||||
|
//.w_h(40.0, 40.0)
|
||||||
|
//.set(self.ids.inv_slot[0], ui_widgets);
|
||||||
|
//}
|
||||||
|
//for i in 1..5 {
|
||||||
|
//Button::image(self.imgs.inv_slot)
|
||||||
|
//.right(10.0)
|
||||||
|
//.label(&format!("{}", i + 1))
|
||||||
|
//.label_color(TEXT_COLOR)
|
||||||
|
//.label_font_size(5)
|
||||||
|
//.set(self.ids.inv_slot[i], ui_widgets);}
|
||||||
|
}
|
||||||
|
|
||||||
// Bag
|
// Bag
|
||||||
if !self.map_open {
|
if !self.map_open {
|
||||||
self.bag_open = ToggleButton::new(self.bag_open, self.imgs.bag, self.imgs.bag_open)
|
self.bag_open = ToggleButton::new(self.bag_open, self.imgs.bag, self.imgs.bag_open)
|
||||||
@ -1538,13 +1542,18 @@ impl Hud {
|
|||||||
pub fn handle_event(&mut self, event: WinEvent) -> bool {
|
pub fn handle_event(&mut self, event: WinEvent) -> bool {
|
||||||
match event {
|
match event {
|
||||||
WinEvent::Ui(event) => {
|
WinEvent::Ui(event) => {
|
||||||
if (self.typing() && event.is_keyboard())
|
if (self.typing() && event.is_keyboard() && self.show_ui)
|
||||||
|| !(self.cursor_grabbed && event.is_keyboard_or_mouse())
|
|| !(self.cursor_grabbed && event.is_keyboard_or_mouse())
|
||||||
{
|
{
|
||||||
self.ui.handle_event(event);
|
self.ui.handle_event(event);
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
WinEvent::KeyDown(Key::ToggleInterface) => {
|
||||||
|
self.toggle_ui();
|
||||||
|
true
|
||||||
|
}
|
||||||
|
_ if !self.show_ui => false,
|
||||||
WinEvent::Zoom(_) => !self.cursor_grabbed && !self.ui.no_widget_capturing_mouse(),
|
WinEvent::Zoom(_) => !self.cursor_grabbed && !self.ui.no_widget_capturing_mouse(),
|
||||||
WinEvent::KeyDown(Key::Enter) => {
|
WinEvent::KeyDown(Key::Enter) => {
|
||||||
self.ui.focus_widget(if self.typing() {
|
self.ui.focus_widget(if self.typing() {
|
||||||
@ -1596,10 +1605,6 @@ impl Hud {
|
|||||||
self.toggle_help();
|
self.toggle_help();
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
Key::Interface => {
|
|
||||||
self.toggle_ui();
|
|
||||||
true
|
|
||||||
}
|
|
||||||
_ => false,
|
_ => false,
|
||||||
},
|
},
|
||||||
WinEvent::KeyDown(key) | WinEvent::KeyUp(key) => match key {
|
WinEvent::KeyDown(key) | WinEvent::KeyUp(key) => match key {
|
||||||
|
@ -34,7 +34,7 @@ pub struct ControlSettings {
|
|||||||
pub spellbook: VirtualKeyCode,
|
pub spellbook: VirtualKeyCode,
|
||||||
pub settings: VirtualKeyCode,
|
pub settings: VirtualKeyCode,
|
||||||
pub help: VirtualKeyCode,
|
pub help: VirtualKeyCode,
|
||||||
pub interface: VirtualKeyCode,
|
pub toggle_interface: VirtualKeyCode,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Settings {
|
impl Default for Settings {
|
||||||
@ -56,7 +56,7 @@ impl Default for Settings {
|
|||||||
spellbook: VirtualKeyCode::P,
|
spellbook: VirtualKeyCode::P,
|
||||||
settings: VirtualKeyCode::N,
|
settings: VirtualKeyCode::N,
|
||||||
help: VirtualKeyCode::F1,
|
help: VirtualKeyCode::F1,
|
||||||
interface: VirtualKeyCode::F2,
|
toggle_interface: VirtualKeyCode::F2,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ impl Window {
|
|||||||
key_map.insert(settings.controls.spellbook, Key::Spellbook);
|
key_map.insert(settings.controls.spellbook, Key::Spellbook);
|
||||||
key_map.insert(settings.controls.settings, Key::Settings);
|
key_map.insert(settings.controls.settings, Key::Settings);
|
||||||
key_map.insert(settings.controls.help, Key::Help);
|
key_map.insert(settings.controls.help, Key::Help);
|
||||||
key_map.insert(settings.controls.interface, Key::Interface);
|
key_map.insert(settings.controls.toggle_interface, Key::ToggleInterface);
|
||||||
|
|
||||||
let tmp = Ok(Self {
|
let tmp = Ok(Self {
|
||||||
events_loop,
|
events_loop,
|
||||||
@ -180,7 +180,7 @@ pub enum Key {
|
|||||||
Social,
|
Social,
|
||||||
Spellbook,
|
Spellbook,
|
||||||
Settings,
|
Settings,
|
||||||
Interface,
|
ToggleInterface,
|
||||||
Help,
|
Help,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user