public CommandCenterRightButton(Game game, Sprite sprite, int drawOrder)
            : base(game)
        {
            ButtonSprite = sprite;

            ButtonSprite.XRelative = 0;
            ButtonSprite.YRelative = 0;

            this.StackOrder = drawOrder;

            spriteText = new SpriteText(game, FontsCollection.GetPack("Calibri 8").Font);
            spriteText.Text = "";
            spriteText.XRelative = 0;
            spriteText.YRelative = 0;
            spriteText.Tint = MouseLeaveColor;
            spriteText.StackOrder = drawOrder + 1;

            AddChild(ButtonSprite);
            AddChild(spriteText);
        }
        public ConstructionPanel(Game game, BaseConstruction construction)
            : base(game)
        {
            frame = new Sprite(game, GraphicsCollection.GetPack("construction-panel-frame"));
            frame.StackOrder = 1;
            AddChild(frame);

            selectedConstruction = construction;

            if (Destroyable())
            {
                destroy = new ConstructionPanelButton(game, ConstructionPanelButtonType.Destroy);
                destroy.StackOrder = 2;
                destroy.XRelative = buttonsXposition;
                destroy.YRelative = 45;
                destroy.OnMouseRelease += new EventHandler<Operation_Cronos.Input.MouseEventArgs>(destroy_OnMouseRelease);
                destroy.OnMouseOver += new EventHandler<ButtonEventArgs>(Button_OnMouseOver);
                destroy.OnMouseLeave += new EventHandler<ButtonEventArgs>(Button_OnMouseLeave);
                AddChild(destroy);
            }

            if (GeneralConstructionUpgradeable())
            {
                upgrade = new ConstructionPanelButton(game, ConstructionPanelButtonType.Upgrade);
                upgrade.StackOrder = 2;
                upgrade.XRelative = buttonsXposition;
                upgrade.YRelative = 173;
                upgrade.OnMouseRelease += new EventHandler<Operation_Cronos.Input.MouseEventArgs>(upgrade_OnMouseRelease);
                upgrade.OnMouseOver += new EventHandler<ButtonEventArgs>(Button_OnMouseOver);
                upgrade.OnMouseLeave += new EventHandler<ButtonEventArgs>(Button_OnMouseLeave);
                AddChild(upgrade);

                textUpgradeCost = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font);
                textUpgradeCost.StackOrder = 2;
                textUpgradeCost.XRelative = 95;
                textUpgradeCost.YRelative = 225;
                textUpgradeCost.Tint = Color.Green;
                textUpgradeCost.Text = GetUpgradeText() + GetUpgradeCost().ToString();
                AddChild(textUpgradeCost);
            }

            if (PopulationConstructionUpgradeable())
            {
                upgrade = new ConstructionPanelButton(game, ConstructionPanelButtonType.Upgrade);
                upgrade.StackOrder = 2;
                upgrade.XRelative = buttonsXposition;
                upgrade.YRelative = 173;
                upgrade.OnMousePress += new EventHandler<Operation_Cronos.Input.MouseEventArgs>(upgrade_OnMouseRelease);
                upgrade.OnMouseOver += new EventHandler<ButtonEventArgs>(Button_OnMouseOver);
                upgrade.OnMouseLeave += new EventHandler<ButtonEventArgs>(Button_OnMouseLeave);
                AddChild(upgrade);

                textUpgradeCost = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font);
                textUpgradeCost.XRelative = 95;
                textUpgradeCost.YRelative = 225;
                textUpgradeCost.StackOrder = 2;
                textUpgradeCost.Tint = Color.Green;
                textUpgradeCost.Text = GetUpgradeText() + GetUpgradeCost().ToString();
                AddChild(textUpgradeCost);
            }

            if (Repairable())
            {
                repair = new ConstructionPanelButton(game, ConstructionPanelButtonType.Repair);
                repair.StackOrder = 2;
                repair.XRelative = buttonsXposition;
                repair.YRelative = 108;
                repair.OnMouseRelease += new EventHandler<Operation_Cronos.Input.MouseEventArgs>(repair_OnMouseRelease);
                repair.OnMouseOver += new EventHandler<ButtonEventArgs>(Button_OnMouseOver);
                repair.OnMouseLeave += new EventHandler<ButtonEventArgs>(Button_OnMouseLeave);
                AddChild(repair);

                textRepairCost = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font);
                textRepairCost.XRelative = 323;
                textRepairCost.YRelative = 225;
                textRepairCost.StackOrder = 2;
                textRepairCost.Tint = Color.Green;
                textRepairCost.Text = "Repair price: " + GetRepairCost().ToString();
                AddChild(textRepairCost);
            }
            else //not repairable
            {
                if (AlreadyRepairedInCurrentYear())
                {
                    textRepairCost = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font);
                    textRepairCost.XRelative = 323;
                    textRepairCost.YRelative = 225;
                    textRepairCost.Tint = Color.Green;
                    textRepairCost.StackOrder = 2;
                    textRepairCost.Text = "Repaired this year";
                    AddChild(textRepairCost);
                }
            }

            close = new ConstructionPanelButton(game, ConstructionPanelButtonType.Close);
            close.StackOrder = 2;
            close.XRelative = 430;
            close.YRelative = 7;
            close.OnMouseRelease += new EventHandler<Operation_Cronos.Input.MouseEventArgs>(close_OnMouseRelease);
            AddChild(close);

            textBuildingNameAndStage = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font);
            textBuildingNameAndStage.XRelative = 95;
            textBuildingNameAndStage.YRelative = 20;
            textBuildingNameAndStage.Tint = Color.Gray;
            textBuildingNameAndStage.StackOrder = 2;
            textBuildingNameAndStage.Text = GetDescriptionFromEnum(selectedConstruction.ConstructionName, 0);
            if (selectedConstruction.ConstructionType != ConstructionType.Population)
                textBuildingNameAndStage.Text += "  -  " + GetDescriptionFromEnum((selectedConstruction.Slot.GetReservation(GameManager.CurrentYear).Status(GameManager.CurrentYear)), 0);
            AddChild(textBuildingNameAndStage);

            textGeneralInfo = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font);
            textGeneralInfo.XRelative = 95;
            textGeneralInfo.YRelative = 60;
            textGeneralInfo.StackOrder = 2;
            textGeneralInfo.Tint = Color.White;
            textGeneralInfo.Text = GetConstructionYear() + "\n" + GetLifetimeLeft() + "\n" + GetConstructionParameters();
            AddChild(textGeneralInfo);

            selectedConstruction.SelectConstruction = true;

            if (selectedConstruction.ConstructionType == ConstructionType.Education ||
                 selectedConstruction.ConstructionType == ConstructionType.Health ||
                 selectedConstruction.ConstructionType == ConstructionType.Population ||
                 selectedConstruction.ConstructionType == ConstructionType.Energy)
                SoundManager.PlaySound((Sounds)Enum.Parse(typeof(Sounds), selectedConstruction.ConstructionType.ToString()));
            else
                SoundManager.PlaySound((Sounds)Enum.Parse(typeof(Sounds), selectedConstruction.ConstructionName.ToString()));
        }
        public CommandCenterOptionsPanel(Game game, int DrawOrder): base(game)
        {
            graphicsCollection = (GraphicsCollection)Game.Services.GetService(typeof(GraphicsCollection));
            generalButtons = new List<List<CommandCenterGeneralButton>>();
            sublistGame = new List<CommandCenterGeneralButton>();
            sublistVideo = new List<CommandCenterGeneralButton>();
            sublistAudio = new List<CommandCenterGeneralButton>();
            sublistControls = new List<CommandCenterGeneralButton>();


            //------------------------------
            //--Setting Default Options (will be used when initializing objects, in the next instructions)
            DefaultOptions = new CommandCenterEventArgs(1);
            //everything is set to a GENERAL default
            //------------------------------


            //---SaveSettings Options Button-----
            btnSaveOptions = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("SaveOptions")), DrawOrder);
            btnSaveOptions.Position = new Point(390, 675);
            btnSaveOptions.OnPress +=new EventHandler<ButtonEventArgs>(Do_SaveOptionsPress);
            btnSaveOptions.OnRelease += new EventHandler<ButtonEventArgs>(Do_SaveOptionsRelease);
            AddChild(btnSaveOptions);
            //---------------------------

            //-----Primary Buttons-------
            btnGame = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Options_Game")), DrawOrder);
            btnGame.Position = new Point(70, 150);
            btnGame.OnPress += new EventHandler<ButtonEventArgs>(Do_GeneralBtnPressed);
            btnGame.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_GeneralBtnMouseOver);
            btnGame.OnMouseLeave+= new EventHandler<ButtonEventArgs>(Do_GeneralBtnMouseLeave);
            AddChild(btnGame);            
            sublistGame.Add(btnGame);

            btnVideo = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Options_Video")), DrawOrder);
            btnVideo.Position = new Point(70, 300);
            btnVideo.OnPress += new EventHandler<ButtonEventArgs>(Do_GeneralBtnPressed);
            btnVideo.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_GeneralBtnMouseOver);
            btnVideo.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_GeneralBtnMouseLeave);
            AddChild(btnVideo);
            sublistVideo.Add(btnVideo);

            btnAudio = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Options_Audio")), DrawOrder);
            btnAudio.Position = new Point(70, 440);
            btnAudio.OnPress += new EventHandler<ButtonEventArgs>(Do_GeneralBtnPressed);
            btnAudio.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_GeneralBtnMouseOver);
            btnAudio.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_GeneralBtnMouseLeave);
            AddChild(btnAudio);
            sublistAudio.Add(btnAudio);

            btnControls = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Options_Controls")), DrawOrder);
            btnControls.Position = new Point(70, 580);
            btnControls.OnPress += new EventHandler<ButtonEventArgs>(Do_GeneralBtnPressed);
            btnControls.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_GeneralBtnMouseOver);
            btnControls.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_GeneralBtnMouseLeave);
            AddChild(btnControls);
            sublistControls.Add(btnControls);

            //---GAME Submenu Buttons-------
            btnGame_SaveGame = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("SaveGame")), DrawOrder);
            btnGame_SaveGame.Position = new Point(260, 128);
            btnGame_SaveGame.OnPress += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnPressed);
            btnGame_SaveGame.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseOver);
            btnGame_SaveGame.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseLeave);
            AddChild(btnGame_SaveGame);
            sublistGame.Add(btnGame_SaveGame);

            btnGame_Difficulty = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Difficulty")), DrawOrder);
            btnGame_Difficulty.Position = new Point(260, 181);
            btnGame_Difficulty.OnPress += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnPressed);
            btnGame_Difficulty.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseOver);
            btnGame_Difficulty.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseLeave);
            AddChild(btnGame_Difficulty);
            sublistGame.Add(btnGame_Difficulty);

                //---Submenu button SaveGame Options-----
            btnSave = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("SaveBtn")), DrawOrder);
            btnSave.Position = new Point(454,126);
            btnSave.OnRelease += new EventHandler<ButtonEventArgs>(Do_BtnSaveMouseRelease);
            AddChild(btnSave);

            AutosaveSprite = new Sprite(game, graphicsCollection.GetPack("Autosave"));
            AutosaveSprite.StackOrder = DrawOrder;
            AutosaveSprite.XRelative = 567;
            AutosaveSprite.YRelative = 133;
            AddChild(AutosaveSprite);

            positions = new int [6]{746,127,705,127,820,127};
            AutosaveScrollbar = new Scrollbar(game, new Sprite(game, graphicsCollection.GetPack("AutosaveTimeDisplay")), new Sprite(Game, graphicsCollection.GetPack("ScrollBarLeftArrow")), new Sprite(Game, graphicsCollection.GetPack("ScrollBarRightArrow")), DrawOrder, positions);
            AutosaveScrollbar.OnScrollUp+=new EventHandler(Do_AutosaveScrollbar_LeftScroll);
            AutosaveScrollbar.OnScrollDown += new EventHandler(Do_AutosaveScrollbar_RightScroll);
            AddChild(AutosaveScrollbar);

            AutosaveTime = new SpriteText(game, FontsCollection.GetPack("Courier New 10").Font);
            AutosaveTime.XRelative = 754;
            AutosaveTime.YRelative = 133;
            TimeValueIndexSelected = DefaultOptions.TimeValueIndex;//by default, autosave every 30 min
            AutosaveTime.Text = TimeValues[TimeValueIndexSelected].ToString() + " min";
            AutosaveTime.Tint = Color.LightGray;
            AddChild(AutosaveTime);

            DefaultOptions.AutosaveTimeValue = TimeValues[TimeValueIndexSelected];
                //---------------------------------------


                //---Submenu button Difficulty Options---
            positions = new int[4] { 443, 185, 508, 180 };
            rbnEasy = new RadioButton(game, new Sprite(game, graphicsCollection.GetPack("Diff_Easy")), new Sprite(Game, graphicsCollection.GetPack("Checkbox")), DrawOrder, positions);
            rbnEasy.AllowDirectUncheck = false;
            rbnEasy.OnCheck += new EventHandler(Do_DifficultyRadioChecked);
            rbnEasy.Name = "Easy";
            AddChild(rbnEasy);
            DifficultyRadioGroup.Add(rbnEasy);

            positions = new int[4] { 558, 185, 651, 180 };
            rbnMedium = new RadioButton(game, new Sprite(game, graphicsCollection.GetPack("Diff_Medium")), new Sprite(Game, graphicsCollection.GetPack("Checkbox")), DrawOrder, positions);
            rbnMedium.AllowDirectUncheck = false;
            rbnMedium.OnCheck += new EventHandler(Do_DifficultyRadioChecked);
            rbnMedium.Name = "Medium";
            AddChild(rbnMedium);
            DifficultyRadioGroup.Add(rbnMedium);

            positions = new int[4] { 703, 185, 773, 180 };
            rbnHard = new RadioButton(game, new Sprite(game, graphicsCollection.GetPack("Diff_Hard")), new Sprite(Game, graphicsCollection.GetPack("Checkbox")), DrawOrder, positions); ;
            rbnHard.AllowDirectUncheck = false;
            rbnHard.OnCheck += new EventHandler(Do_DifficultyRadioChecked);
            rbnHard.Name = "Hard";
            AddChild(rbnHard);
            DifficultyRadioGroup.Add(rbnHard);
                        
            DifficultyLevelCurrentlySelected = DefaultOptions.DifficultyLevel;
            switch (DifficultyLevelCurrentlySelected)
            {
                case "Easy":
                    rbnEasy.Check();
                    break;
                case "Medium":
                    rbnMedium.Check();
                    break;
                case "Hard":
                    rbnHard.Check();
                    break;
                default:
                    rbnEasy.Check();
                    break;
            }
                //---------------------------------------

            //------------------------------


            //---VIDEO Submenu Buttons------
            btnVideo_Resolution = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Resolution")), DrawOrder);
            btnVideo_Resolution.Position = new Point(260, 276);
            btnVideo_Resolution.OnPress += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnPressed);
            btnVideo_Resolution.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseOver);
            btnVideo_Resolution.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseLeave);
            AddChild(btnVideo_Resolution);
            sublistVideo.Add(btnVideo_Resolution);

            btnVideo_FullScreen = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("FullScreen")), DrawOrder);
            btnVideo_FullScreen.Position = new Point(260, 326);
            btnVideo_FullScreen.OnPress += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnPressed);
            btnVideo_FullScreen.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseOver);
            btnVideo_FullScreen.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseLeave);
            AddChild(btnVideo_FullScreen);
            sublistVideo.Add(btnVideo_FullScreen);

                //---Submenu button ResolutionIndex Options-------
            Resolution = new SpriteText(Game, FontsCollection.GetPack("Courier New 10").Font);
            Resolution.XRelative = 617;
            Resolution.YRelative = 280;
            Resolution.Tint = Color.LightGray;
            
            ResolutionValueIndexSelected = DefaultOptions.ResolutionIndex;
            DefaultOptions.ResolutionValue = ResolutionValues[ResolutionValueIndexSelected];

            Resolution.Text = ResolutionValues[ResolutionValueIndexSelected].X.ToString() + " X " + ResolutionValues[ResolutionValueIndexSelected].Y.ToString();
            AddChild(Resolution);

            positions = new int[6] { 592, 275, 550, 275, 738, 275 };
            ResolutionIndicator = new Scrollbar(game, new Sprite(game, graphicsCollection.GetPack("ResolutionDisplay")), new Sprite(Game, graphicsCollection.GetPack("ScrollBarLeftArrow")), new Sprite(Game, graphicsCollection.GetPack("ScrollBarRightArrow")), DrawOrder, positions);        
            ResolutionIndicator.OnScrollUp += new EventHandler(Do_ResolutionIndicator_LeftScroll);
            ResolutionIndicator.OnScrollDown += new EventHandler(Do_ResolutionIndicator_RightScroll);
            AddChild(ResolutionIndicator);
                //------------------------------

                //---Submenu button FullScreen Options-------
            positions = new int[4] {465, 330, 505, 322};
            rbnFullScreenOn = new RadioButton(game, new Sprite(game, graphicsCollection.GetPack("On")), new Sprite(Game, graphicsCollection.GetPack("Checkbox")), DrawOrder, positions);
            rbnFullScreenOn.AllowDirectUncheck = false;
            rbnFullScreenOn.OnCheck +=new EventHandler(Do_FullScreenRadioOnChecked);
            AddChild(rbnFullScreenOn);

            positions = new int[4] {575, 330, 625, 322 };
            rbnFullScreenOff = new RadioButton(game, new Sprite(game, graphicsCollection.GetPack("Off")), new Sprite(Game, graphicsCollection.GetPack("Checkbox")), DrawOrder, positions);
            rbnFullScreenOff.AllowDirectUncheck = false;
            rbnFullScreenOff.OnCheck += new EventHandler(Do_FullScreenRadioOffChecked);
            AddChild(rbnFullScreenOff);

            FullScreenCurrentState = DefaultOptions.FullScreen;//"Off" by default;
            switch (FullScreenCurrentState)
            {
                case "On":
                    rbnFullScreenOn.Check();
                    break;
                case "Off":
                    rbnFullScreenOff.Check();
                    break;
                default:
                    rbnFullScreenOff.Check();
                    break;
            }
                //------------------------------

            //------------------------------


            //---AUDIO Submenu Buttons------
            btnAudio_Volume = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Volume")), DrawOrder);
            btnAudio_Volume.Position = new Point(260, 411);
            btnAudio_Volume.OnPress += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnPressed);
            btnAudio_Volume.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseOver);
            btnAudio_Volume.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseLeave);
            AddChild(btnAudio_Volume);
            sublistAudio.Add(btnAudio_Volume);

            btnAudio_Sound = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Sound")), DrawOrder);
            btnAudio_Sound.Position = new Point(260, 461);
            btnAudio_Sound.OnPress += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnPressed);
            btnAudio_Sound.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseOver);
            btnAudio_Sound.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseLeave);
            AddChild(btnAudio_Sound);
            sublistAudio.Add(btnAudio_Sound);

                //---Submenu button Volume Options-------
            VolumeValueSprite = new Sprite(game, graphicsCollection.GetPack("Increment"));
            VolumeValueSprite.StackOrder = DrawOrder;
            VolumeValueSprite.XRelative = 457;
            VolumeValueSprite.YRelative = 417;
            VolumeValueSprite.FrameNumber = DefaultOptions.VolumeValue;//0 by default
            AddChild(VolumeValueSprite);

            positions = new int[6] {450, 410, 410, 410, 545, 410 };
            VolumeIndicator = new Scrollbar(game, new Sprite(game, graphicsCollection.GetPack("PlusMinusDisplay")), new Sprite(Game, graphicsCollection.GetPack("Minus")), new Sprite(Game, graphicsCollection.GetPack("Plus")), DrawOrder, positions);
            VolumeIndicator.OnScrollUp += new EventHandler(Do_VolumeIndicatorLeftScroll);
            VolumeIndicator.OnScrollDown += new EventHandler(Do_VolumeIndicatorRightScroll);
            AddChild(VolumeIndicator);
                //---------------------------------------

                //---Submenu button Sound Options-------
            positions = new int[4] { 395, 465, 435, 459 };
            rbnSoundOn = new RadioButton(game, new Sprite(game, graphicsCollection.GetPack("On")), new Sprite(Game, graphicsCollection.GetPack("Checkbox")), DrawOrder, positions);
            rbnSoundOn.AllowDirectUncheck = false;
            rbnSoundOn.OnCheck +=new EventHandler(Do_SoundRadioOnChecked);
            AddChild(rbnSoundOn);

            positions = new int[4] { 507, 465, 557, 459 };
            rbnSoundOff = new RadioButton(game, new Sprite(game, graphicsCollection.GetPack("Off")), new Sprite(Game, graphicsCollection.GetPack("Checkbox")), DrawOrder, positions);
            rbnSoundOff.AllowDirectUncheck = false;
            rbnSoundOff.OnCheck += new EventHandler(Do_SoundRadioOffChecked);
            AddChild(rbnSoundOff);

            rbnSoundOn.Check();
            SoundCurrentState = DefaultOptions.SoundState;//"On" by default
            switch (SoundCurrentState)
            {
                case "On":
                    rbnSoundOn.Check();
                    break;
                case "Off":
                    rbnSoundOff.Check();
                    break;
                default:
                    rbnSoundOn.Check();
                    break;
            }
                //------------------------------

            //------------------------------


            //---CONTROLS Submenu Buttons---
            btnControls_Mouse = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("MouseOptions")), DrawOrder);
            btnControls_Mouse.Position = new Point(260, 546);
            btnControls_Mouse.OnPress += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnPressed);
            btnControls_Mouse.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseOver);
            btnControls_Mouse.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseLeave);
            AddChild(btnControls_Mouse);
            sublistControls.Add(btnControls_Mouse);

            btnControls_Keyboard = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("KeyboardOptions")), DrawOrder);
            btnControls_Keyboard.Position = new Point(260, 601);
            btnControls_Keyboard.OnPress += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnPressed);
            btnControls_Keyboard.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseOver);
            btnControls_Keyboard.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseLeave);
            AddChild(btnControls_Keyboard);
            sublistControls.Add(btnControls_Keyboard);

                //---Submenu button CameraSpeed Options-----
            CameraSpeedSprite = new Sprite(game, graphicsCollection.GetPack("CameraSpeed"));
            CameraSpeedSprite.XRelative = 400;
            CameraSpeedSprite.YRelative = 550;
            AddChild(CameraSpeedSprite);

            CameraSpeedValueSprite = new Sprite(game, graphicsCollection.GetPack("Increment"));
            CameraSpeedValueSprite.XRelative = 637;
            CameraSpeedValueSprite.YRelative = 550;
            CameraSpeedValueSprite.FrameNumber = DefaultOptions.CameraSpeed;//0 by default
            AddChild(CameraSpeedValueSprite);

            positions = new int[6] { 630, 543, 590, 543, 727, 543 };
            CameraSpeedIndicator = new Scrollbar(game, new Sprite(game, graphicsCollection.GetPack("PlusMinusDisplay")), new Sprite(Game, graphicsCollection.GetPack("Minus")), new Sprite(Game, graphicsCollection.GetPack("Plus")), DrawOrder, positions);
            CameraSpeedIndicator.OnScrollUp += new EventHandler(Do_CameraSpeedIndicator_LeftScroll);
            CameraSpeedIndicator.OnScrollDown += new EventHandler(Do_CameraSpeedIndicator_RightScroll);
            AddChild(CameraSpeedIndicator);
                //---------------------------------------

                //---Submenu button KeyShortcuts Options-----
            btnKeyShortcuts = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("KeyShortcuts")), DrawOrder);
            btnKeyShortcuts.Position = new Point(440, 600);
            btnKeyShortcuts.OnMousePress += new EventHandler<MouseEventArgs>(Do_BtnKeyShortcutsPressed);
            btnKeyShortcuts.OnMouseRelease += new EventHandler<MouseEventArgs>(Do_BtnKeyShortcutsReleased);
            AddChild(btnKeyShortcuts);

            KeyShortcutsPanel = new Sprite(game, graphicsCollection.GetPack("KeyShortcutsPanel"));
            KeyShortcutsPanel.XRelative = 52;
            KeyShortcutsPanel.YRelative = 125;
            KeyShortcutsPanel.StackOrder = DrawOrder + 2;
            KeyShortcutsPanel.Enabled = false;
            AddChild(KeyShortcutsPanel);

            btnKeyShortcutsPanel_Back = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("btnKeyShortcutsPanel_Back")), DrawOrder+3);
            btnKeyShortcutsPanel_Back.Position = new Point(855, 150);
            btnKeyShortcutsPanel_Back.OnMouseRelease += new EventHandler<MouseEventArgs>(Do_BtnKeyShortcutsPanel_BackReleased);
            btnKeyShortcutsPanel_Back.Enabled = false;
            AddChild(btnKeyShortcutsPanel_Back);
                //---------------------------------------

            //------------------------------

            //------------------------------
            //--Saving/Setting LastSave Options (which are the Default values, at this point)
            TimeValueIndexSelected_LastSave = TimeValueIndexSelected;
           
            if (rbnEasy.IsChecked)
                DifficultyLevel_LastSave = rbnEasy.Name; 
            else
                if (rbnMedium.IsChecked)
                    DifficultyLevel_LastSave = rbnMedium.Name;
                else
                    DifficultyLevel_LastSave = rbnHard.Name;

            ResolutionValueIndexSelected_LastSave = ResolutionValueIndexSelected;

            if (rbnFullScreenOn.IsChecked)
                FullScreenState_LastSave = "On";
            else
                FullScreenState_LastSave = "Off";

            VolumeValue_LastSave = VolumeValueSprite.FrameNumber;

            if (rbnSoundOn.IsChecked)
                SoundState_LastSave = "On";
            else
                SoundState_LastSave = "Off";

            CameraSpeed_LastState = CameraSpeedValueSprite.FrameNumber;
            //------------------------------

            generalButtons.Add(sublistGame);
            generalButtons.Add(sublistVideo);
            generalButtons.Add(sublistAudio);
            generalButtons.Add(sublistControls);

            this.StackOrder = DrawOrder;
        }
Пример #4
0
        public MainMenuInputBox(Game game, Sprite Background, Sprite Cursor,int DrawOrder,int[] position)
            : base(game)
        {
            VerticalPadding = 5;
            SidePadding = 5;

            background = Background;
            background.X = position[0];
            background.Y = position[1];
            background.XRelative = position[0];
            background.YRelative = position[1];
            background.Width = position[2];
            background.DrawOrder = DrawOrder;
            background.Tint = Color.Black;


            //adaptation for classes of the main menu, for they do not derive from VisualComponent
            textFont = ((FontsCollection)Game.Services.GetService(typeof(FontsCollection))).GetPack("MainMenu").Font;  
            //textFont = Game.Content.LoadSettings<SpriteFont>("MainMenu"); old loading version  
            //-----------------------------------             
            text = new SpriteText(game, textFont);
            text.DrawOrder = DrawOrder + 3;
            text.X = background.X + SidePadding;
            text.Y = background.Y + VerticalPadding;
            text.XRelative = background.XRelative + SidePadding;
            text.YRelative = background.YRelative + VerticalPadding;
            TextColor = Color.MediumSeaGreen;
            MaxLength = 18;

            //text used only for initialization, needed to measure text height
            text.Text = "Init";

            Height = text.Height + 2 * VerticalPadding;

            cursor = Cursor;
            cursor.Tint = Color.Chartreuse;
            cursor.Height = text.Height;
            cursor.Width = 2;
            cursor.Y = background.Y+VerticalPadding;
            cursor.X = background.X+SidePadding;
            cursor.YRelative = background.YRelative + VerticalPadding;
            cursor.XRelative = background.XRelative + SidePadding;
            cursor.DrawOrder = DrawOrder + 1;
            cursor.AnimationSpeed = 10;
            cursor.Visible = false;
            cursor.OnFirstFrame += new EventHandler(cursor_OnFirstFrame);            
            
            messageFont = ((FontsCollection)Game.Services.GetService(typeof(FontsCollection))).GetPack("MainMenuNewUserMessage").Font;  
            //messageFont = Game.Content.LoadSettings<SpriteFont>("MainMenuNewUserMessage"); old loading version        
            message = new SpriteText(game, messageFont);
            message.DrawOrder = DrawOrder + 3;
            message.X = background.X + SidePadding;
            message.Y = background.Y + VerticalPadding + Height;
            message.XRelative = background.XRelative + SidePadding;
            message.YRelative = background.YRelative + VerticalPadding + Height;
            message.Tint = Color.Chartreuse;
            message.Text = "Init";
                                   
            Components.Add(background);
            Components.Add(cursor);
            Components.Add(text);

            text.Text = String.Empty;
            Select();
        }
Пример #5
0
        void InitialState()
        {
            //if unspecified, for Sprites, X and Y coordinates are 0 by default
            ImagineStatica = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("ImagineStatica")].Frames);
            ImagineStatica.DrawOrder = drawOrder_ImagineStatica;

            AnimatieVentilatoare = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("AnimatieVentilatoare")].Frames);
            AnimatieVentilatoare.AnimationSpeed = speed_AnimatieVentilatoare;
            AnimatieVentilatoare.GenerateEvents = false; //preloaderSprite will run continuously
            AnimatieVentilatoare.X = 233;
            AnimatieVentilatoare.Y = 163;
            AnimatieVentilatoare.DrawOrder = drawOrder_AnimatieVentilatoare;
            SoundManager.PlaySound(Sounds.MainMenuVents);

            AnimatieStalpDreapta = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("AnimatieStalpDreapta")].Frames);
            AnimatieStalpDreapta.FrameNumber = 5;
            AnimatieStalpDreapta.X = 593;
            AnimatieStalpDreapta.Y = 179;
            AnimatieStalpDreapta.DrawOrder = drawOrder_AnimatieStalpDreapta;

            Portal = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("Portal")].Frames);
            Portal.FrameNumber = 0;
            Portal.X = 240;
            Portal.Y = 93;
            Portal.DrawOrder = drawOrder_Portal;

            AnimatieStalpStanga = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("AnimatieStalpStanga")].Frames);
            AnimatieStalpStanga.FrameNumber = 5;
            AnimatieStalpStanga.X = 43;
            AnimatieStalpStanga.Y = 187;
            AnimatieStalpStanga.DrawOrder = drawOrder_AnimatieStalpStanga;

            AnimatieBrateRobotice = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("AnimatieBrateRobotice")].Frames);
            AnimatieBrateRobotice.FrameNumber = 25;
            AnimatieBrateRobotice.FrameOfInterest = 5;
            AnimatieBrateRobotice.GenerateFrameOfInterestEvent = true;//will generate Event on frame 5
            AnimatieBrateRobotice.X = 175;
            AnimatieBrateRobotice.Y = 0;
            AnimatieBrateRobotice.DrawOrder = drawOrder_AnimatieBrateRobotice;

            AnimatieScari = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("AnimatieScari")].Frames);
            AnimatieScari.FrameNumber = 0;
            AnimatieScari.X = 410;
            AnimatieScari.Y = 420;
            AnimatieScari.DrawOrder = drawOrder_AnimatieScari;

            AnimatieMonitoareSecundare = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("AnimatieMonitoareSecundare")].Frames);
            AnimatieMonitoareSecundare.FrameNumber = 0;
            AnimatieMonitoareSecundare.X = 185;
            AnimatieMonitoareSecundare.Y = 511;
            AnimatieMonitoareSecundare.DrawOrder = drawOrder_AnimatieMonitoareSecundare;

            monitor_4 = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("monitor_4")].Frames);
            monitor_4.FrameNumber = 0;
            monitor_4.X = 285;
            monitor_4.Y = 571;
            monitor_4.DrawOrder = drawOrder_monitors;

            MonitorPrincipal = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MonitorPrincipal")].Frames);
            MonitorPrincipal.X = 583;
            MonitorPrincipal.Y = 498;
            MonitorPrincipal.DrawOrder = drawOrder_MonitorPrincipal;

            Slot_1 = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("Slot_1")].Frames);
            Slot_1.DrawOrder = drawOrder_Slots;
            Slot_1.X = 478;
            Slot_1.Y = 560;
            Slot_2 = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("Slot_2")].Frames);
            Slot_2.DrawOrder = drawOrder_Slots;
            Slot_2.X = 481;
            Slot_2.Y = 615;
            Slot_3 = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("Slot_3")].Frames);
            Slot_3.DrawOrder = drawOrder_Slots;
            Slot_3.X = 483;
            Slot_3.Y = 668;

            int[] positions = new int[6] { 681, 560, 645, 565, 873, 560 };
            btnNewGame = new MainMenuButton(Game, new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("NewGame")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOffLeft")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOffRight")].Frames), drawOrder_Buttons, positions);
            btnNewGame.OnMouseOver += new EventHandler(Do_NewGameMouseOver);
            btnNewGame.OnMouseLeave += new EventHandler(Do_NewGameMouseLeave);
            btnNewGame.OnMouseClick += new EventHandler(Do_NewGameMouseClick);

            positions = new int[6] { 672, 598, 646, 603, 872, 598 };
            btnLoadGame = new MainMenuButton(Game, new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("LoadGame")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOffLeft")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOffRight")].Frames), drawOrder_Buttons, positions);
            btnLoadGame.OnMouseOver += new EventHandler(Do_LoadGameMouseOver);
            btnLoadGame.OnMouseLeave += new EventHandler(Do_LoadGameMouseLeave);
            btnLoadGame.OnMouseClick += new EventHandler(Do_LoadGameMouseClick);

            positions = new int[6] { 695, 636, 647, 641, 871, 636 };
            btnCredits = new MainMenuButton(Game, new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("Credits")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOffLeft")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOffRight")].Frames), drawOrder_Buttons, positions);
            btnCredits.OnMouseOver += new EventHandler(Do_CreditsMouseOver);
            btnCredits.OnMouseLeave += new EventHandler(Do_CreditsMouseLeave);
            btnCredits.OnMouseClick += new EventHandler(Launch_CreditsEvent);

            positions = new int[6] { 730, 674, 648, 679, 870, 674 };
            btnExit = new MainMenuButton(Game, new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("Exit")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOffLeft")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOffRight")].Frames), drawOrder_Buttons, positions);
            btnExit.OnMouseOver += new EventHandler(Do_ExitMouseOver);
            btnExit.OnMouseLeave += new EventHandler(Do_ExitMouseLeave);
            btnExit.OnMouseClick += new EventHandler(Do_ExitMouseClick);

            //ActivareEfectPortal frame 0 is completely transparent
            ActivareEfectPortal = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("ActivareEfectPortal")].Frames);
            ActivareEfectPortal.X = 350;
            ActivareEfectPortal.Y = 200;
            ActivareEfectPortal.DrawOrder = drawOrder_ActivareEfectPortal;

            //hidden
            AnimatieEfectPortal = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("AnimatieEfectPortal")].Frames);
            AnimatieEfectPortal.X = 350;
            AnimatieEfectPortal.Y = 200;
            AnimatieEfectPortal.DrawOrder = 0;

            //hidden
            monitor_1 = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("monitor_1")].Frames);
            monitor_1.DrawOrder = 0;
            monitor_1.X = 201;
            monitor_1.Y = 608;
            monitor_1.GenerateEvents = false;//preloaderSprite will run continuously when Visible

            //hidden
            monitor_2 = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("monitor_2")].Frames);
            monitor_2.DrawOrder = 0;
            monitor_2.X = 395;
            monitor_2.Y = 556;
            monitor_2.GenerateEvents = false;//preloaderSprite will run continuously when Visible

            //hidden
            monitor_3 = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("monitor_3")].Frames);
            monitor_3.DrawOrder = 0;
            monitor_3.X = 302;
            monitor_3.Y = 518;
            monitor_3.GenerateEvents = false;//preloaderSprite will run continuously when Visible

            ExitTimer = new Timer(Game);
            ExitTimer.Interval = 1;//x seconds


            //LoadSettings Screen Section
            positions = new int[4] { 650, 689, 703, 691 };
            btnLoadScreenLoad = new MainMenuButton(Game, new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("LoadScreenLoad")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOff")].Frames), drawOrder_Buttons, positions);
            btnLoadScreenLoad.OnMouseClick += new EventHandler(Do_LoadScreenLoadClick);

            positions = new int[4] { 727, 687, 802, 689 };
            btnLoadScreenDelete = new MainMenuButton(Game, new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("LoadScreenDelete")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOff")].Frames), drawOrder_Buttons, positions);
            btnLoadScreenDelete.OnMouseClick += new EventHandler(Do_LoadScreenDeleteClick);

            LoadScreenFrame = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("LoadScreenFrame")].Frames);
            LoadScreenFrame.DrawOrder = drawOrder_Buttons;
            LoadScreenFrame.X = 647;
            LoadScreenFrame.Y = 560;

            positions = new int[6] { 868, 586, 857, 565, 858, 647 };
            LoadScreenScrollbar = new MainMenuScrollbar(Game, new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("ScrollbarBar")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("ScrollbarUp")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("ScrollbarDown")].Frames), drawOrder_Buttons, positions);
            LoadScreenScrollbar.OnScrollUp += new EventHandler(Do_ScrollUp);
            LoadScreenScrollbar.OnScrollDown += new EventHandler(Do_ScrollDown);

            User1 = new MainMenuUser(Game, "", drawOrder_Buttons, 660, 580);
            User1.OnUserClick += new EventHandler(Do_ChangeSelectedUser);

            User2 = new MainMenuUser(Game, "", drawOrder_Buttons, 660, 610);
            User2.OnUserClick += new EventHandler(Do_ChangeSelectedUser);

            User3 = new MainMenuUser(Game, "", drawOrder_Buttons, 660, 640);
            User3.OnUserClick += new EventHandler(Do_ChangeSelectedUser);

            //NewGame Screen Section
            NewGameScreenUserName = new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("NewGameScreenUserName")].Frames[0]);
            NewGameScreenUserName.X = 650;
            NewGameScreenUserName.Y = 570;
            NewGameScreenUserName.DrawOrder = drawOrder_Buttons;

            positions = new int[4] { 648, 689, 718, 690 };
            btnNewGameScreenStart = new MainMenuButton(Game, new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("StartNewGame")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOff")].Frames), drawOrder_Buttons, positions);
            btnNewGameScreenStart.OnMouseClick += new EventHandler(Launch_NewGameStartEvent);

            positions = new int[3] { 660, 620, 170 }; //X,Y,Width
            inputNewGameUserName = new MainMenuInputBox(Game, new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("pixel")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("pixel")].Frames), drawOrder_Buttons, positions);

            //NewGame/LoadGame/Credits Back Button
            positions = new int[4] { 827, 685, 882, 687 };
            btnBack = new MainMenuButton(Game, new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("Back")].Frames), new Sprite(Game, graphicsCollection[graphicsCollection.GetPackIndex("MouseOnOff")].Frames), drawOrder_Buttons, positions);


            //Credits Screen Section
            txtCreditsCronosTeam = new SpriteText(Game,((FontsCollection)Game.Services.GetService(typeof(FontsCollection))).GetPack("MainMenu").Font); 
            txtCreditsCronosTeam.X = 660;
            txtCreditsCronosTeam.Y = 560;
            txtCreditsCronosTeam.DrawOrder = drawOrder_Buttons;
            txtCreditsCronosTeam.Tint = Color.Chartreuse;
            txtCreditsCronosTeam.Text = "Cronos Team:";
            txtCreditsCronosTeam.MaxLength = 15;

            txtCreditsMembers = new SpriteText(Game,((FontsCollection)Game.Services.GetService(typeof(FontsCollection))).GetPack("MainMenu").Font); 
            txtCreditsMembers.X = 660;
            txtCreditsMembers.Y = 590;
            txtCreditsMembers.DrawOrder = drawOrder_Buttons;
            txtCreditsMembers.Tint = Color.MediumSeaGreen;
            txtCreditsMembers.Text = "Corneliu  Dascalu\nAlexandru Girigan\nAdriana  Dumitras\nGabriel  Tironeac";
            txtCreditsMembers.MaxLength = 100;


            LoadScreenHide();
            CreditsScreenHide();
            NewGameScreenHide();
            txtCreditsCronosTeam.Visible = false;
            txtCreditsMembers.Visible = false;
        }
Пример #6
0
        public MessagePanel(Game game, Rectangle screen)
            : base(game)
        {
            graphicsCollection = (GraphicsCollection)Game.Services.GetService(typeof(GraphicsCollection));

            Color AlphaZero = new Color(99, 99, 99, 0);//Alpha = 0

            BgSprite = new Sprite(game,graphicsCollection[graphicsCollection.GetPackIndex("pixel")].Frames);
            BgSprite.XRelative = 0;
            BgSprite.YRelative = 0;
            BgSprite.Tint = AlphaZero;
            BgSprite.Width = screen.Width;
            BgSprite.Height = screen.Height;
            BgSprite.StackOrder = 1;

            PanelSprite = new Sprite(game, graphicsCollection[graphicsCollection.GetPackIndex("message_panel")].Frames);
            PanelSprite.XRelative = Convert.ToInt32(BgSprite.Width / 2 - PanelSprite.Width / 2);
            PanelSprite.YRelative = Convert.ToInt32(BgSprite.Height / 2 - PanelSprite.Height / 2);
            PanelSprite.FrameNumber = 0;
            PanelSprite.StackOrder = 3;

            MessageSpriteText = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font);
            MessageSpriteText.MaxLength = 500;
            MessageSpriteText.Tint = Color.WhiteSmoke;
            MessageSpriteText.XRelative = PanelSprite.XRelative + HPadding;
            MessageSpriteText.YRelative = PanelSprite.YRelative + VPadding;
            MessageSpriteText.Text = "";
            MessageSpriteText.StackOrder = 5;
            MessageSpriteText.Visible = false;
            
            btnOK = new MessagePanelOKButton(game);
            btnOK.XRelative = Convert.ToInt32(PanelSprite.XRelative + PanelSprite.Width / 2 - btnOK.Width/2);
            btnOK.YRelative = Convert.ToInt32(PanelSprite.YRelative + PanelSprite.Height - btnOK.Height / 2 - 40);
            btnOK.OnRelease += new EventHandler<ButtonEventArgs>(btnOK_OnRelease);
            btnOK.StackOrder = 7;
            btnOK.Visible = false;
            btnOK.Enabled = false;

            tmrOpenPanel = new Timer(game);
            tmrOpenPanel.IntervalType = TimerIntervalType.Miliseconds;
            tmrOpenPanel.Interval = 50;
            tmrOpenPanel.OnTick += new EventHandler(tmrOpenPanel_OnTick);
            tmrOpenPanel.Start();
            
            AddChild(BgSprite);
            AddChild(PanelSprite);
            AddChild(MessageSpriteText);
            AddChild(btnOK);

            ((DisplayManager)Game.Services.GetService(typeof(DisplayManager))).CameraFreeze();
        }
Пример #7
0
        public MainMenuInputBox(Game game, Sprite Background, Sprite Cursor, int DrawOrder, int[] position)
            : base(game)
        {
            VerticalPadding = 5;
            SidePadding     = 5;

            background           = Background;
            background.X         = position[0];
            background.Y         = position[1];
            background.XRelative = position[0];
            background.YRelative = position[1];
            background.Width     = position[2];
            background.DrawOrder = DrawOrder;
            background.Tint      = Color.Black;


            //adaptation for classes of the main menu, for they do not derive from VisualComponent
            textFont = ((FontsCollection)Game.Services.GetService(typeof(FontsCollection))).GetPack("MainMenu").Font;
            //textFont = Game.Content.LoadSettings<SpriteFont>("MainMenu"); old loading version
            //-----------------------------------
            text           = new SpriteText(game, textFont);
            text.DrawOrder = DrawOrder + 3;
            text.X         = background.X + SidePadding;
            text.Y         = background.Y + VerticalPadding;
            text.XRelative = background.XRelative + SidePadding;
            text.YRelative = background.YRelative + VerticalPadding;
            TextColor      = Color.MediumSeaGreen;
            MaxLength      = 18;

            //text used only for initialization, needed to measure text height
            text.Text = "Init";

            Height = text.Height + 2 * VerticalPadding;

            cursor                = Cursor;
            cursor.Tint           = Color.Chartreuse;
            cursor.Height         = text.Height;
            cursor.Width          = 2;
            cursor.Y              = background.Y + VerticalPadding;
            cursor.X              = background.X + SidePadding;
            cursor.YRelative      = background.YRelative + VerticalPadding;
            cursor.XRelative      = background.XRelative + SidePadding;
            cursor.DrawOrder      = DrawOrder + 1;
            cursor.AnimationSpeed = 10;
            cursor.Visible        = false;
            cursor.OnFirstFrame  += new EventHandler(cursor_OnFirstFrame);

            messageFont = ((FontsCollection)Game.Services.GetService(typeof(FontsCollection))).GetPack("MainMenuNewUserMessage").Font;
            //messageFont = Game.Content.LoadSettings<SpriteFont>("MainMenuNewUserMessage"); old loading version
            message           = new SpriteText(game, messageFont);
            message.DrawOrder = DrawOrder + 3;
            message.X         = background.X + SidePadding;
            message.Y         = background.Y + VerticalPadding + Height;
            message.XRelative = background.XRelative + SidePadding;
            message.YRelative = background.YRelative + VerticalPadding + Height;
            message.Tint      = Color.Chartreuse;
            message.Text      = "Init";

            Components.Add(background);
            Components.Add(cursor);
            Components.Add(text);

            text.Text = String.Empty;
            Select();
        }