Skip to content

Commit

Permalink
Don't apply wait multiplier to support screen refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
reconman committed May 12, 2024
1 parent f1ebfc2 commit d120b58
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ interface AutomataApi {

fun <T> useColor(block: () -> T): T

fun Duration.wait()
/**
* Waits for the specified duration.
*
* @param applyMultiplier whether to apply the wait multiplier or not
*/
fun Duration.wait(applyMultiplier: Boolean = true)

fun Location.click(times: Int = 1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class StandardAutomataApi @Inject constructor(
override fun <T> useColor(block: () -> T): T =
colorManager.useColor(block)

override fun Duration.wait() = wait(this)
override fun Duration.wait(applyMultiplier: Boolean) = wait(this, applyMultiplier)

override fun Location.click(times: Int) = click(this, times)

Expand Down
6 changes: 3 additions & 3 deletions libautomata/src/main/java/io/github/lib_automata/Waiter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import javax.inject.Inject
import kotlin.time.Duration

interface Waiter {
operator fun invoke(duration: Duration)
operator fun invoke(duration: Duration, applyMultiplier: Boolean = true)
}

class RealWaiter @Inject constructor(
private val platformImpl: PlatformImpl,
private val exitManager: ExitManager
): Waiter {
override fun invoke(duration: Duration) {
val multiplier = platformImpl.prefs.waitMultiplier
override fun invoke(duration: Duration, applyMultiplier: Boolean) {
val multiplier = if (applyMultiplier) platformImpl.prefs.waitMultiplier else 1.0
exitManager.wait(duration * multiplier)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class RealSupportScreen @Inject constructor(
override fun click(supportClass: SupportClass) =
locations.support.locate(supportClass).click()

override fun delay(duration: Duration) = duration.wait()
override fun delay(duration: Duration) = duration.wait(false)

override fun refresh() {
locations.support.updateClick.click()
Expand Down

0 comments on commit d120b58

Please sign in to comment.