public override bool Touched(Vector2D position)
 {
     if (_isPopup)
     {
         MyConsole.Out("HMM");
         return(true);
     }
     return(false);
 }
Beispiel #2
0
 public static void Display <T>(this T settings) where T : ISettings, IDescription
 {
     MyConsole.WriteNewLineGreen($"Current Settings");
     foreach (var setting in settings.GetType().GetProperties())
     {
         var description = settings.GetPropertyDescription(setting.Name);
         var value       = setting.GetValue(settings);
         MyConsole.WriteLine($"{description,-40} {value}");
     }
 }
Beispiel #3
0
        public static void SaveToFile <T>(this T settings) where T : ISettings
        {
            MyConsole.WriteNewLineGreen("Введите имя файла для сохранения настроек");
            var fileName = MyConsole.ReadLine();
            var dirPath  = AppContext.BaseDirectory + "/settings";
            var filePath = $"{dirPath}/{fileName}.json";

            Directory.CreateDirectory(dirPath);
            string jsonString = settings.SaveToStr();

            File.WriteAllText(filePath, jsonString);
            MyConsole.WriteNewLineGreen($"Настройки сохранены в файл {fileName}.json");
        }
Beispiel #4
0
        public static void ReadFromFile <T>(this T settings) where T : ISettings
        {
            var           dirPath   = AppContext.BaseDirectory + "/settings";
            DirectoryInfo dir       = new DirectoryInfo(dirPath);
            List <string> fileNames = new List <string>();

            foreach (var file in dir.GetFiles("*.json"))
            {
                fileNames.Add(Path.GetFileNameWithoutExtension(file.Name));
            }
            if (fileNames.Count == 0)
            {
                MyConsole.WriteNewLineRed("Файлы настроек не найдены!");
                return;
            }
            var fileName   = MyConsole.SelectFromList(fileNames.ToArray(), "Файлы");
            var filePath   = $"{dirPath}/{fileName}.json";
            var jsonString = File.ReadAllText(filePath);

            settings.ReadFromStr(jsonString);
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            Settings settings = new();

            while (true)
            {
                MyConsole.WriteLine("Hello World!");
                Thread.Sleep(1000);
                settings.Read();
                settings.ReadFromFile();
                settings.Display();

                //settings.BoardLocations = "55555";

                //settings.Save();
                ////settings.SaveToFile();

                //settings.Display();


                //Console.ReadLine();
            }
        }