/
karachi
/
KPO_CP_CrossyRoad
Обзор
Документация
Войти
/
karachi
/
KPO_CP_CrossyRoad
Код
Запросы
5
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
console
ControllerConsole/PlayerNameControllerConsole.cs
63 строки
2 KB
karachi-23
console
11 янв 2025, 00:00
11 янв 2025, 00:00
3330cd2
Код
Авторство
О чём код?
using Controller.Menu; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using ViewConsole.Menu; namespace ControllerConsole { /// <summary> /// Контроллер консольного пункта меню настройки имени игрока /// </summary> public class PlayerNameControllerConsole : MenuPlayerNameController { /// <summary> /// Консольное представление пукта меню изменения имени игрока /// </summary> private readonly PlayerNameViewConsole _playerNameViewConsole; /// <summary> /// Конструктор контроллера консольного меню настройки имени игрока /// </summary> public PlayerNameControllerConsole() { _playerNameViewConsole = new(); } /// <summary> /// Открытие консольного пункта меню изменения имени игрока /// </summary> public override void Start() { Console.Clear(); _playerNameViewConsole.Draw(); bool exit = false; do { ConsoleKeyInfo keyInfo = Console.ReadKey(true); switch (keyInfo.Key) { case ConsoleKey.Backspace: if (PlayerName.Length > 0) PlayerName = PlayerName.Remove(PlayerName.Length - 1); break; case ConsoleKey.Enter: ChangePlayerName(); CallPlayerNameChange(); exit = true; GoToBackCall(); break; case ConsoleKey.Escape: exit = true; GoToBackCall(); break; default: PlayerName += keyInfo.KeyChar; break; } _playerNameViewConsole.PlayerName = PlayerName; _playerNameViewConsole.Draw(); } while (!exit); } } }