示例#1
0
 private void UpdateMenuItemBackgroundImage(MenuCube menuCube, bool isSoundEnabled)
 {
     menuCube.SetTextImage(CreateImagePath("options_cube", new Dictionary <string, string>
     {
         { "sounds", isSoundEnabled ? "on" : "off" }
     }));
 }
        private MenuCube CreateLevelMenuCube(string textImage)
        {
            MenuCube menuCube = new MenuCube(ContentManager);

            menuCube.SetTextImage(textImage);

            return(menuCube);
        }
示例#3
0
        private void CreateMenus()
        {
            _mainMenuCube = new MenuCube(ContentManager)
            {
                Title          = "Main menu",
                SelectionSound = MenuItemSelectionSound,
                Items          = new List <MenuItem>
                {
                    new MenuItem {
                        Title = "Play!", Activated = args => StateManager.Instance.ChangeState(GameState.SelectLevelMenu)
                    },
                    new MenuItem {
                        Title = "Options", Activated = args => ActivateMenuCube(_optionsMenuCube)
                    },
                    new MenuItem {
                        Title = "Editor", Activated = args => StateManager.Instance.ChangeState(GameState.Editor)
                    },
                    new MenuItem {
                        Title = "Exit", Activated = args => _platform.Game.Exit()
                    }
                }
            };
            _mainMenuCube.SetTextImage("main_cube_text_flat");

            _optionsMenuCube = new MenuCube(ContentManager)
            {
                Title          = "Options menu",
                PreviousMenu   = _mainMenuCube,
                SelectionSound = MenuItemSelectionSound,
                Items          = new List <MenuItem>
                {
                    new SwitchMenuItem
                    {
                        OnTitle   = "On", OffTitle = "Off", Prefix = "Sounds",
                        IsOn      = _platform.Settings.IsMusicEnabled,
                        Activated = args =>
                        {
                            _platform.Settings.IsMusicEnabled = ( bool )args;
                            UpdateMenuItemBackgroundImage(_optionsMenuCube, ( bool )args);
                            _platform.Settings.Save();
                        }
                    }
                }
            };
            UpdateMenuItemBackgroundImage(_optionsMenuCube, _platform.Settings.IsMusicEnabled);
        }