// Add sort order so rules that move files go first // to prevent overlapping file names disappearing from // the screenshot directory /// <summary> /// Says if this rule comes before or after another rule /// </summary> /// <param name="obj">ModRule to compare</param> /// <returns>A value that indicates the relative order of the objects being compared.</returns> public int CompareTo(object obj) { if (obj == null) { return(1); } ModRule otherRule = obj as ModRule; if (otherRule != null) { if (ModConfig.DEFAULT_STRING != Directory) { if (ModConfig.DEFAULT_STRING != otherRule.Directory) { return(0); } return(-1); } if (ModConfig.DEFAULT_STRING != otherRule.Directory) { return(1); } return(0); } else { throw new ArgumentException("Object is not a ModRule"); } }
/// <summary> /// Rule said it was time to take a screenshot, /// HUD message has been added and we waited for /// our timeout in ticks, so take a screenshot /// </summary> /// <param name="rule">Rule to follow for this screenshot</param> private void TakeScreenshot(ModRule rule) { string ssPath = rule.GetFileName(); Game1.flashAlpha = 1f; if (null != ssPath) { MTrace($"ssPath = \"{ssPath}\""); string ssDirectory = Path.GetDirectoryName(ssPath); Directory.CreateDirectory(Path.Combine(DefaultSSdirectory.FullName, ssDirectory)); } string mapScreenshotPath = Game1.game1.takeMapScreenshot(rule.ZoomLevel, ssPath, () => { //Nothing here. Just added Action as empty lambda to provide all now required parameters. } ); FileInfo mapScreenshot = new FileInfo(Path.Combine(DefaultSSdirectory.FullName, mapScreenshotPath)); MTrace($"Snapshot saved to {mapScreenshot.FullName}"); Game1.playSound("cameraNoise"); if (ModConfig.DEFAULT_STRING != rule.Directory) { EnqueueAction(() => { MoveScreenshotToCorrectFolder(mapScreenshot, new FileInfo(Path.Combine(rule.Directory, mapScreenshotPath))); CleanUpEmptyDirectories(mapScreenshot.Directory); }, ref m_mvActions ); } }
/// <summary> /// Returns true if these two rules can have overlapping filenames /// </summary> /// <param name="other">Rule to compare agains</param> /// <returns>True if the filenames can overlap</returns> internal bool FileNamesCanOverlap(ModRule other) { if (FileNameFlags.None != (this.FileName & FileNameFlags.UniqueID)) { return(false); } if (FileNameFlags.None != (other.FileName & FileNameFlags.UniqueID)) { return(false); } if (this.FileName != other.FileName) { return(false); } if (Path.GetFullPath(this.Directory) != Path.GetFullPath(other.Directory)) { return(false); } if (FileNameFlags.None != (FileNameFlags.Weather & FileName)) { if (ModTrigger.WeatherFlags.Weather_None == ( this.Trigger.Weather & other.Trigger.Weather)) { return(false); } } if (FileNameFlags.None != (FileNameFlags.Location & FileName)) { if (ModTrigger.LocationFlags.Location_None == ( this.Trigger.Location & other.Trigger.Location)) { return(false); } } if (FileNameFlags.None != (FileNameFlags.Time & FileName)) { if (!this.Trigger.CheckTime(other.Trigger.StartTime) && !this.Trigger.CheckTime(other.Trigger.EndTime) && !other.Trigger.CheckTime(this.Trigger.StartTime) && !other.Trigger.CheckTime(this.Trigger.EndTime)) { return(false); } } if (FileNameFlags.None != (FileNameFlags.Date & FileName)) { if (ModTrigger.DateFlags.Day_None == (ModTrigger.DateFlags.AnyDay & (this.Trigger.Days & other.Trigger.Days))) { return(false); } if (ModTrigger.DateFlags.Day_None == (ModTrigger.DateFlags.AnySeason & (this.Trigger.Days & other.Trigger.Days))) { return(false); } } return(true); }
/// <summary> /// Display the HUD message /// </summary> /// <param name="rule">Rule to use for HUD message</param> // Adding space based on user feedback private void DisplayRuleHUD(ModRule rule) { if (m_config.screenshotNotifications) { Game1.addHUDMessage( new HUDMessage(" " + rule.Name, HUDMessage.screenshot_type) ); } }
/// <summary> /// Display the HUD message /// </summary> /// <param name="rule">Rule to use for HUD message</param> // Adding space based on user feedback private void DisplayRuleHUD(ModRule rule) => Game1.addHUDMessage(new HUDMessage(" " + rule.Name, HUDMessage.screenshot_type));