Esempio n. 1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Task SplashTask = Task.Run(() =>
            {
                SplashForm SF = new SplashForm(10);
                SF.ShowDialog();
                SF.Dispose();
            });

            string FullfilePath             = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath;
            string VersionDirectoryfilePath = Path.GetFullPath(Path.Combine(FullfilePath, @"..\..\" + Application.ProductVersion));
            string BasePath = Path.GetFullPath(Path.Combine(FullfilePath, @"..\..\"));

            Properties.Settings.Default.Upgrade();
            if (Directory.Exists(BasePath))
            {
                DirectoryInfo   DirInfo = new DirectoryInfo(BasePath);
                DirectoryInfo[] Dirs    = DirInfo.GetDirectories();
                for (int i = 0; i < Dirs.Length; i++)
                {
                    if (!Dirs[i].FullName.Equals(VersionDirectoryfilePath))
                    {
                        Directory.Delete(Dirs[i].FullName, true);
                    }
                }
            }
            if (Directory.Exists(LanguagePath))
            {
                CurrentLanguage = File.Exists(Path.Combine(LanguagePath, Properties.Settings.Default.Language + ".txt")) ? new Language(Properties.Settings.Default.Language, Path.Combine(LanguagePath, Properties.Settings.Default.Language + ".txt")) : new Language();
            }
            else
            {
                CurrentLanguage = new Language();
            }

            LevelEditorForm LEF = new LevelEditorForm();

            Application.Run(LEF);
        }
Esempio n. 2
0
        public SettingsForm(LevelEditorForm home)
        {
            Home = home;
            InitializeComponent();
            CenterToParent();
            Localize();
            GamePathTextBox.Text    = Program.GamePath;
            ProjectPathTextBox.Text = Program.ProjectPath;

            #region Databases

            string ver = SettingsInvalid;
            if (File.Exists(Program.SOPDPath))
            {
                FileStream FS   = new FileStream(Program.SOPDPath, FileMode.Open);
                byte[]     Read = new byte[4];
                FS.Read(Read, 0, 4);
                if (Encoding.ASCII.GetString(Read) != "SOPD")
                {
                    throw new Exception("Invalid Database File");
                }

                Version Check = new Version(FS.ReadByte(), FS.ReadByte());
                ver = Program.ParameterDB != null?Program.ParameterDB.Version.ToString() : Check.ToString() + $" ({DatabaseOutdated})";

                FS.Close();
            }
            DateTime date = File.GetLastWriteTime(Program.SOPDPath);
            DatabaseInfoLabel.Text = DatabaseVersionBase.Replace("[DATABASEGENDATE]", date.Year.CompareTo(new DateTime(2018, 1, 1).Year) < 0 ? FileDoesntExist : date.ToLongDateString()).Replace("[VER]", ver);

            ver = SettingsInvalid;
            if (File.Exists(Program.SODDPath))
            {
                FileStream FS   = new FileStream(Program.SODDPath, FileMode.Open);
                byte[]     Read = new byte[4];
                FS.Read(Read, 0, 4);
                if (Encoding.ASCII.GetString(Read) != "SODD")
                {
                    throw new Exception("Invalid Description File");
                }

                Version Check = new Version(FS.ReadByte(), FS.ReadByte());
                ver = Check.Equals(Spotlight.ObjectInformationDatabase.ObjectInformationDatabase.LatestVersion) ? Spotlight.ObjectInformationDatabase.ObjectInformationDatabase.LatestVersion.ToString() : Check.ToString() + $" ({DatabaseOutdated})";
                FS.Close();
            }
            else
            {
                ClearDescriptionsButton.Enabled = false;
            }
            date = File.GetLastWriteTime(Program.SODDPath);
            DescriptionInfoLabel.Text = DescriptionInfoLabel.Text.Replace("[DATABASEGENDATE]", date.Year.CompareTo(new DateTime(2018, 1, 1).Year) < 0 ? FileDoesntExist : date.ToLongDateString()).Replace("[VER]", ver);

            #endregion

            RenderAreaCheckBox.Checked     = Properties.Settings.Default.DrawAreas;
            RenderSkyboxesCheckBox.Checked = Properties.Settings.Default.DrawSkyBoxes;
            switch (Properties.Settings.Default.PlayerChoice)
            {
            case "None":
                PlayerComboBox.SelectedIndex = 0;
                break;

            case "Mario":
                PlayerComboBox.SelectedIndex = 1;
                break;

            case "Luigi":
                PlayerComboBox.SelectedIndex = 2;
                break;

            case "Peach":
                PlayerComboBox.SelectedIndex = 3;
                break;

            case "Toad":
                PlayerComboBox.SelectedIndex = 4;
                break;

            case "Rosalina":
                PlayerComboBox.SelectedIndex = 5;
                break;
            }
            UniqueIDsCheckBox.Checked = Properties.Settings.Default.UniqueIDs;
            IDEditingCheckBox.Checked = Properties.Settings.Default.AllowIDEdits;
            if (!Directory.Exists(Program.LanguagePath))
            {
                LanguageComboBox.Enabled       = false;
                LanguageComboBox.SelectedIndex = 0;
            }
            else
            {
                string[] Files     = Directory.GetFiles(Program.LanguagePath);
                int      langcount = Files.Length;
                for (int i = 0; i < langcount; i++)
                {
                    if (!LanguageComboBox.Items.Contains(Files[i].Replace(Program.LanguagePath + "\\", "").Replace(".txt", "")))
                    {
                        LanguageComboBox.Items.Add(Files[i].Replace(Program.LanguagePath + "\\", "").Replace(".txt", ""));
                    }
                }

                if (File.Exists(Path.Combine(Program.LanguagePath, Properties.Settings.Default.Language + ".txt")))
                {
                    for (int i = 0; i < LanguageComboBox.Items.Count; i++)
                    {
                        if (LanguageComboBox.Items[i].Equals(Properties.Settings.Default.Language))
                        {
                            LanguageComboBox.SelectedIndex = i;
                            break;
                        }
                    }
                }
                else
                {
                    LanguageComboBox.SelectedIndex = 0;
                }
            }
        }