Ejemplo n.º 1
0
        public static XmlDocument presetXML(string tattooName, ulong tattooInstance, Preset pre, bool channelRenabled, bool channelGenabled, bool channelBenabled, bool channelAenabled)
        {
            XmlDocument doc = new XmlDocument();

            XmlElement preset = doc.CreateElement("preset");

            doc.AppendChild(preset);

            XmlElement   complate = doc.CreateElement("complate");
            XmlAttribute att1     = doc.CreateAttribute("name");

            att1.Value = "TattooTemplate";
            complate.Attributes.Append(att1);
            XmlAttribute att2 = doc.CreateAttribute("reskey");

            att2.Value = "key:0333406C:00000000:F7FC14B9EA85B390";
            complate.Attributes.Append(att2);

            XmlNode node1 = valueNode(doc, "assetRoot", "X:");

            complate.AppendChild(node1);
            XmlNode node2 = valueNode(doc, "daeFileName", tattooName);

            complate.AppendChild(node2);
            XmlNode node3 = valueNode(doc, "age", "U");

            complate.AppendChild(node3);
            XmlNode node4 = valueNode(doc, "gender", "U");

            complate.AppendChild(node4);
            XmlNode node5 = valueNode(doc, "species", "U");

            complate.AppendChild(node5);
            XmlNode node6 = valueNode(doc, "bodyType", "Body");

            complate.AppendChild(node6);
            XmlNode node7 = valueNode(doc, "partType", "Body");

            complate.AppendChild(node7);
            XmlNode node8 = valueNode(doc, "filename", "TattooTemplate");

            complate.AppendChild(node8);
            XmlNode node9 = valueNode(doc, "Layer1Mask", "key:00B2D882:00000000:" + FNVhash.FormatFNV(tattooInstance));

            complate.AppendChild(node9);
            XmlNode node10 = valueNode(doc, "Layer1ColorR", pre.rChannelPercentString);

            complate.AppendChild(node10);
            XmlNode node11 = valueNode(doc, "Layer1ColorG", pre.gChannelPercentString);

            complate.AppendChild(node11);
            XmlNode node12 = valueNode(doc, "Layer1ColorB", pre.bChannelPercentString);

            complate.AppendChild(node12);
            XmlNode node13 = valueNode(doc, "Layer1ColorA", pre.aChannelPercentString);

            complate.AppendChild(node13);
            XmlNode node14 = valueNode(doc, "ColorREnabled", channelRenabled.ToString().ToLower());

            complate.AppendChild(node14);
            XmlNode node15 = valueNode(doc, "ColorGEnabled", channelGenabled.ToString().ToLower());

            complate.AppendChild(node15);
            XmlNode node16 = valueNode(doc, "ColorBEnabled", channelBenabled.ToString().ToLower());

            complate.AppendChild(node16);
            XmlNode node17 = valueNode(doc, "ColorAEnabled", channelAenabled.ToString().ToLower());

            complate.AppendChild(node17);
            XmlNode node18 = valueNode(doc, "ThumbnailMode", "false");

            complate.AppendChild(node18);
            XmlNode node19 = valueNode(doc, "SimBuildMode", "true");

            complate.AppendChild(node19);
            XmlComment credit1 = doc.CreateComment("Tattooinator by cmar");

            complate.AppendChild(credit1);
            XmlComment credit2 = doc.CreateComment("In memory of Salem and Mini");

            complate.AppendChild(credit2);

            preset.AppendChild(complate);
            return(doc);
        }
Ejemplo n.º 2
0
        private void TattooGo_button_Click(object sender, EventArgs e)
        {
            float sortOrder;

            try
            {
                sortOrder = float.Parse(CASPsortOrder.Text);
            }
            catch
            {
                MessageBox.Show("Please enter a valid number for Sort Order in CAS");
                return;
            }
            if (String.CompareOrdinal(TattooName.Text, " ") <= 0)
            {
                MessageBox.Show("Please enter a name for the tattoo");
                return;
            }
            if (dds == null)
            {
                MessageBox.Show("Please select an image for the tattoo");
                return;
            }
            ulong  tatInstance;
            string tatName;

            if (TattooName.Text.IndexOf("uutattoo") < 0)
            {
                tatName = "uutattoo" + TattooName.Text;
            }
            else
            {
                tatName = TattooName.Text;
            }
            if (String.CompareOrdinal(TattooInstance.Text, " ") > 0)
            {
                if (!UInt64.TryParse(TattooInstance.Text, System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.InvariantCulture, out tatInstance))
                {
                    MessageBox.Show("Please enter a valid Tattoo Instance number in hexidecimal, or leave it blank");
                    return;
                }
            }
            else
            {
                tatInstance = FNVhash.FNV64(tatName);
            }

            PleaseWait_label.Visible = true;
            this.Refresh();

            uint  tatGroup     = FNVhash.FNV24(tatName);
            ulong txtcInstance = FNVhash.FNV64(tatName + "TattooTemplate_Top_diffuse");

            Package myPack;

            myPack = (Package)Package.NewPackage(0);

            NameMapResource.NameMapResource myMap = new NameMapResource.NameMapResource(0, null);
            myMap.Add(tatInstance, tatName);
            myMap.Add(tatGroup, tatName);
            myMap.Add(txtcInstance, tatName + "TattooTemplate_Top_diffuse");

            XmlDocument doc1 = PresetBuilder.presetXML(tatName, tatInstance, presets[0],
                                                       ChannelR_checkBox.Checked, ChannelG_checkBox.Checked, ChannelB_checkBox.Checked, ChannelA_checkBox.Checked);
            XmlDocument doc2 = PresetBuilder.presetXML(tatName, tatInstance, presets[1],
                                                       ChannelR_checkBox.Checked, ChannelG_checkBox.Checked, ChannelB_checkBox.Checked, ChannelA_checkBox.Checked);
            XmlDocument doc3 = PresetBuilder.presetXML(tatName, tatInstance, presets[2],
                                                       ChannelR_checkBox.Checked, ChannelG_checkBox.Checked, ChannelB_checkBox.Checked, ChannelA_checkBox.Checked);

            CASPartResource.CASPartResource myCasp;
            myCasp = new CASPartResource.CASPartResource(0, null);
            CASPartResource.CASPartResource.Preset pre1 = new CASPartResource.CASPartResource.Preset(0, null, doc1.OuterXml, 1);
            CASPartResource.CASPartResource.Preset pre2 = new CASPartResource.CASPartResource.Preset(0, null, doc2.OuterXml, 2);
            CASPartResource.CASPartResource.Preset pre3 = new CASPartResource.CASPartResource.Preset(0, null, doc3.OuterXml, 3);
            myCasp.Presets = new CASPartResource.CASPartResource.PresetList(null);
            myCasp.Presets.Add(pre1);
            myCasp.Presets.Add(pre2);
            myCasp.Presets.Add(pre3);
            myCasp.Unknown1     = tatName;
            myCasp.SortPriority = sortOrder;
            myCasp.Clothing     = ClothingType.TattooTemplate;
            myCasp.DataType     = DataTypeFlags.Body;
            myCasp.AgeGender    = new AgeGenderFlags(0, null, (CASPtodder_checkBox.Checked ? AgeFlags.Toddler : 0) |
                                                     (CASPchild_checkBox.Checked ? AgeFlags.Child : 0) | (CASPteen_checkBox.Checked ? AgeFlags.Teen : 0) |
                                                     (CASPadult_checkBox.Checked ? AgeFlags.YoungAdult | AgeFlags.Adult : 0) |
                                                     (CASPelder_checkBox.Checked ? AgeFlags.Elder : 0),
                                                     (CASPfemale_checkBox.Checked ? GenderFlags.Female : 0) | (CASPmale_checkBox.Checked ? GenderFlags.Male : 0),
                                                     0, 0);
            myCasp.ClothingCategory = ClothingCategoryFlags.Athletic | ClothingCategoryFlags.Career | ClothingCategoryFlags.Everyday |
                                      ClothingCategoryFlags.FireFighting | ClothingCategoryFlags.Formalwear | ClothingCategoryFlags.Makeover |
                                      ClothingCategoryFlags.MartialArts | ClothingCategoryFlags.Naked | ClothingCategoryFlags.Outerwear |
                                      ClothingCategoryFlags.SkinnyDippingTowel | ClothingCategoryFlags.Sleepwear | ClothingCategoryFlags.Swimwear |
                                      ClothingCategoryFlags.Singed | ClothingCategoryFlags.ValidForMaternity;
            myCasp.CasPart1Index         = 2;
            myCasp.CasPart2Index         = 2;
            myCasp.BlendInfoFatIndex     = 3;
            myCasp.BlendInfoFitIndex     = 4;
            myCasp.BlendInfoThinIndex    = 5;
            myCasp.BlendInfoSpecialIndex = 6;
            myCasp.OverlayPriority       = 2u;
            myCasp.VPXYIndexes           = new ByteIndexList(null);
            myCasp.VPXYIndexes.Add(7);
            myCasp.Diffuse1Indexes = new ByteIndexList(null);
            myCasp.Diffuse1Indexes.Add(8);
            myCasp.Specular1Indexes = new ByteIndexList(null);
            myCasp.Specular1Indexes.Add(9);
            myCasp.BONDIndexes = new ByteIndexList(null);
            myCasp.BONDIndexes.AddRange(new List <byte> {
                2, 2, 2, 2, 2
            });
            myCasp.Unknown4  = "bare";
            myCasp.TGIBlocks = new CountedTGIBlockList(null);
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.DDS, 0, tatInstance));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.XML, 0, 0xF7FC14B9EA85B390));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, 0, 0, 0));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.BBLN, 0, 0xCBE03A305F80FF50));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.BBLN, 0, 0xCBE032305F80F1F8));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.BBLN, 0, 0x540F4B31F0B42342));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.BBLN, 0, 0x82F02E48897E22B4));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.VPXY, 1, tatGroup));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.TXTC, tatGroup, txtcInstance));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.TXTC, tatGroup, 0xCBF29CE484222325));

            uint  fakeType     = (uint)tatInstance;
            uint  fakeGroup    = (uint)(tatInstance >> 32);
            ulong fakeInstance = (ulong)ResourceTypes.DDS << 32;

            TxtcResource.TxtcResource txtc = TattooTextureCompositor.TattooTxtc(new TGIBlock(0, null, fakeType, fakeGroup, fakeInstance));

            VPXY vpxy = new VPXY(0, null, 4, null, 2,
                                 new BoundingBox(0, null, new Vertex(0, null, -.0060f, 1.7157f, -.0060f), new Vertex(0, null, .0060f, 1.7277f, .0060f)),
                                 new byte[] { 0, 0, 0, 0 }, 0, 0, new TGIBlockList(null));
            GenericRCOLResource vpxyRcol = new GenericRCOLResource(0, null);

            vpxyRcol.Version      = 3;
            vpxyRcol.PublicChunks = 1;
            vpxyRcol.ChunkEntries = new GenericRCOLResource.ChunkEntryList(null);
            GenericRCOLResource.ChunkEntry vpxyChunk = new GenericRCOLResource.ChunkEntry(0, null, new TGIBlock(0, null, "ITG", (uint)ResourceTypes.VPXY, 1, tatGroup), vpxy);
            vpxyRcol.ChunkEntries.Add(vpxyChunk);
            IResourceIndexEntry rs = myPack.AddResource(new TGIBlock(0, null, (uint)ResourceTypes.KEY, 0, tatInstance), myMap.Stream, true);

            rs.Compressed = (ushort)0xFFFF;
            rs            = myPack.AddResource(new TGIBlock(0, null, (uint)ResourceTypes.CASP, 0, tatInstance), myCasp.Stream, true);
            rs.Compressed = (ushort)0xFFFF;
            rs            = myPack.AddResource(new TGIBlock(0, null, (uint)ResourceTypes.TXTC, tatGroup, txtcInstance), txtc.Stream, true);
            rs.Compressed = (ushort)0xFFFF;
            rs            = myPack.AddResource(new TGIBlock(0, null, (uint)ResourceTypes.VPXY, 1, tatGroup), vpxyRcol.Stream, true);
            rs.Compressed = (ushort)0xFFFF;
            MemoryStream ms = new MemoryStream();

            doc1.Save(ms);
            rs            = myPack.AddResource(new TGIBlock(0, null, (uint)ResourceTypes.XML, 0, tatInstance), ms, true);
            rs.Compressed = (ushort)0xFFFF;
            MemoryStream ms2 = new MemoryStream();

            dds.UseDXT          = false;
            dds.AlphaDepth      = 8;
            dds.GenerateMipmaps = true;
            dds.Save(ms2);
            rs            = myPack.AddResource(new TGIBlock(0, null, (uint)ResourceTypes.DDS, 0, tatInstance), ms2, true);
            rs.Compressed = (ushort)0xFFFF;
            if (thumbNail != null)
            {
                MemoryStream ms3 = new MemoryStream();
                thumbNail.Save(ms3, System.Drawing.Imaging.ImageFormat.Png);
                rs            = myPack.AddResource(new TGIBlock(0, null, (uint)ResourceTypes.THUM, 1, tatInstance), ms3, true);
                rs.Compressed = (ushort)0xFFFF;
            }

            PleaseWait_label.Visible = false;

            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter          = PackageFilter;
            saveFileDialog1.Title           = "Save as a new package";
            saveFileDialog1.FileName        = TattooName.Text + ".package";
            saveFileDialog1.FilterIndex     = 1;
            saveFileDialog1.CheckFileExists = false;
            saveFileDialog1.CheckPathExists = true;
            saveFileDialog1.OverwritePrompt = true;
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                myPack.SaveAs(saveFileDialog1.FileName);
            }
            ms.Dispose();
            ms2.Dispose();
        }