mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-17 22:55:38 +00:00
Fix bad tile position when close to the last row and last row is full
This commit is contained in:
parent
4e6dcde5a5
commit
c25eaab7fb
|
@ -221,9 +221,13 @@ void ImageGridComponent<T>::updateImages()
|
||||||
|
|
||||||
int start = (cursorRow - (gridDimension.y() / 2)) * gridDimension.x();
|
int start = (cursorRow - (gridDimension.y() / 2)) * gridDimension.x();
|
||||||
|
|
||||||
//if we're at the end put the row as close as we can and no higher
|
// If we are at the end put the row as close as we can and no higher, using the following formula
|
||||||
|
// Where E is the nb of entries, X the grid x dim (nb of column), Y the grid y dim (nb of line)
|
||||||
|
// start = first tile of last row - nb column * (nb line - 1)
|
||||||
|
// = (E - 1) / X * X - X * (Y - 1)
|
||||||
|
// = X * ((E - 1) / X - Y + 1)
|
||||||
if(start + (gridDimension.x() * gridDimension.y()) >= (int)mEntries.size())
|
if(start + (gridDimension.x() * gridDimension.y()) >= (int)mEntries.size())
|
||||||
start = gridDimension.x() * ((int)mEntries.size()/gridDimension.x() - gridDimension.y() + 1);
|
start = gridDimension.x() * (((int)mEntries.size() - 1) / gridDimension.x() - gridDimension.y() + 1);
|
||||||
|
|
||||||
if(start < 0)
|
if(start < 0)
|
||||||
start = 0;
|
start = 0;
|
||||||
|
|
Loading…
Reference in a new issue