Ejemplo n.º 1
0
        private void btnOpenFold_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();

            System.Windows.Forms.DialogResult result = fbd.ShowDialog();
            if (result.ToString() == "OK")
            {
                package = new FontPackage();

                switch (package.LoadH2Folder(fbd.SelectedPath))
                {
                case 0:
                    break;

                case 1:
                    WriteLog("Folder \"\\" + System.IO.Path.GetFileName(inputpkgpath.Text) + "\" contained no valid fonts.");
                    return;
                }
            }
            else
            {
                return;
            }

            inputpkgpath.Text = fbd.SelectedPath;

            WriteLog("Folder \"\\" + System.IO.Path.GetFileName(inputpkgpath.Text) + "\" has been loaded successfully with " + package.Fonts.Count + " fonts.");

            btnSavefile.IsEnabled = true;
            FinishOpening();
        }
Ejemplo n.º 2
0
        private void btnOpenPkg_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
            ofd.RestoreDirectory = true;
            ofd.Title            = "Open Font Package";
            ofd.Filter           = "Font Collection (*.bin,*.txt)|*.bin;*.txt|Single H2 Font (*.*) | *";
            if ((bool)ofd.ShowDialog())
            {
                package = new FontPackage();

                if (!ofd.FileName.EndsWith(".bin"))
                {
                    switch (package.LoadH2(ofd.FileName))
                    {
                    case 0:
                        break;

                    case 1:
                        WriteLog("File \"" + ofd.SafeFileName + "\" has an invalid header version value and was not loaded.");
                        return;

                    case 2:
                        WriteLog("List \"" + ofd.SafeFileName + "\" contained no valid fonts.");
                        return;
                    }

                    btnSavefile.IsEnabled = true;
                }
                else
                {
                    switch (package.Load(ofd.FileName))
                    {
                    case 0:
                        break;

                    case 1:
                        WriteLog("File \"" + ofd.SafeFileName + "\" has an invalid header version value and was not loaded.");
                        return;

                    case 2:
                        WriteLog("File \"" + ofd.SafeFileName + "\" has a font count of 0 and was not loaded.");
                        return;
                    }

                    btnSavefile.IsEnabled = false;
                }

                inputpkgpath.Text = ofd.FileName;

                WriteLog("File \"" + ofd.SafeFileName + "\" has been loaded successfully with " + package.Fonts.Count + " fonts.");

                FinishOpening();
            }
        }
Ejemplo n.º 3
0
        private void HOCopy(object sender, RoutedEventArgs e)
        {
            ushort startchar = ParseChar("Copy", HOstart.Text);

            if (startchar == 0xFFFF)
            {
                return;
            }

            ushort endchar = ParseChar("Copy", HOend.Text);

            if (endchar == 0xFFFF)
            {
                return;
            }

            if (startchar > endchar)
            {
                WriteLog("Copy failed: Invalid character range.");
                return;
            }

            Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
            ofd.RestoreDirectory = true;
            ofd.Title            = "Open Font Package";
            ofd.Filter           = "Font Package (*.bin)|*.bin|Single H2 Font (*.*) | *";
            if ((bool)ofd.ShowDialog())
            {
                FontPackage package2 = new FontPackage();

                bool ish2 = false;

                if (ofd.FileName.EndsWith(".bin"))
                {
                    package2.Load(ofd.FileName);
                }
                else if (!ofd.FileName.EndsWith(".txt"))
                {
                    package2.LoadH2(ofd.FileName);
                    ish2 = true;
                }

                else
                {
                    WriteLog("Copy failed: Halo 2 .txt files not supported for copying.");
                }

                ushort fontindex = 0;

                if (!ish2)
                {
                    fontindex = ParseChar("Copy", HOfont.Text);
                    if (fontindex == 0xFFFF && !ish2)
                    {
                        return;
                    }
                }



                if (fontindex > package2.Fonts.Count)
                {
                    WriteLog("Copy failed: Invalid font index for second package.");
                    package2 = new FontPackage();
                    return;
                }

                for (int i = 0; i < package2.Fonts[fontindex].Characters.Count; i++)
                {
                    if (package2.Fonts[fontindex].Characters[i].CharCode >= startchar && package2.Fonts[fontindex].Characters[i].CharCode <= endchar)
                    {
                        var existingchar = package.Fonts[fontslist.SelectedIndex].FindCharacter(package2.Fonts[fontindex].Characters[i].CharCode);

                        if (existingchar != -1)
                        {
                            package.Fonts[fontslist.SelectedIndex].Characters[existingchar].Data = package2.Fonts[fontindex].Characters[i].Data;
                        }
                        else
                        {
                            package.Fonts[fontslist.SelectedIndex].Characters.Add(package2.Fonts[fontindex].Characters[i]);
                        }
                    }
                }

                package.Fonts[fontslist.SelectedIndex].SortCharacters();

                if ((bool)HOinfo.IsChecked)
                {
                    UpdateFontInfo(package2.Fonts[fontindex].LineHeight, package2.Fonts[fontindex].LineTopPad, package2.Fonts[fontindex].LineBottomPad, package2.Fonts[fontindex].LineIndent);
                }

                UpdateFontDisplay();

                WriteLog("Characters successfully copied from font \"" + package2.Fonts[fontindex].Name + "\" in package \"" + ofd.SafeFileName + "\".");
                package2 = new FontPackage();
            }
        }