//adds deck buttons to the list.  If highlightDeck is in the list, that button is a different color
    void setupDeckButtons(XMLDeck highlightDeck)
    {
        //one button for each player deck
        foreach (XMLDeck xDeck in DeckManagerScript.instance.playerDecks.decks)
        {
            MenuButtonScript xButton = Instantiate(buttonPrefab).GetComponent <MenuButtonScript>();
            xButton.setDeck(xDeck);

            //set button color
            Color targetColor;

            if (xDeck.isModded())
            {
                targetColor = moddedColor;
            }
            else
            {
                targetColor = defaultColor;
            }
            if (xDeck == highlightDeck)
            {
                targetColor = Color.Lerp(targetColor, highlightColor, 0.5f);
            }

            xButton.setColor(targetColor);
            xButton.transform.SetParent(this.transform, false);
            buttons.Add(xButton);
        }

        //another button for making a new deck
        MenuButtonScript ndButton = Instantiate(buttonPrefab).GetComponent <MenuButtonScript>();

        ndButton.setButtonText("New Deck");
        ndButton.setColor(menuColor);
        ndButton.transform.SetParent(this.transform, false);
        buttons.Add(ndButton);
    }
    //adjusts speed if the game cant keep up and handle the wave status indicator
    void Update()
    {
        //respond to keyboard controls by behaving as we would for button clicks
        if (Input.GetButtonDown("Start Wave"))
        {
            TextButtonSelected(startButton.buttonText.text);
        }
        if (Input.GetButtonDown("Pause"))
        {
            TextButtonSelected(pauseButton.buttonText.text);
        }
        if (Input.GetButtonDown("Speed 1"))
        {
            TextButtonSelected(Speed1Button.buttonText.text);
        }
        if (Input.GetButtonDown("Speed 2"))
        {
            TextButtonSelected(Speed2Button.buttonText.text);
        }
        if (Input.GetButtonDown("Speed 3"))
        {
            TextButtonSelected(Speed3Button.buttonText.text);
        }
        if (Input.GetButtonDown("Cycle Speed"))
        {
            if ((desiredTimeScale == 0.0f) || (desiredTimeScale == speed3))
            {
                TextButtonSelected(Speed1Button.buttonText.text);
            }
            else if (desiredTimeScale == speed1)
            {
                TextButtonSelected(Speed2Button.buttonText.text);
            }
            else if (desiredTimeScale == speed2)
            {
                TextButtonSelected(Speed3Button.buttonText.text);
            }
            else
            {
                Debug.LogWarning("Couldn't Cycle Speed: no case for our current speed");
            }
        }
        if (Input.GetButtonDown("Cancel"))
        {
            StartCoroutine(quitPromptCoroutine());
        }

        //attempt to regulate timeScale so the game slows down if the framerate tanks but then speeds back up when things settle down
        //the time scale will go down if frame rate is below the reduce threshold, and up if frame rate is above the increase threshold
        float timeScaleReduceThreshold   = (1.0f / forceSlowDownBelowFPS);
        float timeScaleIncreaseThreshold = (1.0f / allowSpeedUpAboveFPS);

        if (Time.timeScale > desiredTimeScale) //if we are going faster than the player wants...
        {
            Time.timeScale = desiredTimeScale; //then slow down!
            updateSpeedButtons();              //and be sure to update the buttons
        }

        float unscaledSmoothDeltaTime = Time.smoothDeltaTime / Time.timeScale;  //smooth delta time scales by the sim speed, so we have to undo that for framerate calculations

        //force slow down if we cant keep up
        if (unscaledSmoothDeltaTime > timeScaleReduceThreshold) //if frame rate is below the threshold
        {
            //drop by one speed setting, if we can
            if (Time.timeScale == speed3)
            {
                Time.timeScale = speed2;
                updateSpeedButtons();
            }
            else if (Time.timeScale == speed2)
            {
                Time.timeScale = speed1;
                updateSpeedButtons();
            }
        }

        //allow speed to go back up once frame rate recovers
        if (unscaledSmoothDeltaTime < timeScaleIncreaseThreshold) //if the frame rate is doing well...
        {
            if (Time.timeScale < desiredTimeScale)                //and the player wants a higher sim speed...
            {
                //go up to the next setting
                if (Time.timeScale == speed1)
                {
                    Time.timeScale = speed2;
                    updateSpeedButtons();
                }
                else if (Time.timeScale == speed2)
                {
                    Time.timeScale = speed3;
                    updateSpeedButtons();
                }
            }
        }

        //update the wave button text
        int stillToSpawn     = LevelManagerScript.instance.SpawnCount - LevelManagerScript.instance.totalSpawnedThisWave;
        int enemiesRemaining = EnemyManagerScript.instance.activeEnemies.Count;

        if (LevelManagerScript.instance.wavesSpawning > 0)
        {
            //enemies are currently spawning
            startButton.setButtonText("incoming: " + stillToSpawn);
        }
        else if (enemiesRemaining > 0)
        {
            //enemies are done spawning, but some are still alive
            startButton.setButtonText(enemiesRemaining + " remain");
        }
        else
        {
            //we are between waves
            startButton.setButtonText("Start Wave");
            startButton.setColor(defaultColor);
        }
    }