public bool MarkInstalled(ModMetadata meta, ModVersion version, ModDownloadResult downloadDetails) { ModStatus status = GetModStatus(meta); switch (status) { case ModStatus.Installed: ModVersions.Delete(m => m.MetadataId == meta.Id); ModVersions.Insert(version); return(true); case ModStatus.NotInstalled: Mods.Insert(meta); ModVersions.Insert(version); return(true); // Already added as requested, need to modify it case ModStatus.Requested: ModVersion requested = ModVersions.FindOne(v => v.GetModVersion() == version.GetModVersion()); requested.Filename = downloadDetails.Filename; requested.Checksum = downloadDetails.Checksum; return(ModVersions.Update(requested)); } return(false); }
public MouseEventArgs(MouseButton button, int x, int y, ModStatus status) { this.Button = button; this.X = x; this.Y = y; this.Status = status; }
public UpgradeData(ModType type, ModStatus status = ModStatus.normal) { m_current_status = status; m_currentType = type; SetInitialState(); TypeSetup(); }
/// <summary> /// Searches through all folders in the provided directory and returns an ordered list of mods to load.<para/> /// Mods that cannot be loaded will have an unsuccessful <see cref="QMod.Status"/> value. /// </summary> /// <param name="qmodsDirectory">The QMods directory</param> /// <returns>A new, sorted <see cref="List{QMod}"/> ready to be initialized or skipped.</returns> public List <QMod> BuildModLoadingList(string qmodsDirectory) { if (!Directory.Exists(qmodsDirectory)) { Logger.Info("QMods directory was not found! Creating..."); Directory.CreateDirectory(qmodsDirectory); return(new List <QMod>(0)); } string[] subDirectories = Directory.GetDirectories(qmodsDirectory); var modSorter = new SortedCollection <string, QMod>(); var earlyErrors = new List <QMod>(subDirectories.Length); foreach (string subDir in subDirectories) { string[] dllFiles = Directory.GetFiles(subDir, "*.dll", SearchOption.TopDirectoryOnly); if (dllFiles.Length < 1) { continue; } string jsonFile = Path.Combine(subDir, "mod.json"); string folderName = new DirectoryInfo(subDir).Name; if (!File.Exists(jsonFile)) { Logger.Error($"Unable to set up mod in folder \"{folderName}\""); earlyErrors.Add(new QModPlaceholder(folderName, ModStatus.InvalidCoreInfo)); continue; } QMod mod = CreateFromJsonManifestFile(subDir); ModStatus status = Validator.ValidateManifest(mod, subDir); if (status != ModStatus.Success) { Logger.Debug($"Mod '{mod.Id}' will not be loaded"); earlyErrors.Add(mod); continue; } Logger.Debug($"Sorting mod {mod.Id}"); bool added = modSorter.AddSorted(mod); if (!added) { Logger.Debug($"DuplicateId on mod {mod.Id}"); mod.Status = ModStatus.DuplicateIdDetected; earlyErrors.Add(mod); } } List <QMod> modsToLoad = modSorter.GetSortedList(); return(CreateModStatusList(earlyErrors, modsToLoad)); }
private void Unexpand(ModStatus modStatus) { if (ExpandedModStatus == modStatus) { ExpandedModStatus = null; } modStatus.IsExpanded = false; }
public BeatModsQuery(string forGameVersion) { search = null; status = ModStatus.Approved; this.forGameVersion = forGameVersion; sort = BeatModsSort.None; sortDescending = false; }
internal QModPlaceholder(string name, ModStatus status) { this.Id = Patcher.IDRegex.Replace(name, ""); this.DisplayName = name; this.Author = "Unknown"; this.SupportedGame = QModGame.None; this.Enable = false; this.Status = ModStatus.UnidentifiedMod; }
// Configuracion base de cada parametro void SetInitialState() { m_current_status = ModStatus.normal; m_modStrenghtValue = 0; m_modVariationValue = 0f; m_modTrajectoryValue = Trajectory.none; m_penalty_frateMultiplier = 1; m_penalty_effectivenessMultiplier = 1; }
public static string GetStatusName(this ModStatus status) { if (status == ModStatus.All) { return(string.Empty); } return(status.ToString().ToLower()); }
private static void LogStatus(List <QMod> mods, ModStatus statusToReport, string summary, Logger.Level logLevel) { List <QMod> specificMods = mods.FindAll(mod => mod.Status == statusToReport); if (specificMods.Count == 0) { return; } Logger.Log(logLevel, summary); foreach (QMod mod in specificMods) { switch (statusToReport) { case ModStatus.MissingDependency: { if (mod.Dependencies.Length > 0) { Console.WriteLine($"- {mod.DisplayName} ({mod.Id}) is missing these dependencies:"); foreach (string dependency in mod.Dependencies) { if (!QModServices.Main.ModPresent(dependency)) { Console.WriteLine($" - {dependency}"); } } } else { Console.WriteLine($"- {mod.DisplayName} ({mod.Id}) is missing a dependency but none are listed in mod.json, Please check Nexusmods for list of Dependencies."); } break; } case ModStatus.OutOfDateDependency: Console.WriteLine($"- {mod.DisplayName} ({mod.Id}) requires a newer version of these dependencies:"); foreach (RequiredQMod dependency in mod.RequiredMods) { if (dependency.RequiresMinimumVersion) { IQMod dependencyDetails = QModServices.Main.FindModById(dependency.Id); if (dependencyDetails == null || dependencyDetails.ParsedVersion < dependency.MinimumVersion) { Console.WriteLine($" - {dependency.Id} at version {dependency.MinimumVersion} or later"); } } } break; default: Console.WriteLine($"- {mod.DisplayName} ({mod.Id})"); break; } } }
private void ToggleExpand(ModStatus modStatus) { if (modStatus.IsExpanded) { Unexpand(modStatus); } else { Expand(modStatus); } }
private void ComponentClicked(ModStatus which, int offset) { if (which == null) { if (this.currentSortColumn == -1) { this.currentSortColumn = offset; this.currentSortDirection = 0; } else if (this.currentSortColumn == offset) { switch (this.currentSortDirection) { case 0: this.currentSortDirection = 1; break; case 1: this.currentSortColumn = -1; this.currentSortDirection = 0; break; } } else { this.currentSortColumn = offset; this.currentSortDirection = 0; } this.displayIndex = 0; this.UpdateComponents(); if (this.currentSortColumn != -1) { this.ComponentHovered(null, this.currentSortColumn); } } else if (offset == 2) { Game1.playSound("bigSelect"); if (which.UpdateURLType != "???") { try { Process.Start(which.UpdateURL); } catch { } } } }
internal QModPlaceholder(string name, ModStatus status) { Regex regex = new Regex(Patcher.IDRegex); string cleanName = regex.Replace(name, ""); this.Id = cleanName; this.DisplayName = name; this.Author = "Unknown"; this.SupportedGame = QModGame.None; this.Enable = false; this.Status = status; }
public static void SetStatus(Guid modID, ModStatus status) { ModStatus olds; _statuses.TryGetValue(modID, out olds); _statuses[modID] = status; ModStatusEventArgs e = new ModStatusEventArgs() { ModID = modID, Status = status, OldStatus = olds }; StatusChanged(null, e); }
private void Expand(ModStatus modStatus) { if (ExpandedModStatus == modStatus) { return; } if (ExpandedModStatus != null) { Unexpand(modStatus); } ExpandedModStatus = modStatus; ExpandedModStatus.IsExpanded = true; }
/********* ** Protected methods *********/ /// <summary>Read the JSON representation of the object.</summary> /// <param name="reader">The JSON reader.</param> /// <param name="objectType">The object type.</param> /// <param name="existingValue">The object being read.</param> /// <param name="serializer">The calling serializer.</param> public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { List <ModCompatibility> result = new List <ModCompatibility>(); foreach (JProperty property in JObject.Load(reader).Properties()) { string range = property.Name; ModStatus status = (ModStatus)Enum.Parse(typeof(ModStatus), property.Value.Value <string>(nameof(ModCompatibility.Status))); string reasonPhrase = property.Value.Value <string>(nameof(ModCompatibility.ReasonPhrase)); result.Add(new ModCompatibility(range, status, reasonPhrase)); } return(result.ToArray()); }
private static void ComponentClicked(ModStatus which, int offset) { if (offset == 2) { Game1.playSound("bigSelect"); try { Process.Start(which.UpdateURL); } catch { } } }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="versionRange">A version range, which consists of two version strings separated by a '~' character. Either side can be left blank for an unbounded range.</param> /// <param name="status">The mod compatibility.</param> /// <param name="reasonPhrase">The reason phrase to show in log output, or <c>null</c> to use the default value.</param> public ModCompatibility(string versionRange, ModStatus status, string reasonPhrase) { // extract version strings string[] versions = versionRange.Split('~'); if (versions.Length != 2) { throw new FormatException($"Could not parse '{versionRange}' as a version range. It must have two version strings separated by a '~' character (either side can be left blank for an unbounded range)."); } // initialise this.LowerVersion = !string.IsNullOrWhiteSpace(versions[0]) ? new SemanticVersion(versions[0]) : null; this.UpperVersion = !string.IsNullOrWhiteSpace(versions[1]) ? new SemanticVersion(versions[1]) : null; this.Status = status; this.ReasonPhrase = reasonPhrase; }
private static void LogStatus(List <QMod> mods, ModStatus statusToReport, string summary, Logger.Level logLevel) { List <QMod> specificMods = mods.FindAll(mod => mod.Status == statusToReport); if (specificMods.Count == 0) { return; } Logger.Log(logLevel, summary); foreach (QMod mod in specificMods) { Console.WriteLine($"- {mod.DisplayName} ({mod.Id})"); } }
public virtual bool Start() { if (m_status != ModStatus.RUNNING) { try { m_thread.Start(); } catch (Exception ex) { m_status = ModStatus.STOPPED; m_errorSrc = ex; m_parent.WriteLog(LogLevel.ERROR, String.Format("{0} {1}: {2}", m_name, m_status, m_errorSrc.ToString())); return(false); } m_status = ModStatus.RUNNING; } return(true); }
public virtual bool Stop() { if (m_status != ModStatus.STOPPED) { m_done = true; try { shutdown(); } catch (Exception ex) { m_errorSrc = ex; m_parent.WriteLog(LogLevel.ERROR, String.Format("{0} {1}: {2}", m_name, m_status, m_errorSrc.ToString())); return(false); } m_status = ModStatus.STOPPED; } return(true); }
/// <summary> /// 更改模型状态 /// </summary> /// <param name="ms"></param> public void ChangeModStatus(ModStatus ms) { switch (ms) { case ModStatus.WaitingForGenerate: mydb.ExcuteSQL("UPDATE dbo.DSTreeModel SET ModStatus = '等待生成' WHERE ModGUID = '" + ModGUID + "'"); break; case ModStatus.Generating: mydb.ExcuteSQL("UPDATE dbo.DSTreeModel SET ModStatus = '正在生成' WHERE ModGUID = '" + ModGUID + "'"); mydb.ExcuteSQL("DELETE FROM dbo.DSTreeFactors WHERE ModGUID = '" + ModGUID + "'"); mydb.ExcuteSQL("DELETE FROM DSTree WHERE ModGUID = '" + ModGUID + "'"); break; case ModStatus.Generated: mydb.ExcuteSQL("UPDATE dbo.DSTreeModel SET ModStatus = '生成成功',ModGenerateTime=GETDATE() WHERE ModGUID = '" + ModGUID + "'"); break; } }
private ModStatus AddModStatus(string modID) { return(DispatcherHelper.UIDispatcher.InvokeSafe(() => { // Create stub status var modStatus = new ModStatus(modID); // Add mod status Mods.Insert(0, modStatus); // Populate mod info from API in background PopulateModInfoAsync(modID).Forget(); // Populate installed mod entry in background PopulateInstalledModEntryAsync(modID).Forget(); return modStatus; })); }
public ModuleBase() { //set module id Logging.logger.Info("this is ModuleBase"); ModDepends = new List <string>(); ModClassName = this.GetType().ToString(); MosStatus = ModStatus.Blank; SubRM = new Dictionary <string, SubscriberRun>(); PubRM = new PublishRun(); FunInRM = new Dictionary <string, FansInRun>(); SubPubRM = new Dictionary <string, SubPubRun>(); FunInPubRM = new Dictionary <string, FansInPubRun>(); RequestRM = new Dictionary <string, RequestRun>(); ResponseRM = new ResponseRun(); FanInClintRM = new Dictionary <string, FaninClientRun>(); FanoutClientRM = new Dictionary <string, FanoutClientRun>(); FanoutRM = new Dictionary <string, FanoutRun>(); UserTaskRM = new Dictionary <string, UserTaskRun>(); ModDelay = 10; }
private void ComponentHovered(ModStatus which, int offset) { switch (offset) { case 0: this.hoverText = $"{which.ModName}^By: {which.ModAuthor}"; break; case 1: switch (which.UpdateStatus) { case UpdateStatus.UpToDate: this.hoverText = $"You have: {which.CurrentVersion}."; break; case UpdateStatus.OutOfDate: this.hoverText = $"You have: {which.CurrentVersion}^Latest version: {which.NewVersion}"; break; case UpdateStatus.Error: this.hoverText = $"Failed to check updates: ^{which.ErrorReason}"; break; case UpdateStatus.Skipped: this.hoverText = $"Mod not loaded: ^{which.ErrorReason}"; break; } break; case 2: this.hoverText = $"Click to go to: ^{which.UpdateURL}"; break; } this.hoverTextDimensions = UpdateMenu.GetDimensions(this.hoverText); }
public MEETModule(string theName, MEETContainer theContainer) { m_name = theName; if (!theContainer.AddModule(this)) { // leave m_parent as null return; } m_parent = theContainer; m_status = ModStatus.NEW; try { m_thread = new Thread(new ThreadStart(run)); m_thread.Name = m_name; } catch (Exception ex) { m_status = ModStatus.STOPPED; m_errorSrc = ex; m_parent.WriteLog(LogLevel.ERROR, String.Format("{0} {1}: {2}", m_name, m_status, m_errorSrc.ToString())); return; } }
public static void DownloadAndInstall(Mod m, bool isUpdatingMod = false) { // validate mod is not already downloading/updating ModStatus status = Sys.GetStatus(m.ID); if (status == ModStatus.Downloading) { Sys.Message(new WMessage($"{m.Name} is already downloading!", true)); return; } if (status == ModStatus.Updating) { Sys.Message(new WMessage($"{m.Name} is already updating!", true)); return; } if (status == ModStatus.Installed && !isUpdatingMod) { Sys.Message(new WMessage($"{m.Name} is already downloaded and installed!", true)); return; } Action onCancel = () => Sys.RevertStatus(m.ID); Action <Exception> onError = ex => { Sys.Message(new WMessage($"Error occurred downloading/installing {m.Name} - {ex.Message}", WMessageLogLevel.Error, ex)); Sys.RevertStatus(m.ID); }; string file = String.Format("{0}_{1}_{2}.iro", m.ID, SafeStr(m.Name), m.LatestVersion.Version); string temppath = System.IO.Path.Combine(Sys.Settings.LibraryLocation, "temp"); System.IO.Directory.CreateDirectory(temppath); var install = Sys.Library.GetItem(m.ID); if (install != null) { // mod is installed so download update files for updating mod Sys.SetStatus(m.ID, ModStatus.Updating); List <ModPatch> patches = m.GetPatchesFromTo(install.LatestInstalled.VersionDetails.Version, m.LatestVersion.Version); if (patches.Any()) { // download patches to update the mod string pfile = String.Format("{0}_{1}_{2}.irop", m.ID, SafeStr(m.Name), m.LatestVersion.Version); DownloadItem download = new DownloadItem() { Links = patches.Select(p => p.Link).ToList(), SaveFilePath = System.IO.Path.Combine(temppath, pfile), Category = DownloadCategory.Mod, ItemName = "Downloading " + m.Name, OnCancel = onCancel }; download.IProc = new PatchModProcedure() { File = pfile, Install = install, Mod = m, Error = onError }; Sys.Downloads.AddToDownloadQueue(download); return; } else { // no patches available to update so download entire new mod version .iro DownloadItem installDownload = new DownloadItem() { Links = m.LatestVersion.Links, SaveFilePath = System.IO.Path.Combine(temppath, file), Category = DownloadCategory.Mod, ItemName = "Downloading " + m.Name, OnCancel = onCancel }; installDownload.IProc = new InstallModProcedure() { File = file, Mod = m, ExtractSubFolder = m.LatestVersion.ExtractSubFolder, ExtractInto = m.LatestVersion.ExtractInto, Error = onError }; Sys.Downloads.AddToDownloadQueue(installDownload); return; } } Sys.SetStatus(m.ID, ModStatus.Downloading); if (m.LatestVersion.PatchLinks.Any()) { // mod is not installed and the latest version has patches available // so first download and install mod then download all patches for mod PatchController pc = new PatchController(m.LatestVersion.PatchLinks.Count); DownloadItem download = new DownloadItem() { Links = m.LatestVersion.Links, SaveFilePath = System.IO.Path.Combine(temppath, file), ItemName = "Downloading " + m.Name, Category = DownloadCategory.Mod, OnCancel = onCancel }; download.IProc = new DownloadThenPatchProcedure() { File = file, Mod = m, Controller = pc, Error = onError }; Sys.Downloads.AddToDownloadQueue(download); int pCount = 0; foreach (string p in m.LatestVersion.PatchLinks) { string pfile = String.Format("{0}_{1}_{2}_patch{3}.iro", m.ID, SafeStr(m.Name), m.LatestVersion.Version, pCount); pc.PatchFiles.Add(pfile); DownloadItem patchDownload = new DownloadItem() { Links = new List <string>() { p }, SaveFilePath = System.IO.Path.Combine(temppath, pfile), ItemName = "Downloading " + m.Name + " patch " + pCount, Category = DownloadCategory.Mod, OnCancel = () => { pc.PatchFailed(); Sys.RevertStatus(m.ID); } }; patchDownload.IProc = new DownloadPatchProcedure() { File = pfile, Controller = pc, Error = ex => { pc.PatchFailed(); Sys.RevertStatus(m.ID); } }; Sys.Downloads.AddToDownloadQueue(patchDownload); pCount++; } } else { // mod is not installed in library so just download using the links of latest version DownloadItem installDownload = new DownloadItem() { Links = m.LatestVersion.Links, SaveFilePath = System.IO.Path.Combine(temppath, file), Category = DownloadCategory.Mod, ItemName = "Downloading " + m.Name, OnCancel = onCancel }; installDownload.IProc = new InstallModProcedure() { File = file, Mod = m, ExtractSubFolder = m.LatestVersion.ExtractSubFolder, ExtractInto = m.LatestVersion.ExtractInto, Error = onError }; Sys.Downloads.AddToDownloadQueue(installDownload); } }
public static IEnumerable <Mod> OnlyKeepStatus(this IEnumerable <Mod> mods, ModStatus status) { return(mods.Where((e) => (status & e.Status) == e.Status)); }
public static void HandleModRemove(IDomain domain, string modIdentifier) { IDomainHandler handler = domain.GetDomainHandler(); ModStorage storage = new ModStorage(Modifi.DefaultPack.Installed, domain); ModMetadata meta = storage.GetMetadata(modIdentifier); if (meta == null) { Modifi.DefaultLogger.Error("Cannot uninstall {0}; it is not installed.", modIdentifier); return; } ModVersion installed = storage.GetMod(meta); ModStatus status = storage.GetModStatus(meta); switch (status) { case ModStatus.NotInstalled: Modifi.DefaultLogger.Error("Cannot uninstall {0}; it is not installed.", meta.GetName()); return; case ModStatus.Requested: Modifi.DefaultLogger.Information("Removing {0}...", meta.GetName()); storage.Delete(meta); Modifi.DefaultLogger.Information("Done."); return; case ModStatus.Installed: Modifi.DefaultLogger.Information("Removing {0} and deleting files...", meta.GetName()); storage.Delete(meta); string filePath = Path.Combine(Settings.ModPath, installed.Filename); bool correctChecksum = ModUtilities.ChecksumMatches(filePath, installed.Checksum); if (correctChecksum) { try { File.Delete(filePath); } catch (Exception e) { Modifi.DefaultLogger.Error("Error deleting {0}, please delete it manually.", filePath); Modifi.DefaultLogger.Error(e.Message); } } else { Modifi.DefaultLogger.Information("File for {0} found at {1}, but the checksum did not match. Delete?", meta.GetName(), filePath); Menu <string> delete = new Menu <string>(); delete.AddItem("Delete"); delete.AddItem("Leave"); delete.DrawMenu(); switch (delete.SelectedOption.ToLower()) { case "delete": File.Delete(filePath); Modifi.DefaultLogger.Information("File deleted."); break; case "leave": Modifi.DefaultLogger.Information("File left in place."); break; } } break; } storage.Dispose(); }
public static void HandleModAdd(IDomain domain, string modIdentifier, string modVersion = null) { IDomainHandler handler = domain.GetDomainHandler(); ModMetadata meta = handler.GetModMetadata(Modifi.DefaultPack.MinecraftVersion, modIdentifier).Result; // Check mod installation status, error out if already requested/installed using (IModStorage storage = new ModStorage(Modifi.DefaultPack.Installed, domain)) { try { ModStatus status = storage.GetModStatus(meta); switch (status) { case ModStatus.Requested: case ModStatus.Installed: Modifi.DefaultLogger.Error("Mod {0} is already marked as requested, or already installed.", meta.GetName()); return; case ModStatus.Disabled: Modifi.DefaultLogger.Information("Mod {0} is marked at disabled. Please either delete it, or re-enable it."); return; } } catch (Exception e) { Modifi.DefaultLogger.Error(e.Message); return; } } // If the version is already specified, don't ask, just add it if (!String.IsNullOrEmpty(modVersion)) { ModVersion v = handler.GetModVersion(meta, modVersion).Result; // Connect to storage and mark the mod as requested using (ModStorage storage = new ModStorage(Modifi.DefaultPack.MinecraftVersion, domain)) { storage.MarkRequested(meta, v); return; } } // ============================================================ // TODO: ModHelper.PrintModInformation(meta); Menu <ModVersion> menu = new Menu <ModVersion>(); menu.OptionFormatter = (opt) => { Console.ForegroundColor = ConsoleColor.Green; Console.Write(opt.GetVersionName()); Console.ForegroundColor = ConsoleColor.DarkMagenta; Console.Write(" ["); Console.ForegroundColor = ConsoleColor.White; Console.Write(opt.GetModVersion()); Console.ForegroundColor = ConsoleColor.DarkMagenta; Console.Write("]"); Console.ForegroundColor = ConsoleColor.Gray; Console.Write(" [{0}]", opt.GetReleaseType()); Console.WriteLine(); }; ModVersion latestRelease = handler.GetRecentVersions(meta, 1, ModReleaseType.Release).Result.First(); ModVersion latestVersion = handler.GetRecentVersions(meta, 1, ModReleaseType.Any).Result.First(); IEnumerable <ModVersion> versions = handler.GetRecentVersions(meta, 6, ModReleaseType.Any).Result.Skip(1); menu.AddItem(latestRelease); if (latestVersion.GetModVersion() != latestRelease.GetModVersion()) { menu.AddItem(latestVersion); } menu.AddSpacer(); foreach (ModVersion v in versions.Take(5)) { menu.AddItem(v); } menu.DrawMenu(); Console.ResetColor(); Console.WriteLine(); ModVersion version = menu.SelectedOption; Console.WriteLine("Selected Version: " + version.GetModVersion()); // Create a storage handler for the domain and mark the version as requested using (ModStorage storage = new ModStorage(Modifi.DefaultPack.Installed, domain)) { storage.MarkRequested(meta, version); } }