private void MenuModel_IsLoggedChanged(object sender, bool IsLogged) { if (IsLogged) { SelectedAction = MenuValues.First(); } }
public void SetMenuValues(IReadOnlyList <string> values) { if (MenuValues.SequenceEqual(values)) { return; } Menu.SuspendLayout(); clear(); for (int i = 0; i < values.Count; i++) { string text = values[i]; Menu.Controls.Add(CreateMenuItem(text, i)); } MenuItemsCreated?.Invoke(this, EventArgs.Empty); updateItemBorders(); UpdateMenuSize(); Menu.ResumeLayout(false); Menu.PerformLayout(); SelectedIndex = Math.Min(SelectedIndex, values.Count - 1); void updateItemBorders() { const AnchorStyles defaultBorders = AnchorStyles.Left | AnchorStyles.Right; for (int i = 0; i < MenuItems.Count; i++) { var border = defaultBorders; if (i == 0) { border |= AnchorStyles.Top; } if (i == MenuItems.Count - 1) { border |= AnchorStyles.Bottom; } MenuItems[i].VisibleBorders = border; } } }
public List <MenuItem> ReadMenuFile() { if (File.Exists(@MenuDir)) { List <MenuItem> menuItems = File.ReadAllLines(@MenuDir) .Select(v => MenuValues.ParseToObject(v)) .ToList(); return(menuItems); } else { EmptyFile(@MenuDir); return(new List <MenuItem>()); } }
protected override void InternalLoad() { Application.PhysicsManager.IsEnable = true; SceneCamera.FadeOut(30f, null); _menuCurrent = MenuValues.MenuNewgame; }
public override void Update(GameTime gameTime) { base.Update(gameTime); animationManager(gameTime); if (Application.IsApplicationActive) { _time += gameTime.ElapsedGameTime.Milliseconds; if (_time > 500) { _time = 0; _textDisplayed = !_textDisplayed; } if (!_isInitialized) { // Register a gamepad as Player 1 if someone press start // -- Gamepads for (PlayerIndex index = PlayerIndex.One; index <= PlayerIndex.Four; index++) { if (GamePad.GetState(index).Buttons.Start == ButtonState.Pressed) { initializeInput(index); break; } } // -- Keyboards if (Keyboard.GetState().GetPressedKeys().Count() > 0) { initializeInput(PlayerIndex.One); } } else { Application.PhysicsManager.IsEnable = true; manageAsteroids(gameTime); //animation if (_isTitleFalling) { _velocity++;// gameTime.ElapsedGameTime.Milliseconds; _dstTitle.Y += _velocity;//= gameTime.ElapsedGameTime.Milliseconds / 1000; if (_dstTitle.Y >= GroundYForTitle) { _isTitleFalling = false; SpecialEffectsHelper.ShakeScreen(new Vector2(3f, 5f), 0.5f); Application.MagicContentManager.GetSound("s_title_explosion").Play(0.8f, 0f, 0f); _isMenuDisplayed = true; for (int i = 0; i <= 5; i++) { SpecialEffectsHelper.MakeCircularExplosion(new Vector2(_dstTitle.X + (i * (_dstTitle.Width / 5)), GroundYForTitle + _dstTitle.Height * 3 / 4), 150, 1, Color.Beige, false, false, 20); } } } if (_isMenuDisplayed) { foreach (Device device in Application.InputManager.GetLinkedDevices(LapinsInput.LogicalPlayerIndex.One)) { if ((device.GetState(LapinsInput.MappingButtons.A).IsReleased) || (device.GetState(LapinsInput.MappingButtons.Start).IsReleased) || (device.GetState(LapinsInput.MappingButtons.Y).IsReleased)) { changeState(); } else if (device.ThumbStickLeft.Y != 0 && device.ThumbStickLeft.PreviousY == 0) { Application.MagicContentManager.GetSound("s_blipmenu").Play(1f, 0f, 0f); if (device.ThumbStickLeft.Y > 0) { _menuCurrent++; if ((int)_menuCurrent >= MenuValuesSize) _menuCurrent = (MenuValues)0; } else { _menuCurrent--; if ((int)_menuCurrent < 0) _menuCurrent = (MenuValues)(MenuValuesSize - 1); } } } } } } }