private static string MainMenu() { #region Menu initialization var nestedMenuOptions = new ZMenu.Options { Mode = ZMenu.MenuMode.ArrowsOnly, UseSelectedBackColor = true, FrameSpacingHorizontal = 1, FrameSpacingVertical = 0, }; var loadGameMenuItems = SaveLoad.GetSaveGames(); var exitFlag = false; var currentPosition = 0; #endregion while (!exitFlag) { #region Change current displayed options var languageMenuItems = new ZMenu.MenuItemList(); languageMenuItems.AddRange(GameConfig.Languages.Keys.Select(a => new ZMenu.MenuItem(a))); var difficultyItems = new ZMenu.MenuItemList((int)GameConfig.CurrentDifficulty); difficultyItems.AddRange(Enums.All_Difficulties.Select(a => new ZMenu.MenuItem(Lang["Difficulty_" + a.ToString()]))); var galaxySizeItems = new ZMenu.MenuItemList(GameConfig.CurrentGalaxySizeX-3); galaxySizeItems.AddRange(Enums.All_GalaxySizes.Select(a => new ZMenu.MenuItem(Lang["GalaxySize_" + a.ToString()]))); const int xPos = 30; ZColors.SetBackColor(Color.Black); ZOutput.Print(19, xPos, (Lang["StartMenu_Difficulty"] + ":").PadRight(17, ' '), Color.Magenta); ZOutput.Print(38, xPos, Lang["Difficulty_Short_" + GameConfig.CurrentDifficulty].PadRight(10, ' '), Color.White); ZOutput.Print(19, xPos+1, (Lang["StartMenu_GalaxySize"] + ":").PadRight(17, ' '), Color.Green); ZOutput.Print(38, xPos+1, GameConfig.CurrentGalaxySizeX + " x " + GameConfig.CurrentGalaxySizeY, Color.White); ZOutput.Print(19, xPos+2, (Lang["StartMenu_Language"] + ":").PadRight(17, ' '), Color.Magenta); ZOutput.Print(38, xPos+2, Lang["Common_CurrentLanguage"].PadRight(20, ' '), Color.White); #endregion #region Get Menu Result var menuResult = ZMenu.GetMenuResult(18, 6, new ZMenu.MenuItem(Lang["Common_YourAction"]) { Options = new ZMenu.Options { Mode = ZMenu.MenuMode.ShortkeysAndArrows, ItemSpacing = 2, FrameSpacingHorizontal = 3, FrameSpacingVertical = 2, UseSelectedBackColor = true, FrameOptions = new ZFrame.Options { FrameType = FrameType.Double }, }, ChildMenuItems = new ZMenu.MenuItemList(currentPosition) { new ZMenu.MenuItem { Caption = Lang["StartMenu_NewGame"] }, new ZMenu.MenuItem { Caption = Lang["StartMenu_LoadGame"], Options = nestedMenuOptions, ChildMenuItems = loadGameMenuItems, IsActive = loadGameMenuItems.Count > 0 }, new ZMenu.MenuItem { Caption = Lang["StartMenu_Difficulty"], Options = nestedMenuOptions, ChildMenuItems = difficultyItems }, new ZMenu.MenuItem { Caption = Lang["StartMenu_GalaxySize"], Options = nestedMenuOptions, ChildMenuItems = galaxySizeItems }, new ZMenu.MenuItem { Caption = Lang["StartMenu_Language"], Options = nestedMenuOptions, ChildMenuItems = languageMenuItems, IsActive = GameConfig.Languages.Count > 0 }, new ZMenu.MenuItem { Caption = Lang["Common_Quit"] } } }); #endregion #region Choose action if (menuResult.Index == -1) { menuResult.Text = Lang["Common_Quit"]; } var actions = new Dictionary<string, Action> { { Lang["StartMenu_NewGame"], () => { exitFlag = true; }}, { Lang["Difficulty_Easy"], () => { GameConfig.CurrentDifficulty = Difficulty.Easy; currentPosition = 2; }}, { Lang["Difficulty_Normal"], () => { GameConfig.CurrentDifficulty = Difficulty.Normal; currentPosition = 2; }}, { Lang["Difficulty_Hard"], () => { GameConfig.CurrentDifficulty = Difficulty.Hard; currentPosition = 2; }}, { Lang["GalaxySize_Small"], () => { GameConfig.CurrentGalaxySizeX = GameConfig.CurrentGalaxySizeY = 3; currentPosition = 3; }}, { Lang["GalaxySize_Normal"], () => { GameConfig.CurrentGalaxySizeX = GameConfig.CurrentGalaxySizeY = 4; currentPosition = 3; }}, { Lang["GalaxySize_Big"], () => { GameConfig.CurrentGalaxySizeX = GameConfig.CurrentGalaxySizeY = 5; currentPosition = 3; }}, { Lang["Common_Quit"], () => { ZConsoleMain.RestoreMode(); Environment.Exit(0); }} }; if (actions.ContainsKey(menuResult.Text)) actions[menuResult.Text](); else if (GameConfig.Languages.ContainsKey(menuResult.Text)) { GameConfig.Lang = GameConfig.Languages[menuResult.Text]; GameConfig.CurrentLanguageName = menuResult.Text; GameConfig.Apply_Languages(); currentPosition = 4; } else return menuResult.Text; #endregion } return null; }
private static string Get_FightMenuResult(NPC_Model enemy) { #region Get items for menu var mainMenuItems = new ZMenu.MenuItemList { new ZMenu.MenuItem(Menu_Attack_Laser), new ZMenu.MenuItem(Menu_Attack_Missile) { IsActive = Player.CurrentMissiles > 0 }, new ZMenu.MenuItem(Menu_RunAway) }; if (enemy.NPC_Type == NPC_Type.Pirate) { var dropCargoMenuItems = new ZMenu.MenuItemList(); dropCargoMenuItems.AddRange(from merch in Enums.All_Merchandise where Player.CurrentCargo[merch] > 0 select new ZMenu.MenuItem(Menu_DropOneCargo + Lang["Merchandise_" + merch])); dropCargoMenuItems.Add(new ZMenu.MenuItem(Menu_DropAllCargo)); mainMenuItems.Add(new ZMenu.MenuItem { Caption = Menu_DropCargoAndRun, IsActive = Player.CurrentCargo.CurrentLoad > 0, ChildMenuItems = dropCargoMenuItems }); } if (enemy.NPC_Type == NPC_Type.Trader && droppedTraderCargo.Count > 0) { mainMenuItems.Add(new ZMenu.MenuItem { Caption = Menu_ScoopCargo }); } #endregion return ZMenu.GetMenuResult(NPCStatsArea.Left + 24, NPCStatsArea.Top+1, new ZMenu.MenuItem(Lang["Common_YourAction"]) { Options = new ZMenu.Options { ColorScheme = new ZMenu.ColorScheme { FrameForeColor = Color.Cyan, CaptionForeColor = Color.Yellow }, IsMonoStyleColor = true, UseSelectedBackColor = true }, ChildMenuItems = mainMenuItems }, ZFrontier.HotKeys).Text; }
public static ZMenu.MenuItemList GetSaveGames() { if (!Directory.Exists(GameConfig.SaveGamesDirectoty)) Directory.CreateDirectory(GameConfig.SaveGamesDirectoty); var fileNames = Directory.GetFiles(GameConfig.SaveGamesDirectoty, "*.sav"); var saveCount = fileNames.Length; var saveNames = fileNames.Select(Path.GetFileNameWithoutExtension).ToArray(); var saveGames = new ZMenu.MenuItemList(); for (var i = 0; i < Math.Min(saveCount, GameConfig.MaxSaveGamesCount); i++) { saveGames.Add(new ZMenu.MenuItem(saveNames[i])); } return saveGames; }