public static int getInput(int numChoices) { choice = new Choice(0, (numChoices - 1)); if (OnInput != null) { EventArgsChoice argument = new EventArgsChoice(choice); OnInput(null, argument); return choice.getInt(); } else { return 0; } }
public void makeChoice(Choice choice) { //NOTE: THE CHOICES HAVE TO HAVE A FREE LINE ABOVE AND BELOW THEM IN ORDER TO WORK PROPERLY. //ALSO, YOU NEED TO HAVE AT LEAST ONE FREE SPACE BEFORE EACH OF THE CHOICES OR ELSE //THE FIRST CHARACTER WILL BE LOST. YES, THIS IS BAD PROGRAMMING, BUT IT'S NOT HIGH ON THE //LIST OF PRIORITIES TO FIX, CONSIDERING THAT I'M THE ONLY ONE WRITING THIS. Console.SetCursorPosition(0, Console.CursorTop - (choice.getMax() + 2)); Console.ForegroundColor = ConsoleColor.Green; Console.Write("\r>"); Console.CursorVisible = false; int position = 0; ConsoleKeyInfo key = new ConsoleKeyInfo(); do { while (Console.KeyAvailable == false) Thread.Sleep(50); // Loop until input is entered. key = Console.ReadKey(true); if (key.Key == ConsoleKey.UpArrow && position > 0) { Console.Write("\r "); Console.SetCursorPosition(0, Console.CursorTop - 1); SFX.Play("Selection"); position--; Console.Write("\r>"); } else if (key.Key == ConsoleKey.DownArrow && position < (choice.getMax())) { Console.Write("\r "); Console.SetCursorPosition(0, Console.CursorTop + 1); SFX.Play("Selection"); position++; Console.Write("\r>"); } } while (key.Key != ConsoleKey.Enter); Console.CursorVisible = true; choice.setInt(position); Console.ForegroundColor = ConsoleColor.Gray; Console.Clear(); //Console.WriteLine("\rNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNR"); }
public EventArgsChoice(Choice value) { this.value = value; }