From 1d671239f31f6895ce709194645d0213726359b9 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 3 Jul 2024 14:46:27 -0400 Subject: [PATCH] v2.5.0: slightly adjusted spacing for item slots and item buttons --- .../shatteredpixeldungeon/ui/ItemButton.java | 7 ++++++- .../shatteredpixeldungeon/ui/ItemSlot.java | 10 ++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ItemButton.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ItemButton.java index 8c0fa0299..24b3fa7b1 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ItemButton.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ItemButton.java @@ -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(){ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ItemSlot.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ItemSlot.java index 076b9d4c5..bbbf5adfd 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ItemSlot.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ItemSlot.java @@ -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); }