public LoadMenuState() { //check if the directory for levels exists and if not create it //for now it reads (and creates) \MeesGame\bin\Windows\x86\Debug\Content\levels //the reading does work, you can check by adding a .lvl (left column) or a .ai (right column) to the \levels directory. Just make sure it isn't a txt file string directory = FileIO.LEVEL_DIRECTORY; menuContainer = new UIComponent(SimpleLocation.Zero, null); UIComponent centerContainer = new UIComponent(new CenteredLocation(0, 150, true), WrapperDimensions.All); levelExplorer = new FileExplorer(SimpleLocation.Zero, new SimpleDimensions(500, 500), "lvl", directory); levelSettings = new SortedList(new RelativeToLocation(levelExplorer, 100, relativeToLeft: false), new SimpleDimensions(500, 500), settingsDistance * 2); levelSettings.AddConstantComponent(new Background(Utility.SolidWhiteTexture, Utility.DrawingColorToXNAColor(DefaultUIValues.Default.FileExplorerBackground))); startButton = new SpriteSheetButton(new CenteredLocation(0, 700, true, false), null, Strings.begin, (UIComponent o) => { BeginLevel(); }); centerContainer.AddChild(levelExplorer); centerContainer.AddChild(levelSettings); menuContainer.AddChild(centerContainer); menuContainer.AddChild(startButton); InitializeLevelSettingsMenu(); }
private void ShowGameOverState(string backgroundName) { UIComponent gameOverStateOverlay = ((GameEnvironment.GameStateManager.GetGameState("GameOverState") as GameOverState) as GameOverState).Overlay; gameOverStateOverlay.AddChild(new Background(new SpriteSheet(backgroundName).Sprite)); //add the child to the overlay of the GameOverState here because you need the currrentstate. gameOverStateOverlay.AddChild(new SpriteSheetButton(new CenteredLocation(0, 200, true, true), null, currentState.ToString(), (UIComponent o) => GameEnvironment.GameStateManager.SwitchTo("TitleMenuState"))); GameEnvironment.GameStateManager.SwitchTo("GameOverState"); }
private void AddTimerToOverlay() { elapsedTime = TimeSpan.Zero; timerUI = new Textbox(CenteredLocation.All, null, "", "smallfont"); Texture timerUIBackground = new Texture(new DirectionLocation(TIMER_DISTANCE, TIMER_DISTANCE, false), new MeasuredDimensions(timerUI, TIMER_BACKGROUND_OFFSET, TIMER_BACKGROUND_OFFSET), Utility.SolidWhiteTexture, new Color(122, 122, 122, 122)); timerUIBackground.AddConstantComponent(timerUI); timerUI.PermanentInvalid = true; overlay.AddChild(timerUIBackground); }
public TitleMenuState() { MenuContainer = new UIComponent(SimpleLocation.Zero, InheritDimensions.All); MenuContainer.AddChild(new Background(new SpriteSheet("mainMenuOverlay").Sprite)); List <UIComponent> buttons = new List <UIComponent>(); CombinationLocation buttonLocation = new CombinationLocation(new SharedLocation(buttons, -40, 0), new DirectionLocation(yOffset: 10, topToBottom: false)); SpriteSheetButton begin = new SpriteSheetButton(buttonLocation, null, Strings.begin, (UIComponent o) => { ((LoadMenuState)GameEnvironment.GameStateManager.GetGameState("LoadMenuState")).UpdateLevelExplorer(); GameEnvironment.GameStateManager.SwitchTo("LoadMenuState"); }); SpriteSheetButton createLevel = new SpriteSheetButton(buttonLocation, null, Strings.map_editor, (UIComponent o) => { GameEnvironment.GameStateManager.SwitchTo("LevelEditorState"); //reset the gamestate to open blank; GameEnvironment.GameStateManager.CurrentGameState.Reset(); }); SpriteSheetButton settings = new SpriteSheetButton(buttonLocation, null, Strings.settings, (UIComponent o) => { GameEnvironment.GameStateManager.PreviousGameState = GameEnvironment.GameStateManager.CurrentGameState.ToString(); GameEnvironment.GameStateManager.SwitchTo("SettingsMenuState"); }); SpriteSheetButton quit = new SpriteSheetButton(buttonLocation, null, Strings.exit, (UIComponent o) => { GameEnvironment.Instance.Exit(); }); buttons.Add(begin); buttons.Add(createLevel); buttons.Add(settings); buttons.Add(quit); //Level Editor button; MenuContainer.AddChild(begin); MenuContainer.AddChild(createLevel); MenuContainer.AddChild(settings); MenuContainer.AddChild(quit); }
/// <summary> /// Initializes the left and right bars so that the editor can select which tiles to edit and their properties /// </summary> private void InitUI() { overlay = new UIComponent(SimpleLocation.Zero, InheritDimensions.All); tilesList = new SortedList(SimpleLocation.Zero, new InheritDimensions(false, true, TILES_LIST_WIDTH)); tilePropertiesList = new SortedList(new DirectionLocation(leftToRight: false), new InheritDimensions(false, true, PROPERTIES_LIST_WIDTH)); newLevel = new SpriteSheetButton(new DirectionLocation(10, 230, false, false), null, Strings.newmaze, (UIComponent component) => { newLevelBox.Visible = true; }); loadLevel = new SpriteSheetButton(new CombinationLocation(new DirectionLocation(10, 0, false), new RelativeToLocation(newLevel, yOffset: 10, relativeToTop: false)), null, Strings.load, LoadLevel); saveLevel = new SpriteSheetButton(new CombinationLocation(new DirectionLocation(10, 0, false), new RelativeToLocation(loadLevel, yOffset: 10, relativeToTop: false)), null, Strings.save, SaveLevel); InitNewLevelBox(); overlay.AddChild(tilesList); overlay.AddChild(tilePropertiesList); overlay.AddChild(newLevelBox); overlay.AddChild(newLevel); overlay.AddChild(saveLevel); overlay.AddChild(loadLevel); tilesList.ChildClick += OnItemSelect; FillTilesList(); }
/// <summary> /// Creates a setting box, for selecting a setting from a set of options /// </summary> /// <param name="title">The title that should be displayed</param> /// <param name="options">The options to choose from</param> /// <param name="selected">The index that should be selected by default</param> /// <param name="settingBox">The setting box</param> /// <returns>The radio group of the items</returns> private List <RadioButton> InitSettingBox(string title, Dictionary <int, string> options, int selected, out UIComponent settingBox) { settingBox = new UIComponent(SimpleLocation.Zero, WrapperDimensions.All); List <RadioButton> settingRadioGroup = new List <RadioButton>(); Textbox titleText = new Textbox(SimpleLocation.Zero, null, title, textColor: Color.Black); settingBox.AddChild(titleText); for (int i = 0; i < PlayerTypes.Count; i++) { RadioButton radioButton = new RadioButton(new RelativeToLocation(((i == 0) ? titleText : (UIComponent)settingRadioGroup[i - 1]), (i == 0) ? settingsDistance : 0, settingsDistance, relativeToTop: false), options[i], settingRadioGroup); if (i == selected) { radioButton.Selected = true; } settingBox.AddChild(radioButton); } levelSettings.AddChild(settingBox); return(settingRadioGroup); }
public SettingsMenuState() { overlay = new UIComponent(SimpleLocation.Zero, InheritDimensions.All); //Add the background for the menu overlay.AddChild(new Background(new SpriteSheet("settingsScreenOverlay").Sprite)); slider = new Slider(new SimpleLocation(0, 275), new InheritDimensions(false, false, 500, 50)); textbox = new Textbox(new SimpleLocation(25, 200), InheritDimensions.All, Strings.volume); controls = new UIComponent(SimpleLocation.Zero, InheritDimensions.All); overlay.AddChild(slider); overlay.AddChild(textbox); overlay.AddChild(controls); //Button for returning to the titlemenu overlay.AddChild(new SpriteSheetButton(new SimpleLocation(25, 320), null, Strings.menu, (UIComponent o) => { GameEnvironment.GameStateManager.SwitchTo("TitleMenuState"); })); //Button for quitting the game overlay.AddChild(new SpriteSheetButton(new SimpleLocation(25, 430), null, Strings.quit, (UIComponent o) => { GameEnvironment.Instance.Exit(); })); //Button for returning to the previous gamestate overlay.AddChild(new SpriteSheetButton(new SimpleLocation(25, 540), null, Strings.back, (UIComponent o) => { GameEnvironment.GameStateManager.SwitchTo(GameEnvironment.GameStateManager.PreviousGameState); })); //Adds the lines of text for the controls guide controls.AddChild(new Textbox(new SimpleLocation(576, 200), InheritDimensions.All, Strings.controls)); controls.AddChild(new Textbox(new SimpleLocation(580, 275), InheritDimensions.All, Strings.arrows)); controls.AddChild(new Textbox(new SimpleLocation(626, 350), InheritDimensions.All, Strings.move)); controls.AddChild(new Textbox(new SimpleLocation(580, 425), InheritDimensions.All, Strings.space)); controls.AddChild(new Textbox(new SimpleLocation(626, 500), InheritDimensions.All, Strings.specialaction)); controls.AddChild(new Textbox(new SimpleLocation(580, 575), InheritDimensions.All, Strings.p)); controls.AddChild(new Textbox(new SimpleLocation(626, 650), InheritDimensions.All, Strings.settingsmenu)); }