Example #1
0
        /// <summary>
        /// Displays executable data in a box to the right of a screen
        /// </summary>
        /// <param name="executable">The executable to be displayed</param>
        public void DisplayExecutableSettings(ExecutableData executable)
        {
            Location boxLocation  = new Location(40, 4);
            int      height       = 5;
            int      rightPadding = 3;
            List <Tuple <string, string, int> > boxLines = new List <Tuple <string, string, int> >()
            {
                new Tuple <string, string, int>("Executable path: ", executable.ExecutablePath, 1),
                new Tuple <string, string, int>("Shortcut name: ", executable.ShortcutName, height - 1),
                new Tuple <string, string, int>("Create desktop shortcut: ", executable.OnDesktop.ToString(), height)
            };

            Borders borders = new Borders(true)
            {
                TopStyle    = "*",
                LeftStyle   = "-|",
                RightStyle  = "|-",
                BottomStyle = "*"
            };
            Location bottomRightOfBox = new Location(Console.WindowWidth - rightPadding, boxLocation.Y + height +
                                                     borders.TopStyle.Length + borders.BottomStyle.Length + 1);

            FormattedWriteSettings writeSettings = new FormattedWriteSettings
            {
                MaximumWidth        = bottomRightOfBox.X - boxLocation.X,
                InnerPadding        = new Padding(0, borders.LeftStyle.Length + 1, borders.RightStyle.Length + 1, 0),
                ResetCursorPosition = true,
                NewLine             = false
            };

            ConsoleUtils.CreateBox(boxLocation, bottomRightOfBox, borders);
            for (int i = 0; i < boxLines.Count; ++i)
            {
                writeSettings.Location = new Location(boxLocation.X, boxLocation.Y + boxLines[i].Item3);
                if (i < boxLines.Count - 1)
                {
                    writeSettings.MaximumHeight = boxLines[i + 1].Item3 - boxLines[i].Item3;
                }
                else
                {
                    writeSettings.MaximumHeight = height - boxLines[i].Item3 + 1;
                }
                ConsoleUtils.FormattedWrite(boxLines[i].Item1, writeSettings);
                writeSettings.Location.X   += boxLines[i].Item1.Length;
                writeSettings.MaximumWidth -= boxLines[i].Item1.Length;

                ConsoleUtils.FormattedWrite(boxLines[i].Item2, writeSettings);
                writeSettings.MaximumWidth += boxLines[i].Item1.Length;
            }
        }
Example #2
0
        /// <summary>
        /// The screen used to add a save
        /// </summary>
        /// <param name="game">The game where it is being saves</param>
        /// <returns>A completed save</returns>
        static Save EditSaveScreen(Save save)
        {
            int           previewMaxWidth = 0;
            int           menuMaxWidth    = 0;
            int           menuOption      = 0;
            bool          show            = true;
            List <string> menuOptions;
            Location      previewLocation = new Location();

            while (menuOption != 7)
            {
                ConsoleUtils.PrepNewScreen("Game Save Manager");
                if (Console.WindowWidth > "Game Save Manager".Length + ("Current Music: ".Length + CurrentSong.Length + 6) * 2)
                {
                    ConsoleUtils.FormattedWrite("Current Music: " + CurrentSong, new FormattedWriteSettings {
                        Location = new Location(0, 1), TextAlignment = Alignment.Right, InnerPadding = new Padding(0, 2, 0), ResetCursorPosition = true
                    });
                }

                // Get maximum widths
                if (Console.WindowWidth >= 100)
                {
                    previewMaxWidth = 45;
                    menuMaxWidth    = Console.WindowWidth - previewMaxWidth - 25;
                    previewLocation = new Location(Console.WindowWidth - previewMaxWidth - 12, 8);
                }
                else if (Console.WindowWidth >= 80)
                {
                    previewMaxWidth = 45 - (100 - Console.WindowWidth);
                    menuMaxWidth    = Console.WindowWidth - previewMaxWidth - 25;
                    previewLocation = new Location(Console.WindowWidth - previewMaxWidth - 12, 8);
                }
                else
                {
                    menuMaxWidth = Console.WindowWidth - 5;
                    show         = false;
                }

                if (show)
                {
                    Location prevLocation = new Location();

                    // Write preview
                    Console.SetCursorPosition(previewLocation.X, previewLocation.Y);
                    FormattedWriteSettings sharedSettings = new FormattedWriteSettings {
                        MaximumWidth = previewMaxWidth, InnerPadding = new Padding(0, 0, 1)
                    };
                    if (save.Favourited)
                    {
                        ConsoleUtils.FormattedWrite("**Favourited**", new FormattedWriteSettings()
                        {
                            MaximumWidth = previewMaxWidth, TextAlignment = Alignment.Centre, InnerPadding = new Padding(0)
                        });
                    }
                    ConsoleUtils.FormattedWrite(save.Title, new FormattedWriteSettings(sharedSettings)
                    {
                        Location = new Location()
                    });
                    ConsoleUtils.FormattedWrite("Save Data:", new FormattedWriteSettings {
                        InnerPadding = new Padding(0)
                    });
                    ConsoleUtils.FormattedWrite(save.SaveData, new FormattedWriteSettings(sharedSettings)
                    {
                        Location = new Location()
                    });
                    ConsoleUtils.FormattedWrite("Notes:", new FormattedWriteSettings {
                        InnerPadding = new Padding(0)
                    });
                    foreach (string note in save.Notes)
                    {
                        ConsoleUtils.FormattedWrite(note, new FormattedWriteSettings(sharedSettings)
                        {
                            InnerPadding = new Padding(0), Location = new Location()
                        });
                    }


                    ConsoleUtils.CreateBorder(new Location(previewLocation.X, previewLocation.Y), new Location(previewLocation.X + previewMaxWidth, Console.CursorTop), new Padding(1, 2), new Borders
                    {
                        TopStyle    = "_\\*",
                        LeftStyle   = "|:|",
                        RightStyle  = "|:|",
                        BottomStyle = "-+"
                    });
                    Console.SetCursorPosition(prevLocation.X, prevLocation.Y);
                }

                // Show different menu if there are any games
                menuOptions = new List <string>()
                {
                    "Title", "Save Data", "Notes"
                };
                if (save.Favourited)
                {
                    menuOptions.Add("Unfavourite Save");
                }
                else
                {
                    menuOptions.Add("Favourite Save");
                }
                if (save.SaveData != "")
                {
                    menuOptions.Add("Save to collection");
                }
                if (ExtraMusic.ThreadState == ThreadState.Aborted)
                {
                    menuOptions.Add("Start Music");
                }
                else
                {
                    menuOptions.Add("Stop Music");
                }
                menuOptions.Add("Quit (without saving)");
                ConsoleUtils.CreateMenu(menuOptions, "Main Menu:");
                if (save.SaveData == "")
                {
                    // Display menu
                    menuOption = ConsoleUtils.FancyGetInteger("Menu Option: ", "Menu choice must be an integer", "Default", 1, 6, new FormattedWriteSettings {
                        NewLine = false
                    }, maxCharLength: 1);

                    if (menuOption > 4)
                    {
                        menuOption += 1;
                    }
                }
                else
                {
                    // Display menu
                    menuOption = ConsoleUtils.FancyGetInteger("Menu Option: ", "Menu choice must be an integer", "Default", 1, 7, new FormattedWriteSettings {
                        NewLine = false
                    }, maxCharLength: 1);
                }

                // Change values
                if (menuOption == 1)
                {
                    Console.WriteLine();
                    save.Title = ConsoleUtils.FancyGetInput("Title: ", menuMaxWidth);
                }
                else if (menuOption == 2)
                {
                    Console.WriteLine();
                    save.SaveData = ConsoleUtils.FancyGetInput("Save Data: ", menuMaxWidth);
                }
                else if (menuOption == 3)
                {
                    save.Notes = NotesScreen(save.Notes.ToList());
                }
                else if (menuOption == 4)
                {
                    save.Favourited = save.Favourited == false;
                }
                else if (menuOption == 5)
                {
                    if (save.Date != null)
                    {
                        save.Date = DateTime.Now;
                    }
                    return(save);
                }
                else if (menuOption == 6)
                {
                    if (ExtraMusic.ThreadState == ThreadState.Aborted)
                    {
                        ExtraMusic = new Thread(() => BackgroundMusic());
                        ExtraMusic.Start();
                    }
                    else
                    {
                        ExtraMusic.Abort();
                    }
                }
            }

            return(null);
        }