mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-03-14 02:16:10 +00:00
Refactor menu for ui2d updates; shadow & outline text (#468)
* Refactored menu to use new helpers, updated references to TexBox members to remove m_ * Updated menu opts to have text fx & centered text
This commit is contained in:
parent
d5c0d636a0
commit
fc742bc242
1 changed files with 35 additions and 23 deletions
|
@ -286,9 +286,15 @@ pub unsafe fn draw(root_pane: &mut Pane) {
|
|||
}
|
||||
bg_left_material.set_white_res_color(BG_LEFT_ON_WHITE_COLOR);
|
||||
bg_left_material.set_black_res_color(BG_LEFT_ON_BLACK_COLOR);
|
||||
text.text_shadow_enable(true);
|
||||
text.text_outline_enable(true);
|
||||
text.set_color(255, 255, 255, 255);
|
||||
} else {
|
||||
bg_left_material.set_white_res_color(BG_LEFT_OFF_WHITE_COLOR);
|
||||
bg_left_material.set_black_res_color(BG_LEFT_OFF_BLACK_COLOR);
|
||||
text.text_shadow_enable(false);
|
||||
text.text_outline_enable(false);
|
||||
text.set_color(85, 89, 92, 255);
|
||||
}
|
||||
|
||||
bg_left.set_visible(true);
|
||||
|
@ -309,6 +315,17 @@ pub unsafe fn draw(root_pane: &mut Pane) {
|
|||
{
|
||||
let text = text.as_textbox();
|
||||
text.set_text_string(name);
|
||||
|
||||
if is_selected {
|
||||
text.text_shadow_enable(true);
|
||||
text.text_outline_enable(true);
|
||||
text.set_color(255, 255, 255, 255);
|
||||
} else {
|
||||
text.text_shadow_enable(false);
|
||||
text.text_outline_enable(false);
|
||||
text.set_color(85, 89, 92, 255);
|
||||
}
|
||||
|
||||
text.set_visible(true);
|
||||
}
|
||||
|
||||
|
@ -371,13 +388,13 @@ pub unsafe fn draw(root_pane: &mut Pane) {
|
|||
|
||||
match gauge_vals.state {
|
||||
GaugeState::MinHover | GaugeState::MinSelected => {
|
||||
text_pane.m_bits |= 1 << TextBoxFlag::ShadowEnabled as u8;
|
||||
text_pane.m_bits = text_pane.m_bits & !(1 << TextBoxFlag::InvisibleBorderEnabled as u8);
|
||||
text_pane.text_shadow_enable(true);
|
||||
text_pane.text_outline_enable(true);
|
||||
text_pane.set_color(255, 255, 255, 255);
|
||||
}
|
||||
_ => {
|
||||
text_pane.m_bits = text_pane.m_bits & !(1 << TextBoxFlag::ShadowEnabled as u8);
|
||||
text_pane.m_bits |= 1 << TextBoxFlag::InvisibleBorderEnabled as u8;
|
||||
text_pane.text_shadow_enable(false);
|
||||
text_pane.text_outline_enable(false);
|
||||
text_pane.set_color(85, 89, 92, 255);
|
||||
}
|
||||
}
|
||||
|
@ -387,13 +404,13 @@ pub unsafe fn draw(root_pane: &mut Pane) {
|
|||
|
||||
match gauge_vals.state {
|
||||
GaugeState::MaxHover | GaugeState::MaxSelected => {
|
||||
text_pane.m_bits |= 1 << TextBoxFlag::ShadowEnabled as u8;
|
||||
text_pane.m_bits = text_pane.m_bits & !(1 << TextBoxFlag::InvisibleBorderEnabled as u8);
|
||||
text_pane.text_shadow_enable(true);
|
||||
text_pane.text_outline_enable(true);
|
||||
text_pane.set_color(255, 255, 255, 255);
|
||||
}
|
||||
_ => {
|
||||
text_pane.m_bits |= 1 << TextBoxFlag::InvisibleBorderEnabled as u8;
|
||||
text_pane.m_bits = text_pane.m_bits & !(1 << TextBoxFlag::ShadowEnabled as u8);
|
||||
text_pane.text_shadow_enable(false);
|
||||
text_pane.text_outline_enable(false);
|
||||
text_pane.set_color(85, 89, 92, 255);
|
||||
}
|
||||
}
|
||||
|
@ -591,23 +608,23 @@ pub static BUILD_TAB_TXTS: ui::PaneCreationCallback = |_, root_pane, original_bu
|
|||
));
|
||||
let help_pane = build!(help_block, ResTextBox, kind, TextBox);
|
||||
help_pane.set_text_string("abcd");
|
||||
let it = help_pane.m_text_buf as *mut u16;
|
||||
let it = help_pane.text_buf as *mut u16;
|
||||
match txt_idx {
|
||||
// Left Tab: ZL
|
||||
0 => {
|
||||
*it = 0xE0E6;
|
||||
*(it.add(1)) = 0x0;
|
||||
help_pane.m_text_len = 1;
|
||||
help_pane.text_len = 1;
|
||||
}
|
||||
1 => {
|
||||
*it = 0x0;
|
||||
help_pane.m_text_len = 0;
|
||||
help_pane.text_len = 0;
|
||||
}
|
||||
// Right Tab: ZR
|
||||
2 => {
|
||||
*it = 0xE0E7;
|
||||
*(it.add(1)) = 0x0;
|
||||
help_pane.m_text_len = 1;
|
||||
help_pane.text_len = 1;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -637,7 +654,6 @@ pub static BUILD_OPT_TXTS: ui::PaneCreationCallback = |_, root_pane, original_bu
|
|||
|
||||
let block = block as *mut ResTextBox;
|
||||
let mut text_block = *block;
|
||||
text_block.enable_shadow();
|
||||
text_block.text_alignment(TextAlignment::Center);
|
||||
|
||||
text_block.set_name(menu_text_name_fmt!(x, y));
|
||||
|
@ -653,7 +669,9 @@ pub static BUILD_OPT_TXTS: ui::PaneCreationCallback = |_, root_pane, original_bu
|
|||
text_pane.set_text_string(format!("Opt {txt_idx}!").as_str());
|
||||
// Ensure Material Colors are not hardcoded so we can just use SetTextColor.
|
||||
text_pane.set_default_material_colors();
|
||||
text_pane.set_color(255, 255, 255, 255);
|
||||
text_pane.set_color(85, 89, 92, 255);
|
||||
text_pane.set_text_shadow(ResVec2::new(4.0, -3.0), ResVec2::new(1.0, 1.0), [BLACK, BLACK], 0.0);
|
||||
text_pane.set_text_alignment(HorizontalPosition::Center, VerticalPosition::Center);
|
||||
text_pane.detach();
|
||||
menu_pane.append_child(text_pane);
|
||||
|
||||
|
@ -814,21 +832,15 @@ pub static BUILD_SLIDER_TXTS: ui::PaneCreationCallback = |_, root_pane, original
|
|||
));
|
||||
label_block.font_size = ResVec2::new(25.0, 50.0);
|
||||
|
||||
// Aligns text to the center horizontally
|
||||
label_block.text_position = 4;
|
||||
|
||||
label_block.shadow_offset = ResVec2::new(4.0, -3.0);
|
||||
label_block.shadow_cols = [BLACK, BLACK];
|
||||
label_block.shadow_scale = ResVec2::new(1.0, 1.0);
|
||||
|
||||
let label_pane = build!(label_block, ResTextBox, kind, TextBox);
|
||||
|
||||
label_pane.set_text_string(format!("Slider opt {idx}!").as_str());
|
||||
// Ensure Material Colors are not hardcoded so we can just use SetTextColor.
|
||||
label_pane.set_default_material_colors();
|
||||
label_pane.set_color(85, 89, 92, 255);
|
||||
// Turns on text outline
|
||||
label_pane.m_bits = label_pane.m_bits & !(1 << TextBoxFlag::InvisibleBorderEnabled as u8);
|
||||
label_pane.text_outline_enable(true);
|
||||
label_pane.set_text_shadow(ResVec2::new(4.0, -3.0), ResVec2::new(1.0, 1.0), [BLACK, BLACK], 0.0);
|
||||
label_pane.set_text_alignment(HorizontalPosition::Left, VerticalPosition::Top);
|
||||
label_pane.detach();
|
||||
|
||||
slider_root_pane.append_child(label_pane);
|
||||
|
|
Loading…
Add table
Reference in a new issue