Exemplo n.º 1
0
        public void ReEncode()
        {
            PLT0Node plt = null;

            if (((TEX0Node)_resource).HasPalette)
            {
                plt = ((TEX0Node)_resource).GetPaletteNode();
            }

            using (TextureConverterDialog dlg = new TextureConverterDialog())
            {
                dlg.LoadImages((Resource as TEX0Node).GetImage(0));
                dlg.ShowDialog(MainForm.Instance, Resource as TEX0Node);
            }

            if (plt != null && !((TEX0Node)_resource).HasPalette)
            {
                plt.Dispose();
                plt.Remove();
            }
        }
Exemplo n.º 2
0
        private void btnOkay_Click(object sender, EventArgs e)
        {
            TextureConverter format = TextureConverter.Get((WiiPixelFormat)cboFormat.SelectedItem);

            if (format.IsIndexed)
            {
                _textureData = format.EncodeTextureIndexed(_indexed, (int)numLOD.Value, (WiiPaletteFormat)cboPaletteFormat.SelectedItem, out _paletteData);
            }
            else
            {
                if ((format.RawFormat == WiiPixelFormat.CMPR) && (_cmprBuffer != null))
                {
                    _textureData = ((CMPR)format).EncodeTextureCached(_source, (int)numLOD.Value, _cmprBuffer);
                }
                else
                {
                    _textureData = format.EncodeTexture(_source, (int)numLOD.Value);
                }
            }

            if (_parent != null)
            {
                _original = _parent.CreateResource <TEX0Node>(Path.GetFileNameWithoutExtension(_imageSource));
                if (_paletteData != null)
                {
                    _originalPalette      = _parent.CreateResource <PLT0Node>(_original.Name);
                    _originalPalette.Name = _original.Name;
                    _originalPalette.ReplaceRaw(_paletteData);
                }
                _original.ReplaceRaw(_textureData);
            }
            else if (_original != null)
            {
                if (_originalPalette != null)
                {
                    if (_paletteData != null)
                    {
                        _originalPalette.ReplaceRaw(_paletteData);
                    }
                    else
                    {
                        _originalPalette.Remove();
                        _originalPalette.Dispose();
                    }
                }
                else if (_paletteData != null)
                {
                    if ((_original.Parent == null) || (_original.Parent.Parent == null))
                    {
                        _paletteData.Dispose();
                        _paletteData = null;
                    }
                    else
                    {
                        _parent               = _original.Parent.Parent as BRESNode;
                        _originalPalette      = _parent.CreateResource <PLT0Node>(_original.Name);
                        _originalPalette.Name = _original.Name;
                        _originalPalette.ReplaceRaw(_paletteData);
                    }
                }
                _original.ReplaceRaw(_textureData);
            }

            DialogResult = DialogResult.OK;
            Close();
        }