v2.5.0: slightly adjusted spacing for item slots and item buttons

This commit is contained in:
Evan Debenham
2024-07-03 14:46:27 -04:00
parent b0b2a32a84
commit 1d671239f3
2 changed files with 14 additions and 3 deletions

View File

@@ -81,7 +81,12 @@ public class ItemButton extends Component {
bg.y = y;
bg.size( width, height );
slot.setRect( x + 2, y + 2, width - 4, height - 4 );
slot.setRect(x, y, width, height);
if (width() >= 24 || height >= 24) {
slot.setMargins(2, 2, 2, 2);
} else {
slot.setMargins(1, 1, 1, 1);
}
}
public Item item(){

View File

@@ -153,8 +153,14 @@ public class ItemSlot extends Button {
}
if (itemIcon != null){
itemIcon.x = x + width - (ItemSpriteSheet.Icons.SIZE + itemIcon.width())/2f - margin.right;
itemIcon.y = y + (ItemSpriteSheet.Icons.SIZE - itemIcon.height)/2f + margin.top;
//center the icon slightly if there is enough room
if (width >= 24 || height >= 24) {
itemIcon.x = x + width - (ItemSpriteSheet.Icons.SIZE + itemIcon.width()) / 2f - margin.right;
itemIcon.y = y + (ItemSpriteSheet.Icons.SIZE - itemIcon.height) / 2f + margin.top;
} else {
itemIcon.x = x + width - itemIcon.width() - margin.right;
itemIcon.y = y + margin.top;
}
PixelScene.align(itemIcon);
}