OpenEnroth 631fe01
Loading...
Searching...
No Matches
Functions
ItemGrid.cpp File Reference
#include "ItemGrid.h"
#include <cassert>

Functions

static int roundIntDown (int a, int b)
 
static int divIntDown (int a, int b)
 
int itemOffset (int dimension)
 Calculate offsets for placing items in inventory grid. More...
 
Pointi mapToInventoryGrid (Pointi mousePos, Pointi inventoryTopLeft)
 

Function Documentation

◆ divIntDown()

static int divIntDown ( int  a,
int  b 
)
static

◆ itemOffset()

int itemOffset ( int  dimension)

Calculate offsets for placing items in inventory grid.

Inventory grid have 32x32 pixels cells. Items don't exactly fit into the grid, but are slightly smaller or larger. The function calculates offsets for the item to be centered. Calculations are the same for height and width.

Parameters
dimensionWidth or height of the item.
Returns
Offset in pixels.

◆ mapToInventoryGrid()

Pointi mapToInventoryGrid ( Pointi  mousePos,
Pointi  inventoryTopLeft 
)
Parameters
mousePosMouse position.
inventoryTopLeftTop left position of the inventory grid.
Returns
Inventory grid position, in grid coordinates. Might be out of grid if the mouse position is out of grid.

◆ roundIntDown()

static int roundIntDown ( int  a,
int  b 
)
static