예제 #1
0
 private async void AddModJob(Textures.ITexture2D tex2D, string replacingfile)
 {
     ModMaker modmaker = await ModMaker.GetCurrentInstance();
     KFreonLib.Scripting.ModMaker.AddJob(tex2D, replacingfile, WhichGame, pathBIOGame);
     modmaker.ExternalRefresh();
 }
예제 #2
0
        private void UpdateModifiedTex(Textures.ITexture2D tex2D, TreeTexInfo tex, int ind)
        {
            if (!tex2D.hasChanged)
                tex2D.hasChanged = true;
            tex.Textures[0] = tex2D;

            // KFreon: Change texture in tree
            if (!ChangedTextures.Contains(ind))
                ChangedTextures.Add(ind);
            Tree.ReplaceTex(ind, tex);
        }
예제 #3
0
        private bool SaveFile(List<string> Filenames, List<int> ExpIDs, Textures.ITexture2D tex2D, int j)
        {
            if (cts.IsCancellationRequested)
                return false;

            PCCObjects.IPCCObject PCC = null;
            string currentPCC = Filenames[j];

            // KFreon: Skip non existent pccs
            if (!File.Exists(currentPCC))
                return true;

            // KFreon: Fix pathing
            string temppath = WhichGame == 1 ? Path.GetDirectoryName(pathBIOGame) : pathBIOGame;
            if (!currentPCC.Contains(temppath))
                currentPCC = Path.Combine(temppath, currentPCC);

            DebugOutput.PrintLn("Now saving pcc: " + currentPCC + "...");
            PCC = PCCObjects.Creation.CreatePCCObject(currentPCC, WhichGame);

            if (String.Compare(tex2D.texName, PCC.Exports[ExpIDs[j]].ObjectName, true) != 0 || (PCC.Exports[ExpIDs[j]].ClassName != "Texture2D" && PCC.Exports[ExpIDs[j]].ClassName != "LightMapTexture2D" && PCC.Exports[ExpIDs[j]].ClassName != "TextureFlipBook"))
                throw new InvalidDataException("Export object has wrong class or name");

            Textures.ITexture2D temptex2D = PCC.CreateTexture2D(ExpIDs[j], pathBIOGame);
            temptex2D.CopyImgList(tex2D, PCC);
            PCC.Exports[ExpIDs[j]].SetData(temptex2D.ToArray(PCC.Exports[ExpIDs[j]].DataOffset, PCC));
            PCC.saveToFile(currentPCC);
            PCC.Dispose();
            return true;
        }
예제 #4
0
        private string ExternalImageSelector(Textures.ITexture2D tex2D)
        {
            string path = "";
            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Title = "Select the image to add";
                ofd.Filter = "Image file|*.dds|All files|*.*";
                //                ofd.Filter = "Image file|*" + tex2D.getFileFormat() + "|All files|*.*";

                if (ofd.ShowDialog() != DialogResult.OK)
                    return "";
                else
                    path = ofd.FileName;
            }

            StringBuilder sb = new StringBuilder();

            // KFreon: Check replacing texture
            using (ImageEngineImage img = new ImageEngineImage(path))
            {
                if (!img.Format.InternalFormat.ToString().Contains(tex2D.texFormat, StringComparison.OrdinalIgnoreCase))
                    sb.Append("Invalid format. Selected image is: " + img.Format.InternalFormat.ToString() + "  Required: " + tex2D.texFormat.ToUpperInvariant());

                if (img.NumMipMaps < tex2D.Mips)
                    sb.AppendLine("Mipmap error. Requires: " + tex2D.Mips + ".  Currently: " + img.NumMipMaps);
            }


            if (sb.Length != 0)
            {
                MessageBox.Show(sb.ToString(), "Mission Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return "";
            }

            return path;
        }
예제 #5
0
        private void DisplayTextureProperties(Textures.ITexture2D tex2D, Textures.IImageInfo info)
        {
            List<string> message = new List<string>();
            message.Add("Texture Name:  " + tex2D.texName);
            message.Add("Format:  " + (tex2D.texFormat.ToLower().Contains("g8") ? tex2D.texFormat + @"/L8" : (tex2D.texFormat.ToLower().Contains("normalmap") ? "ThreeDc" : tex2D.texFormat)));
            message.Add("Width:  " + info.imgSize.width + ",  Height:  " + info.imgSize.height);
            //message.Add("LODGroup:  " + (tex2D.hasChanged ? "TEXTUREGROUP_Shadowmap" : ((String.IsNullOrEmpty(tex2D.LODGroup) ? "None (Uses World)" : tex2D.LODGroup))));
            // Heff: Were ALL modified textures assigned the shadowmap texture group?
            message.Add("LODGroup:  " + (String.IsNullOrEmpty(tex2D.LODGroup) ? "None (Uses World)" : tex2D.LODGroup));
            message.Add("Texmod Hash:  " + Textures.Methods.FormatTexmodHashAsString(tex2D.Hash));

            if (WhichGame != 1)
                message.Add("Texture Cache File:  " + (String.IsNullOrEmpty(tex2D.arcName) ? "PCC Stored" : tex2D.arcName + ".tfc"));

            PropertiesRTB.Text = String.Join(Environment.NewLine, message);
        }
예제 #6
0
        private void UpdateTexDetails(int index, out TreeTexInfo tex, out Textures.ITexture2D tex2D)
        {
            tex = Tree.GetTex(index);
            tex2D = tex.Textures[0];

            //if (tex2D.imgList.Count == 0)
            if (!tex2D.hasChanged)
            {
                //Textures.ITexture2D newtex2D = KFreonFormsLib.Textures.Creation.CreateTexture2D(KFreonFormsLib.PCCObjects.Creation.CreatePCCObject(tex2D.allPccs[0], WhichGame), tex2D.expIDs[0], WhichGame, pathBIOGame, tex2D.Hash);
                tex2D = Textures.Creation.CreateTexture2D(tex2D, WhichGame, pathBIOGame);

                tex.Textures = new List<Textures.ITexture2D>();
                tex.Textures.Add(tex2D);
                Tree.ReplaceTex(index, tex);
            }
        }
예제 #7
0
        private void DisplayTextureProperties(Textures.ITexture2D tex2D, Textures.IImageInfo info)
        {
            List<string> message = new List<string>();
            message.Add("Texture Name:  " + tex2D.texName);
            message.Add("Format:  " + tex2D.texFormat.ToString().Replace("DDS_", ""));
            message.Add("Width:  " + info.imgSize.width + ",  Height:  " + info.imgSize.height);
            int mipcount = tex2D.imgList.Where(t => t.offset != -1).Count();
            message.Add("Mipmaps:  " + (mipcount > 1 ? "Yes (" + mipcount + ")" : "No (1)"));
            //message.Add("LODGroup:  " + (tex2D.hasChanged ? "TEXTUREGROUP_Shadowmap" : ((String.IsNullOrEmpty(tex2D.LODGroup) ? "None (Uses World)" : tex2D.LODGroup))));
            // Heff: Were ALL modified textures assigned the shadowmap texture group?
            message.Add("LODGroup:  " + (string.IsNullOrEmpty(tex2D.LODGroup) ? "None (Uses World)" : tex2D.LODGroup));
            message.Add("Texmod Hash:  " + Textures.Methods.FormatTexmodHashAsString(tex2D.Hash));

            if (WhichGame != 1)
                message.Add("Texture Cache File:  " + (info.storageType == 0  ? "PCC Stored" : tex2D.arcName + ".tfc"));

            PropertiesRTB.Text = string.Join(Environment.NewLine, message);
        }
예제 #8
0
        private string ExternalImageSelector(Textures.ITexture2D tex2D)
        {
            string path = "";
            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Title = "Select the image to add";
                ofd.Filter = "Image file|*.dds|All files|*.*";
                //                ofd.Filter = "Image file|*" + tex2D.getFileFormat() + "|All files|*.*";

                if (ofd.ShowDialog() != DialogResult.OK)
                    return "";
                else
                    path = ofd.FileName;
            }

            // KFreon: Check replacing texture
            string selectedformat;
            if (!Textures.Methods.CheckTextureFormat(File.ReadAllBytes(path), tex2D.texFormat, out selectedformat))
            {
                MessageBox.Show("Invalid format. Selected image is: " + selectedformat.ToUpperInvariant() + "  Required: " + tex2D.texFormat.ToUpperInvariant(), "Mission Failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return "";
            }

            // KFreon: Check replacing mips
            int numMips = 0;
            bool CorrectMips = Textures.Methods.CheckTextureMips(path, tex2D.Mips, out numMips);
            if (!CorrectMips)
            {
                MessageBox.Show("Mipmap error. Requires: " + tex2D.Mips + ".  Currently: " + numMips, "Mission Failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return "";
            }
            return path;
        }