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;
        }
        // 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);
        }
        //        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);
        }