package ru.dbotthepony.mc.otm.menu.input

import ru.dbotthepony.mc.otm.core.GetterSetter
import ru.dbotthepony.mc.otm.menu.MatteryMenu
import java.util.function.BooleanSupplier
import kotlin.reflect.KMutableProperty0

class BooleanInputWithFeedback(menu: MatteryMenu) : AbstractPlayerInputWithFeedback<Boolean>() {
	override val input = menu.booleanInput { consumer?.invoke(it) }
	override val value by menu.mSynchronizer.computedBool(BooleanSupplier { supplier?.invoke() ?: false }).property

	constructor(menu: MatteryMenu, state: KMutableProperty0<Boolean>) : this(menu) {
		with(state)
	}

	constructor(menu: MatteryMenu, state: GetterSetter<Boolean>) : this(menu) {
		with(state)
	}

	fun switchValue() {
		accept(!value)
	}
}
