public void RebuildItems() { List <SaveState> saveStates = new List <SaveState>(); string[] files = Directory.GetFiles(SaveManager.SaveFilePath, "*.svf", SearchOption.TopDirectoryOnly); foreach (string file in files) { FileStream fs = new FileStream(file, FileMode.Open); BinaryFormatter bf = new BinaryFormatter(); saveStates.Add((SaveState)bf.Deserialize(fs)); fs.Close(); } slot1 = saveStates.Count == 0 || String.IsNullOrEmpty(saveStates[0].PlayerName) ? "---" : saveStates[0].PlayerName; slot2 = saveStates.Count <= 1 || String.IsNullOrEmpty(saveStates[1].PlayerName) ? "---" : saveStates[1].PlayerName; slot3 = saveStates.Count <= 2 || String.IsNullOrEmpty(saveStates[2].PlayerName) ? "---" : saveStates[2].PlayerName; menuItems.Clear(); menuItems.Add(new MenuItem(slot1, fontName, true)); menuItems.Add(new MenuItem(slot2, fontName)); menuItems.Add(new MenuItem(slot3, fontName)); menuItems.Add(new MenuItem(back, fontName)); SetPositions(); menuItems[3].ItemPosition += itemOffset; menuLabels.Clear(); menuLabels.Add(new MenuLabel(select, fontName)); menuLabels[0].Position = ShortcutProvider.ScreenCenter - ShortcutProvider.GetFontCenter(fontName, select) - 3 * itemOffset; }
protected void SetPositions() { for (int i = 0; i < menuItems.Count; ++i) { menuItems[i].ItemPosition = ShortcutProvider.ScreenCenter - ShortcutProvider.GetFontCenter(fontName, menuItems[i].ItemName) + (i - 2) * itemOffset; } }
public NewGameMenu() { menuLabels.Add(new MenuLabel(name, fontName)); menuItems.Add(new MenuItem(ok, fontName, false)); menuItems.Add(new MenuItem(back, fontName, true)); menuLabels[0].Position = ShortcutProvider.ScreenCenter - ShortcutProvider.GetFontCenter(fontName, menuItems[0].ItemName) + new Vector2(-200, 0); menuItems[0].ItemPosition = ShortcutProvider.ScreenCenter - ShortcutProvider.GetFontCenter(fontName, menuItems[1].ItemName) + 2 * itemOffset; menuItems[1].ItemPosition = ShortcutProvider.ScreenCenter - ShortcutProvider.GetFontCenter(fontName, menuItems[1].ItemName) + 3 * itemOffset; EventInput.EventInput.Initialize(VariableProvider.Game.Window); EventInput.EventInput.CharEntered += new EventInput.CharEnteredHandler(CharacterEntered); TextBuffer = ""; confirmDialog = new ConfirmOverlay(this); }
public override void Draw(SpriteBatch spriteBatch) { base.Draw(spriteBatch); spriteBatch.DrawString( FontProvider.GetFont(fontName), confirmText + GameVariableProvider.SaveState.PlayerName + "?", ShortcutProvider.Vector2Point(menuItems[0].ItemPosition - itemOffset - new Vector2(ShortcutProvider.GetFontCenter(fontName, confirmText + GameVariableProvider.SaveState.PlayerName + "?").X, 0)), Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, .2f); }