Пример #1
0
        public static void SaveProject(string filePath)
        {
            var data = JsonConvert.SerializeObject(MainWindow.Clothes, Formatting.Indented);

            File.WriteAllText(filePath, data);
            StatusController.SetStatus("Project saved.");
        }
Пример #2
0
        public static void LoadProject(string filePath)
        {
            var data = JsonConvert.DeserializeObject <List <ClothData> >(File.ReadAllText(filePath));

            MainWindow.Clothes.Clear();

            var clothes = data.OrderBy(x => x.Name, new AlphanumericComparer()).ToList();

            foreach (var cloth in clothes)
            {
                MainWindow.Clothes.Add(cloth);
            }
            StatusController.SetStatus("Project loaded. Total clothes: " + MainWindow.Clothes.Count);
        }
Пример #3
0
        private void RemoveUnderCursor_Click(object sender, RoutedEventArgs e)
        {
            if (_selectedCloth == null)
            {
                return;
            }
            var removedClothName = _selectedCloth.Name;

            var clothes = Clothes.OrderBy(x => x.Name, new AlphanumericComparer()).ToList();

            Clothes.Clear();
            foreach (var cloth in clothes.Where(c => c != _selectedCloth))
            {
                Clothes.Add(cloth);
            }

            _selectedCloth               = null;
            editGroupBox.Visibility      = Visibility.Collapsed;
            clothEditWindow.Visibility   = Visibility.Collapsed;
            pedPropEditWindow.Visibility = Visibility.Collapsed;
            StatusController.SetStatus($"Removed '{removedClothName}'. Total clothes: " + Clothes.Count);
        }
Пример #4
0
        private void BuildButton_Click(object sender, RoutedEventArgs e)
        {
            TargetResourceType resType = TargetResourceType.AltV;

            if (isSinglePlayerRadio.IsChecked == true)
            {
                resType = TargetResourceType.Single;
            }
            else if (isFivemResourceRadio.IsChecked == true)
            {
                resType = TargetResourceType.FiveM;
            }

            CollectionName = collectionNameText.Text;

            if (FilePathHasInvalidChars(OutputFolder))
            {
                MessageBox.Show("Output folder path contains invalid characters.\nPlease choose another output location.");
                StatusController.SetStatus("Error: Invalid build output folder.");
                return;
            }

            new ClothesResourceBuilderFactory().BuildResource(resType, OutputFolder, CollectionName);
        }
Пример #5
0
        public void AddClothes(ClothData.Sex targetSex)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                CheckFileExists = true,
                Filter          = "Clothes geometry (*.ydd)|*.ydd",
                FilterIndex     = 1,
                DefaultExt      = "ydd",
                Multiselect     = true,
                Title           = "Adding " + (targetSex == ClothData.Sex.Male ? "male" : "female") + " clothes"
            };

            if (openFileDialog.ShowDialog() != true)
            {
                return;
            }

            foreach (string filename in openFileDialog.FileNames)
            {
                string            baseFileName = Path.GetFileName(filename);
                ClothNameResolver cData        = new ClothNameResolver(baseFileName);

                if (cData.IsVariation)
                {
                    StatusController.SetStatus($"Item {baseFileName} can't be added. Looks like it's variant of another item");
                    continue;
                }

                ClothData nextCloth = new ClothData(filename, cData.ClothType, cData.DrawableType, cData.BindedNumber, cData.Postfix, targetSex);

                if (cData.ClothType == ClothNameResolver.ClothTypes.Component)
                {
                    nextCloth.SearchForFirstPersonModel();
                    nextCloth.SearchForTextures();

                    var clothes = MainWindow.Clothes.ToList();
                    clothes.Add(nextCloth);
                    clothes = clothes.OrderBy(x => x.Name, new AlphanumericComparer()).ToList();
                    MainWindow.Clothes.Clear();

                    foreach (var cloth in clothes)
                    {
                        MainWindow.Clothes.Add(cloth);
                    }

                    StatusController.SetStatus(nextCloth + " added (" +
                                               (!string.IsNullOrEmpty(nextCloth.FirstPersonModelPath)
                                                   ? "FP Model found, "
                                                   : "") + "Found " + nextCloth.Textures.Count +
                                               " textures). Total clothes: " + MainWindow.Clothes.Count);
                }
                else
                {
                    nextCloth.SearchForTextures();

                    var clothes = MainWindow.Clothes.ToList();
                    clothes.Add(nextCloth);
                    clothes = clothes.OrderBy(x => x.Name, new AlphanumericComparer()).ToList();
                    MainWindow.Clothes.Clear();

                    foreach (var cloth in clothes)
                    {
                        MainWindow.Clothes.Add(cloth);
                    }

                    StatusController.SetStatus(nextCloth + " added. (Found " + nextCloth.Textures.Count +
                                               " textures). Total clothes: " + MainWindow.Clothes.Count);
                }
            }
        }