summaryrefslogtreecommitdiff
path: root/src/main/kotlin/tech/thatgravyboat
diff options
context:
space:
mode:
authornea <romangraef@gmail.com>2022-05-04 02:34:18 +0200
committernea <romangraef@gmail.com>2022-05-04 02:34:18 +0200
commit42f9c22d1ac3d9fc68db3245c436ecfb5677e154 (patch)
tree435d0a62f3e99c1721e7f44ba16a618fd619431f /src/main/kotlin/tech/thatgravyboat
parenta5f48eef1cae67b34866ee76718062a5df535e92 (diff)
downloadRewardClaim-master.tar.gz
RewardClaim-master.tar.bz2
RewardClaim-master.zip
Prevent double clicks on two different rewards from activating double clicksHEADmaster
Diffstat (limited to 'src/main/kotlin/tech/thatgravyboat')
-rw-r--r--src/main/kotlin/tech/thatgravyboat/rewardclaim/ui/RewardClaimGui.kt14
1 files 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()
}