private void drawMenu()
        {
            MenuIcon one = new MenuIcon("one", null);
            MenuIcon two = new MenuIcon("two", null);
            MenuIcon three = new MenuIcon("three", null);
            MenuIcon four = new MenuIcon("four", null);

            List<MenuIcon> listOfMenuIcons = new List<MenuIcon>();
            listOfMenuIcons.Add(one);
            listOfMenuIcons.Add(two);
            listOfMenuIcons.Add(three);
            listOfMenuIcons.Add(four);
            optionsMenu = new Menu(Globals.MenuLayout.FourMatrix, listOfMenuIcons, "Options Menu");
        }
        /// <summary>
        /// Initiates the MenuController with an empty menu model and the provided tobii controller.
        /// </summary>
        /// <param name="tobii">The tobii controller associated with the application.</param>
        /// <param name="initialMenu">The opening menu</param>
        /// <exception cref="InvalidOperationException">If the MenuController is instantiated a second time.</exception>
        public MenuController(TobiiController tobii, Menu initialMenu)
        {
            if (initiated)
            {
                throw new InvalidOperationException("The MenuController has already been initiated.");
            }
            logger.Info("Initializing MenuController.");
            menuModel = MenuModel.Instance;
            logger.Info("Got " + tobii +" from constructor.");
            tobiiController = tobii;
            logger.Info("MenuController.tobiiController is now: "+ tobiiController +".");
            initiated = true;

            LoadMenu(initialMenu);
        }
        private void EndGame(Player winner)
        {
            if (backgroundSound.IsPlaying)
            {
                backgroundSound.Pause();
            }

            humanControl.Stop();

            // Build menu

            List<MenuIcon> options = new List<MenuIcon>(1);
            MenuIcon cancel = new MenuIcon("");
            cancel.region = new GUIRegion(Recellection.windowHandle,
                new System.Windows.Rect(0, Globals.VIEWPORT_HEIGHT - 100, Globals.VIEWPORT_WIDTH, 100));
            options.Add(cancel);
            Menu menu = new Menu(options);
            MenuController.LoadMenu(menu);

            Recellection.CurrentState = new EndGameView(! (winner is AIPlayer));

            MenuController.GetInput();

            MenuController.UnloadMenu();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="player"></param>
        public static void ConstructBuilding(Player player, Tile constructTile, Building sourceBuilding, World theWorld)
        {
            logger.Trace("Constructing a building for a player");
            //TODO Somehow present a menu to the player, and then
            //use the information to ADD (not the document) the fromBuilding.

            MenuIcon baseCell = new MenuIcon(Language.Instance.GetString("BaseCell") +
                    " (" + player.unitAcc.CalculateBuildingCostInflation(Globals.BuildingTypes.Base)+")",
                    Recellection.textureMap.GetTexture(Globals.TextureTypes.BaseBuilding), Color.Black);

            MenuIcon resourceCell = new MenuIcon(Language.Instance.GetString("ResourceCell") +
                    " (" + player.unitAcc.CalculateBuildingCostInflation(Globals.BuildingTypes.Resource) + ")",
                    Recellection.textureMap.GetTexture(Globals.TextureTypes.ResourceBuilding), Color.Black);

            MenuIcon defensiveCell = new MenuIcon(Language.Instance.GetString("DefensiveCell") +
                    " (" + player.unitAcc.CalculateBuildingCostInflation(Globals.BuildingTypes.Barrier) + ")",
                    Recellection.textureMap.GetTexture(Globals.TextureTypes.BarrierBuilding), Color.Black);

            MenuIcon aggressiveCell = new MenuIcon(Language.Instance.GetString("AggressiveCell") +
                    " (" + player.unitAcc.CalculateBuildingCostInflation(Globals.BuildingTypes.Aggressive) + ")",
                    Recellection.textureMap.GetTexture(Globals.TextureTypes.AggressiveBuilding), Color.Black);
            MenuIcon cancel = new MenuIcon(Language.Instance.GetString("Cancel"),
                    Recellection.textureMap.GetTexture(Globals.TextureTypes.No));
            List<MenuIcon> menuIcons = new List<MenuIcon>();
            menuIcons.Add(baseCell);
            menuIcons.Add(resourceCell);
            menuIcons.Add(defensiveCell);
            menuIcons.Add(aggressiveCell);
            menuIcons.Add(cancel);
            Menu ConstructBuildingMenu = new Menu(Globals.MenuLayout.NineMatrix, menuIcons, Language.Instance.GetString("ChooseBuilding"), Color.Black);
            MenuController.LoadMenu(ConstructBuildingMenu);
            Recellection.CurrentState = MenuView.Instance;
            Globals.BuildingTypes building;

            MenuIcon choosenMenu = MenuController.GetInput();
            Recellection.CurrentState = WorldView.Instance;
            MenuController.UnloadMenu();
            if (choosenMenu.Equals(baseCell))
            {
                building = Globals.BuildingTypes.Base;
            }
            else if (choosenMenu.Equals(resourceCell))
            {
                building = Globals.BuildingTypes.Resource;
            }
            else if (choosenMenu.Equals(defensiveCell))
            {
                building = Globals.BuildingTypes.Barrier;
            }
            else if (choosenMenu.Equals(aggressiveCell))
            {
                building = Globals.BuildingTypes.Aggressive;
            }
            else
            {
                return;
            }

            // If we have selected a tile, and we can place a building at the selected tile...
            try
            {
                if (!AddBuilding(building, sourceBuilding,
                        constructTile.position, theWorld, player))
                {
                    //SoundsController.playSound("Denied");
                }
            }
            catch (BuildingOutOfRangeException bore)
            {
                throw bore;
            }
        }
 private void CreateSpecialCommandMenuHelp()
 {
     helpMenu = null;
 }
        private void CreateSpecialCommandMenu()
        {
            Recellection.graphics.GraphicsDevice.SetRenderTarget(0, textRenderTex);
            Recellection.graphics.GraphicsDevice.Clear(Color.White);

            textDrawer.Begin();
            //textDrawer.Draw(Recellection.textureMap.GetTexture(Globals.TextureTypes.SpecialCommandMenu), Vector2.Zero, Color.White);
            float textScale = 2;

            //This is the offset from the buttonvector where the text will be drawn
            Vector2 offset = new Vector2(buttonDimension.X / 4, (buttonDimension.Y / 2) - ((fontSzInPx / 2) * textScale));

            icons = new List<GUIRegion>();

            //Init the regions!
            icons.Add(new GUIRegion(Recellection.windowHandle, new System.Windows.Rect(0, 0, buttonDimension.X, buttonDimension.Y)));
            textDrawer.DrawString(Recellection.screenFont, Language.Instance.GetString("SpecialCommandMenu1"), offset, Color.Black, 0, Vector2.Zero, textScale, SpriteEffects.None, 0);

            icons.Add(new GUIRegion(Recellection.windowHandle, new System.Windows.Rect(buttonDimension.X, 0, buttonDimension.X, buttonDimension.Y)));
            textDrawer.DrawString(Recellection.screenFont, Language.Instance.GetString("SpecialCommandMenu2"), new Vector2(buttonDimension.X, 0) + offset, Color.Black, 0, Vector2.Zero, textScale, SpriteEffects.None, 0);

            icons.Add(new GUIRegion(Recellection.windowHandle, new System.Windows.Rect(buttonDimension.X * 2, 0, buttonDimension.X, buttonDimension.Y)));
            textDrawer.DrawString(Recellection.screenFont, Language.Instance.GetString("SpecialCommandMenu3"), new Vector2(buttonDimension.X * 2, 0) + offset, Color.Black, 0, Vector2.Zero, textScale, SpriteEffects.None, 0);

            /////////////

            icons.Add(new GUIRegion(Recellection.windowHandle, new System.Windows.Rect(0, buttonDimension.Y, buttonDimension.X, buttonDimension.Y)));
            textDrawer.DrawString(Recellection.screenFont, Language.Instance.GetString("SpecialCommandMenu4"), new Vector2(0, buttonDimension.Y) + offset, Color.Black, 0, Vector2.Zero, textScale, SpriteEffects.None, 0);

            //The center region is not used
            icons.Add(new GUIRegion(Recellection.windowHandle, new System.Windows.Rect(buttonDimension.X * 2, buttonDimension.Y, buttonDimension.X, buttonDimension.Y)));
            textDrawer.DrawString(Recellection.screenFont, Language.Instance.GetString("SpecialCommandMenu5"), new Vector2(buttonDimension.X * 2, buttonDimension.Y) + offset, Color.Black, 0, Vector2.Zero, textScale, SpriteEffects.None, 0);

            ////////////

            icons.Add(new GUIRegion(Recellection.windowHandle, new System.Windows.Rect(0, buttonDimension.Y * 2, buttonDimension.X, buttonDimension.Y)));
            textDrawer.DrawString(Recellection.screenFont, Language.Instance.GetString("SpecialCommandMenu6"), new Vector2(0, buttonDimension.Y * 2) + offset, Color.Black, 0, Vector2.Zero, textScale, SpriteEffects.None, 0);

            icons.Add(new GUIRegion(Recellection.windowHandle, new System.Windows.Rect(buttonDimension.X, buttonDimension.Y * 2, buttonDimension.X, buttonDimension.Y)));
            textDrawer.DrawString(Recellection.screenFont, Language.Instance.GetString("SpecialCommandMenu7"), new Vector2(buttonDimension.X, buttonDimension.Y * 2) + offset, Color.Black, 0, Vector2.Zero, textScale, SpriteEffects.None, 0);

            icons.Add(new GUIRegion(Recellection.windowHandle, new System.Windows.Rect(buttonDimension.X * 2, buttonDimension.Y * 2, buttonDimension.X, buttonDimension.Y)));
            textDrawer.DrawString(Recellection.screenFont, Language.Instance.GetString("SpecialCommandMenu8"), new Vector2(buttonDimension.X * 2, buttonDimension.Y * 2) + offset, Color.Black, 0, Vector2.Zero, textScale, SpriteEffects.None, 0);

            textDrawer.End();

            Recellection.graphics.GraphicsDevice.SetRenderTarget(0, null);

            menuPic = textRenderTex.GetTexture();

            helpMenu = new Menu(Globals.MenuTypes.SpecialCommandMenu, true);
        }
        /// <summary>
        /// Builds a Menu for changing languages and processes the result.
        /// </summary>
        private void ChangeLanguageMenu()
        {
            String[] availableLanguages = Language.Instance.GetAvailableLanguages();

            #if DEBUG
            LoggerFactory.GetLogger().Info("Available Languages:");
            #endif

            Dictionary<MenuIcon, String> languageDic = new Dictionary<MenuIcon, String>();

            foreach (String lang in availableLanguages)
            {
                #if DEBUG
                LoggerFactory.GetLogger().Info(lang);
                #endif

                MenuIcon aLanguage = new MenuIcon(lang);
                languageDic.Add(aLanguage, lang);
            }

            List<MenuIcon> iconList = new List<MenuIcon>(languageDic.Keys);

            MenuIcon cancel = new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No));
            iconList.Add(cancel);

            Menu langMenu = new Menu(Globals.MenuLayout.NineMatrix, iconList, Language.Instance.GetString("ChooseLanguage"));

            MenuController.LoadMenu(langMenu);
            Recellection.CurrentState = MenuView.Instance;

            MenuIcon choosenLang = MenuController.GetInput();
            if (choosenLang != cancel)
            {
                Language.Instance.SetLanguage(languageDic[choosenLang]);
                LoggerFactory.GetLogger().Info("Language set to " + languageDic[choosenLang]);
            }
            MenuController.UnloadMenu();
        }
 /// <summary>
 /// Opens up and loads a specified menu.
 /// </summary>
 /// <param name="m">The menu to load.</param>
 public static void LoadMenu(Menu m)
 {
     //for the case where there is nothing on the stack yet
     if (menuModel.Peek() != null)
     {
         tobiiController.UnloadMenu(menuModel.Peek());
     }
     menuModel.Push(m);
     tobiiController.LoadMenu(m);
 }
 private void CreateCommandMenuHelp()
 {
     helpMenu = null;
 }
        private void upgradeMenu()
        {
            Building building = selectedTile.GetBuilding();

            MenuIcon speed = new MenuIcon(Language.Instance.GetString("UpgradeSpeed"), null, Color.Black);
            MenuIcon power = new MenuIcon(Language.Instance.GetString("UpgradePower"), null, Color.Black);
            MenuIcon cancel = new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No), Color.Black);

            List<MenuIcon> menuIcons = new List<MenuIcon>();
            menuIcons.Add(speed);
            menuIcons.Add(power);
            menuIcons.Add(cancel);

            Menu upgradeMenu = new Menu(Globals.MenuLayout.FourMatrix, menuIcons, Language.Instance.GetString("UpgradeMenu"), Color.Black);
            MenuController.LoadMenu(upgradeMenu);
            Recellection.CurrentState = MenuView.Instance;
            MenuIcon chosenMenu = MenuController.GetInput();
            Recellection.CurrentState = WorldView.Instance;
            MenuController.UnloadMenu();

            if (chosenMenu == speed)
            {
                if (!playerInControll.unitAcc.PayAndUpgradeSpeed(building))
                {
                    //SoundsController.playSound("Denied");
                }
            }
            else if (chosenMenu == power)
            {
                if (!playerInControll.unitAcc.PayAndUpgradePower(building))
                {
                    //SoundsController.playSound("Denied");
                }
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="previousSelection"></param>
        private void TileMenu()
        {
            MenuIcon moveUnits = new MenuIcon(Language.Instance.GetString("MoveUnits"), null, Color.Black);
            MenuIcon cancel = new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No), Color.Black);

            List<MenuIcon> menuIcons = new List<MenuIcon>();
            if (theWorld.GetMap().GetTile(previousSelection.absPoint).GetUnits(playerInControll).Count > 0)
            {
                // Only show this options if there are units.
                menuIcons.Add(moveUnits);
            }
            menuIcons.Add(cancel);

            Menu buildingMenu = new Menu(Globals.MenuLayout.FourMatrix, menuIcons, Language.Instance.GetString("TileMenu"), Color.Black);
            MenuController.LoadMenu(buildingMenu);
            Recellection.CurrentState = MenuView.Instance;
            MenuIcon choosenMenu = MenuController.GetInput();
            Recellection.CurrentState = WorldView.Instance;
            MenuController.UnloadMenu();

            if (choosenMenu == moveUnits)
            {
                Selection currSel = retrieveSelection();
                if (! (currSel.state == State.TILE || currSel.state == State.BUILDING))
                {
                    return;
                }

                Tile from = theWorld.GetMap().GetTile(previousSelection.absPoint);
                SelectTile(theWorld.GetMap().GetTile(currSel.absPoint));

                UnitController.MoveUnits(playerInControll, from, selectedTile, from.GetUnits().Count);
            }
        }
        private void GameMenu()
        {
            MenuIcon endTurn = new MenuIcon(Language.Instance.GetString("EndTurn"));
            MenuIcon endGame = new MenuIcon(Language.Instance.GetString("EndGame"));
            MenuIcon cancel = new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No));

            List<MenuIcon> options = new List<MenuIcon>(4);
            options.Add(endTurn);
            options.Add(endGame);
            options.Add(cancel);

            Menu menu = new Menu(Globals.MenuLayout.FourMatrix, options, "");
            MenuController.LoadMenu(menu);

            bool done = false;
            while(! done)
            {
                Recellection.CurrentState = MenuView.Instance;
                MenuIcon input = MenuController.GetInput();
                if (input == endTurn)
                {
                    finished = true;
                    break;
                }
                else if (input == endGame)
                {
                    List<MenuIcon> promptOptions = new List<MenuIcon>(2);
                    MenuIcon yes = new MenuIcon(Language.Instance.GetString("Yes"), Recellection.textureMap.GetTexture(Globals.TextureTypes.Yes));
                    MenuIcon no = new MenuIcon(Language.Instance.GetString("No"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No));
                    promptOptions.Add(yes);
                    promptOptions.Add(no);
                    MenuController.LoadMenu(new Menu(Globals.MenuLayout.Prompt, promptOptions, Language.Instance.GetString("AreYouSureYouWantToEndTheGame")));
                    MenuIcon inp = MenuController.GetInput();
                    MenuController.UnloadMenu();

                    if (inp == yes)
                    {
                        // This should make the player lose :D
                        List<Building> buildingsToRemove = new List<Building>();
                        foreach(Graph g in playerInControll.GetGraphs())
                        {
                            foreach(Building b in g.GetBuildings())
                            {
                                buildingsToRemove.Add(b);
                            }
                        }
                        foreach(Building b in buildingsToRemove)
                        {
                            BuildingController.RemoveBuilding(b);
                        }
                        finished = true;
                        break;
                    }
                }
                else if (input == cancel)
                {
                    break;
                }
            }
            Recellection.CurrentState = WorldView.Instance;
            MenuController.UnloadMenu();
        }
        /// <summary>
        /// Loads the Building menu from a selection.
        /// Must have building on tile.
        /// </summary>
        /// <param name="theSelection"></param>
        private void BuildingMenu()
        {
            World.Map map = theWorld.GetMap();
            Building building = selectedTile.GetBuilding();
            if (building == null || building.owner != playerInControll)
            {
                return;
            }
            int toHeal = Math.Min(building.maxHealth - building.currentHealth, building.units.Count());

            MenuIcon setWeight = new MenuIcon(Language.Instance.GetString("SetWeight"));
            MenuIcon buildCell = new MenuIcon(Language.Instance.GetString("BuildCell"));
            MenuIcon removeCell = new MenuIcon(Language.Instance.GetString("RemoveCell"));
            MenuIcon upgradeUnits = new MenuIcon(Language.Instance.GetString("UpgradeUnits") + " (" + playerInControll.unitAcc.GetUpgradeCost() + ")");
            MenuIcon moveUnits = new MenuIcon(Language.Instance.GetString("MoveUnits"));
            MenuIcon repairCell = new MenuIcon(Language.Instance.GetString("RepairCell") + " (" + toHeal + ")");
            MenuIcon setAggro = new MenuIcon(Language.Instance.GetString("SetAggro"));
            MenuIcon Cancel = new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No));

            List<MenuIcon> menuIcons = new List<MenuIcon>();
            menuIcons.Add(setWeight);
            menuIcons.Add(buildCell);
            menuIcons.Add(removeCell);
            menuIcons.Add(upgradeUnits);
            menuIcons.Add(moveUnits);
            menuIcons.Add(repairCell);
            menuIcons.Add(setAggro);
            menuIcons.Add(Cancel);

            Menu buildingMenu = new Menu(Globals.MenuLayout.NineMatrix, menuIcons, Language.Instance.GetString("BuildingMenu"), Color.Black);
            MenuController.LoadMenu(buildingMenu);
            Recellection.CurrentState = MenuView.Instance;
            MenuIcon choosenMenu = MenuController.GetInput();
            Recellection.CurrentState = WorldView.Instance;
            MenuController.UnloadMenu();

            if (choosenMenu.Equals(setWeight))
            {
                GraphController.Instance.SetWeight(building);
            }
            else if (choosenMenu.Equals(buildCell))
            {
                tobii.SetFeedbackColor(Color.DarkGreen);
                Selection destsel;
                do
                {
                    SetConstructionLines(BuildingController.GetValidBuildingInterval(selectedTile.position, theWorld));
                    destsel = retrieveSelection();
                    RemoveconstructionTileLines(BuildingController.GetValidBuildingInterval(selectedTile.position, theWorld));
                }
                while (destsel.state != State.TILE);

                tobii.SetFeedbackColor(Color.White);

                SelectTile(map.GetTile(destsel.absPoint));

                //TODO Add a check to see if the tile is a correct one. The diffrence between the selected tiles coordinates and the source building shall not exceed 3.
                if (selectedTile.GetBuilding() == null)
                {
                    try
                    {
                        BuildingController.ConstructBuilding(playerInControll, selectedTile, building, theWorld);
                        tobii.SetFeedbackColor(Color.White);
                    }
                    catch (BuildingController.BuildingOutOfRangeException)
                    {
                        logger.Debug("Caught BuildingOutOfRangeExcpetion");
                    }
                }
                else
                {
                    //SoundsController.playSound("Denied");
                    tobii.SetFeedbackColor(Color.White);
                    return;
                }
            }
            else if (choosenMenu.Equals(removeCell))
            {
                BuildingController.RemoveBuilding(building);
            }
            else if (choosenMenu.Equals(upgradeUnits))
            {
                upgradeMenu();
            }
            else if (choosenMenu.Equals(moveUnits))
            {
                tobii.SetFeedbackColor(Color.Red);

                Selection destsel = retrieveSelection();
                if (destsel.state == State.BUILDING || destsel.state == State.TILE)
                {
                    Tile selTile = map.GetTile(destsel.absPoint);
                    UnitController.MoveUnits(playerInControll, selectedTile, selTile, building.GetUnits().Count);
                }

                tobii.SetFeedbackColor(Color.White);
            }
            else if (choosenMenu.Equals(repairCell))
            {
                playerInControll.unitAcc.DestroyUnits(building.units, toHeal);
                building.Repair(toHeal);
            }
            else if (choosenMenu.Equals(setAggro))
            {
                building.IsAggressive = !building.IsAggressive;
                building.UpdateAggressiveness(null, new Event<IEnumerable<Unit>>(building.GetUnits(), EventType.ADD));
            }
            else if (choosenMenu.Equals(Cancel))
            {
                return;
            }
            else
            {
                return;
            }
        }
        private void ChangeVolumeMenu()
        {
            MenuIcon musicVolumeUp = new MenuIcon(Language.Instance.GetString("MusicVolumeUp"));
            MenuIcon musicVolumeDown = new MenuIcon(Language.Instance.GetString("MusicVolumeDown"));
            MenuIcon sfxVolumeUp = new MenuIcon(Language.Instance.GetString("EffectsVolumeUp"));
            MenuIcon sfxVolumeDown = new MenuIcon(Language.Instance.GetString("EffectsVolumeDown"));
            MenuIcon empty = new MenuIcon("");
            MenuIcon done = new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No));

            List<MenuIcon> iconList = new List<MenuIcon>(); ;
            iconList.Add(musicVolumeUp);
            iconList.Add(empty);
            iconList.Add(musicVolumeDown);
            iconList.Add(sfxVolumeUp);
            iconList.Add(sfxVolumeDown);
            iconList.Add(done);

            Menu volumeMenu = new Menu(Globals.MenuLayout.NineMatrix, iconList, "");

            MenuController.LoadMenu(volumeMenu);

            bool notFinished = true;

            while (notFinished)
            {
                MenuIcon response = MenuController.GetInput();

                if (response == musicVolumeUp)
                {
                    if (GameOptions.Instance.musicVolume <= 1.0f)
                    {
                        SoundsController.changeMusicVolume(GameOptions.Instance.musicVolume + 0.1f);
                    }
                }
                else if (response == musicVolumeDown)
                {
                    SoundsController.changeMusicVolume(GameOptions.Instance.musicVolume - 0.1f);
                }
                else if (response == sfxVolumeUp)
                {
                    if (GameOptions.Instance.sfxVolume <= 1.0f)
                    {
                        SoundsController.changeEffectsVolume(GameOptions.Instance.sfxVolume + 0.1f);
                    }
                }
                else if (response == sfxVolumeDown)
                {
                    SoundsController.changeEffectsVolume(GameOptions.Instance.sfxVolume - 0.1f);
                }
                else if (response == done)
                {
                    notFinished = false;
                }
            }
            MenuController.UnloadMenu();
        }
 /// <summary>
 /// Push a new menu onto the stack
 /// </summary>
 /// <param name="m"></param>
 public void Push(Menu m)
 {
     menuStack.Push(m);
     if (MenuEvent != null)
     {
         MenuEvent(this, new Event<Menu>(m, EventType.ADD));
     }
 }
 /// <summary>
 /// Gets the position of the menu provided
 /// </summary>
 /// <param name="m"></param>
 /// <returns></returns>
 public Vector2 GetPosition(Menu m)
 {
     return menuPositions[m];
 }
 private void CreateConfirmationMenuHelp()
 {
     helpMenu = null;
 }
        public void Run()
        {
            logger.Debug("Initializer is running.");

            #region Build main menu
            MenuIcon newgame = new MenuIcon(Language.Instance.GetString("NewGame"), null, Color.Black);
            MenuIcon options = new MenuIcon(Language.Instance.GetString("Options"), null, Color.Black);
            MenuIcon help = new MenuIcon(Language.Instance.GetString("Help"), null, Color.Black);
            MenuIcon quit = new MenuIcon(Language.Instance.GetString("Quit"), null, Color.Black);

            List<MenuIcon> menuOptions = new List<MenuIcon>();
            menuOptions.Add(newgame);
            menuOptions.Add(options);
            menuOptions.Add(help);
            menuOptions.Add(quit);

            Menu mainMenu = new Menu(Globals.MenuLayout.FourMatrix, menuOptions, "", Color.Black);

            MenuView view = MenuView.Instance;

            // Just to make sure everything is in there...
            new MenuController(TobiiController.GetInstance(this.windowHandle), mainMenu);
            #endregion

            ShowSplashScreen();

            Cue backgroundSound = Sounds.Instance.LoadSound("Menu");
            backgroundSound.Play();

            while(true)
            {
                backgroundSound.Resume();
                Recellection.CurrentState = view;
                logger.Info("Waiting for Tobii input...");
                MenuIcon response = MenuController.GetInput();

                logger.Info("Got input!");

                if (response == newgame)
                {
                    // START THE GAME ALREADY!

                    GameInitializer gameInit = new GameInitializer();
                    backgroundSound.Pause();
                    WorldView.Initiate(gameInit.theWorld);
                    Recellection.CurrentState = WorldView.Instance;// new WorldView(gameInit.theWorld);
                    VictorTurner vt = new VictorTurner(gameInit);
                    vt.Run();
                }
                else if (response == quit)
                {
                    List<MenuIcon> promptOptions = new List<MenuIcon>(2);
                    MenuIcon yes = new MenuIcon(Language.Instance.GetString("Yes"), Recellection.textureMap.GetTexture(Globals.TextureTypes.Yes));
                    MenuIcon no = new MenuIcon(Language.Instance.GetString("No"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No));
                    promptOptions.Add(yes);
                    promptOptions.Add(no);
                    MenuController.LoadMenu(new Menu(Globals.MenuLayout.Prompt, promptOptions, Language.Instance.GetString("AreYouSureYouWantToQuit")));
                    Recellection.CurrentState = MenuView.Instance;

                    if (MenuController.GetInput() == yes)
                    {
                        Environment.Exit(0);
                    }

                    MenuController.UnloadMenu();
                }
                else if (response == options)
                {
                    Configurator.Instance.ChangeOptions();
                }
                else if (response == help)
                {
                    List<MenuIcon> opt = new List<MenuIcon>(1);
                    MenuIcon cancel = new MenuIcon("");
                    cancel.region = new GUIRegion(Recellection.windowHandle,
                        new System.Windows.Rect(0, Globals.VIEWPORT_HEIGHT - 100, Globals.VIEWPORT_WIDTH, 100));
                    opt.Add(cancel);
                    Menu menu = new Menu(opt);
                    MenuController.LoadMenu(menu);

                    Recellection.CurrentState = new HelpView();

                    MenuController.GetInput();

                    MenuController.UnloadMenu();
                }
                else
                {
                    Recellection.playBeethoven();
                }
            }
        }
 private void CreateMainMenuHelp()
 {
     helpMenu = null;
 }
 private void CreateOptionsMenuHelp()
 {
     helpMenu = null;
 }
        private void ChangeDifficultyMenu()
        {
            Dictionary<MenuIcon, String> difficultyDic = new Dictionary<MenuIcon, String>();

            #if DEBUG
            LoggerFactory.GetLogger().Info("Available difficulties:");
            #endif

            foreach(String diff in System.Enum.GetNames(typeof(Globals.Difficulty)))
            {
                #if DEBUG
                LoggerFactory.GetLogger().Info(diff);
                #endif

                MenuIcon aDifficulty = new MenuIcon(diff);
                difficultyDic.Add(aDifficulty, diff);
            }

            List<MenuIcon> iconList = new List<MenuIcon>(difficultyDic.Keys);

            MenuIcon cancel = new MenuIcon(Language.Instance.GetString("Cancel"), Recellection.textureMap.GetTexture(Globals.TextureTypes.No));
            iconList.Add(cancel);

            Menu diffMenu = new Menu(Globals.MenuLayout.FourMatrix, iconList, Language.Instance.GetString("ChooseADifficulty"));

            MenuController.LoadMenu(diffMenu);
            Recellection.CurrentState = MenuView.Instance;

            MenuIcon choosenDiff = MenuController.GetInput();

            if (choosenDiff != cancel)
            {
                GameOptions.Instance.difficulty = (Globals.Difficulty) Enum.Parse(typeof(Globals.Difficulty), difficultyDic[choosenDiff]);
                LoggerFactory.GetLogger().Info("Difficulty set to " + difficultyDic[choosenDiff]);
            }
            MenuController.UnloadMenu();
        }