Esempio n. 1
0
        /// <summary>
        /// Replace the MenSelmapMark texture in toReplace with the image in newBitmap, flipping the channels if the image has solid black in all four corners.
        /// </summary>
        /// <param name="newBitmap">The new texture to use</param>
        /// <param name="toReplace">The TEX0 to insert the texture in</param>
        /// <param name="createNew">If true, the format of the existing texture will not be used as a fallback, even if useExistingAsFallback is true</param>
        private void ReplaceSelmapMark(Bitmap newBitmap, TEX0Node toReplace, bool createNew)
        {
            WiiPixelFormat format =
                selmapMarkFormat != null
                                        ? selmapMarkFormat.Value
                                : useExistingAsFallback && !createNew
                                        ? toReplace.Format
                                : BitmapUtilities.HasAlpha(newBitmap)
                                        ? WiiPixelFormat.IA4
                                        : WiiPixelFormat.I4;

            Console.WriteLine(format);
            Bitmap toEncode = BitmapUtilities.HasSolidCorners(newBitmap) ? BitmapUtilities.AlphaSwap(newBitmap) : newBitmap;

            BrawlLib.IO.FileMap tMap = TextureConverter.Get(format).EncodeTEX0Texture(toEncode, 1);
            toReplace.ReplaceRaw(tMap);
        }
Esempio n. 2
0
        public bool AddMenSelmapMark(string path, bool ask)
        {
            string tmp = null;

            if (path.EndsWith(".tex0", StringComparison.InvariantCultureIgnoreCase))
            {
                tmp = TempFiles.Create(".png");
                NodeFactory.FromFile(null, path).Export(tmp);
            }
            Bitmap bitmap = new Bitmap(tmp ?? path);

            if (BitmapUtilities.HasSolidCorners(bitmap))
            {
                bitmap = BitmapUtilities.AlphaSwap(bitmap);
            }
            string name = Path.GetFileNameWithoutExtension(path);

            if (ask)
            {
                using (var nameDialog = new AskNameDialog(bitmap)) {
                    nameDialog.Text = name;
                    if (nameDialog.ShowDialog() != DialogResult.OK)
                    {
                        return(false);
                    }
                    else
                    {
                        name = nameDialog.NameText;
                    }
                }
            }
            BRRESNode bres = sc_selmap.FindChild("MiscData[80]", false) as BRRESNode;
            TEX0Node  tex0 = bres.CreateResource <TEX0Node>(name);

            ReplaceSelmapMark(bitmap, tex0, true);
            return(true);
        }