Beispiel #1
0
        private string ToModString(VehicleModCollection mods)
        {
            var modList = new Dictionary <string, string>();

            if (mods.IsPrimaryColorCustom)
            {
                modList["CustomPrimary"] = Trainer.ColorToRgbString(mods.CustomPrimaryColor);
            }
            else
            {
                modList["PrimaryColour"] = Convert.ToString((int)mods.PrimaryColor);
            }

            if (mods.IsSecondaryColorCustom)
            {
                modList["CustomSecondary"] = Trainer.ColorToRgbString(mods.CustomSecondaryColor);
            }
            else
            {
                modList["SecondaryColour"] = Convert.ToString((int)mods.SecondaryColor);
            }

            modList["PearlescentColour"] = Convert.ToString((int)mods.PearlescentColor);
            modList["Livery"]            = Convert.ToString(mods.Livery);
            modList["PlateText"]         = mods.LicensePlate;
            modList["PlateStyle"]        = Convert.ToString((int)mods.LicensePlateStyle);
            modList["RimColour"]         = Convert.ToString((int)mods.RimColor);
            modList["WindowTint"]        = Convert.ToString((int)mods.WindowTint);
            modList["DashboardColour"]   = Convert.ToString((int)mods.DashboardColor);
            modList["NeonColour"]        = Trainer.ColorToRgbString(mods.NeonLightsColor);
            modList["TyreSmokeColour"]   = Trainer.ColorToRgbString(mods.TireSmokeColor);
            modList["TyreSmoke"]         = mods[VehicleToggleModType.TireSmoke].IsInstalled ? "true" : "false";
            modList["Turbo"]             = mods[VehicleToggleModType.Turbo].IsInstalled ? "true" : "false";
            modList["XenonHeadlights"]   = mods[VehicleToggleModType.XenonHeadlights].IsInstalled ? "true" : "false";
            modList["TrimColour"]        = Convert.ToString((int)mods.TrimColor);
            modList["ColourCombo"]       = Convert.ToString(mods.ColorCombination);
            modList["WheelType"]         = Convert.ToString((int)mods.WheelType);

            for (var i = 0; i < 4; i++)
            {
                modList[$"NeonEnabled{i}"] = mods.IsNeonLightsOn((VehicleNeonLight)i) ? "true" : "false";
            }

            foreach (var mod in mods.GetAllMods())
            {
                var modTypeInt = (int)mod.ModType;
                modList[$"Mod#{modTypeInt}"] = Convert.ToString(mod.Index);
            }

            return(JsonConvert.SerializeObject(modList));
        }
Beispiel #2
0
        public Dictionary <string, List <MenuItem> > GetOtherModsMenus()
        {
            var menus = new Dictionary <string, List <MenuItem> >();

            Vehicle vehicle = Game.PlayerPed.CurrentVehicle;

            if (vehicle == null)
            {
                menus["vehicles.mods.other"] = new List <MenuItem>()
                {
                    new MenuItem()
                    {
                        text = "Please enter a vehicle to view mods",
                    }
                };
            }
            else
            {
                VehicleModCollection mods = vehicle.Mods;

                var modTypeMenu = new List <MenuItem>();

                foreach (var mod in mods.GetAllMods())
                {
                    var modMenu = new List <MenuItem>();

                    for (var i = -1; i < mod.ModCount; i++)
                    {
                        var name = mod.GetLocalizedModName(i);

                        if (name == string.Empty)
                        {
                            name = $"{mod.LocalizedModTypeName} {i}";
                        }

                        if (mod.Index == i)
                        {
                            name += " (Current)";
                        }

                        modMenu.Add(new MenuItem()
                        {
                            text   = name,
                            action = $"vehmodother {(int)mod.ModType}={i}",
                        });
                    }

                    menus[$"vehicles.mods.other.{mod.ModType}"] = modMenu;

                    modTypeMenu.Add(new MenuItem()
                    {
                        text = mod.LocalizedModTypeName,
                        sub  = $"vehicles.mods.other.{mod.ModType}",
                    });
                }

                modTypeMenu.Sort((x, y) => x.text.CompareTo(y.text));

                menus["vehicles.mods.other"] = modTypeMenu;
            }

            return(menus);
        }