Пример #1
0
        private void replaceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (activeBntx != null)
            {
                TextureData tex = GetSelectedBntxTexture();

                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Filter = tex.ExportFilter;

                ofd.Multiselect = false;
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    tex.Replace(ofd.FileName);
                }
            }
            if (activeFtexContainer != null)
            {
                FTEX tex = GetSelectedFtexTexture();

                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Filter = tex.ExportFilter;

                ofd.Multiselect = false;
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    tex.Replace(ofd.FileName);
                }
            }
        }
Пример #2
0
        private void exportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (activeBntx != null)
            {
                TextureData tex = GetSelectedBntxTexture();

                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter = tex.ExportFilter;

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    tex.Export(sfd.FileName);
                }
            }
            if (activeFtexContainer != null)
            {
                FTEX tex = GetSelectedFtexTexture();

                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter = tex.ExportFilter;

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    tex.Export(sfd.FileName);
                }
            }
        }
Пример #3
0
        public void LoadTexture()
        {
            int imageIndex = 0;

            imgList.Images.Clear();

            listViewCustom1.LargeImageList = imgList;
            listViewCustom1.Items.Clear();
            listViewCustom1.View = View.LargeIcon;
            SetControlSpacing(listViewCustom1, 75, 75);

            Console.WriteLine($"activeBntx " + (activeBntx != null));

            if (activeBntx != null)
            {
                Thread Thread = new Thread((ThreadStart)(() =>
                {
                    foreach (var tex in activeBntx.Textures.Values)
                    {
                        Bitmap temp = tex.GetBitmap();

                        if (listViewCustom1.InvokeRequired)
                        {
                            listViewCustom1.Invoke((MethodInvoker) delegate {
                                listViewCustom1.Items.Add(tex.Text, imageIndex++);
                                // Running on the UI thread
                                imgList.Images.Add(temp);
                                var dummy = imgList.Handle;
                            });
                        }

                        temp.Dispose();
                    }
                }));
                Thread.Start();
            }

            imageIndex = 0;

            if (activeFtexContainer != null)
            {
                foreach (var tex in activeFtexContainer.ResourceNodes.Values)
                {
                    FTEX ftex = (FTEX)tex;

                    listViewCustom1.Items.Add(ftex.Text, imageIndex++);

                    Bitmap temp = ftex.GetBitmap();
                    imgList.Images.Add(temp);
                    var dummy = imgList.Handle;
                    temp.Dispose();
                }
            }
        }
Пример #4
0
        private void textureListView_DoubleClick(object sender, EventArgs e)
        {
            if (activeBntx != null)
            {
                TextureData tex = GetSelectedBntxTexture();

                if (tex != null)
                {
                    LoadImageEditor(tex, tex.Texture);
                }
            }
            if (activeFtexContainer != null)
            {
                FTEX tex = GetSelectedFtexTexture();

                if (tex != null)
                {
                    LoadImageEditor(tex, tex.texture);
                }
            }
        }
Пример #5
0
        public void InitializeTextureListView(FMAT fmat)
        {
            material = fmat;

            textureRefListView.Items.Clear();
            textureRefListView.SmallImageList = textureImageList;
            textureRefListView.FullRowSelect  = true;

            foreach (MatTexture tex in material.TextureMaps)
            {
                ListViewItem item = new ListViewItem();
                item.Text = tex.Name;
                item.SubItems.Add(tex.SamplerName);

                if (material.shaderassign.samplers.ContainsValue(tex.SamplerName))
                {
                    var FragSampler = material.shaderassign.samplers.FirstOrDefault(x => x.Value == tex.SamplerName).Key;
                    item.SubItems.Add(FragSampler.ToString());
                }

                textureRefListView.Items.Add(item);
            }

            textureImageList.Images.Clear();

            int CurTex = 0;

            if (PluginRuntime.bntxContainers.Count == 0 &&
                PluginRuntime.ftexContainers.Count == 0)
            {
                foreach (ListViewItem item in textureRefListView.Items)
                {
                    AddBlankTexture(item, item.Text, CurTex++);
                }
            }
            return;


            bool FoundTexture = false;

            foreach (ListViewItem item in textureRefListView.Items)
            {
                foreach (BNTX bntx in PluginRuntime.bntxContainers)
                {
                    if (bntx.Textures.ContainsKey(item.Text))
                    {
                        FoundTexture = true;

                        Thread Thread = new Thread((ThreadStart)(() =>
                        {
                            Bitmap temp = bntx.Textures[item.Text].GetBitmap();

                            textureRefListView.Invoke(new Action(() =>
                            {
                                textureImageList.Images.Add(item.Text, temp);
                            }));

                            temp.Dispose();
                        }));
                        Thread.Start();

                        item.ImageIndex = CurTex++;
                    }
                }
                foreach (BFRESGroupNode ftexCont in PluginRuntime.ftexContainers)
                {
                    if (ftexCont.ResourceNodes.ContainsKey(item.Text))
                    {
                        FoundTexture = true;

                        FTEX   tex         = (FTEX)ftexCont.ResourceNodes[item.Text];
                        var    renderedTex = tex.RenderableTex;
                        Bitmap temp        = tex.GetBitmap();

                        textureImageList.Images.Add(tex.Text, temp);

                        item.ImageIndex = CurTex++;

                        var dummy = textureImageList.Handle;
                        temp.Dispose();
                    }
                }
                if (FoundTexture == false)
                {
                    AddBlankTexture(item, item.Text, CurTex++);
                }
            }
        }
Пример #6
0
        private void textureRefListView_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Do this only if none are selected so they don't flicker off/on on change
            if (textureRefListView.SelectedIndices.Count <= 0)
            {
                btnEdit.Enabled    = false;
                samplerHintTB.Text = "";
                samplerTB.Text     = "";
                btnRemove.Enabled  = false;
            }

            Reset();

            if (textureRefListView.SelectedIndices.Count > 0)
            {
                btnEdit.Enabled   = true;
                btnRemove.Enabled = true;

                int index = textureRefListView.SelectedIndices[0];

                MatTexture matTex = (MatTexture)material.TextureMaps[index];

                samplerHintTB.Text = matTex.Type.ToString();

                string name = matTex.Name;
                textureNameTB.Text = name;

                if (matTex.SamplerName != null)
                {
                    samplerTB.Text = matTex.SamplerName;
                }

                if (matTex.switchSampler != null)
                {
                    stPropertyGrid1.LoadProperty(matTex.switchSampler, OnPropertyChanged);
                }
                if (matTex.wiiUSampler != null)
                {
                    stPropertyGrid1.LoadProperty(matTex.wiiUSampler, OnPropertyChanged);
                }

                foreach (BNTX bntx in PluginRuntime.bntxContainers)
                {
                    if (bntx.Textures.ContainsKey(name))
                    {
                        Thread = new Thread((ThreadStart)(() =>
                        {
                            textureBP.Image = Toolbox.Library.Imaging.GetLoadingImage();
                            textureBP.Image = bntx.Textures[name].GetBitmap();
                        }));
                        Thread.Start();
                    }
                }
                foreach (BFRESGroupNode ftexCont in PluginRuntime.ftexContainers)
                {
                    if (ftexCont.ResourceNodes.ContainsKey(name))
                    {
                        FTEX ftex = ((FTEX)ftexCont.ResourceNodes[name]);
                        //Make sure to skip textures without image data! This is very important for botw tex2 files.
                        if (ftex.texture.Data == null || ftex.texture.Data.Length == 0)
                        {
                            continue;
                        }

                        Thread = new Thread((ThreadStart)(() =>
                        {
                            textureBP.Image = Toolbox.Library.Imaging.GetLoadingImage();
                            textureBP.Image = ftex.GetBitmap();
                        }));
                        Thread.Start();
                    }
                }
            }
        }