Skip to content

Conversation

@Lulonaut
Copy link
Contributor

@Lulonaut Lulonaut commented Mar 7, 2024

closes #934
closes #935

@Lulonaut Lulonaut marked this pull request as ready for review March 10, 2024 08:42
Copy link
Collaborator

@jani270 jani270 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some style things, also might wanna move the buttons more into the middle and down?

Copy link
Member

@lineargraph lineargraph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works nicely. Feel free to merge.

object KotlinRenderUtils {

@JvmStatic
fun renderItemStackButton(button: Rectangle, item: ItemStack, texture: ResourceLocation) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like taking in a Rectangle here is a bit misleading, since the actual dimensions of the rectangle are entirely ignored (not used for the texture or centering the itemstack.

Comment on lines +422 to +428
if (priceSourceButtonRect.contains(mouseX, mouseY)) {
currentPriceSource = PriceSource.values()[(currentPriceSource.ordinal + 1) % PriceSource.values().size]
Utils.playPressSound()
getData()
}

if (sortButtonRect.contains(mouseX, mouseY)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point we might as well add a utility like

    inline fun <reified E : Enum<E>> E.nextEnum(): E {
        val values = enumValues<E>()
        return values[(ordinal + 1) % values.size]
    }

Not really needed here tho.

Comment on lines +72 to +73
// Lazy initialisation to allow for guiLeft and guiTop to be initialized first
private val priceSourceButtonRect by lazy { Rectangle(guiLeft + 54, guiTop + 155, 20, 20) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically this breaks if the window gets resized. Then again, we don't have any mechanism for invalidating these rects, so this will be fine.

@lineargraph lineargraph merged commit 1a2c550 into master Mar 12, 2024
@lineargraph lineargraph deleted the sackspagebuttons branch March 12, 2024 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants