From e9c12d363a45d7cc1581fd882f3701b5388f4a8e Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Thu, 13 Jun 2024 21:34:57 +0200 Subject: Backend: code cleanup in custom wardrobe (#2088) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/inventory/wardrobe/CustomWardrobe.kt | 41 ++++++---------------- 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobe.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobe.kt index a8e334bff..69df1cf56 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobe.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobe.kt @@ -464,18 +464,8 @@ object CustomWardrobe { add( Renderable.clickable( Renderable.hoverable( - Renderable.string( - (if (wardrobeSlot.favorite) "§c" else "§7") + "❤", - scale = textScale, - horizontalAlign = HorizontalAlignment.CENTER, - verticalAlign = VerticalAlignment.CENTER, - ), - Renderable.string( - (if (wardrobeSlot.favorite) "§4" else "§8") + "❤", - scale = textScale, - horizontalAlign = HorizontalAlignment.CENTER, - verticalAlign = VerticalAlignment.CENTER, - ), + centerString((if (wardrobeSlot.favorite) "§c" else "§7") + "❤", scale = textScale), + centerString((if (wardrobeSlot.favorite) "§4" else "§8") + "❤", scale = textScale), ), onClick = { wardrobeSlot.favorite = !wardrobeSlot.favorite @@ -486,12 +476,7 @@ object CustomWardrobe { if (config.estimatedValue && shouldRender) { add( Renderable.hoverTips( - Renderable.string( - "§2$", - scale = textScale, - horizontalAlign = HorizontalAlignment.CENTER, - verticalAlign = VerticalAlignment.CENTER, - ), + centerString("§2$", scale = textScale), WardrobeAPI.createPriceLore(wardrobeSlot), ), ) @@ -518,12 +503,7 @@ object CustomWardrobe { Renderable.placeholder(buttonWidth, buttonHeight), onClick, ), - Renderable.string( - text, - horizontalAlign = HorizontalAlignment.CENTER, - verticalAlign = VerticalAlignment.CENTER, - scale = textScale, - ), + centerString(text, scale = textScale), false, ), hoveredColor, @@ -536,12 +516,7 @@ object CustomWardrobe { Renderable.drawInsideRoundedRect( Renderable.doubleLayered( Renderable.placeholder(buttonWidth, buttonHeight), - Renderable.string( - text, - horizontalAlign = HorizontalAlignment.CENTER, - verticalAlign = VerticalAlignment.CENTER, - scale = textScale, - ), + centerString(text, scale = textScale), ), unhoveredColor.darker(0.57), padding = 0, @@ -638,4 +613,10 @@ object CustomWardrobe { } fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled && WardrobeAPI.inWardrobe() + + fun centerString( + text: String, + scale: Double = 1.0, + color: Color = Color.WHITE, + ) = Renderable.string(text, scale, color, horizontalAlign = HorizontalAlignment.CENTER) } -- cgit