コード例 #1
0
ファイル: Imc.cs プロジェクト: shinnova/xivModdingFramework
        /// <summary>
        /// Gets the IMC internal path for the given model info
        /// </summary>
        /// <param name="modelInfo">The model info of the item</param>
        /// <param name="itemType">The type of the item</param>
        /// <returns>A touple containing the Folder and File strings</returns>
        private static (string Folder, string File) GetImcPath(IItemModel item)
        {
            string imcFolder = item.GetItemRootFolder();
            string imcFile;

            var primaryId   = item.ModelInfo.PrimaryID.ToString().PadLeft(4, '0');
            var secondaryId = item.ModelInfo.SecondaryID.ToString().PadLeft(4, '0');
            var itemType    = item.GetPrimaryItemType();

            switch (itemType)
            {
            case XivItemType.equipment:
                imcFile = $"e{primaryId}{ImcExtension}";
                break;

            case XivItemType.accessory:
                imcFile = $"a{primaryId}{ImcExtension}";
                break;

            case XivItemType.weapon:
                imcFile = $"b{secondaryId}{ImcExtension}";
                break;

            case XivItemType.monster:
                imcFile = $"b{secondaryId}{ImcExtension}";
                break;

            case XivItemType.demihuman:
                imcFile = $"e{secondaryId}{ImcExtension}";
                break;

            default:
                imcFolder = "";
                imcFile   = "";
                break;
            }

            return(imcFolder, imcFile);
        }
コード例 #2
0
        public ImportModelViewModel(ImportModelView view, IItemModel item, XivRace race, string submeshId, bool dataOnly, Action onComplete = null, string lastImportFilePath = null)
        {
            _view               = view;
            _item               = item;
            _race               = race;
            _submeshId          = submeshId;
            _dataOnly           = dataOnly;
            _onComplete         = onComplete;
            _lastImportFilePath = lastImportFilePath;

            if (typeof(XivCharacter) == _item.GetType())
            {
                // Fix up naming scheme for character items to match user expectation.
                var clone = (XivCharacter)((XivCharacter)_item).Clone();
                clone.Name = clone.SecondaryCategory;
                _item      = clone;
            }

            var gameDirectory = new DirectoryInfo(Settings.Default.FFXIV_Directory);
            var saveDirectory = new DirectoryInfo(Settings.Default.Save_Directory);
            var dataFile      = IOUtil.GetDataFileFromPath(_item.GetItemRootFolder());

            _mdl       = new Mdl(gameDirectory, dataFile);
            _importers = _mdl.GetAvailableImporters();

            SetupRaces();


            // We need to explicitly fork this onto a new thread to avoid deadlock.
            Task.Run(AssignPath).Wait();

            var defaultPath = $"{IOUtil.MakeItemSavePath(_item, saveDirectory, _race)}\\3D".Replace("/", "\\");
            var modelName   = Path.GetFileNameWithoutExtension(_internalPath);


            // Scan to see which file type(s) actually exist.
            bool foundValidFile = false;

            // FBX is default, so check that first.
            var startingPath = Path.Combine(defaultPath, modelName) + ".fbx";

            if (File.Exists(startingPath))
            {
                foundValidFile = true;
            }

            if (!foundValidFile)
            {
                foreach (var suffix in _importers)
                {
                    startingPath = Path.Combine(defaultPath, modelName) + "." + suffix;
                    if (File.Exists(startingPath))
                    {
                        foundValidFile = true;
                        break;
                    }
                }
            }

            if (!foundValidFile)
            {
                // Auto-fill the last import file path if the file still exists, otherwise just default to reusing the existing model
                startingPath = File.Exists(_lastImportFilePath) ? _lastImportFilePath : "";
            }


            _view.FileNameTextBox.Text = startingPath;

            // Event Handlers
            _view.SelectFileButton.Click += SelectFileButton_Click;
            _view.ImportButton.Click     += ImportButton_Click;
            _view.EditButton.Click       += EditButton_Click;
            _view.Closing += _view_Closing;
            _view.OverrideRaceButton.Checked   += OverrideRaceButton_Checked;
            _view.OverrideRaceButton.Unchecked += OverrideRaceButton_Unchecked;

            // Default Settings for specific categories, event handlers are added to allow users to opt out of these defaults
            if (item.SecondaryCategory == XivStrings.Face)
            {
                _view.UseOriginalShapeDataButton.IsChecked = Settings.Default.UseOriginalShapeDataForFace;
                _view.UseOriginalShapeDataButton.Click    += UseOriginalShapeDataButton_Clicked;
            }
            if (item.SecondaryCategory == XivStrings.Hair)
            {
                _view.CloneUV1Button.IsChecked = Settings.Default.CloneUV1toUV2ForHair;
                _view.CloneUV1Button.Click    += CloneUV1Button_Clicked;
            }

            var iType = item.GetPrimaryItemType();

            if (iType == xivModdingFramework.Items.Enums.XivItemType.equipment || iType == xivModdingFramework.Items.Enums.XivItemType.accessory || iType == xivModdingFramework.Items.Enums.XivItemType.weapon)
            {
                _view.ForceUVsButton.IsChecked = Settings.Default.ForceUV1QuadrantForGear;
                _view.ForceUVsButton.Click    += ForceUVsButton_Clicked;
            }
        }
コード例 #3
0
        public ImportModelViewModel(ImportModelView view, IItemModel item, XivRace race, string submeshId, bool dataOnly, Action onComplete = null)
        {
            _view       = view;
            _item       = item;
            _race       = race;
            _submeshId  = submeshId;
            _dataOnly   = dataOnly;
            _onComplete = onComplete;

            var gameDirectory = new DirectoryInfo(Settings.Default.FFXIV_Directory);
            var saveDirectory = new DirectoryInfo(Settings.Default.Save_Directory);
            var dataFile      = IOUtil.GetDataFileFromPath(_item.GetItemRootFolder());

            _mdl       = new Mdl(gameDirectory, dataFile);
            _importers = _mdl.GetAvailableImporters();


            // We need to explicitly fork this onto a new thread to avoid deadlock.
            Task.Run(AssignPath).Wait();

            var defaultPath = $"{IOUtil.MakeItemSavePath(_item, saveDirectory, _race)}\\3D";

            defaultPath = defaultPath.Replace("/", "\\");
            var modelName = Path.GetFileNameWithoutExtension(_internalPath);


            // Scan to see which file type(s) actually exist.
            bool foundValidFile = false;

            // FBX is default, so check that first.
            var startingPath = Path.Combine(defaultPath, modelName) + ".fbx";

            if (File.Exists(startingPath))
            {
                foundValidFile = true;
            }
            if (!foundValidFile)
            {
                foreach (var suffix in _importers)
                {
                    startingPath = Path.Combine(defaultPath, modelName) + "." + suffix;
                    if (File.Exists(startingPath))
                    {
                        foundValidFile = true;
                        break;
                    }
                }
            }

            if (!foundValidFile)
            {
                startingPath = "";
            }


            _view.FileNameTextBox.Text = startingPath;

            // Event Handlers
            _view.SelectFileButton.Click += SelectFileButton_Click;
            _view.ImportButton.Click     += ImportButton_Click;
            _view.EditButton.Click       += EditButton_Click;
            _view.Closing += _view_Closing;

            // Default Settings for specific categories.
            if (item.SecondaryCategory == XivStrings.Face)
            {
                _view.EnableShapeDataButton.IsChecked = true;
            }
            if (item.SecondaryCategory == XivStrings.Hair)
            {
                _view.CloneUV1Button.IsChecked = true;
            }

            var iType = item.GetPrimaryItemType();

            if (iType == xivModdingFramework.Items.Enums.XivItemType.equipment || iType == xivModdingFramework.Items.Enums.XivItemType.accessory || iType == xivModdingFramework.Items.Enums.XivItemType.weapon)
            {
                _view.ForceUVsButton.IsChecked = true;
            }
        }