// CONSTRUCTORS --------------------------------------------------------------------------------------------------------------------------------
        public TitleScreen(MenuSystemScene pMenuSystem)
        {
            MenuSystem = pMenuSystem;
            FontMap map = Crystallography.UI.FontManager.Instance.GetMap( Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25, "Bold") );

            TitleImage = Support.SpriteFromFile("/Application/assets/images/UI/header.png");
            TouchToStartText = new Label("touch to start", map);
            TouchToStartText.Position = new Vector2(229.0f, 73.0f);
            TouchToStartText.Color = LevelManager.Instance.Palette[0];
            TouchToStartText.Color.A = 0.0f;

            Scheduler.Instance.Schedule( TouchToStartText, (dt) => {
                TouchToStartText.Color.A += 0.25f * dt;
                if (TouchToStartText.Color.A >= 1.0f) {
                    TouchToStartText.Color.A = 1.0f;
                    TouchToStartText.UnscheduleAll();
                }
            }, 0, false, 0);

            this.AddChild(TitleImage);
            this.AddChild(TouchToStartText);

            #if DEBUG
            Console.WriteLine(GetType().ToString() + " created" );
            #endif
        }
 public override void OnExit()
 {
     base.OnExit ();
     TouchToStartText.UnscheduleAll();
     TouchToStartText = null;
     MenuSystem = null;
     Support.RemoveTextureWithFileName("/Application/assets/images/UI/header.png");
 }
 // OVERRIDES -------------------------------------------------------------------------------------------------
 public override void OnExit()
 {
     base.OnExit ();
     MenuSystem = null;
     loadProc.Clear();
     loadProc = null;
     this.RemoveAllChildren(true);
     Support.RemoveTextureWithFileName("/Application/assets/images/UI/eyes.png");
 }
        public SplashScreen(MenuSystemScene pMenuSystem)
        {
            //			stopwatch = Stopwatch.StartNew();
            _timer = 0.0f;
            MenuSystem = pMenuSystem;

            loadProc = new List<Action>{
                () => {
                    ;//dummy
                },
                () => {
                    SplashImage = Support.SpriteFromFile("/Application/assets/images/UI/eyes.png");
                    this.AddChild(SplashImage);
                },
                () => {
                    var temp = Support.SpriteFromFile("/Application/assets/images/UI/header.png");
                    temp = Support.SpriteFromFile("/Application/assets/images/UI/menuBtnBG_blue2.png");
                    temp = Support.SpriteFromFile("/Application/assets/images/UI/menuBtnBG_red2.png");
                    temp = Support.SpriteFromFile("/Application/assets/images/UI/menuBtnBG_bottom.png");
                    temp = Support.SpriteFromFile("/Application/assets/images/UI/menuBtnBG_top.png");
                    var b = new BetterButton();
                    b.Cleanup();
                    Support.LoadAtlas("crystallonUI", ".png");
                    Support.LoadAtlas("gamePieces", ".png");
                },
                () => {
                    Scheduler.Instance.Schedule( this, (dt) => {
                    _timer += dt;
                        if (_timer > 3.0f) {
                            MenuSystem.SetScreen("Title");
                            this.UnscheduleAll();
                        }
                    }, 0.0f, false, 0);
                }
            };

            this.ScheduleUpdate(0);
        }
        public override void OnExit()
        {
            ColorIcon.Destroy();
            BackButton.UnregisterPalette();
            PlayButton.UnregisterPalette();
            LevelSelectItem.LevelSelectionDetected -= HandleLevelSelectItemLevelSelectionDetected;
            BackButton.ButtonUpAction -= HandleBackButtonButtonUpAction;
            PlayButton.ButtonUpAction -= HandlePlayButtonButtonUpAction;
            this.SwipePanels.OnSwipeComplete -= HandleSwipePanelshandleOnSwipeComplete;

            base.OnExit ();

            MenuSystem = null;
            Panels.Clear();
            this.SwipePanels = null;
            LevelSelectTitleText = null;
            LevelSelectInstructionsText = null;

            BlackBlock1 = null;
            BlackBlock2 = null;

            BackButton = null;
            PlayButton = null;

            for (int i=0; i < Icons.Length; i++){
                Icons[i] = null;
            }
            Icons = null;
            //			Solutions.Clear();
            Solutions = null;
        }
        // CONSTRUCTOR ----------------------------------------------------------------------------------------------------------------------
        public LevelSelectScreen(MenuSystemScene pMenuSystem)
        {
            SelectedLevel = 0;
            var init = ColorIcon.Instance;
            MenuSystem = pMenuSystem;

            var pages = FMath.Ceiling((GameScene.TOTAL_LEVELS-1) / (float)LevelPage.ITEMS_PER_PAGE);

            Panels = new List<Node>{};

            for (int i=0; i < pages; i++) {
                Panels.Add( new LevelPage(i) );
                (Panels[i] as LevelPage).Disable();
            }
            (Panels[0] as LevelPage).Enable();

            this.SwipePanels = new SwipePanels(Panels) {
                Width = 457.0f,
                Position = new Vector2(95.0f,46.0f)
            };

            Indicator = new LevelSelectIndicator();

            // BLACK MASKS TO HIDE MORE LEVELS BEHIND
            BlackBlock1 = Support.UnicolorSprite("white", 255,255,255,255);
            BlackBlock1.Color = Support.ExtractColor("333330");
            BlackBlock1.Scale = new Vector2(361.0f/16.0f, Director.Instance.GL.Context.Screen.Height/16.0f);
            BlackBlock1.Position = new Vector2(Director.Instance.GL.Context.Screen.Width-361.0f, 0.0f);

            BlackBlock2 = Support.UnicolorSprite("white", 255,255,255,255);
            BlackBlock2.Color = LevelManager.Instance.BackgroundColor;
            BlackBlock2.Position = Vector2.Zero;
            BlackBlock2.Scale = new Vector2(50.0f/16.0f, Director.Instance.GL.Context.Screen.Height/16.0f);

            BlackBlock3 = Support.UnicolorSprite("white", 255,255,255,255);
            BlackBlock3.Color = Support.ExtractColor("333330");
            BlackBlock3.Scale = new Vector2(361.0f/16.0f, 115.0f/16.0f);
            BlackBlock3.Position = new Vector2(Director.Instance.GL.Context.Screen.Width-361.0f, Director.Instance.GL.Context.Screen.Height - 115.0f);

            BlackBlock4 = Support.UnicolorSprite("white", 255,255,255,255);
            BlackBlock4.Color = Support.ExtractColor("333330");
            BlackBlock4.Scale = new Vector2(361.0f/16.0f, 253.0f/16.0f);
            BlackBlock4.Position = new Vector2(Director.Instance.GL.Context.Screen.Width-361.0f, 0.0f);

            LevelNumberText = new Label(){
                Text = SelectedLevel.ToString(),
                Position = new Vector2(Director.Instance.GL.Context.Screen.Width-339.0f, Director.Instance.GL.Context.Screen.Height-78.0f),
                FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 64, "Bold") ),
                Color = LevelManager.Instance.BackgroundColor
            };
            //			CenterText(LevelNumberText);

            //			SolutionPanel = new HudPanel(){
            //			};

            PossibleSolutionsText = new Label(){
                Text = "possible solutions",
                Position = new Vector2(Director.Instance.GL.Context.Screen.Width - 339.0f, Director.Instance.GL.Context.Screen.Height-100.0f),
                FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25, "Bold") ),
                Color = LevelManager.Instance.BackgroundColor
            };

            Solutions = new SolutionSlider();

            //			Solutions = new List<SolutionIcon>(); //{
            //				new SolutionIcon(){
            //					CubeText = "99",
            //					ScoreText = "88"
            //				},
            //				new SolutionIcon(){
            //					CubeText = "99",
            //					ScoreText = "88"
            //				},
            //				new SolutionIcon(){
            //					CubeText = "99",
            //					ScoreText = "88"
            //				},
            //				new SolutionIcon(){
            //					CubeText = "99",
            //					ScoreText = "88"
            //				},
            //				new SolutionIcon(){
            //					CubeText = "99",
            //					ScoreText = "88"
            //				}
            //			};
            //			for( int i=0; i < Solutions.Count; i++) {
            //				Solutions[i].Visible = false;
            //				var column = i % 4;
            //				var row = ( i - column ) / 4;
            //				Solutions[i].Position = new Vector2(Director.Instance.GL.Context.Screen.Width - 339.0f + 60.0f * column,
            //				                                    Director.Instance.GL.Context.Screen.Height - 200.0f - row * 80.0f);
            //				this.AddChild(Solutions[i]);
            //			}

            QualitiesText = new Label() {
                Text = "qualities",
                Position = new Vector2(623.0f, 223.0f),
                FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25, "Bold") ),
                Color = LevelManager.Instance.BackgroundColor
            };

            //			CompletionPercentageText = new Label() {
            //				Text = (1.0f).ToString("P0"),
            //				Position = new Vector2(638.0f, 150.0f),
            //				FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25, "Bold") ),
            ////				Color = new Vector4( 0.16078431f, 0.88627451f, 0.88627451f, 1.0f)
            //			};
            //			CenterText(CompletionPercentageText);
            //			this.AddChild(CompletionPercentageText);

            Icons = new Node[4];
            IconLabels = new Label[4];
            for( int i=0; i < Icons.Length; i++) {
                Icons[i] = Support.TiledSpriteFromFile("/Application/assets/images/icons/icons.png", 4, 2);
                Icons[i].Position = new Vector2(623.0f + 68.0f * (float)i, 2.0f * BUTTON_HEIGHT + 20.0f);
            //				Icons[i].Scale = new Vector2(0.25f, 0.25f);
                IconLabels[i] = new Label() {
                    FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 36, "Bold") ),
                    Color = LevelManager.Instance.BackgroundColor
                };
            }

            LevelSelectTitleText = new Label(){
                Text="level select",
                Position = new Vector2(50.0f, 488.0f),
                FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 36, "Regular") ),
                Color = Support.ExtractColor("333330")
            };

            LevelSelectInstructionsText = new Label(){
                Text="select a cube and then press play.",
                Position = new Vector2(50.0f, 465.0f),
                FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25, "Regular") ),
                Color = Support.ExtractColor("333330")
            };

            BackButton = new BetterButton(361.0f, BUTTON_HEIGHT) {
                Text = "back",
                Position = new Vector2(Director.Instance.GL.Context.Screen.Width-361.0f, BUTTON_HEIGHT)
            };
            BackButton.background.RegisterPalette(2);

            PlayButton = new BetterButton(361.0f, BUTTON_HEIGHT) {
                Text = "play",
                Position = new Vector2(Director.Instance.GL.Context.Screen.Width-361.0f, 0.0f)
            };
            PlayButton.background.RegisterPalette(1);

            // SWIPE LAYER
            this.AddChild(this.SwipePanels);
            foreach( LevelPage panel in Panels) {
                this.AddChild(panel);
            }
            (Panels[0] as LevelPage).Items[0].AddChild(Indicator);

            // UI LAYERS
            BackLayer = new Layer();
            this.AddChild(BackLayer);
            FrontLayer = new Layer();
            this.AddChild(FrontLayer);

            // BACK LAYER ELEMENTS
            BackLayer.AddChild(BlackBlock1);
            BackLayer.AddChild(BlackBlock2);
            BackLayer.AddChild(Solutions);

            // FRONT LAYER ELEMENTS
            FrontLayer.AddChild(BlackBlock3);
            FrontLayer.AddChild(BlackBlock4);

            FrontLayer.AddChild(LevelNumberText);
            FrontLayer.AddChild(PossibleSolutionsText);
            FrontLayer.AddChild(QualitiesText);
            for( int i=0; i < Icons.Length; i++) {
                FrontLayer.AddChild(Icons[i]);
            }
            FrontLayer.AddChild(LevelSelectTitleText);
            FrontLayer.AddChild(LevelSelectInstructionsText);
            FrontLayer.AddChild(BackButton);
            FrontLayer.AddChild(PlayButton);
        }
        // CONSTRUCTOR ---------------------------------------------------------
        public OptionsMenuScreen(MenuSystemScene pMenuSystem)
        {
            MenuSystem = pMenuSystem;

            // SLIDERS -----------------------

            // MUSIC SLIDER
            musicVolume = Support.MusicSystem.Instance.Volume;
            effectsVolume = Support.SoundSystem.Instance.Volume;
            orbitDistance = SelectionGroup.EASE_DISTANCE;
            stickiness = SelectionGroup.MAXIMUM_PICKUP_VELOCITY;

            float anchorX = (960.0f - (2.0f * (float)SLIDER_TRACK_LENGTH + SLIDER_H_GAP)) / 2.0f;
            float anchorY = 397.0f;

            musicSlider = new Slider(SLIDER_TRACK_LENGTH) {
                Text = "music volume",
                max = 1.0f,
                min = 0.0f,
                Position = new Vector2(anchorX, anchorY),
                OnChange = (volume) => {
                    Support.MusicSystem.Instance.SetVolume(volume);
                }
            };
            musicSlider.SetSliderValue((float)(DataStorage.options[0]/100.0f));
            musicSlider.RegisterPalette(2);

            // SOUND EFFECTS SLIDER
            effectsSlider = new Slider(SLIDER_TRACK_LENGTH) {
                Text = "sound effects volume",
                max = 1.0f,
                min = 0.0f,
                Position = new Vector2(anchorX, anchorY - SLIDER_V_GAP),
                OnChange = (volume) => {
                    Support.SoundSystem.Instance.SetVolume(volume);
                    Support.SoundSystem.Instance.Play( LevelManager.Instance.SoundPrefix + "high.wav" );
                }
            };
            effectsSlider.SetSliderValue((float)(DataStorage.options[1]/100.0f));
            effectsSlider.RegisterPalette(1);

            // SELECTION SENSITIVITY SLIDER
            stickySlider = new Slider(SLIDER_TRACK_LENGTH) {
                Text = "selection sensitivity",
                max = 1000.0f,
                min = 300.0f,
                Position = new Vector2(anchorX + musicSlider.Length + SLIDER_H_GAP, anchorY),
                OnChange = (velocity) => {
                    SelectionGroup.MAXIMUM_PICKUP_VELOCITY = velocity;
                }
            };
            stickySlider.SetSliderValue((float)DataStorage.options[3]);
            stickySlider.RegisterPalette(1);

            // ORBIT DISTANCE SLIDER
            orbitSlider = new Slider(SLIDER_TRACK_LENGTH) {
                Text = "selection float distance",
                max = 120.0f,
                min = 60.0f,
                Position = new Vector2(stickySlider.Position.X, anchorY - SLIDER_V_GAP),
                OnChange = (radius) => {
                    SelectionGroup.EASE_DISTANCE = radius;
                }
            };
            orbitSlider.SetSliderValue((float)DataStorage.options[2]);
            orbitSlider.RegisterPalette(0);

            // BUTTONS -------------------------------

            // OK BUTTON
            OKButton = new BetterButton(BUTTON_WIDTH, BUTTON_HEIGHT) {
                Text = "ok",
                Position = new Vector2(960.0f-BUTTON_WIDTH, 0.0f),
            //				Color = new Vector4(0.8980f, 0.0745f, 0.0745f, 1.0f)
            };
            OKButton.background.RegisterPalette(1);

            // CANCEL BUTTON
            CancelButton = new BetterButton(BUTTON_WIDTH, BUTTON_HEIGHT) {
                Text = "cancel",
                Position = new Vector2(OKButton.Position.X, BUTTON_HEIGHT),
            //				Color = new Vector4(0.1608f, 0.8863f, 0.8863f, 1.0f)
            };
            CancelButton.background.RegisterPalette(2);

            // CLEAR DATA BUTTON
            ClearButton = new BetterButton(BUTTON_WIDTH, BUTTON_HEIGHT) {
                Text = "clear all data",
                Position = new Vector2(0.0f, 0.0f),
            //				Color = new Vector4(0.1608f, 0.8863f, 0.8863f, 1.0f)
            };
            ClearButton.background.RegisterPalette(2);

            // CLEAR DATA CONFIRMATION PANEL -------------------------

            // CLEAR MESSAGE PANEL
            ClearPanel = new MessagePanel(BUTTON_WIDTH, 165.0f) {
                TitleText = "really?",
                Text = "erase all your progress?\nthis cannot be undone.",
                Offset = new Vector2(0.0f, 0.0f),//OKButton.Height),
                Width = OKButton.Width
            };
            ClearPanel.BackgroundAlpha = 1.0f;

            // CLEAR DATA CONFIRMATION BUTTON
            ClearOKButton = new BetterButton(BUTTON_WIDTH, BUTTON_HEIGHT) {
                Text = "make it so",
                Position = new Vector2(0.0f, 0.0f),
            //				Color = new Vector4(0.8980f, 0.0745f, 0.0745f, 1.0f)
            };
            ClearOKButton.background.RegisterPalette(1);

            this.AddChild(musicSlider);
            this.AddChild(effectsSlider);
            this.AddChild(stickySlider);
            this.AddChild(orbitSlider);
            this.AddChild(OKButton);
            this.AddChild(CancelButton);
            this.AddChild(ClearButton);
            this.AddChild(ClearPanel);

            ClearPanel.AddChild(ClearOKButton);
        }
        public override void OnExit()
        {
            OKButton.UnregisterPalette();
            ClearButton.UnregisterPalette();
            ClearOKButton.UnregisterPalette();
            CancelButton.UnregisterPalette();

            OKButton.ButtonUpAction -= HandleOKButtonButtonUpAction;
            ClearButton.ButtonUpAction -= HandleClearButtonButtonUpAction;
            ClearPanel.OnSlideInStart -= HandleClearPanelOnSlideInStart;;
            ClearPanel.OnSlideInComplete -= HandleClearPanelOnSlideInComplete;
            ClearPanel.OnSlideOutStart -= HandleClearPanelOnSlideOutStart;
            ClearPanel.OnSlideOutComplete -= HandleClearPanelOnSlideOutComplete;
            ClearOKButton.ButtonUpAction -= HandleClearOKButtonButtonUpAction;
            CancelButton.ButtonUpAction -= HandleCancelButtonButtonUpAction;

            base.OnExit ();
            stickySlider = null;
            orbitSlider = null;
            effectsSlider = null;
            musicSlider = null;
            OKButton = null;
            MenuSystem = null;
        }
        //        protected SpriteTile _cubeIcon;
        //        protected SpriteTile _scoreIcon;
        //        protected SpriteTile _timeIcon;
        // CONSTRUCTOR ------------------------------------------
        public InfiniteModeScreen(MenuSystemScene pMenuSystem)
        {
            MenuSystem = pMenuSystem;

            var map = Crystallography.UI.FontManager.Instance.GetMap( Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25, "Bold") );

            _bestCubes = _bestPoints = 0;
            _bestTime = 0.0f;

            _timeLimitText = new Label() {
                FontMap = map,
                Color = Colors.Black
            };
            //			_timeLimitText.RegisterPalette(0);
            this.AddChild(_timeLimitText);

            timeLimitSlider = new Slider(540) {
                Text = "time limit",
                Position = new Vector2(33.0f, 440.0f),
                max = 60.0f,
                min = 5.0f,
                discreteOptions = new List<float>() { 5.0f, 10.0f, 20.0f, 35.0f, 60.0f },
                OnChange = (unused) => {
                    if ( timeLimitSlider.Value != timeLimitSlider.max ) {
                        _timeLimitText.Text = timeLimitSlider.Value.ToString() + " minutes";
                        _bestTitleText.Text = _timeLimitText.Text;
                        if(_highScoreEntries != null) {
            //							_highScoreEntries[0].ShowBestTime(false);
                            _highScoreEntries[0].BestCubes = DataStorage.timedCubes[timeLimitSlider.SelectedOption,0,0];
                            _highScoreEntries[0].BestPoints = DataStorage.timedScores[timeLimitSlider.SelectedOption,0,1];
                        }
                    } else {
                        _timeLimitText.Text = "infinite";
                        if(_highScoreEntries != null) {
            //							_highScoreEntries[0].ShowBestTime(true);

                            _highScoreEntries[0].BestCubes = DataStorage.infiniteCubes[0,0];
                            _highScoreEntries[0].BestPoints = DataStorage.infiniteScores[0,1];
            //							_highScoreEntries[0].BestTime = DataStorage.infiniteTimes[0,2];
                        }
                    }
                }
            };
            timeLimitSlider.AddTickmarks();
            timeLimitSlider.RegisterPalette(2);
            timeLimitSlider.SetSliderValue( (float)DataStorage.options[4] );
            this.AddChild(timeLimitSlider);

            //			_timeLimitText.Position = new Vector2(timeLimitSlider.Position.X + timeLimitSlider.Length + 20.0f, timeLimitSlider.Position.Y);
            _timeLimitText.Position = new Vector2(timeLimitSlider.Position.X + 4.0f, timeLimitSlider.Position.Y - 41.0f);

            //			_fourthQualityText = new Label() {
            //				FontMap = map
            //			};
            //			_fourthQualityText.RegisterPalette(1);
            //			this.AddChild(_fourthQualityText);

            //			fourthQualitySlider = new Slider() {
            //				Text = "fourth quality",
            //				Position = new Vector2(timeLimitSlider.Position.X, timeLimitSlider.Position.Y - 100.0f),
            //				max = 2.0f,
            //				min = 0.0f,
            //				discreteOptions = new List<float>() { 0.0f, 1.0f, 2.0f },
            //				OnChange = (unused) => {
            //					switch(fourthQualitySlider.Value.ToString("#0.#")) {
            //					case("0"):
            //						_fourthQualityText.Text = "none";
            //						break;
            //					case("1"):
            //						_fourthQualityText.Text = "particles";
            //						break;
            //					case("2"):
            //						_fourthQualityText.Text = "sound";
            //						break;
            //					}
            //				}
            //			};
            //			fourthQualitySlider.AddTickmarks();
            //			fourthQualitySlider.RegisterPalette(1);
            //			fourthQualitySlider.SetSliderValue( 1.0f );
            ////			this.AddChild(fourthQualitySlider);
            //
            //			_fourthQualityText.Position = new Vector2(fourthQualitySlider.Position.X + fourthQualitySlider.Length + 20.0f, fourthQualitySlider.Position.Y);
            //
            _fourthQualityTitle = new Label() {
                Text = "bonus quality",
                FontMap = Crystallography.UI.FontManager.Instance.GetMap( Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 32, "Bold") ),
                Position = new Vector2(33.0f, 326.0f),
                Color = Colors.Black
            };
            this.AddChild(_fourthQualityTitle);

            _buttonHighlight = Support.UnicolorSprite("Black", 0,0,0,255);
            _buttonHighlight.Scale = new Vector2(10.8125f, 12.125f);
            this.AddChild(_buttonHighlight);

            _soundButton = new BetterButton(173.0f, 176.0f) {
                Text = "sound",
                TextFont = FontManager.Instance.GetInGame("Bariol", 25, "Bold"),
                Icon = Support.TiledSpriteFromFile("/Application/assets/images/icons/icons.png", 4, 2),
                IconAndTextOffset = new Vector2(31.0f, 17.0f),
                TextOffset = new Vector2(-58.0f, -50.0f),
                Position = new Vector2(33.0f, 109.0f)
            };
            _soundButton.Icon.TileIndex1D = 4;
            _soundButton.background.RegisterPalette(0);
            _soundButton.Icon.Color = LevelManager.Instance.BackgroundColor;
            this.AddChild(_soundButton);

            _particleButton = new BetterButton(173.0f, 176.0f) {
                Text = "particles",
                TextFont = FontManager.Instance.GetInGame("Bariol", 25, "Bold"),
                Icon = Support.TiledSpriteFromFile("/Application/assets/images/icons/icons.png", 4, 2),
                IconAndTextOffset = new Vector2(31.0f, 17.0f),
                TextOffset = new Vector2(-58.0f, -50.0f),
                Position = new Vector2(216.0f, 109.0f)
            };
            _particleButton.Icon.TileIndex1D = 2;
            _particleButton.background.RegisterPalette(1);
            _particleButton.Icon.Color = LevelManager.Instance.BackgroundColor;
            this.AddChild(_particleButton);

            _noneButton = new BetterButton(173.0f, 176.0f) {
                Text = "none",
                TextFont = FontManager.Instance.GetInGame("Bariol", 25, "Bold"),
                Icon = Support.TiledSpriteFromFile("/Application/assets/images/icons/icons.png", 4, 2),
                IconAndTextOffset = new Vector2(31.0f, 17.0f),
                TextOffset = new Vector2(-64.0f, -50.0f),
                Position = new Vector2(399.0f, 109.0f)
            };
            _noneButton.Icon.TileIndex1D = 6;
            _noneButton.background.RegisterPalette(2);
            this.AddChild(_noneButton);

            _instructionsButton = new BetterButton(362.0f, 62.0f) {
                Text = "instructions",
                Position = Vector2.Zero
            };
            _instructionsButton.background.RegisterPalette(2);
            this.AddChild(_instructionsButton);

            _bestBG = Support.UnicolorSprite("black", 0,0,0,255);
            _bestBG.Position = new Vector2(598.0f, 0.0f);
            _bestBG.Scale = new Vector2(22.625f, 34.0f);
            this.AddChild(_bestBG);

            _bestTitleText = new Label() {
                Text = _timeLimitText.Text,
                FontMap = Crystallography.UI.FontManager.Instance.GetMap( Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 32, "Bold") ),
                Position = new Vector2(_bestBG.Position.X + 41.0f, 465.0f)
            };
            //			_bestTitleText.RegisterPalette(2);
            _bestTitleText.Color = LevelManager.Instance.BackgroundColor;
            this.AddChild(_bestTitleText);

            _highScoreEntries = new HighScoreEntry[3];
            _highScoreEntries[0] = new HighScoreEntry() {
                BestCubes = DataStorage.infiniteCubes[0,0],
                BestPoints = DataStorage.infiniteCubes[0,1],
            //				BestTime = (float)DataStorage.infiniteCubes[0,2],
                Position = new Vector2(_bestTitleText.Position.X, _bestTitleText.Position.Y - 316.0f)
            };
            //			_highScoreEntries[1] = new HighScoreEntry() {
            //				BestCubes = DataStorage.infiniteScores[0,0],
            //				BestPoints = DataStorage.infiniteScores[0,1],
            //				BestTime = (float)DataStorage.infiniteScores[0,2],
            //				Position = new Vector2(_bestTitleText.Position.X, _bestTitleText.Position.Y - 120)
            //			};
            //			_highScoreEntries[2] = new HighScoreEntry() {
            //				BestCubes = DataStorage.infiniteTimes[0,0],
            //				BestPoints = DataStorage.infiniteTimes[0,1],
            //				BestTime = (float)DataStorage.infiniteTimes[0,2],
            //				Position = new Vector2(_bestTitleText.Position.X, _bestTitleText.Position.Y - 180)
            //			};
            //			for(int i=0; i<3; i++){
            //				this.AddChild(_highScoreEntries[i]);
            //			}
            this.AddChild(_highScoreEntries[0]);

            cancelButton = new BetterButton(362.0f, 62.0f) {
                Text = "main menu",
                Position = new Vector2(598.0f, 62.0f)
            };
            cancelButton.background.RegisterPalette(1);
            this.AddChild(cancelButton);

            playButton = new BetterButton(362.0f, 62.0f) {
                Text = "play",
                Position = new Vector2(598.0f, 0.0f)
            };
            playButton.background.RegisterPalette(0);
            this.AddChild(playButton);

            _instructionsPanel = new ChallengeModeInstructionsPanel();
            this.AddChild(_instructionsPanel);
        }
        // CONSTRUCTORS -----------------------------------------------------------------------------------------
        public MainMenuScreen(MenuSystemScene pMenuSystem)
        {
            MenuSystem = pMenuSystem;

            //			var bgcolor = Director.Instance.GL.Context.GetClearColor();
            var bgcolor = LevelManager.Instance.BackgroundColor;
            bgcolor.A = 1.0f;

            MenuBGTop = Support.SpriteFromFile("/Application/assets/images/UI/menuBtnBG_top.png");
            MenuBGTop.Position = new Vector2(351.0f, 436.0f);
            MenuBGTop.RegisterPalette(1);

            MaskBGTop = Support.UnicolorSprite("white", 255, 255, 255, 255);
            MaskBGTop.Color = bgcolor;
            MaskBGTop.Position = MenuBGTop.Position.Xy;
            MaskBGTop.Scale = new Vector2(16.0f, 4.875f);

            NewGameButton = new BetterButton(256.0f, 64.0f) {
                Text = "tutorial",
                Position = new Vector2(94.0f, 372.0f),
            };
            NewGameButton.background.RegisterPalette(1);

            MaskBGButton1 = Support.UnicolorSprite("white", 255, 255, 255, 255);
            MaskBGButton1.Color = bgcolor;
            MaskBGButton1.Position = NewGameButton.Position.Xy;
            MaskBGButton1.Scale = new Vector2(16.1f, 4.0f);

            MenuBGSpacer1 = Support.SpriteFromFile("/Application/assets/images/UI/menuBtnBG_blue2.png");
            MenuBGSpacer1.Position = new Vector2(351.0f, 285.0f);
            MenuBGSpacer1.FlipU = true;
            MenuBGSpacer1.RegisterPalette(2);

            MaskBGSpacer1 = Support.UnicolorSprite("white", 255, 255, 255, 255);
            MaskBGSpacer1.Color = bgcolor;
            MaskBGSpacer1.Position = MenuBGSpacer1.Position.Xy;
            MaskBGSpacer1.Scale = new Vector2(16.2f, 9.4375f);

            LevelSelectButton = new BetterButton(256.0f, 64.0f) {
                Text = "puzzle mode",
                Position = new Vector2(94.0f, 285.0f),
            //				Color = new Vector4(0.1608f, 0.8863f, 0.8863f, 1.0f)
            };
            LevelSelectButton.background.RegisterPalette(2);

            MaskBGButton2 = Support.UnicolorSprite("white", 255, 255, 255, 255);
            MaskBGButton2.Color = bgcolor;
            MaskBGButton2.Position = LevelSelectButton.Position.Xy;
            MaskBGButton2.Scale = new Vector2(16.1f, 4.0f);

            MenuBGSpacer2 = Support.SpriteFromFile("/Application/assets/images/UI/menuBtnBG_red2.png");
            MenuBGSpacer2.Position = new Vector2(351.0f, 198.0f);
            MenuBGSpacer2.FlipU = true;
            MenuBGSpacer2.RegisterPalette(1);

            MaskBGSpacer2 = Support.UnicolorSprite("white", 255, 255, 255, 255);
            MaskBGSpacer2.Color = bgcolor;;
            MaskBGSpacer2.Position = MenuBGSpacer2.Position.Xy;
            MaskBGSpacer2.Scale = new Vector2(16.2f, 9.4375f);

            InstructionsButton = new BetterButton(256.0f, 64.0f) {
                Text = "challenge mode",
                Position = new Vector2(94.0f, 198.0f),
            };
            InstructionsButton.background.RegisterPalette(1);

            MaskBGButton3 = Support.UnicolorSprite("white", 255, 255, 255, 255);
            MaskBGButton3.Color = bgcolor;
            MaskBGButton3.Position = InstructionsButton.Position.Xy;
            MaskBGButton3.Scale = new Vector2(16.1f, 4.0f);

            MenuBGSpacer3 = Support.SpriteFromFile("/Application/assets/images/UI/menuBtnBG_blue2.png");
            MenuBGSpacer3.Position = new Vector2(351.0f, 111.0f);
            MenuBGSpacer3.FlipU = true;
            MenuBGSpacer3.RegisterPalette(2);

            MaskBGSpacer3 = Support.UnicolorSprite("white", 255, 255, 255, 255);
            MaskBGSpacer3.Color = bgcolor;
            MaskBGSpacer3.Position = MenuBGSpacer3.Position.Xy;
            MaskBGSpacer3.Scale = new Vector2(16.2f, 9.4375f);

            CreditsButton = new BetterButton(256.0f, 64.0f) {
                Text = "options",
                Position = new Vector2(94.0f, 111.0f),
            //				Color = new Vector4(0.1608f, 0.8863f, 0.8863f, 1.0f)
            };
            CreditsButton.background.RegisterPalette(2);

            MaskBGButton4 = Support.UnicolorSprite("white", 255, 255, 255, 255);
            MaskBGButton4.Color = bgcolor;
            MaskBGButton4.Position = CreditsButton.Position.Xy;
            MaskBGButton4.Scale = new Vector2(16.1f, 4.0f);

            MenuBGBottom = Support.SpriteFromFile("/Application/assets/images/UI/menuBtnBG_bottom.png");
            MenuBGBottom.Position = new Vector2(351.0f, 32.0f);
            MenuBGBottom.RegisterPalette(1);

            MaskBGBottom = Support.UnicolorSprite("white", 255, 255, 255, 255);
            MaskBGBottom.Color = bgcolor;
            MaskBGBottom.Position = MenuBGBottom.Position.Xy;
            MaskBGBottom.Scale = new Vector2(16.0f, 4.9375f);

            this.AddChild(MenuBGBottom);
            this.AddChild(MaskBGBottom);
            this.AddChild(MenuBGSpacer3);
            this.AddChild(MaskBGSpacer3);
            this.AddChild(MenuBGSpacer2);
            this.AddChild(MaskBGSpacer2);
            this.AddChild(MenuBGSpacer1);
            this.AddChild(MaskBGSpacer1);
            this.AddChild(MenuBGTop);
            this.AddChild(MaskBGTop);
            this.AddChild(NewGameButton);
            this.AddChild(LevelSelectButton);
            this.AddChild(InstructionsButton);
            this.AddChild(CreditsButton);
            this.AddChild(MaskBGButton1);
            this.AddChild(MaskBGButton2);
            this.AddChild(MaskBGButton3);
            this.AddChild(MaskBGButton4);

            #if METRICS
            HoldTimer = 0.0f;

            PrintAnalyticsButton = new BetterButton(256.0f, 64.0f) {
                Text = "print metrics",
                Position = new Vector2(704.0f, 281.0f),
                Color = new Vector4(0.8980f, 0.0745f, 0.0745f, 1.0f),
                On = false
            }

            ClearAnalyticsButton = new BetterButton(256.0f, 64.0f) {
                Text = "clear metrics",
                Position = new Vector2(704.0f, 281.0f),
                Color = new Vector4(0.8980f, 0.0745f, 0.0745f, 1.0f),
                On = false
            }
            #endif
        }
 public override void OnExit()
 {
     base.OnExit ();
     NewGameButton.ButtonUpAction -= HandleNewGameButtonButtonUpAction;
     LevelSelectButton.ButtonUpAction -= HandleLevelSelectButtonButtonUpAction;
     CreditsButton.ButtonUpAction -= HandleCreditsButtonButtonUpAction;
     InstructionsButton.ButtonUpAction -= HandleInstructionsButtonButtonUpAction;
     #if METRICS
     PrintAnalyticsButton.ButtonUpAction -= HandlePrintAnalyticsButtonButtonUpAction;
     ClearAnalyticsButton.ButtonUpAction -= HandleClearAnalyticsButtonButtonUpAction;
     #endif
     this.RemoveAllChildren(true);
     MenuSystem = null;
     MenuBGBottom = null;
     MenuBGSpacer1 = null;
     MenuBGSpacer2 = null;
     MenuBGSpacer3 = null;
     MenuBGTop = null;
     MaskBGBottom = null;
     MaskBGButton1 = null;
     MaskBGButton2 = null;
     MaskBGButton3 = null;
     MaskBGButton4 = null;
     MaskBGSpacer1 = null;
     MaskBGSpacer2 = null;
     MaskBGSpacer3 = null;
     MaskBGTop = null;
     NewGameButton = null;
     LevelSelectButton = null;
     CreditsButton = null;
     InstructionsButton = null;
     RemoveAllAssets();
 }
        public override void OnExit()
        {
            BackButton.ButtonUpAction -= HandleBackButtonButtonUpAction;
            base.OnExit ();

            Panels.Clear();
            this.RemoveAllChildren(true);
            MenuSystem = null;
            this.SwipePanels = null;
            CreditsTitleText = null;
            BackButton = null;
        }
        // CONSTRUCTORS --------------------------------------------------------------------------------------------------------------------
        public CreditsScreen(MenuSystemScene pMenuSystem)
        {
            MenuSystem = pMenuSystem;

            Panels = new List<Node> {
                new CreditsPanel(),
                new ThanksPanel()
            };

            SwipePanels = new SwipePanels(Panels) {
                Position = new Vector2(44.0f, 88.0f)
            };
            this.AddChild(this.SwipePanels);

            foreach(Node panel in Panels) {
                this.AddChild(panel);
            }

            CreditsTitleText = new Label{
                Text = "credits",
                Position = new Vector2(36.0f, 444.0f),
                FontMap = Crystallography.UI.FontManager.Instance.GetMap( Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 72, "Regular") )
            };
            this.AddChild(CreditsTitleText);

            BackButton = new ButtonEntity("       back", MenuSystem, null, Support.TiledSpriteFromFile("Application/assets/images/blueBtn.png", 1, 3).TextureInfo, new Vector2i(0,0));
            BackButton.label.FontMap = Crystallography.UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 36, "Bold") );
            BackButton.setPosition(816.0f, 35.0f);
            this.AddChild(BackButton.getNode());
        }
        public override void OnExit()
        {
            BackButton.ButtonUpAction -= HandleBackButtonButtonUpAction;
            base.OnExit ();

            MenuSystem = null;
            //			InstructionsTitleText = null;
            BackButton = null;
            Panels.Clear();
            this.SwipePanels = null;
        }
        // CONSTRUCTORS ---------------------------------------------------------------------------------------------------------------------------
        public InstructionsScreen(MenuSystemScene pMenuSystem)
        {
            MenuSystem = pMenuSystem;

            Panels = new List<Node>{
                new InstructionsPage1(),
                new InstructionsPage2(),
                new InstructionsPage3(),
                new InstructionsPage4(),
                new InstructionsPage5(),
                new InstructionsPage8(),
                new InstructionsPage7()
            };

            this.SwipePanels = new SwipePanels(Panels) {
            //				Position = new Vector2(18.0f, 33.0f)
            };
            this.AddChild(this.SwipePanels);

            foreach (Node panel in Panels) {
                this.AddChild(panel);
            }

            BackButton = new ButtonEntity("       back", MenuSystem, null, Support.TiledSpriteFromFile("Application/assets/images/blueBtn.png", 1, 3).TextureInfo, new Vector2i(0,0));
            BackButton.label.FontMap = Crystallography.UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 36, "Bold") );
            BackButton.setPosition(816.0f, 35.0f);
            this.AddChild(BackButton.getNode());
        }