Skip to content

Commit

Permalink
fix layouting
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam- committed Jun 20, 2024
1 parent 0eab5e4 commit 0b5129f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public void addItemAfter(int itemId, int pos)
{
dirty = true;

for (int i = pos; i < layout.length; ++i)
int i;
for (i = pos; i < layout.length; ++i)
{
if (layout[i] == -1)
{
Expand All @@ -105,7 +106,7 @@ public void addItemAfter(int itemId, int pos)
}

resize(Math.max(pos + 1, layout.length + 1));
layout[pos] = itemId;
layout[i] = itemId;
}

public void removeItem(int itemId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,10 @@ public Layout generateLayout(TagTab tab)

int lpos = base + (pos % 3);
int old = l.getItemAtPos(lpos);
if (old != -1) removed.add(old);
if (old != -1) {
log.debug("Moving {}", itemManager.getItemComposition(old).getName());
removed.add(old);
}

Item item = e.getItem(format[pos]);
if (item != null)
Expand Down Expand Up @@ -618,9 +621,23 @@ public Layout generateLayout(TagTab tab)
}
}

// Middle row
for (int j = 0; j < 5; ++j)
{
int idx = j*8 + 3;

int old = l.getItemAtPos(idx);
if (old != -1)
{
removed.add(old);
l.setItemAtPos(-1, idx);
}
}

int pos = 56;
for (int itemId : removed) {
if (l.count(itemId) == 0) {
log.debug("Adding {} at {}", itemManager.getItemComposition(itemId).getName(), pos);
l.addItemAfter(itemId, pos++);
}
}
Expand Down

0 comments on commit 0b5129f

Please sign in to comment.