518 {
521 List<TEX0Node> texList = new List<TEX0Node>();
523 {
525 {
526 continue;
527 }
528
530 if (tx0.
Name.StartsWith(matchName) && tx0.
Name.LastIndexOf(
".") > 0 &&
531 tx0.
Name.LastIndexOf(
".") < tx0.Name.Length &&
532 int.TryParse(
533 tx0.
Name.Substring(tx0.
Name.LastIndexOf(
".") + 1,
534 tx0.
Name.Length - (tx0.
Name.LastIndexOf(
".") + 1)), out
int x) && x >= 0)
535 {
536 tx0.texSortNum = x;
537 if (x <= 0)
538 {
539 tx0.texSortNum = 0;
541 {
543 }
544
545 tx0.Name =
"InfStc." + tx0.
texSortNum.ToString(
"000");
547 .FindChildrenByName("InfStc." + x.ToString("0000"))
548 .Count() > 0)
549 {
552 "InfStc." + x.ToString(
553 "0000")))
554 {
556 }
557 }
558 }
559 else if (x == 9001)
560 {
561 tx0.texSortNum = 475 + x % 9001;
563 {
565 }
566
567 tx0.Name =
"InfStc." + tx0.
texSortNum.ToString(
"000");
569 .FindChildrenByName("InfStc." + x.ToString("0000"))
570 .Count() > 0)
571 {
574 "InfStc." + x.ToString(
575 "0000")))
576 {
578 }
579 }
580 }
581 else if (x % 50 <= 10 && x % 50 != 0 ||
582 x >= 0961 && x <= 0965 ||
583 x >= 1711 && x <= 1715 ||
584 x >= 1861 && x <= 1864 ||
585 x >= 2011 && x <= 2015 ||
586 x >= 2311 && x <= 2314)
587 {
588 tx0.texSortNum = (int) Math.Floor(((double) x + 1) / 50.0) * 10 + x % 10;
589
590 if (x % 10 == 0 ||
591 x >= 0961 && x <= 0965 ||
592 x >= 1711 && x <= 1715 ||
593 x >= 1861 && x <= 1864 ||
594 x >= 2011 && x <= 2015 ||
595 x >= 2311 && x <= 2314)
596 {
597 tx0.texSortNum += 10;
598 }
599
601 {
603 }
604
605 tx0.Name =
"InfStc." + tx0.
texSortNum.ToString(
"000");
607 .FindChildrenByName("InfStc." + x.ToString("0000"))
608 .Count() > 0)
609 {
612 "InfStc." + x.ToString(
613 "0000")))
614 {
616 }
617 }
618 }
619 else
620 {
622 {
624 }
625
626 tx0.Name =
"InfStcX." + tx0.
texSortNum.ToString(
"0000");
628 .FindChildrenByName("InfStc." + x.ToString("0000"))
629 .Count() > 0)
630 {
633 "InfStc." + x.ToString(
634 "0000")))
635 {
637 }
638 }
639 }
640 }
641 }
642
645 {
647 .FindChildrenByName(newPat0.
Name);
648 if (temp.Length > 0)
649 {
651 {
653 }
654 }
655 }
656
658 {
660 .FindChildrenByName(newPat0.
Name);
661 if (temp.Length > 0)
662 {
664 {
666 }
667 }
668 }
669
670 if (MessageBox.Show(
671 "Would you like to convert the InfFace portraits to the new system as well at this time?",
672 "Convert InfFace?", MessageBoxButtons.YesNo) == DialogResult.Yes)
673 {
674 string infFaceFolder = "";
675 bool autoFoundFolder = false;
676 if (Program.RootPath.EndsWith("\\info2\\info.pac", StringComparison.OrdinalIgnoreCase))
677 {
678 string autoFolder =
679 Program.RootPath.Substring(0, Program.RootPath.LastIndexOf("\\info2\\info.pac")) +
680 "\\info\\portrite";
681 if (Directory.Exists(autoFolder))
682 {
683 if (MessageBox.Show(
684 "The folder for InfFace was autodetected to be: \n" + autoFolder +
685 "\n\nIs this correct?", "InfFace Converter", MessageBoxButtons.YesNo) ==
686 DialogResult.Yes)
687 {
688 infFaceFolder = autoFolder;
689 autoFoundFolder = true;
690 }
691 }
692 }
693
694 if (!autoFoundFolder)
695 {
696 FolderBrowserDialog f = new FolderBrowserDialog
697 {
698 Description = "Select the \"portrite\" folder"
699 };
700 DialogResult dr = f.ShowDialog();
701 infFaceFolder = f.SelectedPath;
702 if (dr != DialogResult.OK || infFaceFolder == null || infFaceFolder == "")
703 {
704 return;
705 }
706 }
707
708 try
709 {
710 DirectoryInfo d = Directory.CreateDirectory(infFaceFolder);
711 DirectoryInfo d2 = Directory.CreateDirectory(infFaceFolder + '\\' + "temp");
712 Console.WriteLine(infFaceFolder);
713 int count = 0;
714 foreach (FileInfo infFace in d.GetFiles().Reverse())
715 {
716 Console.WriteLine(infFaceFolder + '\\' + infFace.Name);
717 int properlength = infFace.Name.EndsWith(".brres", StringComparison.OrdinalIgnoreCase)
718 ? infFace.Name.Length - ".brres".Length
719 : infFace.Name.Length;
720
721 if (infFace.Name.StartsWith("InfFace") && !infFace.Name.StartsWith("InfFaceX") &&
722 infFace.Name.EndsWith(".brres", StringComparison.CurrentCultureIgnoreCase) &&
723 int.TryParse(infFace.Name.Substring(7, properlength - 7), out int x) && x >= 0)
724 {
725 int n = x;
726 if (x <= 0)
727 {
728 n = 0;
729 infFace.MoveTo(infFaceFolder + '\\' + "temp" + '\\' + "InfFace" + n.ToString("000") +
730 ".brres");
731 }
732 else if (x >= 9001 && x <= 9014)
733 {
734 n = 661 + x % 9001;
735 infFace.MoveTo(infFaceFolder + '\\' + "temp" + '\\' + "InfFace" + n.ToString("000") +
736 ".brres");
737 }
738 else if (x % 50 <= 10 && x % 50 != 0 ||
739 x >= 0961 && x <= 0965 ||
740 x >= 1711 && x <= 1715 ||
741 x >= 1861 && x <= 1864 ||
742 x >= 2011 && x <= 2015 ||
743 x >= 2311 && x <= 2314)
744 {
745 n = (int) Math.Floor(((double) x + 1) / 50.0) * 10 + x % 10;
746
747 if (x % 10 == 0 ||
748 x >= 0961 && x <= 0965 ||
749 x >= 1711 && x <= 1715 ||
750 x >= 1861 && x <= 1864 ||
751 x >= 2011 && x <= 2015 ||
752 x >= 2311 && x <= 2314)
753 {
754 n += 10;
755 }
756
757 infFace.MoveTo(infFaceFolder + '\\' + "temp" + '\\' + "InfFace" + n.ToString("000") +
758 ".brres");
759 count++;
760 }
761 else
762 {
763 infFace.MoveTo(infFaceFolder + '\\' + "temp" + '\\' + "InfFaceX" + n.ToString("0000") +
764 ".brres");
765 count++;
766 }
767 }
768 }
769
770 foreach (FileInfo infFace in d2.GetFiles())
771 {
772 infFace.MoveTo(infFaceFolder + '\\' + infFace.Name +
773 (infFace.Name.EndsWith(".brres", StringComparison.OrdinalIgnoreCase)
774 ? ""
775 : ".brres"));
776 }
777
778 d2.Delete();
779 if (count > 0)
780 {
781 MessageBox.Show("InfFace conversion successful!");
782 }
783 else
784 {
785 MessageBox.Show("No convertable InfFace portraits found in " + infFaceFolder);
786 }
787 }
788 catch (Exception e)
789 {
790 MessageBox.Show(e.Message);
791 }
792 }
793 }