miijs 1.5.6 → 1.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +366 -15
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -82,7 +82,7 @@ function downloadImage(url, filepath) {
82
82
  });
83
83
  });
84
84
  }
85
- var wiiCols=["Red","Orange","Yellow","Lime","Green","Blue","Light Blue","Pink","Purple","Brown","White","Black"];
85
+ var wiiCols=["Red","Orange","Yellow","Lime","Green","Blue","Cyan","Pink","Purple","Brown","White","Black"];
86
86
  var wiiFaceFeatures=["None","Blush","Makeup and Blush","Freckles","Bags","Wrinkles on Cheeks","Wrinkles near Eyes","Chin Wrinkle","Makeup","Stubble","Wrinkles near Mouth","Wrinkles"];
87
87
  var wiiSkinColors=["White","Tanned White","Darker Skin","Tanned Darker","Mostly Black","Black"];
88
88
  var wiiMouthColors=["Peach","Red","Pink"];
@@ -279,7 +279,7 @@ var hairTable={
279
279
  '70': '132',
280
280
  '71': '633'
281
281
  };
282
- var cols3DS=["Red","Orange","Yellow","Lime","Green","Blue","Teal","Pink","Purple","Brown","White","Black"];
282
+ var cols3DS=["Red","Orange","Yellow","Lime","Green","Blue","Cyan","Pink","Purple","Brown","White","Black"];
283
283
  var skinCols3DS=["White","Tanned White","Darker White","Tanned Darker","Mostly Black","Black"];
284
284
  var faceFeatures3DS=["None","Near Eye Creases","Cheek Creases","Far Eye Creases","Near Nose Creases","Giant Bags","Cleft Chin","Chin Crease","Sunken Eyes","Far Cheek Creases","Lines Near Eyes","Wrinkles"];
285
285
  var makeups3DS=["None","Blush","Orange Blush","Blue Eyes","Blush 2","Orange Blush 2","Blue Eyes and Blush","Orange Eyes and Blush","Purple Eyes and Blush 2","Freckles","Beard Stubble","Beard and Mustache Stubble"];
@@ -593,8 +593,297 @@ function lookupTable(table,value,paginated){
593
593
  }
594
594
  return undefined;
595
595
  }
596
+ var kidNames={
597
+ "Male":[
598
+ "Aaron",
599
+ "Adam",
600
+ "Adrian",
601
+ "Aiden",
602
+ "Ayden",
603
+ "Alex",
604
+ "Alexander",
605
+ "Alfie",
606
+ "Andrew",
607
+ "Anthony",
608
+ "Archie",
609
+ "Austin",
610
+ "Ben",
611
+ "Benjamin",
612
+ "Bentley",
613
+ "Bill",
614
+ "Billy",
615
+ "Blake",
616
+ "Bradley",
617
+ "Brandon",
618
+ "Brayden",
619
+ "Brody",
620
+ "Bryson",
621
+ "Caleb",
622
+ "Callum",
623
+ "Cameron",
624
+ "Carlos",
625
+ "Charlie",
626
+ "Charles",
627
+ "Carson",
628
+ "Carter",
629
+ "Chase",
630
+ "Chris",
631
+ "Christian",
632
+ "Cody",
633
+ "Colton",
634
+ "Connor",
635
+ "Cooper",
636
+ "Damian",
637
+ "Daniel",
638
+ "David",
639
+ "Dexter",
640
+ "Dominic",
641
+ "Dylan",
642
+ "Easton",
643
+ "Edward",
644
+ "Eli",
645
+ "Elijah",
646
+ "Elliot",
647
+ "Ethan",
648
+ "Evan",
649
+ "Finlay",
650
+ "Frankie",
651
+ "Freddie",
652
+ "Gabriel",
653
+ "Gavin",
654
+ "George",
655
+ "Grayson",
656
+ "Harrison",
657
+ "Harvey",
658
+ "Henry",
659
+ "Hudson",
660
+ "Hugo",
661
+ "Hunter",
662
+ "Ian",
663
+ "Isaac",
664
+ "Isaiah",
665
+ "Jace",
666
+ "Jack",
667
+ "Jackson",
668
+ "Jaxon",
669
+ "Jacob",
670
+ "Jake",
671
+ "James",
672
+ "Jason",
673
+ "Jayden",
674
+ "Jenson",
675
+ "Jeremiah",
676
+ "John",
677
+ "Juan",
678
+ "Jonathan",
679
+ "Jordan",
680
+ "Jose",
681
+ "Joseph",
682
+ "Josiah",
683
+ "Joshua",
684
+ "Jude",
685
+ "Julian",
686
+ "Justin",
687
+ "Kai",
688
+ "Kayden",
689
+ "Kevin",
690
+ "Kian",
691
+ "Landon",
692
+ "Levi",
693
+ "Leo",
694
+ "Logan",
695
+ "Lucas",
696
+ "Luke",
697
+ "Luis",
698
+ "Lachlan",
699
+ "Mason",
700
+ "Matthew",
701
+ "Max",
702
+ "Michael",
703
+ "Miguel",
704
+ "Nathan",
705
+ "Nathaniel",
706
+ "Nicholas",
707
+ "Noah",
708
+ "Nolan",
709
+ "Olly",
710
+ "Oliver",
711
+ "Owen",
712
+ "Parker",
713
+ "Philip",
714
+ "Rhys",
715
+ "Reece",
716
+ "Rob",
717
+ "Robert",
718
+ "Ryan",
719
+ "Ryder",
720
+ "Samuel",
721
+ "Sebastian",
722
+ "Seth",
723
+ "Thomas",
724
+ "Tommy",
725
+ "Trent",
726
+ "Tristan",
727
+ "Tyler",
728
+ "William",
729
+ "Liam",
730
+ "Wyatt",
731
+ "Xavier",
732
+ "Zac",
733
+ "Zachary",
734
+ "Alex",
735
+ "Alexis",
736
+ "Angel",
737
+ "Bailey",
738
+ "Darcy",
739
+ "Darcey",
740
+ "Genesis",
741
+ "Kennedy",
742
+ "Mackenzie",
743
+ "Morgan",
744
+ "Peyton",
745
+ "Sam",
746
+ "Taylor"
747
+ ],
748
+ "Female":[
749
+ "Aaliyah",
750
+ "Abigail",
751
+ "Addison",
752
+ "Madison",
753
+ "Maddison",
754
+ "Alexa",
755
+ "Alexandra",
756
+ "Alison",
757
+ "Allison",
758
+ "Alyssa",
759
+ "Amelia",
760
+ "Amy",
761
+ "Andrea",
762
+ "Anna",
763
+ "Annabelle",
764
+ "Aria",
765
+ "Ariana",
766
+ "Arianna",
767
+ "Ashley",
768
+ "Aubree",
769
+ "Aubrey",
770
+ "Audrey",
771
+ "Autumn",
772
+ "Ava",
773
+ "Avery",
774
+ "Bella",
775
+ "Bethany",
776
+ "Brianna",
777
+ "Brooklyn",
778
+ "Camila",
779
+ "Caroline",
780
+ "Charlotte",
781
+ "Chloe",
782
+ "Khloe",
783
+ "Claire",
784
+ "Ella",
785
+ "Ellie",
786
+ "Elenor",
787
+ "Elizabeth",
788
+ "Lizabeth",
789
+ "Liza",
790
+ "Emily",
791
+ "Emma",
792
+ "Eva",
793
+ "Evie",
794
+ "Evelyn",
795
+ "Faith",
796
+ "Gabriella",
797
+ "Gianna",
798
+ "Grace",
799
+ "Hailey",
800
+ "Hannah",
801
+ "Harper",
802
+ "Heidi",
803
+ "Hollie",
804
+ "Holly",
805
+ "Isabella",
806
+ "Isobel",
807
+ "Jasmine",
808
+ "Jessica",
809
+ "Jocelyn",
810
+ "Julia",
811
+ "Katherine",
812
+ "Kayla",
813
+ "Kaylee",
814
+ "Kimberly",
815
+ "Kylie",
816
+ "Lacey",
817
+ "Lauren",
818
+ "Layla",
819
+ "Leah",
820
+ "Lexie",
821
+ "Lilian",
822
+ "Lily",
823
+ "Lola",
824
+ "London",
825
+ "Lucy",
826
+ "Lydia",
827
+ "Madeline",
828
+ "Madelyn",
829
+ "Maisie",
830
+ "Makayla",
831
+ "Maya",
832
+ "Mya",
833
+ "Megan",
834
+ "Melanie",
835
+ "Mia",
836
+ "Molly",
837
+ "Naomi",
838
+ "Natalie",
839
+ "Nevaeh",
840
+ "Olivia",
841
+ "Paige",
842
+ "Poppy",
843
+ "Piper",
844
+ "Reagan",
845
+ "Rebecca",
846
+ "Riley",
847
+ "Rosie",
848
+ "Samantha",
849
+ "Sarah",
850
+ "Savannah",
851
+ "Scarlett",
852
+ "Serenity",
853
+ "Skye",
854
+ "Skylar",
855
+ "Sofia",
856
+ "Sophia",
857
+ "Sophie",
858
+ "Spring",
859
+ "Stella",
860
+ "Summer",
861
+ "Sydney",
862
+ "Trinity",
863
+ "Vanessa",
864
+ "Victoria",
865
+ "Violet",
866
+ "Winter",
867
+ "Zara",
868
+ "Zoe",
869
+ "Zoey",
870
+ "Alex",
871
+ "Alexis",
872
+ "Angel",
873
+ "Bailey",
874
+ "Darcy",
875
+ "Darcey",
876
+ "Genesis",
877
+ "Kennedy",
878
+ "Mackenzie",
879
+ "Morgan",
880
+ "Peyton",
881
+ "Sam",
882
+ "Taylor"
883
+ ]
884
+ };
596
885
  module.exports={
597
- readWiiBin:function(binPath){
886
+ readWiiBin:function(binOrPath){
598
887
  var thisMii={
599
888
  info:{},
600
889
  face:{},
@@ -607,7 +896,12 @@ module.exports={
607
896
  glasses:{},
608
897
  facialHair:{}
609
898
  };
610
- binary = fs.readFileSync(binPath);
899
+ if(binOrPath.test(/[^01]/ig)){
900
+ binary = fs.readFileSync(binOrPath);
901
+ }
902
+ else{
903
+ binary=Buffer.from(binOrPath);
904
+ }
611
905
  var name="";
612
906
  for(var i=0;i<10;i++){
613
907
  name+=binary.slice(3+i*2, 4+i*2)+"";
@@ -628,7 +922,7 @@ module.exports={
628
922
  thisMii.face.col=wiiSkinColors[parseInt(temp.slice(3,6),2)];//0-5
629
923
  temp=getBinaryFromAddress(0x21);
630
924
  thisMii.face.feature=wiiFaceFeatures[parseInt(getBinaryFromAddress(0x20).slice(6,8)+temp.slice(0,2),2)];//0-11
631
- thisMii.info.mingle=temp[5]==="1"?false:true;//0 for Mingle, 1 for Don't Mingle
925
+ thisMii.info.mingle=temp[5]==="0";//0 for Mingle, 1 for Don't Mingle
632
926
  temp=getBinaryFromAddress(0x2C);
633
927
  for(var i=0;i<12;i++){
634
928
  if(wiiNoses[i]===parseInt(temp.slice(0,4),2)){
@@ -697,7 +991,7 @@ module.exports={
697
991
  thisMii.facialHair.mustacheYPos=parseInt(temp2.slice(3,8),2);//0-16, default 2
698
992
  return thisMii;
699
993
  },
700
- read3DSQR:async function(qrPath){
994
+ read3DSQR:async function(binOrPath){
701
995
  function readMii(){
702
996
  var miiJson={
703
997
  info:{},
@@ -808,14 +1102,19 @@ module.exports={
808
1102
  fs.unlinkSync("./decryptedTemp.3dMii");
809
1103
  return miiJson;
810
1104
  }
811
- var data=fs.readFileSync(qrPath);
812
- var img=await loadImage(data);
813
- const canvas = createCanvas(img.width, img.height);
814
- const ctx = canvas.getContext('2d');
815
- ctx.drawImage(img, 0, 0);
816
- const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
817
- const qrCode = jsQR(imageData.data, imageData.width, imageData.height);
818
-
1105
+ let qrCode;
1106
+ if(/[^01]/ig.test(binOrPath)){
1107
+ var data=fs.readFileSync(binOrPath);
1108
+ var img=await loadImage(data);
1109
+ const canvas = createCanvas(img.width, img.height);
1110
+ const ctx = canvas.getContext('2d');
1111
+ ctx.drawImage(img, 0, 0);
1112
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
1113
+ qrCode = jsQR(imageData.data, imageData.width, imageData.height);
1114
+ }
1115
+ else{
1116
+ qrCode=binOrPath;
1117
+ }
819
1118
  if (qrCode) {
820
1119
  var data = decodeAesCcm(new Uint8Array(qrCode.binaryData));
821
1120
  fs.writeFileSync("./decryptedTemp.3dMii",Buffer.from(data));
@@ -1213,7 +1512,7 @@ module.exports={
1213
1512
  studioMii[0xA] = mii.eyebrows.squash;
1214
1513
  studioMii[0xC] = mii.eyebrows.rot;
1215
1514
  studioMii[0xF] = mii.eyebrows.distApart;
1216
- studioMii[0x10] = mii.eyebrows.yPos+3;
1515
+ studioMii[0x10] = mii.eyebrows.yPos;
1217
1516
  studioMii[0x2C] = tables.noses[mii.nose.type[0]][mii.nose.type[1]];
1218
1517
  studioMii[0x2B] = mii.nose.size;
1219
1518
  studioMii[0x2D] = mii.nose.yPos;
@@ -1419,5 +1718,57 @@ module.exports={
1419
1718
  miiTo.mole.yPos=mii.mole.yPos;
1420
1719
  }
1421
1720
  return miiTo;
1721
+ },
1722
+ make3DSChild:function(dad,mom,options={}){
1723
+ var g=options.gender||Math.floor(Math.random()*2)===1?"Male":"Female";
1724
+ var child={
1725
+ "info":{
1726
+ "birthMonth":new Date().getMonth()+1,
1727
+ "birthday":new Date().getDay(),
1728
+ "height":64,
1729
+ "weight":64,
1730
+ "creatorName":"",
1731
+ "gender":g,
1732
+ "name":options.name||kidNames[g][Math.floor(Math.random()*kidNames[g].length)],
1733
+ "favColor":options.favColor||cols3DS[Math.floor(Math.random()*cols3DS.length)]
1734
+ },
1735
+ "perms":{
1736
+ "sharing":true,
1737
+ "copying":true
1738
+ },
1739
+ "hair":{
1740
+ "style":[8,3],
1741
+ "col":Math.floor(Math.random()*2)===1?dad.hair.col:mom.hair.col,
1742
+ "flipped":false
1743
+ },
1744
+ "face":{
1745
+ "shape":Math.floor(Math.random()*2)===1?dad.face.shape:mom.face.shape,
1746
+ "feature":Math.floor(Math.random()*2)===1?dad.face.feature:mom.face.feature,
1747
+ "makeup":g==="Male"?"None":Math.floor(Math.random()*2)===1?dad.face.makeup:mom.face.makeup
1748
+ },
1749
+ "eyes":Math.floor(Math.random()*2)===1?dad.eyes:mom.eyes,
1750
+ "eyebrows":Math.floor(Math.random()*2)===1?dad.eyebrows:mom.eyebrows,
1751
+ "nose":Math.floor(Math.random()*2)===1?dad.nose:mom.nose,
1752
+ "mouth":Math.floor(Math.random()*2)===1?dad.mouth:mom.mouth,
1753
+ "facialHair":g==="Female"?{
1754
+ "mustacheType": 0,
1755
+ "beardType": 0,
1756
+ "col": "Black",
1757
+ "mustacheSize": 4,
1758
+ "mustacheYPos": 10
1759
+ }:dad.facialHair,
1760
+ "glasses":Math.floor(Math.random()*2)===1?dad.glasses:mom.glasses,
1761
+ "mole":Math.floor(Math.random()*2)===1?dad.mole:mom.mole,
1762
+ "creatorName":""
1763
+ };
1764
+ child.eyebrows.col=child.hair.col;
1765
+ var c=[skinCols3DS.indexOf(mom.face.col),skinCols3DS.indexOf(dad.face.col)];
1766
+ if(c[0]>c[1]){
1767
+ c[1]=c[0];
1768
+ c[0]=skinCols3DS.indexOf(dad.face.col);
1769
+ }
1770
+ child.face.col=skinCols3DS[c[0]+Math.round((c[1]-c[0])/2)];
1771
+ child.name=child.info.name;
1772
+ return child;
1422
1773
  }
1423
1774
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miijs",
3
- "version": "1.5.6",
3
+ "version": "1.5.7",
4
4
  "description": "Read, Edit, Write, and make Special Miis from a Wiimote binary file or 3DS QR Code to a binary file or QR code",
5
5
  "main": "index.js",
6
6
  "scripts": {