aboutsummaryrefslogtreecommitdiff
path: root/src/gui/guiInventoryList.cpp
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2020-11-04 16:19:54 +0100
committerElias Fleckenstein <eliasfleckenstein@web.de>2020-11-04 16:19:54 +0100
commitad148587dcf5244c2d2011dba339786c765c54c4 (patch)
treebdd914121cd326da2ed26679838878e3edffc841 /src/gui/guiInventoryList.cpp
parent1145b05ea0bda87dc0827821385810eced08f774 (diff)
downloaddragonfireclient-ad148587dcf5244c2d2011dba339786c765c54c4.tar.xz
Make Lint Happy
Diffstat (limited to 'src/gui/guiInventoryList.cpp')
-rw-r--r--src/gui/guiInventoryList.cpp108
1 files changed, 50 insertions, 58 deletions
diff --git a/src/gui/guiInventoryList.cpp b/src/gui/guiInventoryList.cpp
index 58d7ae771..a0fef4073 100644
--- a/src/gui/guiInventoryList.cpp
+++ b/src/gui/guiInventoryList.cpp
@@ -19,33 +19,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/hud.h"
#include "client/client.h"
-GUIInventoryList::GUIInventoryList(gui::IGUIEnvironment *env,
- gui::IGUIElement *parent,
- s32 id,
- const core::rect<s32> &rectangle,
- InventoryManager *invmgr,
- const InventoryLocation &inventoryloc,
- const std::string &listname,
- const v2s32 &geom,
- const s32 start_item_i,
- const v2s32 &slot_size,
- const v2f32 &slot_spacing,
- GUIFormSpecMenu *fs_menu,
- const Options &options,
- gui::IGUIFont *font) :
- gui::IGUIElement(gui::EGUIET_ELEMENT, env, parent, id, rectangle),
- m_invmgr(invmgr),
- m_inventoryloc(inventoryloc),
- m_listname(listname),
- m_geom(geom),
- m_start_item_i(start_item_i),
- m_slot_size(slot_size),
- m_slot_spacing(slot_spacing),
- m_fs_menu(fs_menu),
- m_options(options),
- m_font(font),
- m_hovered_i(-1),
- m_already_warned(false)
+GUIInventoryList::GUIInventoryList(gui::IGUIEnvironment *env, gui::IGUIElement *parent,
+ s32 id, const core::rect<s32> &rectangle, InventoryManager *invmgr,
+ const InventoryLocation &inventoryloc, const std::string &listname,
+ const v2s32 &geom, const s32 start_item_i, const v2s32 &slot_size,
+ const v2f32 &slot_spacing, GUIFormSpecMenu *fs_menu,
+ const Options &options, gui::IGUIFont *font) :
+ gui::IGUIElement(gui::EGUIET_ELEMENT, env, parent, id, rectangle),
+ m_invmgr(invmgr), m_inventoryloc(inventoryloc), m_listname(listname),
+ m_geom(geom), m_start_item_i(start_item_i), m_slot_size(slot_size),
+ m_slot_spacing(slot_spacing), m_fs_menu(fs_menu), m_options(options),
+ m_font(font), m_hovered_i(-1), m_already_warned(false)
{
}
@@ -58,9 +42,9 @@ void GUIInventoryList::draw()
if (!inv) {
if (!m_already_warned) {
warningstream << "GUIInventoryList::draw(): "
- << "The inventory location "
- << "\"" << m_inventoryloc.dump() << "\" doesn't exist"
- << std::endl;
+ << "The inventory location "
+ << "\"" << m_inventoryloc.dump()
+ << "\" doesn't exist" << std::endl;
m_already_warned = true;
}
return;
@@ -69,9 +53,9 @@ void GUIInventoryList::draw()
if (!ilist) {
if (!m_already_warned) {
warningstream << "GUIInventoryList::draw(): "
- << "The inventory list \"" << m_listname << "\" @ \""
- << m_inventoryloc.dump() << "\" doesn't exist"
- << std::endl;
+ << "The inventory list \"" << m_listname
+ << "\" @ \"" << m_inventoryloc.dump()
+ << "\" doesn't exist" << std::endl;
m_already_warned = true;
}
return;
@@ -97,21 +81,25 @@ void GUIInventoryList::draw()
core::rect<s32> rect = imgrect + base_pos + p;
ItemStack item = ilist->getItem(item_i);
- bool selected = selected_item
- && m_invmgr->getInventory(selected_item->inventoryloc) == inv
- && selected_item->listname == m_listname
- && selected_item->i == item_i;
+ bool selected = selected_item &&
+ m_invmgr->getInventory(selected_item->inventoryloc) ==
+ inv &&
+ selected_item->listname == m_listname &&
+ selected_item->i == item_i;
core::rect<s32> clipped_rect(rect);
clipped_rect.clipAgainst(AbsoluteClippingRect);
bool hovering = m_hovered_i == item_i;
- ItemRotationKind rotation_kind = selected ? IT_ROT_SELECTED :
- (hovering ? IT_ROT_HOVERED : IT_ROT_NONE);
+ ItemRotationKind rotation_kind =
+ selected ? IT_ROT_SELECTED
+ : (hovering ? IT_ROT_HOVERED : IT_ROT_NONE);
// layer 0
if (hovering) {
- driver->draw2DRectangle(m_options.slotbg_h, rect, &AbsoluteClippingRect);
+ driver->draw2DRectangle(
+ m_options.slotbg_h, rect, &AbsoluteClippingRect);
} else {
- driver->draw2DRectangle(m_options.slotbg_n, rect, &AbsoluteClippingRect);
+ driver->draw2DRectangle(
+ m_options.slotbg_n, rect, &AbsoluteClippingRect);
}
// Draw inv slot borders
@@ -121,21 +109,27 @@ void GUIInventoryList::draw()
s32 x2 = rect.LowerRightCorner.X;
s32 y2 = rect.LowerRightCorner.Y;
s32 border = 1;
- core::rect<s32> clipping_rect = Parent ? Parent->getAbsoluteClippingRect()
- : core::rect<s32>();
- core::rect<s32> *clipping_rect_ptr = Parent ? &clipping_rect : nullptr;
+ core::rect<s32> clipping_rect =
+ Parent ? Parent->getAbsoluteClippingRect()
+ : core::rect<s32>();
+ core::rect<s32> *clipping_rect_ptr =
+ Parent ? &clipping_rect : nullptr;
driver->draw2DRectangle(m_options.slotbordercolor,
- core::rect<s32>(v2s32(x1 - border, y1 - border),
- v2s32(x2 + border, y1)), clipping_rect_ptr);
+ core::rect<s32>(v2s32(x1 - border, y1 - border),
+ v2s32(x2 + border, y1)),
+ clipping_rect_ptr);
driver->draw2DRectangle(m_options.slotbordercolor,
- core::rect<s32>(v2s32(x1 - border, y2),
- v2s32(x2 + border, y2 + border)), clipping_rect_ptr);
+ core::rect<s32>(v2s32(x1 - border, y2),
+ v2s32(x2 + border, y2 + border)),
+ clipping_rect_ptr);
driver->draw2DRectangle(m_options.slotbordercolor,
- core::rect<s32>(v2s32(x1 - border, y1),
- v2s32(x1, y2)), clipping_rect_ptr);
+ core::rect<s32>(v2s32(x1 - border, y1),
+ v2s32(x1, y2)),
+ clipping_rect_ptr);
driver->draw2DRectangle(m_options.slotbordercolor,
- core::rect<s32>(v2s32(x2, y1),
- v2s32(x2 + border, y2)), clipping_rect_ptr);
+ core::rect<s32>(v2s32(x2, y1),
+ v2s32(x2 + border, y2)),
+ clipping_rect_ptr);
}
// layer 1
@@ -179,8 +173,7 @@ bool GUIInventoryList::OnEvent(const SEvent &event)
// find the element that would be hovered if this inventorylist was invisible
bool was_visible = IsVisible;
IsVisible = false;
- IGUIElement *hovered =
- Environment->getRootGUIElement()->getElementFromPoint(
+ IGUIElement *hovered = Environment->getRootGUIElement()->getElementFromPoint(
core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y));
// if the player clicks outside of the formspec window, hovered is not
@@ -216,11 +209,10 @@ s32 GUIInventoryList::getItemIndexAtPos(v2s32 p) const
v2s32 base_pos = AbsoluteRect.UpperLeftCorner;
// instead of looping through each slot, we look where p would be in the grid
- s32 i = (p.X - base_pos.X) / (s32)m_slot_spacing.X
- + m_geom.X * ((p.Y - base_pos.Y) / (s32)m_slot_spacing.Y);
+ s32 i = (p.X - base_pos.X) / (s32)m_slot_spacing.X +
+ m_geom.X * ((p.Y - base_pos.Y) / (s32)m_slot_spacing.Y);
- v2s32 p0((i % m_geom.X) * m_slot_spacing.X,
- (i / m_geom.X) * m_slot_spacing.Y);
+ v2s32 p0((i % m_geom.X) * m_slot_spacing.X, (i / m_geom.X) * m_slot_spacing.Y);
core::rect<s32> rect = imgrect + base_pos + p0;