public BlockInfo(DataTable dataTable, String name, ModList modList, Mod curMod) { data = dataTable; this.modList = modList; this.curMod = curMod; this.name = name; InitializeComponent(); loadData(); }
public override bool generate(ModList mods) { int n = 0; if (mods.contains("agent") && !mods.contains("injured")) n = rnd.Next(1,100); Console.WriteLine("Generating injured event"); if (n > 90) return true; else //return false; return true; //for testing }
private static void LoadModsFromFolder(string folderPath) { foreach (var modFile in (new DirectoryInfo(folderPath)).GetFiles("*.dll")) { if (Utils.ModsBlacklist.BlacklistedMods.Contains(modFile.Name)) { Logger.InfoLog($"-{modFile.Name} is in blacklist, skipping it"); continue; } Mod modToAdd = LoadMod(modFile); modToAdd.CurrentlyEnabled = folderPath != PathList.ModsFolderPath; modToAdd.IsEnabled = modToAdd.CurrentlyEnabled; bool isDuplicate = false; foreach (var mod in ModList) { //if added mod is already applied if (mod.Meta.ModName == modToAdd.Meta.ModName) { Logger.InfoLog($"-{modToAdd.Meta.ModName} is already applied, overriding it with newer version"); isDuplicate = true; mod.IsEnabled = true; mod.CurrentlyEnabled = true; EnableMod(modToAdd); break; } } if (isDuplicate) { continue; } ModList.Add(modToAdd); } }
public void IsVisible_WithAllAndNoNameFilter_ReturnsTrueForCompatible() { using (var tidy = new DisposableKSP()) { KSPManager manager = new KSPManager( new NullUser(), new FakeConfiguration(tidy.KSP, tidy.KSP.Name) ) { CurrentInstance = tidy.KSP }; var ckan_mod = TestData.FireSpitterModule(); var registry = Registry.Empty(); registry.AddAvailable(ckan_mod); var item = new ModList(delegate { }); Assert.That(item.IsVisible( new GUIMod(ckan_mod, registry, manager.CurrentInstance.VersionCriteria()), manager.CurrentInstance.Name )); manager.Dispose(); } }
public BackupModPackCreator() { InitializeComponent(); _gameDirectory = new DirectoryInfo(Properties.Settings.Default.FFXIV_Directory); var modding = new Modding(_gameDirectory); _modList = modding.GetModList(); DataContext = new BackupModpackViewModel(); ModpackList.ItemsSource = new List <BackupModpackItemEntry>(); ModPackName.Text = string.Format("Backup_{0}", DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")); // Manually add an entry for the mods that don't belong to a modpack ((List <BackupModpackItemEntry>)ModpackList.ItemsSource).Add(new BackupModpackItemEntry(UIStrings.Standalone_Non_ModPack)); foreach (var modpack in _modList.ModPacks) { var entry = new BackupModpackItemEntry(modpack.name); ((List <BackupModpackItemEntry>)ModpackList.ItemsSource).Add(entry); } ModpackList.SelectedIndex = 0; }
public TestInstaller(string archive, ModList modList, string outputFolder, string downloadFolder, SystemParameters parameters) : base(archive, modList, outputFolder, downloadFolder, parameters) { ConfigureProcessor(1, new Subject <int>().StartWith(1)); }
/// <summary> /// 使用要计算的谱面和要使用的Mod初始化pp计算器 /// </summary> /// <param name="beatmap"></param> /// <param name="mods"></param> public CatchPerformanceCalculator(CatchBeatmap beatmap, ModList mods) { Beatmap = beatmap; Mods = mods; DifficultyCalculator = new CatchDifficultyCalculator(beatmap, mods); }
public async Task TestModValidation() { var modlist = new ModList { GameType = Game.Skyrim, Archives = new List <Archive> { new Archive( new NexusDownloader.State { Game = Game.Skyrim, Author = "bill", ModID = 42, FileID = 33, }) { Hash = Hash.FromLong(42) } }, Directives = new List <Directive> { new FromArchive { ArchiveHashPath = HashRelativePath.FromStrings(Hash.FromULong(42).ToBase64(), "foo\\bar\\baz.pex"), To = (RelativePath)"foo\\bar\\baz.pex" } } }; // Error due to file downloaded from 3rd party modlist.GameType = Game.Skyrim; modlist.Archives[0] = new Archive(new HTTPDownloader.State("https://somebadplace.com")) { Hash = Hash.FromLong(42) }; var errors = await validate.Validate(modlist); Assert.Single(errors); // Ok due to file downloaded from whitelisted 3rd party modlist.GameType = Game.Skyrim; modlist.Archives[0] = new Archive(new HTTPDownloader.State("https://somegoodplace.com/baz.7z")) { Hash = Hash.FromLong(42) }; errors = await validate.Validate(modlist); Assert.Empty(errors); // Error due to file downloaded from bad 3rd party modlist.GameType = Game.Skyrim; modlist.Archives[0] = new Archive(new GoogleDriveDownloader.State("bleg")) { Hash = Hash.FromLong(42) }; errors = await validate.Validate(modlist); Assert.Single(errors); // Ok due to file downloaded from good google site modlist.GameType = Game.Skyrim; modlist.Archives[0] = new Archive(new GoogleDriveDownloader.State("googleDEADBEEF")) { Hash = Hash.FromLong(42) }; errors = await validate.Validate(modlist); Assert.Empty(errors); }
public EventSelector() { mods = new ModList(); chains = new List<Event>(); }
protected async Task <Uri> MakeModList(string modFileName) { var archive_data = Encoding.UTF8.GetBytes("Cheese for Everyone!"); var test_archive_path = modFileName.RelativeTo(Fixture.ServerPublicFolder); await test_archive_path.WriteAllBytesAsync(archive_data); ModListData = new ModList(); ModListData.Archives.Add( new Archive(new HTTPDownloader.State(MakeURL(modFileName))) { Hash = await test_archive_path.FileHashAsync() ?? Hash.Empty, Name = "test_archive", Size = test_archive_path.Size, }); var modListPath = "test_modlist.wabbajack".RelativeTo(Fixture.ServerPublicFolder); await using (var fs = await modListPath.Create()) { using var za = new ZipArchive(fs, ZipArchiveMode.Create); var entry = za.CreateEntry("modlist"); await using var es = entry.Open(); ModListData.ToJson(es); } ModListMetaData = new List <ModlistMetadata> { new ModlistMetadata { Official = false, Author = "Test Suite", Description = "A test", DownloadMetadata = new DownloadMetadata { Hash = await modListPath.FileHashAsync() ?? Hash.Empty, Size = modListPath.Size }, Links = new ModlistMetadata.LinksObject { MachineURL = "test_list", Download = MakeURL("test_modlist.wabbajack") } }, new ModlistMetadata { Official = true, Author = "Test Suite", Description = "A list with a broken hash", DownloadMetadata = new DownloadMetadata() { Hash = Hash.FromLong(42), Size = 42 }, Links = new ModlistMetadata.LinksObject { MachineURL = "broken_list", Download = MakeURL("test_modlist.wabbajack") } } }; var metadataPath = "test_mod_list_metadata.json".RelativeTo(Fixture.ServerPublicFolder); await ModListMetaData.ToJsonAsync(metadataPath); return(new Uri(MakeURL("test_mod_list_metadata.json"))); }
internal ModListMessage(ModList mods, ulong steamId, bool fromServer = false) { Mods = mods; SteamId = new CSteamID(steamId); FromServer = fromServer; }
private static async Task SaveCharaMakeParameterSet(CharaMakeParameterSet cmp, IndexFile index = null, ModList modlist = null) { var _dat = new Dat(XivCache.GameInfo.GameDirectory); var dummyItem = new XivGenericItemModel(); dummyItem.Name = "human.cmp"; dummyItem.SecondaryCategory = Constants.InternalModSourceName; await _dat.ImportType2Data(cmp.GetBytes(), HumanCmpPath, Constants.InternalModSourceName, dummyItem, index, modlist); }
private static async Task <CharaMakeParameterSet> GetCharaMakeParameterSet(bool forceOriginal = false, IndexFile index = null, ModList modlist = null) { var _dat = new Dat(XivCache.GameInfo.GameDirectory); var data = await _dat.GetType2Data(HumanCmpPath, forceOriginal, index, modlist); var cmp = new CharaMakeParameterSet(data); return(cmp); }
/// <summary> /// Performs the base level alteration to the CMP file, without going through .rgsp files. /// </summary> /// <param name="data"></param> /// <param name="index"></param> /// <param name="modlist"></param> /// <returns></returns> private static async Task SetScalingParameter(RacialGenderScalingParameter data, IndexFile index = null, ModList modlist = null) { var cmp = await GetCharaMakeParameterSet(false, index, modlist); cmp.SetScalingParameter(data); await SaveCharaMakeParameterSet(cmp, index, modlist); }
public static async Task <RacialGenderScalingParameter> GetScalingParameter(XivSubRace race, XivGender gender, bool forceOriginal = false, IndexFile index = null, ModList modlist = null) { var cmp = await GetCharaMakeParameterSet(forceOriginal, index, modlist); return(cmp.GetScalingParameter(race, gender)); }
public IEnumerable <string> Validate(ModList modlist) { ConcurrentStack <string> ValidationErrors = new ConcurrentStack <string>(); var nexus_mod_permissions = modlist.Archives .Where(a => a.State is NexusDownloader.State) .PMap(a => (a.Hash, FilePermissions((NexusDownloader.State)a.State), a)) .ToDictionary(a => a.Hash, a => new { permissions = a.Item2, archive = a.a }); modlist.Directives .OfType <PatchedFromArchive>() .PMap(p => { if (nexus_mod_permissions.TryGetValue(p.ArchiveHashPath[0], out var archive)) { var ext = Path.GetExtension(p.ArchiveHashPath.Last()); var url = (archive.archive.State as NexusDownloader.State).NexusURL; if (Consts.AssetFileExtensions.Contains(ext) && !(archive.permissions.CanModifyAssets ?? true)) { ValidationErrors.Push($"{p.To} from {url} is set to disallow asset modification"); } else if (Consts.ESPFileExtensions.Contains(ext) && !(archive.permissions.CanModifyESPs ?? true)) { ValidationErrors.Push($"{p.To} from {url} is set to disallow asset ESP modification"); } } }); modlist.Directives .OfType <FromArchive>() .PMap(p => { if (nexus_mod_permissions.TryGetValue(p.ArchiveHashPath[0], out var archive)) { var url = (archive.archive.State as NexusDownloader.State).NexusURL; if (!(archive.permissions.CanExtractBSAs ?? true) && p.ArchiveHashPath.Skip(1).ButLast().Any(a => Consts.SupportedBSAs.Contains(Path.GetExtension(a).ToLower()))) { ValidationErrors.Push($"{p.To} from {url} is set to disallow BSA Extraction"); } } }); var nexus = NexusApi.NexusApiUtils.ConvertGameName(GameRegistry.Games[modlist.GameType].NexusName); modlist.Archives .Where(a => a.State is NexusDownloader.State) .Where(m => NexusApi.NexusApiUtils.ConvertGameName(((NexusDownloader.State)m.State).GameName) != nexus) .Do(m => { var permissions = FilePermissions((NexusDownloader.State)m.State); if (!(permissions.CanUseInOtherGames ?? true)) { ValidationErrors.Push( $"The modlist is for {nexus} but {m.Name} is for game type {((NexusDownloader.State)m.State).GameName} and is not allowed to be converted to other game types"); } }); modlist.Archives .Where(m => !m.State.IsWhitelisted(ServerWhitelist)) .Do(m => { ValidationErrors.Push($"{m.Name} is not a whitelisted download"); }); return(ValidationErrors.ToList()); }
public abstract bool generate(ModList mods);
/// <summary> /// Applies a custom .rgsp file to the main Human.CMP file. /// </summary> /// <param name="filePath"></param> /// <param name="index"></param> /// <param name="modlist"></param> /// <returns></returns> internal static async Task ApplyRgspFile(string filePath, IndexFile index = null, ModList modlist = null) { var _dat = new Dat(XivCache.GameInfo.GameDirectory); var rgspData = await _dat.GetType2Data(filePath, false, index, modlist); var rgsp = new RacialGenderScalingParameter(rgspData); await SetScalingParameter(rgsp, index, modlist); }
/// <summary> /// Do not use, must be public for Unity to access. /// </summary> /// <param name="reader"></param> public override void Deserialize(NetworkReader reader) { Mods = ModList.Read(reader); SteamId = new CSteamID(reader.ReadUInt64()); FromServer = reader.ReadBoolean(); }
internal static async Task RestoreDefaultScaling(string rgspPath, IndexFile index = null, ModList modlist = null) { var match = RgspPathExtractFormat.Match(rgspPath); if (!match.Success) { throw new InvalidDataException("Invalid .RGSP file path."); } var race = (XivSubRace)Int32.Parse(match.Groups[1].Value); var gender = (XivGender)Int32.Parse(match.Groups[2].Value); await RestoreDefaultScaling(race, gender, index, modlist); }
public TridevModHelper(ModList modList, EventBus.EventBus eventBus) { ModList = modList; EventBus = eventBus; }
private void Menu_ModList_Click(object sender, RoutedEventArgs e) { ModList ml = new ModList(); ml.Show(); }
/// <summary> /// 获取谱面的HitObject数量 /// </summary> /// <param name="b"></param> /// <param name="mods"></param> /// <returns></returns> public virtual int GetBeatmapHitObjectCount(Beatmap b, ModList mods) { return(0); }
void UpdateModLoadConfig() { ModLoadConfig newModLoadConfig = new ModLoadConfig(); XmlSerializer serializer = new XmlSerializer(typeof(ModLoadConfig)); FileStream stream = new FileStream(modFolderPath + "ModLoadConfig.xml", FileMode.Create); for (int i = 0; i < ModList.Items.Count; i++) { newModLoadConfig.ModLoadOrder.Add(new ModLoadConfig.ModEntry(ModList.GetItemText(ModList.Items[i]), ModList.GetItemChecked(i))); } serializer.Serialize(stream, newModLoadConfig); stream.Close(); }
/// <summary> /// 使用一个难度计算器初始化pp计算器 /// </summary> /// <param name="calculator"></param> public CatchPerformanceCalculator(CatchDifficultyCalculator calculator) { DifficultyCalculator = calculator; Beatmap = calculator.Beatmap; Mods = calculator.Mods; }
public async Task <long> ImportTex(string internalPath, string externalPath, IItem item, string source, IndexFile cachedIndexFile = null, ModList cachedModList = null) { long offset = 0; var path = internalPath; var df = IOUtil.GetDataFileFromPath(path); var data = await MakeTexData(path, externalPath); var modding = new Modding(_gameDirectory); Mod entry = null; if (cachedModList != null) { entry = cachedModList.Mods.FirstOrDefault(x => x.fullPath == path); } else { entry = await modding.TryGetModEntry(path); } var type = Path.GetExtension(path) == ".atex" ? 2 : 4; offset = await _dat.WriteModFile(data, path, source, item, cachedIndexFile, cachedModList); return(offset); }
/// <inheritdoc/> public override int GetBeatmapHitObjectCount(Beatmap b, ModList mods) { return(b?.HitObjects.Count ?? 0); }
/// <summary> /// Saves a given set of modified entries to the EST file. /// Entries with a SkeletonID of 0 will be removed. /// </summary> /// <param name="type"></param> /// <param name="modifiedEntries"></param> /// <returns></returns> public static async Task SaveExtraSkeletonEntries(EstType type, List <ExtraSkeletonEntry> modifiedEntries, IItem referenceItem = null, IndexFile cachedIndexFile = null, ModList cachedModList = null) { var entries = await GetEstFile(type, false); // Add/Remove entries. foreach (var entry in modifiedEntries) { if (entry.SkelId == 0) { // Remove this entry. if (entries[entry.Race].ContainsKey(entry.SetId)) { entries[entry.Race].Remove(entry.SetId); } } else { // Add or update this entry. if (entries[entry.Race].ContainsKey(entry.SetId)) { entries[entry.Race][entry.SetId] = entry; } else { entries[entry.Race].Add(entry.SetId, entry); } } } // Save file. await SaveEstFile(type, entries, referenceItem, cachedIndexFile, cachedModList); }
public TestInstaller(AbsolutePath archive, ModList modList, AbsolutePath outputFolder, AbsolutePath downloadFolder, SystemParameters parameters) : base(archive, modList, outputFolder, downloadFolder, parameters, steps: 1, modList.GameType) { DesiredThreads.OnNext(1); }
private static async Task SaveEstFile(EstType type, Dictionary <XivRace, Dictionary <ushort, ExtraSkeletonEntry> > entries, IItem referenceItem = null, IndexFile cachedIndexFile = null, ModList cachedModList = null) { var count = entries.Select(x => x.Value.Count).Aggregate((x, y) => x + y); var data = new byte[4 + (count * 6)]; IOUtil.ReplaceBytesAt(data, BitConverter.GetBytes(count), 0); var races = entries.Keys.ToList(); races.Sort(); var index = 0; foreach (var race in races) { var sets = entries[race].Keys.ToList(); sets.Sort(); foreach (var set in sets) { var entry = entries[race][set]; ExtraSkeletonEntry.Write(data, entry, count, index); index++; } } var _dat = new Dat(_gameDirectory); await _dat.ImportType2Data(data, EstFiles[type], Constants.InternalModSourceName, referenceItem, cachedIndexFile, cachedModList); }
/// <summary> /// Recalculates the modListHash for comparison and sets the mod-IDs of the modvalues for the library. /// Should be called after the mods are changed. /// </summary> public void UpdateModList() { modIDs = ModList?.Select(m => m.id).ToList() ?? new List <string>(); modListHash = CalculateModListHash(ModList); }
public void TestModValidation() { var modlist = new ModList { GameType = Game.Skyrim, Archives = new List <Archive> { new Archive { State = new NexusDownloader.State { GameName = "Skyrim", Author = "bill", ModID = "42", FileID = "33", }, Hash = "DEADBEEF" } }, Directives = new List <Directive> { new FromArchive { ArchiveHashPath = new[] { "DEADBEEF", "foo\\bar\\baz.pex" }, To = "foo\\bar\\baz.pex" } } }; IEnumerable <string> errors; // No errors, simple archive extraction errors = validate.Validate(modlist); Assert.AreEqual(errors.Count(), 0); // Error due to patched file modlist.Directives[0] = new PatchedFromArchive { PatchID = Guid.NewGuid().ToString(), ArchiveHashPath = new[] { "DEADBEEF", "foo\\bar\\baz.pex" }, }; errors = validate.Validate(modlist); Assert.AreEqual(errors.Count(), 1); // Error due to extracted BSA file modlist.Directives[0] = new FromArchive { ArchiveHashPath = new[] { "DEADBEEF", "foo.bsa", "foo\\bar\\baz.dds" }, }; errors = validate.Validate(modlist); Assert.AreEqual(errors.Count(), 1); // No error since we're just installing the .bsa, not extracting it modlist.Directives[0] = new FromArchive { ArchiveHashPath = new[] { "DEADBEEF", "foo.bsa" }, }; errors = validate.Validate(modlist); Assert.AreEqual(0, errors.Count()); // Error due to game conversion modlist.GameType = Game.SkyrimSpecialEdition; modlist.Directives[0] = new FromArchive { ArchiveHashPath = new[] { "DEADBEEF", "foo\\bar\\baz.dds" }, }; errors = validate.Validate(modlist); Assert.AreEqual(errors.Count(), 1); // Error due to file downloaded from 3rd party modlist.GameType = Game.Skyrim; modlist.Archives[0] = new Archive() { State = new HTTPDownloader.State() { Url = "https://somebadplace.com" }, Hash = "DEADBEEF" }; errors = validate.Validate(modlist); Assert.AreEqual(1, errors.Count()); // Ok due to file downloaded from whitelisted 3rd party modlist.GameType = Game.Skyrim; modlist.Archives[0] = new Archive { State = new HTTPDownloader.State { Url = "https://somegoodplace.com/baz.7z" }, Hash = "DEADBEEF" }; errors = validate.Validate(modlist); Assert.AreEqual(0, errors.Count()); // Error due to file downloaded from bad 3rd party modlist.GameType = Game.Skyrim; modlist.Archives[0] = new Archive { State = new GoogleDriveDownloader.State { Id = "bleg" }, Hash = "DEADBEEF" }; errors = validate.Validate(modlist); Assert.AreEqual(errors.Count(), 1); // Ok due to file downloaded from good google site modlist.GameType = Game.Skyrim; modlist.Archives[0] = new Archive { State = new GoogleDriveDownloader.State { Id = "googleDEADBEEF" }, Hash = "DEADBEEF" }; errors = validate.Validate(modlist); Assert.AreEqual(0, errors.Count()); }
public TestInstaller(AbsolutePath archive, ModList modList, AbsolutePath outputFolder, AbsolutePath downloadFolder, SystemParameters parameters) : base(archive, modList, outputFolder, downloadFolder, parameters, steps: 1, modList.GameType) { Queue.SetActiveThreadsObservable(Observable.Return(1)); }
internal ModListMessage(ModList mods, CSteamID steamId, bool fromServer = false) { Mods = mods; SteamId = steamId; FromServer = fromServer; }