Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void importNewIconImageToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var f = FileIO.OpenFile(ApplicationSettings.ImageFileFilter);

            if (f != null)
            {
                using (Bitmap bmp = new Bitmap(f))
                {
                    var tobj = TOBJConverter.BitmapToTOBJ(bmp, HSDRaw.GX.GXTexFmt.CI8, HSDRaw.GX.GXTlutFmt.RGB565);

                    if (sssEditor.SelectedObject is MEXStageIconEntry ico)
                    {
                        ico.IconTOBJ = tobj;
                        IconJOBJManager.RefreshRendering = true;
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonImportName_Click(object sender, EventArgs e)
        {
            var f = FileIO.OpenFile(ApplicationSettings.ImageFileFilter);

            if (f != null)
            {
                using (Bitmap bmp = new Bitmap(f))
                {
                    var tobj = TOBJConverter.BitmapToTOBJ(bmp, HSDRaw.GX.GXTexFmt.IA4, HSDRaw.GX.GXTlutFmt.IA8);

                    if (sssEditor.SelectedObject is MEXStageIconEntry ico)
                    {
                        ico.NameTOBJ = tobj;
                        StageNameJOBJManager.RefreshRendering = true;
                    }
                }
            }
        }
Example #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void generateNameTagToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (sssEditor.SelectedObject is MEXStageIconEntry entry)
     {
         var settings = new NameTagSettings();
         using (PropertyDialog d = new PropertyDialog("Name Tag Settings", settings))
         {
             if (d.ShowDialog() == DialogResult.OK)
             {
                 using (Bitmap bmp = MexMapGenerator.GenerateStageName(settings.StageName, settings.Location))
                 {
                     if (bmp == null)
                     {
                         MessageBox.Show("Could not find fonts \"Palatino Linotype\" and/or \"A-OTF Folk Pro H\"", "Font not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         return;
                     }
                     entry.NameTOBJ = TOBJConverter.BitmapToTOBJ(bmp, HSDRaw.GX.GXTexFmt.I4, HSDRaw.GX.GXTlutFmt.IA8);
                 }
             }
         }
     }
 }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="datPath"></param>
        /// <param name="pack"></param>
        private void InjectCharSelectImages(ZipFile pack, string datPath, HSD_TOBJ[] icons, HSD_TOBJ emblemTexture, MEXFighterEntry fighter, int stride, int groupID)
        {
            var cssFile = new HSDRawFile(datPath);

            if (cssFile.Roots[0].Data is SBM_SelectChrDataTable cssTable)
            {
                // get base width and height
                int width  = 132;
                int height = 188;
                if (cssTable.PortraitMaterialAnimation.Children[2].Child.MaterialAnimation.TextureAnimation.ImageCount > 0)
                {
                    width  = cssTable.PortraitMaterialAnimation.Children[2].Child.MaterialAnimation.TextureAnimation.ImageBuffers[0].Data.Width;
                    height = cssTable.PortraitMaterialAnimation.Children[2].Child.MaterialAnimation.TextureAnimation.ImageBuffers[0].Data.Height;
                }
                // LOAD CSPs
                var        csps     = pack.Where(e => Regex.IsMatch(e.FileName, "CSS/css..\\.png")).ToArray();
                HSD_TOBJ[] cspTOBJs = new HSD_TOBJ[csps.Length];
                foreach (var c in csps)
                {
                    var index = int.Parse(Regex.Match(c.FileName, @"\d\d").Value);
                    using (MemoryStream stream = new MemoryStream(GetBytes(c)))
                        using (var bmp = new System.Drawing.Bitmap(stream))
                        {
                            // shrink but don't grow
                            if (bmp.Width > width || bmp.Height > height)
                            {
                                using (System.Drawing.Bitmap resized = new System.Drawing.Bitmap(width, height))
                                {
                                    using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(resized))
                                        g.DrawImage(bmp, 0, 0, width, height);

                                    cspTOBJs[index] = TOBJConverter.BitmapToTOBJ(resized, HSDRaw.GX.GXTexFmt.CI8, HSDRaw.GX.GXTlutFmt.RGB5A3);
                                }
                            }
                            else
                            {
                                cspTOBJs[index] = TOBJConverter.BitmapToTOBJ(bmp, HSDRaw.GX.GXTexFmt.CI8, HSDRaw.GX.GXTlutFmt.RGB5A3);
                            }
                        }
                }

                // Inject Icons
                foreach (var n in cssTable.SingleMenuMaterialAnimation.Children[9].Children)
                {
                    InjectIntoMatTexAnim(n.MaterialAnimation.TextureAnimation, icons, groupID, stride, MAX_COSTUME_COUNT);
                }

                // Inject CSPs
                foreach (var n in cssTable.MenuMaterialAnimation.Children[6].Children)
                {
                    InjectIntoMatTexAnim(n.MaterialAnimation.TextureAnimation, cspTOBJs, groupID, stride, MAX_COSTUME_COUNT);
                }

                foreach (var n in cssTable.SingleMenuMaterialAnimation.Children[6].Children)
                {
                    InjectIntoMatTexAnim(n.MaterialAnimation.TextureAnimation, cspTOBJs, groupID, stride, MAX_COSTUME_COUNT);
                }

                foreach (var n in cssTable.PortraitMaterialAnimation.Children[2].Children)
                {
                    InjectIntoMatTexAnim(n.MaterialAnimation.TextureAnimation, cspTOBJs, groupID, stride, MAX_COSTUME_COUNT);
                }


                // Emblem

                foreach (var n in cssTable.MenuMaterialAnimation.Children[5].Children)
                {
                    InjectIntoMatTexAnim(n.MaterialAnimation.Next.TextureAnimation, new HSDRaw.Common.HSD_TOBJ[] { emblemTexture }, groupID, stride, 1, fighter.InsigniaID);
                }

                foreach (var n in cssTable.SingleMenuMaterialAnimation.Children[5].Children)
                {
                    InjectIntoMatTexAnim(n.MaterialAnimation.Next.TextureAnimation, new HSDRaw.Common.HSD_TOBJ[] { emblemTexture }, groupID, stride, 1, fighter.InsigniaID);
                }

                foreach (var n in cssTable.PortraitMaterialAnimation.Children[1].Children)
                {
                    InjectIntoMatTexAnim(n.MaterialAnimation.Next.TextureAnimation, new HSDRaw.Common.HSD_TOBJ[] { emblemTexture }, groupID, stride, 1, fighter.InsigniaID);
                }
            }

            editedFiles.Add(new Tuple <HSDRawFile, string, bool>(cssFile, datPath, true));
        }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        private void InstallUI(ZipFile pack, MEXFighterEntry fighter)
        {
            Console.WriteLine($"Installing UI data...");

            // LOAD Stock Icons
            var icons = pack.Where(e => Regex.IsMatch(e.FileName, "Icon/ico..\\.png")).ToArray();

            HSD_TOBJ[] iconTOBJs = new HSD_TOBJ[icons.Length];
            foreach (var c in icons)
            {
                var index = int.Parse(Regex.Match(c.FileName, @"\d\d").Value);
                using (MemoryStream stream = new MemoryStream(GetBytes(c)))
                    using (var bmp = new System.Drawing.Bitmap(stream))
                        iconTOBJs[index] = TOBJConverter.BitmapToTOBJ(bmp, HSDRaw.GX.GXTexFmt.CI4, HSDRaw.GX.GXTlutFmt.RGB5A3);
            }

            // Load Menu Icon

            // Load Emblem
            var      emblemPack    = pack["UI/emblem.obj"];
            HSD_TOBJ emblemTexture = null;
            HSD_JOBJ emblemModel   = null;

            if (emblemPack != null)
            {
                EmblemModel model;
                using (MemoryStream stream = new MemoryStream())
                {
                    emblemPack.Extract(stream);
                    stream.Position = 0;
                    model           = Converters.EmblemConverter.GenerateEmblemModelFromOBJ(stream);
                }
                emblemModel   = Converters.EmblemConverter.GenerateEmblemModel(model);
                emblemTexture = Converters.EmblemConverter.GenerateEmblemIconImage(model);
            }

            // Load Misc Name Tags and icons

            var      largeName        = pack["UI/result_victory_name.png"];
            var      smallName        = pack["UI/result_name.png"];
            HSD_TOBJ largeNameTexture = null;
            HSD_TOBJ smallNameTexture = null;

            if (largeName != null)
            {
                using (MemoryStream stream = new MemoryStream(GetBytes(largeName)))
                    using (var bmp = new System.Drawing.Bitmap(stream))
                        largeNameTexture = TOBJConverter.BitmapToTOBJ(bmp, HSDRaw.GX.GXTexFmt.I4, HSDRaw.GX.GXTlutFmt.IA8);
            }
            if (smallName != null)
            {
                using (MemoryStream stream = new MemoryStream(GetBytes(smallName)))
                    using (var bmp = new System.Drawing.Bitmap(stream))
                        smallNameTexture = TOBJConverter.BitmapToTOBJ(bmp, HSDRaw.GX.GXTexFmt.I4, HSDRaw.GX.GXTlutFmt.IA8);
            }

            // --------------------------------------------------------------------------

            var root = Path.GetDirectoryName(MainForm.Instance.FilePath);

            int stride     = editor.FighterControl.FighterEntries.Count - 3;
            int internalID = editor.FighterControl.FighterEntries.IndexOf(fighter);
            var externalId = MEXIdConverter.ToExternalID(internalID, editor.FighterControl.FighterEntries.Count);
            int GroupID    = externalId - (externalId > 18 ? 1 : 0);

            // Inject CSPs and Stock Icons into Character Select
            //var chrSelPath = Path.Combine(root, "MnSlChr.usd");
            //if (File.Exists(chrSelPath))
            //    InjectCharSelectImages(pack, chrSelPath, iconTOBJs, emblemTexture, fighter, stride, GroupID);

            // Inject Stock Icons into IfAll, GmRst

            var ifallPath = Path.Combine(root, "IfAll.usd");

            if (File.Exists(ifallPath))
            {
                var datFile = new HSDRawFile(ifallPath);

                var mark = datFile.Roots.Find(e => e.Name.Equals("Stc_scemdls")).Data as HSDNullPointerArrayAccessor <HSD_JOBJDesc>;

                for (int i = 0; i < 7; i++) // first 7
                {
                    InjectIntoMatTexAnim(mark[0].MaterialAnimations[0].Children[i].MaterialAnimation.TextureAnimation, iconTOBJs, GroupID, stride, MAX_COSTUME_COUNT);
                }


                var emblemGroup = datFile.Roots.Find(e => e.Name.Equals("DmgMrk_scene_models")).Data as HSDNullPointerArrayAccessor <HSD_JOBJDesc>;

                InjectIntoMatTexAnim(emblemGroup[0].MaterialAnimations[0].Child.MaterialAnimation.TextureAnimation, new HSDRaw.Common.HSD_TOBJ[] { emblemTexture }, GroupID, stride, 1, fighter.InsigniaID);


                editedFiles.Add(new Tuple <HSDRawFile, string, bool>(datFile, ifallPath, true));
            }


            var gmRst = Path.Combine(root, "GmRst.usd");

            if (File.Exists(gmRst))
            {
                var datFile = new HSDRawFile(gmRst);

                var flmsce = datFile.Roots.Find(e => e.Name.Equals("flmsce")).Data as HSD_SOBJ;
                var pnlsce = datFile.Roots.Find(e => e.Name.Equals("pnlsce")).Data as HSD_SOBJ;

                // Stock Icons-------------------------------------
                for (int i = 5; i <= 8; i++) // at 5-8, 2nd mat anim
                {
                    InjectIntoMatTexAnim(
                        pnlsce.JOBJDescs[0].MaterialAnimations[0].Children[i].MaterialAnimation.Next.TextureAnimation,
                        iconTOBJs,
                        GroupID,
                        stride,
                        MAX_COSTUME_COUNT);
                }

                // Emblem Textures--------------------------------------
                var matgroup = pnlsce.JOBJDescs[0].MaterialAnimations[0].Children[17];

                for (int i = 0; i < 4; i++)
                {
                    InjectIntoMatTexAnim(matgroup.Children[i].MaterialAnimation.TextureAnimation, new HSDRaw.Common.HSD_TOBJ[] { emblemTexture }, GroupID, stride, 1, fighter.InsigniaID);
                }

                // Emblem Model--------------------------------------
                var emblemGroup = flmsce.JOBJDescs[0];

                if (emblemModel != null)
                {
                    var modelIndex = emblemGroup.RootJoint.Children[4].Children.Length;

                    fighter.InsigniaID = (byte)modelIndex;

                    var jointClone = HSDAccessor.DeepClone <HSDRaw.Common.Animation.HSD_AnimJoint>(emblemGroup.JointAnimations[0].Children[4].Child);
                    jointClone.Next = null;

                    var matjointClone = HSDAccessor.DeepClone <HSDRaw.Common.Animation.HSD_MatAnimJoint>(emblemGroup.MaterialAnimations[0].Children[4].Child);
                    matjointClone.Next = null;

                    emblemGroup.JointAnimations[0].Children[4].AddChild(jointClone);
                    emblemGroup.MaterialAnimations[0].Children[4].AddChild(matjointClone);
                    emblemGroup.RootJoint.Children[4].AddChild(emblemModel);
                }


                // name textures
                var largenameGroup = pnlsce.JOBJDescs[0].MaterialAnimations[0].Children[0].Children[2].MaterialAnimation.Next.TextureAnimation;

                InjectIntoMatTexAnim(largenameGroup, new HSD_TOBJ[] { largeNameTexture }, GroupID, stride, 1);

                var smallnameGroup = pnlsce.JOBJDescs[0].MaterialAnimations[0];

                for (int i = 9; i < 13; i++)
                {
                    InjectIntoMatTexAnim(smallnameGroup.Children[i].Children[1].MaterialAnimation.TextureAnimation, new HSD_TOBJ[] { smallNameTexture }, GroupID, stride, 1);
                }


                editedFiles.Add(new Tuple <HSDRawFile, string, bool>(datFile, gmRst, true));
            }

            // Inject Emblem

            // Generate Emblem Models and Inject

            // Inject Misc Name Tags and icons
        }