Esempio n. 1
0
        /// <summary>Finds the <see cref="WoWLanguagePack"/>s associated with this <see cref="WoWInstallation"/>.</summary>
        /// <param name="installation"><see cref="WoWInstallation"/> belonging to the language packs.</param>
        /// <remarks>Each <see cref="WoWLanguagePack"/> itself contains another list of archives.</remarks>
        /// <exception cref="FileNotFoundException">Couldn't determine installation kind.</exception>
        public IList<WoWLanguagePack> CollectLanguagePacks(WoWInstallation installation)
        {
            if (!installationKind.HasValue && !DetermineInstallationKind().HasValue) throw new FileNotFoundException();

            var languagePackList = new List<WoWLanguagePack>();

            foreach (string directoryPath in Directory.GetDirectories(dataPath))
            {
                string directoryName = Path.GetFileName(directoryPath);

                if (directoryName != null && directoryName.Length == 4)
                {
                    try
                    {
                        // Tries to create a CultureInfo object from th directory name
                        // WoW language packs use standard culture identifiers, meaning this should only fail if an invalid directory is found here
                        CultureInfo culture = CultureInfo.GetCultureInfo(directoryName.Substring(0, 2) + '-' + directoryName.Substring(2, 2));
                        var archives = versionHandlers[installationKind.Value].CollectLanguagePackArchives(directoryPath, directoryName);
                        languagePackList.Add(new WoWLanguagePack(installation, culture, archives));
                    }
                    catch (ArgumentException) { } // Catches only CultureNotFoundException, which should only happen when there is no CultureInfo with that name
                }
            }

            return languagePackList;
        }
Esempio n. 2
0
        static WoWLanguagePack ChooseLanguagePack(WoWInstallation wowInstallation)
        {
            CultureInfo desiredCulture = Properties.Settings.Default.LanguagePackCulture;

            if (wowInstallation.LanguagePacks.Count == 1)
            {
                return(wowInstallation.LanguagePacks[0]);
            }

            foreach (WoWLanguagePack languagePack in wowInstallation.LanguagePacks)
            {
                if (languagePack.Culture == desiredCulture)
                {
                    return(languagePack);
                }
            }

            using (LanguagePackDialog languagePackDialog = new LanguagePackDialog())
            {
                languagePackDialog.WoWInstallation = wowInstallation;

                switch (languagePackDialog.ShowDialog())
                {
                case DialogResult.OK:
                    return(languagePackDialog.LanguagePack);

                default:
                    return(null);
                }
            }
        }
Esempio n. 3
0
 public MpqFileReader(WoWInstallation installation)
 {
     var languagePack = installation.LanguagePacks.FirstOrDefault(l => l.Culture.Equals(CultureInfo.CurrentUICulture))
         ?? installation.LanguagePacks.FirstOrDefault(l => l.Culture.Name == "en-GB")
         ?? installation.LanguagePacks.First();
     _fileSystem = installation.CreateFileSystem(languagePack, false);
 }
        /// <summary>Finds the <see cref="WoWLanguagePack"/>s associated with this <see cref="WoWInstallation"/>.</summary>
        /// <param name="installation"><see cref="WoWInstallation"/> belonging to the language packs.</param>
        /// <remarks>Each <see cref="WoWLanguagePack"/> itself contains another list of archives.</remarks>
        /// <exception cref="FileNotFoundException">Couldn't determine installation kind.</exception>
        public IList <WoWLanguagePack> CollectLanguagePacks(WoWInstallation installation)
        {
            if (!installationKind.HasValue && !DetermineInstallationKind().HasValue)
            {
                throw new FileNotFoundException();
            }

            var languagePackList = new List <WoWLanguagePack>();

            foreach (string directoryPath in Directory.GetDirectories(dataPath))
            {
                string directoryName = Path.GetFileName(directoryPath);

                if (directoryName != null && directoryName.Length == 4)
                {
                    try
                    {
                        // Tries to create a CultureInfo object from th directory name
                        // WoW language packs use standard culture identifiers, meaning this should only fail if an invalid directory is found here
                        CultureInfo culture  = CultureInfo.GetCultureInfo(directoryName.Substring(0, 2) + '-' + directoryName.Substring(2, 2));
                        var         archives = versionHandlers[installationKind.Value].CollectLanguagePackArchives(directoryPath, directoryName);
                        languagePackList.Add(new WoWLanguagePack(installation, culture, archives));
                    }
                    catch (ArgumentException) { } // Catches only CultureNotFoundException, which should only happen when there is no CultureInfo with that name
                }
            }

            return(languagePackList);
        }
Esempio n. 5
0
 public MainForm(WoWInstallation wowInstallation, WoWLanguagePack languagePack)
 {
     InitializeComponent();
     // Initialize WoW file system
     this.wowInstallation = wowInstallation;
     this.languagePack    = languagePack;
     // Create resources for drawing text
     zoneInformationBrush = Brushes.White;
     zoneInformationPen   = new Pen(Color.Black, 5);
     // Get and create resources for error…
     zoneErrorBrush = Brushes.Red;
     // Creates the bitmap
     mapBitmap = new Bitmap(1002, 668, PixelFormat.Format32bppRgb);
     Size      = new Size(this.Width - renderPanel.ClientSize.Width + 1002, this.Height - renderPanel.ClientSize.Height + 668);
     renderPanel.BackgroundImage = mapBitmap;
     // Initialization
     InitializeFileSystem();
     LoadDatabases();
     LoadFonts();
     currentContinent = -1;
     InitializeMapData();
     FillContinents();
     FillZones();
     LoadCosmicHighlights();
     UpdateMap();
 }
Esempio n. 6
0
        public MpqFileReader(WoWInstallation installation)
        {
            var languagePack = installation.LanguagePacks.FirstOrDefault(l => l.Culture.Equals(CultureInfo.CurrentUICulture))
                               ?? installation.LanguagePacks.FirstOrDefault(l => l.Culture.Name == "en-GB")
                               ?? installation.LanguagePacks.First();

            _fileSystem = installation.CreateFileSystem(languagePack, false);
        }
Esempio n. 7
0
 public MainForm(WoWInstallation wowInstallation, WoWLanguagePack languagePack)
 {
     InitializeComponent();
     this.wowInstallation     = wowInstallation;
     this.languagePack        = languagePack;
     this.wowFileSystem       = wowInstallation.CreateFileSystem(languagePack, false);
     spellDatabase            = LoadDatabase <SpellRecord>(@"DBFilesClient\Spell.dbc");
     spellIconDatabase        = LoadDatabase <SpellIconRecord>(@"DBFilesClient\SpellIcon.dbc");
     countToolStripLabel.Text = string.Format(CultureInfo.CurrentUICulture, Properties.Resources.SpellCountFormatString, spellDatabase.Records.Count);
     spellInformation         = new SpellInformation(spellDatabase);
     UpdateDisplayInfo();
 }
Esempio n. 8
0
        private void OpenWoWFileSystem()
        {
            UseWaitCursor = true;

            Application.DoEvents();

            if (fileSystem != null)
            {
                fileSystem.Dispose();
            }
            fileSystem = null;

            try
            {
                var wowInstallation = WoWInstallation.Find();

                languagePackDialog.WoWInstallation = wowInstallation;

                foreach (var languagePack in wowInstallation.LanguagePacks)
                {
                    if (languagePack.Culture == System.Globalization.CultureInfo.CurrentCulture)
                    {
                        languagePackDialog.LanguagePack = languagePack;
                    }
                }

                if (wowInstallation.LanguagePacks.Count > 1)
                {
                    if (languagePackDialog.ShowDialog(this) != DialogResult.OK)
                    {
                        return;
                    }
                }

                ClearView();
                fileSystem = wowInstallation.CreateFileSystem(languagePackDialog.LanguagePack, false, true);
                SetTitle(wowInstallation.Path);
                FillTreeView();

                saveAsToolStripMenuItem.Enabled = true;
                saveAsToolStripButton.Enabled   = true;
            }
            catch (Exception ex) { ErrorDialog(ex.ToString()); }
            finally { UseWaitCursor = false; }
        }
Esempio n. 9
0
        static WoWInstallation FindWoWInstallation()
        {
            WoWInstallation wowInstallation = null;

            // Try to find a valid wow installation
            try { wowInstallation = WoWInstallation.Find(); }
            catch (DirectoryNotFoundException)
            {
                // If we can't find wow, terminate here
                MessageBox.Show(Properties.Resources.CannotFindWow, Properties.Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Properties.Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }

            return(wowInstallation);
        }
Esempio n. 10
0
        static WoWLanguagePack ChooseLanguagePack(WoWInstallation wowInstallation)
        {
            CultureInfo desiredCulture = Properties.Settings.Default.LanguagePackCulture;

            if (wowInstallation.LanguagePacks.Count == 1)
                return wowInstallation.LanguagePacks[0];

            foreach (WoWLanguagePack languagePack in wowInstallation.LanguagePacks)
                if (languagePack.Culture == desiredCulture)
                    return languagePack;

            using (LanguagePackDialog languagePackDialog = new LanguagePackDialog())
            {
                languagePackDialog.WoWInstallation = wowInstallation;

                switch (languagePackDialog.ShowDialog())
                {
                    case DialogResult.OK:
                        return languagePackDialog.LanguagePack;
                    default:
                        return null;
                }
            }
        }
Esempio n. 11
0
 public MpqFileReader() : this(WoWInstallation.Find())
 {
 }
Esempio n. 12
0
        internal WoWLanguagePack(WoWInstallation wowInstallation, CultureInfo culture, IList<WoWArchiveInformation> archiveArray)
        {
            this.wowInstallation = wowInstallation;
            this.culture = culture;
            this.wowCultureId = string.Join(null, culture.Name.Split('-'));
            if (!localeFieldIndexDictionary.TryGetValue(this.wowCultureId, out this.localeFieldIndex))
                this.localeFieldIndex = -1;
            this.dataPath = IOPath.Combine(wowInstallation.DataPath, wowCultureId);

            archiveCollection = new ReadOnlyCollection<WoWArchiveInformation>(archiveArray);
        }