package com.iofferyoutea.WitchQueen

import com.badlogic.gdx.Gdx
import kotlinx.coroutines.*
import ktx.app.KtxScreen
import java.lang.ref.WeakReference

object ScreenManager {
    var currentScreen: WeakReference<KtxScreen>? = null
    val screens: MutableSet<WeakReference<KtxScreen>> = mutableSetOf<WeakReference<KtxScreen>>() // Does this need to be mutable?

    fun switchScreen(newScreen: WeakReference<KtxScreen>): Boolean {
        if (!screens.contains(newScreen)) {
            Gdx.app.log("ScreenManager", "newScreen not found in screens. Adding...")
            screens.add(newScreen)
        }

        currentScreen = screens.find { it == newScreen }

        return currentScreen != null
    }
}
