From 42f9c22d1ac3d9fc68db3245c436ecfb5677e154 Mon Sep 17 00:00:00 2001 From: nea Date: Wed, 4 May 2022 02:34:18 +0200 Subject: [PATCH] Prevent double clicks on two different rewards from activating double clicks --- .../thatgravyboat/rewardclaim/ui/RewardClaimGui.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/tech/thatgravyboat/rewardclaim/ui/RewardClaimGui.kt b/src/main/kotlin/tech/thatgravyboat/rewardclaim/ui/RewardClaimGui.kt index 1950acb..88ad1b7 100644 --- a/src/main/kotlin/tech/thatgravyboat/rewardclaim/ui/RewardClaimGui.kt +++ b/src/main/kotlin/tech/thatgravyboat/rewardclaim/ui/RewardClaimGui.kt @@ -133,16 +133,16 @@ class RewardClaimGui(private val id: String) : WindowScreen() { private val rewards = Array(3) { i -> UIReward(57.5.percent(), 30.percent() + (18 * i).percent()) childOf background }.also { - for (reward in it) { + for ((i,reward) in it.withIndex()) { reward.onMouseClick { event -> if (event.mouseButton == 0 && state == State.SUCCESSFUL) { - for (j in 0..2) { - it[j].setSelected(it[j] == reward) - if (it[j] != event.currentTarget) continue - selected = j - selectedReward.updateInfo(data.rewards[selected], data.language) + val wasSelected = i == selected + selected = i + it.forEach { rew -> + rew.setSelected(rew == reward) } - if (event.clickCount >= 2) { + selectedReward.updateInfo(data.rewards[selected], data.language) + if (event.clickCount >= 2 && wasSelected) { if (Config.showDoubleClickConfirmation) confirmPopup() else claimReward() }