Example #1
0
 private void ClearDescriptionsButton_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(DescriptionClearText, DescriptionClearHeader, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         File.Delete(Program.SODDPath);
         DescriptionInfoLabel.Text = DescriptionVersionBase.Replace("[DATABASEGENDATE]", FileDeleted).Replace("[VER]", SettingsInvalid);
         MessageBox.Show(DescriptionClearSuccessText, DescriptionClearSuccessHeader, MessageBoxButtons.OK, MessageBoxIcon.Information);
         ClearDescriptionsButton.Enabled = false;
     }
 }
        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;
        }
        public void Localize()
        {
            this.Localize(
                GamePathLabel,
                ProjectPathLabel,
                ObjectParameterGroupBox,
                RebuildDatabaseButton,
                ClearDescriptionsButton,
                RenderingGroupBox,
                RenderAreaCheckBox,
                RenderSkyboxesCheckBox,
                PlayerLabel,

                LoadingAndSavingGroupBox,
                UniqueIDsCheckBox,
                EditingGroupBox,
                IDEditingCheckBox,
                MiscellaneousGroupBox,
                LanguageLabel,
                SplashSizeLabel,
                SplashTestButton,
                ResetSpotlightButton,

                LoadingAndSavingGroupBox,
                UniqueIDsCheckBox,
                EditingGroupBox,
                IDEditingCheckBox,
                MiscellaneousGroupBox,
                LanguageLabel,
                SplashSizeLabel,
                SplashTestButton,
                ResetSpotlightButton
                );

            Loading = true;
            int tempplayerid = PlayerComboBox.SelectedIndex;

            PlayerComboBox.Items.Clear();
            PlayerComboBox.Items.Add(Program.CurrentLanguage.GetTranslation("PlayerNone") ?? "None");
            PlayerComboBox.Items.Add(Program.CurrentLanguage.GetTranslation("PlayerMario") ?? "Mario");
            PlayerComboBox.Items.Add(Program.CurrentLanguage.GetTranslation("PlayerLuigi") ?? "Luigi");
            PlayerComboBox.Items.Add(Program.CurrentLanguage.GetTranslation("PlayerPeach") ?? "Peach");
            PlayerComboBox.Items.Add(Program.CurrentLanguage.GetTranslation("PlayerToad") ?? "Toad");
            PlayerComboBox.Items.Add(Program.CurrentLanguage.GetTranslation("PlayerRosalina") ?? "Rosalina");
            PlayerComboBox.SelectedIndex = tempplayerid;
            Loading = false;

            #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.Database.ObjectInformationDatabase.LatestVersion) ? Spotlight.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

            switch (PlayerComboBox.SelectedIndex)
            {
            case 0:
                Properties.Settings.Default.PlayerChoice = "None";
                break;

            case 1:
                Properties.Settings.Default.PlayerChoice = "Mario";
                break;

            case 2:
                Properties.Settings.Default.PlayerChoice = "Luigi";
                break;

            case 3:
                Properties.Settings.Default.PlayerChoice = "Peach";
                break;

            case 4:
                Properties.Settings.Default.PlayerChoice = "Toad";
                break;

            case 5:
                Properties.Settings.Default.PlayerChoice = "Rosalina";
                break;
            }
        }
Example #4
0
        public void Localize()
        {
            Text = Program.CurrentLanguage.GetTranslation("SettingsTitle") ?? "Spotlight - Settings";
            DatabaseVersionBase          = Program.CurrentLanguage.GetTranslation("DatabaseVersionBase") ?? "Database Last Built on: [DATABASEGENDATE].    Version: [VER]";
            DescriptionVersionBase       = Program.CurrentLanguage.GetTranslation("DescriptionVersionBase") ?? "Descriptions Last Edited on: [DATABASEGENDATE].    Version: [VER]";
            FileDoesntExist              = Program.CurrentLanguage.GetTranslation("FileDoesntExist") ?? "N/A (File doesn't exist)";
            FileDeleted                  = Program.CurrentLanguage.GetTranslation("FileDeleted") ?? "N/A (File was deleted)";
            SettingsInvalid              = Program.CurrentLanguage.GetTranslation("SettingsInvalid") ?? "Invalid";
            DatabaseOutdated             = Program.CurrentLanguage.GetTranslation("DatabaseOutdated") ?? "Outdated";
            DatabasePickerTitle          = Program.CurrentLanguage.GetTranslation("DatabasePickerTitle") ?? "Select the Game Directory of Super Mario 3D World";
            InvalidFolder                = Program.CurrentLanguage.GetTranslation("InvalidFolder") ?? "The Directory doesn't contain ObjectData and StageData.";
            InvalidGamePath              = Program.CurrentLanguage.GetTranslation("DatabaseOutdated") ?? "The GamePath is invalid";
            InvalidProjectPath           = Program.CurrentLanguage.GetTranslation("DatabaseOutdated") ?? "The ProjectPath is invalid";
            DatabaseRebuildSuccessText   = Program.CurrentLanguage.GetTranslation("DatabaseRebuildSuccessText") ?? "Database has been rebuilt!";
            DatabaseRebuildSuccessHeader = Program.CurrentLanguage.GetTranslation("DatabaseRebuildSuccessHeader") ?? "Success";
            DescriptionClearText         = Program.CurrentLanguage.GetTranslation("DescriptionClearText") ??
                                           @"Are you sure you want to empty out your description database?
(This action cannot be undone)";
            DescriptionClearHeader        = Program.CurrentLanguage.GetTranslation("DescriptionClearHeader") ?? "Confirmation";
            DescriptionClearSuccessText   = Program.CurrentLanguage.GetTranslation("DescriptionClearSuccessText") ?? "Descriptions Deleted";
            DescriptionClearSuccessHeader = Program.CurrentLanguage.GetTranslation("DescriptionClearSuccessHeader") ?? "Success";
            ResetWarningText   = Program.CurrentLanguage.GetTranslation("ResetWarningText") ?? "This will reset all your customizations, delete your Object Database and Description Database, and quit spotlight without saving.\nAre you sure you want to continue?";
            ResetWarningHeader = Program.CurrentLanguage.GetTranslation("ResetWarningHeader") ?? "Warning";

            GamePathLabel.Text           = Program.CurrentLanguage.GetTranslation("GamePathLabel") ?? "Game Directory:";
            ProjectPathLabel.Text        = Program.CurrentLanguage.GetTranslation("ProjectPathLabel") ?? "Project Directory:";
            ObjectParameterGroupBox.Text = Program.CurrentLanguage.GetTranslation("ObjectParameterGroupBox") ?? "Databases";
            RebuildDatabaseButton.Text   = Program.CurrentLanguage.GetTranslation("RebuildDatabaseButton") ?? "Rebuild";
            ClearDescriptionsButton.Text = Program.CurrentLanguage.GetTranslation("ClearDescriptionsButton") ?? "Clear";
            RenderingGroupBox.Text       = Program.CurrentLanguage.GetTranslation("RenderingGroupBox") ?? "Rendering";
            RenderAreaCheckBox.Text      = Program.CurrentLanguage.GetTranslation("RenderAreaCheckBox") ?? "Render Areas";
            RenderSkyboxesCheckBox.Text  = Program.CurrentLanguage.GetTranslation("RenderSkyboxesCheckBox") ?? "Render Skyboxes";
            PlayerLabel.Text             = Program.CurrentLanguage.GetTranslation("PlayerLabel") ?? "Player:";
            Loading = true;
            int tempplayerid = PlayerComboBox.SelectedIndex;

            PlayerComboBox.Items.Clear();
            PlayerComboBox.Items.Add(Program.CurrentLanguage.GetTranslation("PlayerNone") ?? "None");
            PlayerComboBox.Items.Add(Program.CurrentLanguage.GetTranslation("PlayerMario") ?? "Mario");
            PlayerComboBox.Items.Add(Program.CurrentLanguage.GetTranslation("PlayerLuigi") ?? "Luigi");
            PlayerComboBox.Items.Add(Program.CurrentLanguage.GetTranslation("PlayerPeach") ?? "Peach");
            PlayerComboBox.Items.Add(Program.CurrentLanguage.GetTranslation("PlayerToad") ?? "Toad");
            PlayerComboBox.Items.Add(Program.CurrentLanguage.GetTranslation("PlayerRosalina") ?? "Rosalina");
            PlayerComboBox.SelectedIndex = tempplayerid;
            switch (PlayerComboBox.SelectedIndex)
            {
            case 0:
                Properties.Settings.Default.PlayerChoice = "None";
                break;

            case 1:
                Properties.Settings.Default.PlayerChoice = "Mario";
                break;

            case 2:
                Properties.Settings.Default.PlayerChoice = "Luigi";
                break;

            case 3:
                Properties.Settings.Default.PlayerChoice = "Peach";
                break;

            case 4:
                Properties.Settings.Default.PlayerChoice = "Toad";
                break;

            case 5:
                Properties.Settings.Default.PlayerChoice = "Rosalina";
                break;
            }
            Loading = false;
            LoadingAndSavingGroupBox.Text = Program.CurrentLanguage.GetTranslation("LoadingAndSavingGroupBox") ?? "Loading and Saving";
            UniqueIDsCheckBox.Text        = Program.CurrentLanguage.GetTranslation("UniqueIDsCheckBox") ?? "Only load unique ObjectIDs (disable if objects disappear when loading a custom level)";
            EditingGroupBox.Text          = Program.CurrentLanguage.GetTranslation("EditingGroupBox") ?? "Editing";
            IDEditingCheckBox.Text        = Program.CurrentLanguage.GetTranslation("IDEditingCheckBox") ?? "Enable ID Editing";
            MiscellaneousGroupBox.Text    = Program.CurrentLanguage.GetTranslation("MiscellaneousGroupBox") ?? "Miscellaneous";
            LanguageLabel.Text            = Program.CurrentLanguage.GetTranslation("LanguageLabel") ?? "Language:";
            SplashSizeLabel.Text          = Program.CurrentLanguage.GetTranslation("SplashSizeLabel") ?? "Splash Size:";
            SplashTestButton.Text         = Program.CurrentLanguage.GetTranslation("SplashTestButton") ?? "Test";
            ResetSpotlightButton.Text     = Program.CurrentLanguage.GetTranslation("ResetSpotlightButton") ?? "Reset";

            #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.Database.ObjectInformationDatabase.LatestVersion) ? SpotLight.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
        }