예제 #1
0
        /// <summary>
        /// Gets the MTRL data of the given mesh
        /// </summary>
        /// <param name="mesh">The mesh to obtain the data from</param>
        /// <returns>The MTRLData of the given mesh</returns>
        public MTRLData MTRL3D(int mesh)
        {
            MTRLData mtrlData    = null;
            bool     isDemiHuman = false;

            if (selectedItem.PrimaryMTRLFolder != null)
            {
                isDemiHuman = selectedItem.PrimaryMTRLFolder.Contains("demihuman");
            }

            var itemVersion = IMC.GetVersion(selectedCategory, selectedItem, false).Item1;
            var itemType    = Helper.GetCategoryType(selectedCategory);

            try
            {
                if (selectedItem.ItemName.Equals(Strings.Face) || selectedItem.ItemName.Equals(Strings.Hair) || isDemiHuman)
                {
                    string slotAbr;

                    if (isDemiHuman)
                    {
                        slotAbr = Info.slotAbr[SelectedPart.Name];
                    }
                    else if (selectedCategory.Equals(Strings.Character))
                    {
                        var race = materialStrings[mesh].Substring(materialStrings[mesh].IndexOf("c") + 1, 4);

                        if (materialStrings[mesh].Contains("h00"))
                        {
                            var hairNum    = materialStrings[mesh].Substring(materialStrings[mesh].IndexOf("h00") + 1, 4);
                            var mtrlFolder = string.Format(Strings.HairMtrlFolder, race, hairNum);
                            slotAbr = materialStrings[mesh].Substring(materialStrings[mesh].LastIndexOf("_") - 3, 3);
                            slotAbr = Info.HairTypes.FirstOrDefault(x => x.Value == slotAbr).Key;

                            var hairInfo = MTRL.GetMTRLDatafromType(selectedItem, SelectedRace, hairNum, slotAbr, itemVersion, selectedCategory);
                            return(hairInfo.Item1);
                        }
                        else if (materialStrings[mesh].Contains("f00"))
                        {
                            var faceNum    = materialStrings[mesh].Substring(materialStrings[mesh].IndexOf("f00") + 1, 4);
                            var mtrlFolder = string.Format(Strings.FaceMtrlFolder, race, faceNum);
                            slotAbr = materialStrings[mesh].Substring(materialStrings[mesh].LastIndexOf("_") - 3, 3);
                            slotAbr = Info.FaceTypes.FirstOrDefault(x => x.Value == slotAbr).Key;

                            var faceInfo = MTRL.GetMTRLDatafromType(selectedItem, SelectedRace, faceNum, slotAbr, itemVersion, selectedCategory);
                            return(faceInfo.Item1);
                        }
                        else
                        {
                            slotAbr = selectedPart.Name;
                        }
                    }
                    else
                    {
                        slotAbr = selectedPart.Name;
                    }

                    var info = MTRL.GetMTRLDatafromType(selectedItem, SelectedRace, selectedPart.Name, slotAbr, itemVersion, selectedCategory);
                    mtrlData = info.Item1;
                }
                else
                {
                    Tuple <MTRLData, ObservableCollection <ComboBoxInfo> > info;

                    if (itemType.Equals("character") || itemType.Equals("equipment"))
                    {
                        try
                        {
                            if (materialStrings[mesh].Contains("b00") || materialStrings[mesh].Contains("t00") || materialStrings[mesh].Contains("h00"))
                            {
                                if (materialStrings[mesh].Contains("mt_c"))
                                {
                                    var mtrlFolder = "";
                                    var race       = materialStrings[mesh].Substring(materialStrings[mesh].IndexOf("c") + 1, 4);

                                    if (materialStrings[mesh].Contains("b00"))
                                    {
                                        mtrlFolder = string.Format(Strings.BodyMtrlFolder, race, materialStrings[mesh].Substring(materialStrings[mesh].IndexOf("b00") + 1, 4));
                                    }
                                    else if (materialStrings[mesh].Contains("t00"))
                                    {
                                        mtrlFolder = string.Format(Strings.TailMtrlFolder, race, materialStrings[mesh].Substring(materialStrings[mesh].IndexOf("t00") + 1, 4));
                                    }
                                    else if (materialStrings[mesh].Contains("h00"))
                                    {
                                        mtrlFolder = string.Format(Strings.HairMtrlFolder, race, materialStrings[mesh].Substring(materialStrings[mesh].IndexOf("h00") + 1, 4));
                                    }

                                    var mtrlFile = materialStrings[mesh].Substring(1);

                                    return(MTRL.GetMTRLInfo(Helper.GetItemOffset(FFCRC.GetHash(mtrlFolder), FFCRC.GetHash(mtrlFile)), true));
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine(ex.Message);
                            Debug.WriteLine(ex.StackTrace);
                        }
                    }
                    else
                    {
                        info = MTRL.GetMTRLData(selectedItem, SelectedRace.ID, selectedCategory, SelectedPart.Name, itemVersion, "", "", "0000");
                    }

                    if (SelectedPart.Name.Equals("Secondary"))
                    {
                        info = MTRL.GetMTRLData(selectedItem, SelectedRace.ID, selectedCategory, SelectedPart.Name, itemVersion, "Secondary", "", "0000");
                    }
                    else
                    {
                        string part   = "a";
                        string itemID = selectedItem.PrimaryModelID;

                        if (materialStrings.Count > 1)
                        {
                            try
                            {
                                part   = materialStrings[mesh].Substring(materialStrings[mesh].LastIndexOf("_") + 1, 1);
                                itemID = materialStrings[mesh].Substring(materialStrings[mesh].IndexOf("_") + 2, 4);
                            }
                            catch (Exception ex)
                            {
                                Debug.WriteLine(ex.Message);
                                Debug.WriteLine(ex.StackTrace);
                            }
                        }

                        if (selectedCategory.Equals(Strings.Pets))
                        {
                            part = "1";
                        }

                        info = MTRL.GetMTRLData(selectedItem, SelectedRace.ID, selectedCategory, part, itemVersion, "", itemID, "0000");
                    }

                    if (info != null)
                    {
                        mtrlData = info.Item1;
                    }
                    else
                    {
                        var combo = new ComboBoxInfo()
                        {
                            Name = "Default", ID = materialStrings[mesh].Substring(materialStrings[mesh].IndexOf("c") + 1, 4), IsNum = false
                        };

                        if (SelectedPart.Name.Equals("-"))
                        {
                            info = MTRL.GetMTRLData(selectedItem, combo.ID, selectedCategory, "a", itemVersion, "", "", "0000");
                        }
                        else
                        {
                            info = MTRL.GetMTRLData(selectedItem, combo.ID, selectedCategory, SelectedPart.Name, itemVersion, "", "", "0000");
                        }

                        mtrlData = info.Item1;
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                Debug.WriteLine(ex.StackTrace);
                return(null);
            }

            return(mtrlData);
        }
예제 #2
0
        public ModListModel ParseEntry(JsonEntry entry)
        {
            ModListModel mlm = new ModListModel();
            string       race, map, part, type;

            if (entry.fullPath.Contains("weapon") || entry.fullPath.Contains("accessory") || entry.fullPath.Contains("decal") || entry.fullPath.Contains("vfx") || entry.fullPath.Contains("ui/"))
            {
                race = Strings.All;
            }
            else if (entry.fullPath.Contains("monster") || entry.fullPath.Contains("demihuman"))
            {
                race = Strings.Monster;
            }
            else
            {
                race = entry.fullPath.Substring(entry.fullPath.LastIndexOf('/'));

                if ((entry.fullPath.Contains("_fac_") || entry.fullPath.Contains("_etc_") || entry.fullPath.Contains("_acc_")) && Properties.Settings.Default.DX_Ver.Equals(Strings.DX11))
                {
                    race = race.Substring(race.LastIndexOf("--c") + 3, 4);
                }
                else if (entry.fullPath.Contains("_fac_") || entry.fullPath.Contains("_etc_") || entry.fullPath.Contains("_acc_"))
                {
                    race = race.Substring(race.LastIndexOf("/c") + 2, 4);
                }
                else if (entry.fullPath.Contains("_c_"))
                {
                    race = race.Substring(race.IndexOf("_c") + 2, 4);
                }
                else
                {
                    race = race.Substring(race.LastIndexOf('c') + 1, 4);
                }
                race = Info.IDRace[race];
            }

            mlm.Race = race;


            if (entry.fullPath.Contains("_d."))
            {
                map = Strings.Diffuse;
            }
            else if (entry.fullPath.Contains("_n."))
            {
                map = Strings.Normal;
            }
            else if (entry.fullPath.Contains("_s."))
            {
                map = Strings.Specular;
            }
            else if (entry.fullPath.Contains("material"))
            {
                map = Strings.ColorSet;
            }
            else if (entry.fullPath.Contains("model"))
            {
                map = "3D";
            }
            else if (entry.fullPath.Contains("ui/"))
            {
                map = "UI";
            }
            else
            {
                map = Strings.Mask;
            }

            mlm.Map = map;


            if (entry.fullPath.Contains("_b_"))
            {
                part = "b";
            }
            else if (entry.fullPath.Contains("_c_"))
            {
                part = "c";
            }
            else if (entry.fullPath.Contains("_d_"))
            {
                part = "d";
            }
            else if (entry.fullPath.Contains("decal"))
            {
                part = entry.fullPath.Substring(entry.fullPath.LastIndexOf('_') + 1, entry.fullPath.LastIndexOf('.') - (entry.fullPath.LastIndexOf('_') + 1));
            }
            else
            {
                part = "a";
            }

            mlm.Part = part;


            if (entry.fullPath.Contains("_iri_"))
            {
                type = "Iris";
            }
            else if (entry.fullPath.Contains("_etc_"))
            {
                type = "Etc.";
            }
            else if (entry.fullPath.Contains("_fac_"))
            {
                type = "Face";
            }
            else if (entry.fullPath.Contains("_hir_"))
            {
                type = "Hair";
            }
            else if (entry.fullPath.Contains("_acc_"))
            {
                type = "Accessory";
            }
            else if (entry.fullPath.Contains("demihuman"))
            {
                type = entry.fullPath.Substring(entry.fullPath.LastIndexOf('_') - 3, 3);
                type = (Info.slotAbr).FirstOrDefault(x => x.Value == type).Key;
            }
            else
            {
                type = "-";
            }

            mlm.Type = type;

            if (entry.fullPath.Contains("material"))
            {
                var info = MTRL.GetMTRLInfo(entry.modOffset, false);

                var bitmap = TEX.TextureToBitmap(info.ColorData, 9312, 4, 16);

                mlm.BMP = Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
            }
            else if (entry.fullPath.Contains("model"))
            {
                mlm.BMP = new BitmapImage(new Uri("pack://application:,,,/FFXIV TexTools 2;component/Resources/3DModel.png"));
            }
            else
            {
                TEXData texData;

                if (entry.fullPath.Contains("vfx"))
                {
                    texData = TEX.GetVFX(entry.modOffset, entry.datFile);
                }
                else
                {
                    if (entry.fullPath.Contains("icon"))
                    {
                        texData = TEX.GetTex(entry.modOffset, entry.datFile);
                    }
                    else
                    {
                        texData = TEX.GetTex(entry.modOffset, entry.datFile);
                    }
                }

                mlm.BMP = Imaging.CreateBitmapSourceFromHBitmap(texData.BMP.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
            }

            var offset = Helper.GetDataOffset(FFCRC.GetHash(entry.fullPath.Substring(0, entry.fullPath.LastIndexOf("/"))), FFCRC.GetHash(Path.GetFileName(entry.fullPath)), entry.datFile);

            if (offset == entry.modOffset)
            {
                mlm.ActiveBorder  = Brushes.Green;
                mlm.Active        = Brushes.Transparent;
                mlm.ActiveOpacity = 1;
            }
            else if (offset == entry.originalOffset)
            {
                mlm.ActiveBorder  = Brushes.Red;
                mlm.Active        = Brushes.Gray;
                mlm.ActiveOpacity = 0.5f;
            }
            else
            {
                mlm.ActiveBorder  = Brushes.Red;
                mlm.Active        = Brushes.Red;
                mlm.ActiveOpacity = 1;
            }

            mlm.Entry = entry;

            return(mlm);
        }
예제 #3
0
        public ModListModel ParseEntry(JsonEntry entry)
        {
            ModListModel mlm = new ModListModel();
            string       race, map, part, type;

            if (entry.fullPath.Contains("mt_"))
            {
                Debug.WriteLine(entry.fullPath);
            }

            if (entry.fullPath.Contains("weapon") || entry.fullPath.Contains("accessory") || entry.fullPath.Contains("decal") || entry.fullPath.Contains("vfx") || entry.fullPath.Contains("ui/"))
            {
                race = Strings.All;
            }
            else if (entry.fullPath.Contains("monster") || entry.fullPath.Contains("demihuman"))
            {
                race = Strings.Monster;
            }
            else
            {
                race = entry.fullPath.Substring(entry.fullPath.LastIndexOf('/'));
                if (entry.fullPath.Contains("mt_") && entry.fullPath.Contains("_acc_"))
                {
                    race = race.Substring(race.IndexOf("_") + 2, 4);
                }
                else if ((entry.fullPath.Contains("_fac_") || entry.fullPath.Contains("_etc_") || entry.fullPath.Contains("_acc_")) && Properties.Settings.Default.DX_Ver.Equals(Strings.DX11))
                {
                    race = race.Substring(race.LastIndexOf("--c") + 3, 4);
                }
                else if (entry.fullPath.Contains("_fac_") || entry.fullPath.Contains("_etc_") || entry.fullPath.Contains("_acc_"))
                {
                    race = race.Substring(race.LastIndexOf("/c") + 2, 4);
                }
                else if (entry.fullPath.Contains("_c_"))
                {
                    race = race.Substring(race.IndexOf("_c") + 2, 4);
                }
                else
                {
                    if (entry.fullPath.Contains(".mdl") && entry.fullPath.Contains("_fac"))
                    {
                        race = race.Substring(race.IndexOf('c') + 1, 4);
                    }
                    else
                    {
                        race = race.Substring(race.LastIndexOf('c') + 1, 4);
                    }
                }

                if (entry.fullPath.Contains("mt_"))
                {
                    Debug.WriteLine(race + "\n");
                }

                race = Info.IDRace[race];
            }

            mlm.Race = race;


            if (entry.fullPath.Contains("_d."))
            {
                map = Strings.Diffuse;
            }
            else if (entry.fullPath.Contains("_n."))
            {
                map = Strings.Normal;
            }
            else if (entry.fullPath.Contains("_s."))
            {
                map = Strings.Specular;
            }
            else if (entry.fullPath.Contains("material"))
            {
                map = Strings.ColorSet;
            }
            else if (entry.fullPath.Contains("model"))
            {
                map = "3D";
            }
            else if (entry.fullPath.Contains("ui/"))
            {
                map = "UI";
            }
            else
            {
                map = Strings.Mask;
            }

            mlm.Map = map;


            if (entry.fullPath.Contains("_b_"))
            {
                part = "b";
            }
            else if (entry.fullPath.Contains("_c_"))
            {
                part = "c";
            }
            else if (entry.fullPath.Contains("_d_"))
            {
                part = "d";
            }
            else if (entry.fullPath.Contains("decal"))
            {
                part = entry.fullPath.Substring(entry.fullPath.LastIndexOf('_') + 1, entry.fullPath.LastIndexOf('.') - (entry.fullPath.LastIndexOf('_') + 1));
            }
            else
            {
                part = "a";
            }

            mlm.Part = part;


            if (entry.fullPath.Contains("_iri_"))
            {
                type = "Iris";
            }
            else if (entry.fullPath.Contains("_etc_"))
            {
                type = "Etc.";
            }
            else if (entry.fullPath.Contains("_fac_"))
            {
                type = "Face";
            }
            else if (entry.fullPath.Contains("_hir_"))
            {
                type = "Hair";
            }
            else if (entry.fullPath.Contains("_acc_"))
            {
                type = "Accessory";
            }
            else if (entry.fullPath.Contains("demihuman"))
            {
                type = entry.fullPath.Substring(entry.fullPath.LastIndexOf('_') - 3, 3);
                type = (Info.slotAbr).FirstOrDefault(x => x.Value == type).Key;
            }
            else
            {
                type = "-";
            }

            mlm.Type = type;

            if (entry.fullPath.Contains("material"))
            {
                var info = MTRL.GetMTRLInfo(entry.modOffset, false);

                using (var bitmap = TEX.ColorSetToBitmap(info.ColorData))
                    mlm.BMP = TexHelper.CreateBitmapSource(bitmap);
                mlm.BMP.Freeze();
            }
            else if (entry.fullPath.Contains("model"))
            {
                mlm.BMP = new BitmapImage(new Uri("pack://application:,,,/FFXIV TexTools 2;component/Resources/3DModel.png"));
            }
            else
            {
                TEXData texData;

                if (entry.fullPath.Contains("vfx"))
                {
                    texData = TEX.GetVFX(entry.modOffset, entry.datFile);
                }
                else
                {
                    if (entry.fullPath.Contains("icon"))
                    {
                        texData = TEX.GetTex(entry.modOffset, entry.datFile);
                    }
                    else
                    {
                        texData = TEX.GetTex(entry.modOffset, entry.datFile);
                    }
                }

                var scale = 1;

                if (texData.Width >= 4096 || texData.Height >= 4096)
                {
                    scale = 16;
                }
                else if (texData.Width >= 2048 || texData.Height >= 2048)
                {
                    scale = 8;
                }
                else if (texData.Width >= 1024 || texData.Height >= 1024)
                {
                    scale = 4;
                }

                var nWidth  = texData.Width / scale;
                var nHeight = texData.Height / scale;

                var resizedImage = TexHelper.CreateResizedImage(texData.BMPSouceNoAlpha, nWidth, nHeight);
                mlm.BMP = (BitmapSource)resizedImage;
                mlm.BMP.Freeze();
            }

            var offset = Helper.GetDataOffset(FFCRC.GetHash(entry.fullPath.Substring(0, entry.fullPath.LastIndexOf("/"))), FFCRC.GetHash(Path.GetFileName(entry.fullPath)), entry.datFile);

            if (offset == entry.modOffset)
            {
                mlm.ActiveBorder  = Brushes.Green;
                mlm.Active        = Brushes.Transparent;
                mlm.ActiveOpacity = 1;
            }
            else if (offset == entry.originalOffset)
            {
                mlm.ActiveBorder  = Brushes.Red;
                mlm.Active        = Brushes.Gray;
                mlm.ActiveOpacity = 0.5f;
            }
            else
            {
                mlm.ActiveBorder  = Brushes.Red;
                mlm.Active        = Brushes.Red;
                mlm.ActiveOpacity = 1;
            }

            mlm.Entry = entry;

            return(mlm);
        }