/// <summary>
        /// Imports a first generation mod pack
        /// </summary>
        /// <param name="modPackDirectory">The mod pack directory</param>
        private void ImportOldModPack()
        {
            var modding = new Modding(_gameDirectory);

            var originalModPackData = _texToolsModPack.GetOriginalModPackJsonData(_modPackDirectory);

            foreach (var modsJson in originalModPackData)
            {
                var race   = GetRace(modsJson.FullPath);
                var number = GetNumber(modsJson.FullPath);
                var type   = GetType(modsJson.FullPath);
                var map    = GetMap(modsJson.FullPath);

                var active   = false;
                var isActive = modding.IsModEnabled(modsJson.FullPath, false);

                if (isActive == XivModStatus.Enabled)
                {
                    active = true;
                }

                _simpleDataList.Add(new SimpleModPackEntries
                {
                    Name      = modsJson.Name,
                    Category  = modsJson.Category,
                    Race      = race.ToString(),
                    Part      = type,
                    Num       = number,
                    Map       = map,
                    Active    = active,
                    JsonEntry = new ModsJson
                    {
                        Name      = modsJson.Name,
                        Category  = modsJson.Category,
                        FullPath  = modsJson.FullPath,
                        DatFile   = modsJson.DatFile,
                        ModOffset = modsJson.ModOffset,
                        ModSize   = modsJson.ModSize
                    }
                });
            }

            ModPackName.Content    = "N/A";
            ModPackAuthor.Content  = "N/A";
            ModPackVersion.Content = "N/A";

            _simpleDataList.Sort();

            ModListView.ItemsSource = new ObservableCollection <SimpleModPackEntries>(_simpleDataList);

            ModListView.SelectAll();
        }
        public SimpleModPackCreator()
        {
            InitializeComponent();

            _gameDirectory = new DirectoryInfo(Properties.Settings.Default.FFXIV_Directory);
            var modListDirectory = new DirectoryInfo(Path.Combine(_gameDirectory.Parent.Parent.FullName, XivStrings.ModlistFilePath));
            var modding          = new Modding(_gameDirectory);

            var modList = JsonConvert.DeserializeObject <ModList>(File.ReadAllText(modListDirectory.FullName));

            foreach (var mod in modList.Mods)
            {
                if (mod.fullPath.Equals(string.Empty))
                {
                    continue;
                }

                var race = GetRace(mod.fullPath);

                var number = GetNumber(mod.fullPath);

                var type = GetType(mod.fullPath);

                var map = GetMap(mod.fullPath);

                var active   = false;
                var isActive = modding.IsModEnabled(mod.fullPath, false);

                if (isActive == XivModStatus.Enabled)
                {
                    active = true;
                }

                _simpleDataList.Add(new SimpleModPackEntries
                {
                    Name     = mod.name,
                    Category = mod.category,
                    Race     = race.ToString(),
                    Part     = type,
                    Num      = number,
                    Map      = map,
                    Active   = active,
                    ModEntry = mod
                });
            }

            _simpleDataList.Sort();

            ModListView.ItemsSource = new ObservableCollection <SimpleModPackEntries>(_simpleDataList);
        }
        /// <summary>
        /// Imports a simple mod pack
        /// </summary>
        /// <param name="modPackJson">The mod pack json</param>
        private void ImportSimpleModPack(ModPackJson modPackJson)
        {
            var modding = new Modding(_gameDirectory);

            foreach (var modsJson in modPackJson.SimpleModsList)
            {
                var race   = GetRace(modsJson.FullPath);
                var number = GetNumber(modsJson.FullPath);
                var type   = GetType(modsJson.FullPath);
                var map    = GetMap(modsJson.FullPath);

                var active   = false;
                var isActive = modding.IsModEnabled(modsJson.FullPath, false);

                if (isActive == XivModStatus.Enabled)
                {
                    active = true;
                }

                modsJson.ModPackEntry = new ModPack
                {
                    name = modPackJson.Name, author = modPackJson.Author, version = modPackJson.Version
                };

                _simpleDataList.Add(new SimpleModPackEntries
                {
                    Name      = modsJson.Name,
                    Category  = modsJson.Category,
                    Race      = race.ToString(),
                    Part      = type,
                    Num       = number,
                    Map       = map,
                    Active    = active,
                    JsonEntry = modsJson,
                });
            }

            ModPackName.Content    = modPackJson.Name;
            ModPackAuthor.Content  = modPackJson.Author;
            ModPackVersion.Content = modPackJson.Version;

            _simpleDataList.Sort();

            ModListView.ItemsSource = new ObservableCollection <SimpleModPackEntries>(_simpleDataList);

            ModListView.SelectAll();
        }
示例#4
0
        /// <summary>
        /// Adds the given mod entry to the simple mod pack data list
        /// </summary>
        /// <param name="modsJson">The JSON describing the mod to be added to the list</param>
        /// <param name="modding"></param>
        /// <param name="modPackJson">The JSON describing the entire modpack</param>
        /// <returns>Task</returns>
        private async Task AddToList(ModsJson modsJson, Modding modding, ModPackJson modPackJson)
        {
            var raceTask = GetRace(modsJson.FullPath);

            var numberTask = GetNumber(modsJson.FullPath);

            var typeTask = GetType(modsJson.FullPath);

            var partTask = GetPart(modsJson.FullPath);

            var mapTask = GetMap(modsJson.FullPath);

            var active       = false;
            var isActiveTask = modding.IsModEnabled(modsJson.FullPath, false);

            var taskList = new List <Task> {
                raceTask, numberTask, typeTask, partTask, mapTask, isActiveTask
            };

            var    race = XivRace.All_Races;
            string number = string.Empty, type = string.Empty, part = string.Empty, map = string.Empty;
            var    isActive = XivModStatus.Disabled;

            while (taskList.Any())
            {
                var finished = await Task.WhenAny(taskList);

                if (finished == raceTask)
                {
                    taskList.Remove(raceTask);
                    race = await raceTask;
                }
                else if (finished == numberTask)
                {
                    taskList.Remove(numberTask);
                    number = await numberTask;
                }
                else if (finished == typeTask)
                {
                    taskList.Remove(typeTask);
                    type = await typeTask;
                }
                else if (finished == partTask)
                {
                    taskList.Remove(partTask);
                    part = await partTask;
                }
                else if (finished == mapTask)
                {
                    taskList.Remove(mapTask);
                    map = await mapTask;
                }
                else if (finished == isActiveTask)
                {
                    taskList.Remove(isActiveTask);
                    isActive = await isActiveTask;
                }
            }

            if (isActive == XivModStatus.Enabled || isActive == XivModStatus.MatAdd)
            {
                active = true;
            }

            modsJson.ModPackEntry = new ModPack
            {
                name = modPackJson.Name, author = modPackJson.Author, version = modPackJson.Version
            };

            System.Windows.Application.Current.Dispatcher.Invoke(() => _simpleDataList.Add(new SimpleModPackEntries
            {
                Name      = modsJson.Name,
                Category  = modsJson.Category,
                Race      = race.ToString(),
                Type      = type,
                Part      = part,
                Num       = number,
                Map       = map,
                Active    = active,
                JsonEntry = modsJson,
            }));
        }