示例#1
0
        internal unsafe void TexChanged(object sender, EventArgs e)
        {
            MDL0MaterialRefNode mr = TargetTexRef;
            PAT0TextureNode     node;

            if (mr == null || _updating)
            {
                return;
            }

            if (SelectedAnimation != null && CurrentFrame > 0)
            {
                node = SelectedAnimation.FindChild(mr._parent.Name + "/Texture" + mr.Index, true) as PAT0TextureNode;

                if (node != null)
                {
                    PAT0TextureEntryNode tex = node.GetEntry(CurrentFrame - 1);
                    if (tex == null)
                    {
                        if (!String.IsNullOrEmpty(texBox.Text) || !String.IsNullOrEmpty(pltBox.Text))
                        {
                            tex        = new PAT0TextureEntryNode();
                            tex._frame = CurrentFrame - 1;
                            if (node.Children.Count > 0)
                            {
                                node.InsertChild(tex, true, node.GetPrevious(CurrentFrame - 1).Index + 1);
                            }
                            else
                            {
                                node.AddChild(tex, true);
                            }
                            tex.Texture = texBox.Text;
                            tex.Palette = pltBox.Text;
                        }
                    }
                    else
                    {
                        if (!String.IsNullOrEmpty(texBox.Text) || !String.IsNullOrEmpty(pltBox.Text))
                        {
                            tex.Texture = texBox.Text;
                            tex.Palette = pltBox.Text;
                        }
                        else
                        {
                            tex.Remove();
                        }
                    }
                }
            }

            TargetModel.ApplyPAT(SelectedAnimation, CurrentFrame);
            ResetTexture();
            ResetPalette();
            _mainWindow.ModelPanel.Invalidate();
        }