Exemple #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();
            }


            Form host = new Form();

            host.Controls.Add(new GLControl());

            host.Load += (x, y) =>
            {
                StartUpForm = new LevelEditorForm();

                Rectangle?bounds = null;

                while (StartUpForm != null)
                {
                    var f = StartUpForm;
                    StartUpForm = null;

                    f.Load += (x2, y2) =>
                    {
                        if (bounds != null)
                        {
                            f.SetBounds(bounds.Value.X, bounds.Value.Y, bounds.Value.Width, bounds.Value.Height);
                        }
                    };

                    f.Shown += (x2, y2) => f.TopLevel = true;

                    f.ShowDialog(host);
                    bounds = f.DesktopBounds;
                }

                host.Close();
            };


            Application.Run(host);
        }
Exemple #2
0
        public SettingsForm(LevelEditorForm home)
        {
            Home = home;
            InitializeComponent();
            CenterToParent();
            Localize();

            if (Properties.Settings.Default.GamePaths == null)
            {
                Properties.Settings.Default.GamePaths = new StringCollection();
            }

            if (Properties.Settings.Default.ProjectPaths == null)
            {
                Properties.Settings.Default.ProjectPaths = new StringCollection();
            }

            if (!string.IsNullOrEmpty(Program.GamePath))
            {
                Properties.Settings.Default.GamePaths.AddUnique(Program.GamePath);
            }

            if (!string.IsNullOrEmpty(Program.ProjectPath))
            {
                Properties.Settings.Default.ProjectPaths.AddUnique(Program.ProjectPath);
            }

            Properties.Settings.Default.Save();

            GamePathTextBox.Text = Program.GamePath;
            GamePathTextBox.PossibleSuggestions = Properties.Settings.Default.GamePaths.ToArray();

            ProjectPathTextBox.Text = Program.ProjectPath;
            ProjectPathTextBox.PossibleSuggestions = Properties.Settings.Default.ProjectPaths.ToArray();

            #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(Database.ObjectInformationDatabase.LatestVersion) ? Database.ObjectInformationDatabase.LatestVersion.ToString() : Check.ToString() + $" ({DatabaseOutdated})";
                FS.Close();
            }
            else
            {
                ClearDescriptionsButton.Enabled = false;
            }
            date = File.GetLastWriteTime(Program.SODDPath);
            DescriptionInfoLabel.Text = DescriptionVersionBase.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;
            RenderTransparentWallsCheckBox.Checked = Properties.Settings.Default.DrawTransparentWalls;

            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;
            DoNotLoadTexturesCheckBox.Checked = Properties.Settings.Default.DoNotLoadTextures;
            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;
                }
            }

            string tmp = Properties.Settings.Default.SplashSize.Width + "x" + Properties.Settings.Default.SplashSize.Height;
            SplashSizeComboBox.SelectedItem = tmp;
        }