private void btnOkay_Click(object sender, EventArgs e) { TextureConverter format = TextureConverter.Get((WiiPixelFormat)cboFormat.SelectedItem); if (format.IsIndexed) { if (_originalREFT == null) { _textureData = format.EncodeTextureIndexed(_indexed, (int)numLOD.Value, (WiiPaletteFormat)cboPaletteFormat.SelectedItem, out _paletteData); } else { _textureData = format.EncodeREFTTextureIndexed(_indexed, (int)numLOD.Value, (WiiPaletteFormat)cboPaletteFormat.SelectedItem); } } else { if ((format.RawFormat == WiiPixelFormat.CMPR) && (_cmprBuffer != null)) { if (_originalREFT == null) { _textureData = ((CMPR)format).EncodeTextureCached(_source, (int)numLOD.Value, _cmprBuffer); } else { _textureData = ((CMPR)format).EncodeREFTTextureCached(_source, (int)numLOD.Value, _cmprBuffer); } } else if (_originalREFT == null) { _textureData = format.EncodeTexture(_source, (int)numLOD.Value); } else { _textureData = format.EncodeREFTTexture(_source, (int)numLOD.Value, WiiPaletteFormat.IA8, false); } } 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); } else if (_originalREFT != null) { _originalREFT.ReplaceRaw(_textureData); } DialogResult = DialogResult.OK; Close(); }