1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-14 09:05:19 +02:00

small drawItemStack cleanup

-> Replace the three bool params with an enum
-> Add struct for the static content, leads to less repetition
-> cache enable_animations setting
This commit is contained in:
est31
2016-02-07 20:27:50 +01:00
parent 6cd2b3b445
commit 16c7008771
3 changed files with 32 additions and 44 deletions

View File

@@ -2196,6 +2196,8 @@ void GUIFormSpecMenu::drawList(const ListDrawSpec &s, int phase,
&& m_selected_item->listname == s.listname
&& m_selected_item->i == item_i;
bool hovering = rect.isPointInside(m_pointer);
ItemRotationKind rotation_kind = selected ? IT_ROT_SELECTED :
(hovering ? IT_ROT_HOVERED : IT_ROT_NONE);
if (phase == 0) {
if (hovering) {
@@ -2238,7 +2240,7 @@ void GUIFormSpecMenu::drawList(const ListDrawSpec &s, int phase,
{
drawItemStack(driver, m_font, item,
rect, &AbsoluteClippingRect, m_gamedef,
selected, hovering, false);
rotation_kind);
}
// Draw tooltip
@@ -2284,7 +2286,7 @@ void GUIFormSpecMenu::drawSelectedItem()
if (!m_selected_item) {
drawItemStack(driver, m_font, ItemStack(),
core::rect<s32>(v2s32(0, 0), v2s32(0, 0)),
NULL, m_gamedef, false, false, true);
NULL, m_gamedef, IT_ROT_DRAGGED);
return;
}
@@ -2297,7 +2299,7 @@ void GUIFormSpecMenu::drawSelectedItem()
core::rect<s32> imgrect(0,0,imgsize.X,imgsize.Y);
core::rect<s32> rect = imgrect + (m_pointer - imgrect.getCenter());
drawItemStack(driver, m_font, stack, rect, NULL, m_gamedef, false, false, true);
drawItemStack(driver, m_font, stack, rect, NULL, m_gamedef, IT_ROT_DRAGGED);
}
void GUIFormSpecMenu::drawMenu()
@@ -2434,7 +2436,7 @@ void GUIFormSpecMenu::drawMenu()
// Viewport rectangle on screen
core::rect<s32> rect = imgrect + spec.pos;
drawItemStack(driver, m_font, item, rect, &AbsoluteClippingRect,
m_gamedef, false, false, false);
m_gamedef, IT_ROT_NONE);
}
/*
@@ -2452,7 +2454,7 @@ void GUIFormSpecMenu::drawMenu()
if (!item_hovered) {
drawItemStack(driver, m_font, ItemStack(),
core::rect<s32>(v2s32(0, 0), v2s32(0, 0)),
NULL, m_gamedef, false, true, false);
NULL, m_gamedef, IT_ROT_HOVERED);
}
/* TODO find way to show tooltips on touchscreen */