Пример #1
0
        public static void Save(ProjectConfig config, string filePath)
        {
            string fileText = JsonConvert.SerializeObject(config, Formatting.Indented);

            File.WriteAllText(filePath, fileText);
            HPPConfig.GetInstance().LastProjectPath = filePath;
        }
Пример #2
0
        /*
         *  -------
         *  Methods
         *  -------
         */
        public static ProjectConfig Open(string filePath)
        {
            string fileText = File.ReadAllText(filePath);

            HPPConfig.GetInstance().LastProjectPath = filePath;
            return(JsonConvert.DeserializeObject <ProjectConfig>(fileText));
        }
Пример #3
0
        /// <summary>
        /// Gets the current instance of the Power Plant config.
        /// </summary>
        public static HPPConfig GetInstance() // Technically not a constructor but still a singleton.
        {
            if (Instance == null)
            {
                Instance = new HPPConfig();
            }

            return(Instance);
        }
Пример #4
0
        /// <summary>
        /// Loads the current Power Plant Config. Note: Returns a new instance on successful load, throw the old instance away.
        /// </summary>
        public HPPConfig Load(MainForm.MainForm mainForm)
        {
            if (!File.Exists(ConfigPath))
            {
                Save();
                System.Windows.Forms.MessageBox.Show("It appears this is your first time using Heroes Power Plant.\nIf you haven't yet, please check out readme.md as that file has useful info regarding use of the program.\nThere are also tutorials available on YouTube and Sonic Retro.");
                mainForm.AboutBox.Show();
            }

            string fileText = File.ReadAllText(ConfigPath);

            Instance = JsonConvert.DeserializeObject <HPPConfig>(fileText);
            Instance.ApplyConfig(mainForm);

            return(Instance);
        }
Пример #5
0
        /// <summary>
        /// Loads the current Power Plant Config. Note: Returns a new instance on successful load, throw the old instance away.
        /// </summary>
        public HPPConfig Load(MainForm.MainForm mainForm)
        {
            if (!File.Exists(ConfigPath))
            {
                Save();
                System.Windows.Forms.MessageBox.Show("It appears this is your first time using Heroes Power Plant.\nIf you haven't yet, please check out the Heroes Power Plant wiki on GitHub, as it features a complete guide on using the program and creating custom stages for Sonic Heroes and Shadow the Hedgehog.");
                mainForm.AboutBox.Show();
            }

            string fileText = File.ReadAllText(ConfigPath);

            Instance = JsonConvert.DeserializeObject <HPPConfig>(fileText);
            Instance.ApplyConfig(mainForm);

            return(Instance);
        }