Exemple #1
0
        public DecaledVehicleOutfit Clone()
        {
            List <SingleVehicleDecal> clonedList = new List <SingleVehicleDecal>();

            DecalList.ForEach(d => clonedList.Add(d.Clone()));
            DecaledVehicleOutfit cloneOutfit = new DecaledVehicleOutfit(this.OutfitName, clonedList);

            cloneOutfit.VehicleModelHash = this.VehicleModelHash;
            cloneOutfit.FriendlyName     = this.FriendlyName;
            cloneOutfit.DisplayName      = this.DisplayName;
            return(cloneOutfit);
        }
Exemple #2
0
        public static void SaveSingleVehicleOutfit(DecaledVehicleOutfit outfit)
        {
            string fileName = outfit.OutfitName;

            foreach (var c in System.IO.Path.GetInvalidFileNameChars())
            {
                fileName = fileName.Replace(c, '-');
            }

            string filepath = ExportsPath + fileName + ".xml";

            XMLHelper.SaveObjectToXML(outfit, filepath); // If a file already exists, it will be overwritten.
            //UI.ShowSubtitle("Outfit Exported to: \n~y~" + filepath);
        }
Exemple #3
0
        public static void DeleteSingleVehicleOutfit(DecaledVehicleOutfit outfit)
        {
            string fileName = outfit.OutfitName;

            foreach (var c in System.IO.Path.GetInvalidFileNameChars())
            {
                fileName = fileName.Replace(c, '-');
            }

            string filepath = ExportsPath + fileName + ".xml";

            if (System.IO.File.Exists(filepath))
            {
                System.IO.File.Delete(filepath);
            }
        }
Exemple #4
0
        public static void SaveCurrentEditOutfitPermanently(out int indexOfSavedOutfit, out bool isNewOufit)
        {
            if (AllVehicleGraffitiOutfits == null)
            {
                AllVehicleGraffitiOutfits = new List <DecaledVehicleOutfit>();
            }
            DecaledVehicleOutfit savedOutfit = AllVehicleGraffitiOutfits.FirstOrDefault(o => CurrentEditOutfit.OutfitName.Equals(o.OutfitName) && CurrentEditOutfit.VehicleModelHash == o.VehicleModelHash);

            // If the current edit outfit already exists in the saved outfit list..
            if (savedOutfit != default(DecaledVehicleOutfit))
            {
                savedOutfit.DecalList = CurrentEditOutfit.Clone().DecalList;

                // Also affect other loaded outfits derived from the saved outfit.
                foreach (var outfit in LoadedVehicleOutfits)
                {
                    if (CurrentEditOutfit.OutfitName.Equals(outfit.OutfitName) && CurrentEditOutfit.VehicleModelHash == outfit.VehicleModelHash)
                    {
                        foreach (var decal in outfit.DecalList)
                        {
                            decal.Remove();
                        }
                        outfit.DecalList = CurrentEditOutfit.Clone().DecalList;

                        // Makes sure the decals from this outfit point to its specific vehicle
                        // instead of the vehicle from the CurrentEditOutfit outfit.
                        outfit.ApplyToVehicle(outfit.CurrentVehicle);
                    }
                }

                indexOfSavedOutfit = AllVehicleGraffitiOutfits.IndexOf(savedOutfit);
                isNewOufit         = false;
            }
            // If the current edit outfit does NOT exist in the saved outfit list..
            else
            {
                savedOutfit = CurrentEditOutfit.Clone();
                AllVehicleGraffitiOutfits.Add(savedOutfit);
                indexOfSavedOutfit = AllVehicleGraffitiOutfits.Count - 1;
                isNewOufit         = true;
            }

            //SaveAllVehicleGraffitiToFile();
            SaveSingleVehicleOutfit(savedOutfit);

            UI.ShowSubtitle("Outfit saved: " + CurrentEditOutfit.OutfitName, 8000);
        }
Exemple #5
0
        public static void LoadAllVehicleOutfitsFromFolder()
        {
            string[] vehicleOutfitFilePaths = System.IO.Directory.GetFiles(ExportsPath, "*.xml");

            foreach (string outfitFilePath in vehicleOutfitFilePaths)                                                // Example of outfitFilePath: scripts/Graffiti Mod/Imports/Itasha Red.outfit
            {
                DecaledVehicleOutfit outfit = XMLHelper.LoadXMLToObject(new DecaledVehicleOutfit(), outfitFilePath); // outfit would be the object deserialized from Itasha Red.outfit

                if (outfit == null || outfit == default(DecaledVehicleOutfit))
                {
                    continue;                                                            // Skip if the outfit is null or default
                }
                if (AllVehicleGraffitiOutfits.Any(existing => existing.OutfitName.Equals(outfit.OutfitName)))
                {
                    continue;                          // Skip if the oufit already exists
                }
                AllVehicleGraffitiOutfits.Add(outfit); // Add outfit to main outfit list
            }
        }
Exemple #6
0
        public static void DisplaySingleVehicleDecalInfo(DecaledVehicleOutfit savedOutfit, SingleVehicleDecal specificDecal)
        {
            if (LoadedVehicleOutfits != null)
            {
                foreach (var loadedOutfit in LoadedVehicleOutfits.ToList().Where(lo =>
                                                                                 savedOutfit.OutfitName.Equals(lo.OutfitName) && savedOutfit.VehicleModelHash == lo.VehicleModelHash))
                {
                    foreach (var decal in loadedOutfit.DecalList.ToList().Where(ld =>
                                                                                specificDecal.Graffiti.TextureName.Equals(ld.Graffiti.TextureName) && specificDecal.Location == ld.Location))
                    {
                        if (loadedOutfit.CurrentVehicle == null || !loadedOutfit.CurrentVehicle.Exists())
                        {
                            return;
                        }

                        decal.ShowInfo3D();
                    }
                }
            }
        }