From 40484ab3714eb5b8d5d6f7e3f32406cf5e543fb3 Mon Sep 17 00:00:00 2001 From: Jamie Taylor Date: Wed, 23 Jun 2021 19:32:46 -0400 Subject: [PATCH] Add offset{X,Y} config properties for overlay --- ReleaseNotes.md | 2 ++ ToDew/ToDoOverlay.cs | 16 +++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 9abc9e6..7bcfdca 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -5,6 +5,8 @@ * Add import and export console commands +* Add `offsetX` and `offsetY` config properties for the overlay. + ## Version 1.8.4 * Make weeks start on Monday (not Sunday) to match the game calendar. diff --git a/ToDew/ToDoOverlay.cs b/ToDew/ToDoOverlay.cs index 350dbe8..0d096aa 100644 --- a/ToDew/ToDoOverlay.cs +++ b/ToDew/ToDoOverlay.cs @@ -19,6 +19,8 @@ public class OverlayConfig { public int maxItems = 10; public Color backgroundColor = Color.Black * 0.2f; public Color textColor = Color.White * 0.8f; + public int offsetX = 0; + public int offsetY = 0; public static void RegisterConfigMenuOptions(Func getThis, GenericModConfigMenuAPI api, IManifest modManifest) { api.RegisterLabel(modManifest, I18n.Config_Overlay(), I18n.Config_Overlay_Desc()); api.RegisterSimpleOption(modManifest, I18n.Config_Overlay_Enabled(), I18n.Config_Overlay_Enabled_Desc(), () => getThis().enabled, (bool val) => getThis().enabled = val); @@ -92,7 +94,7 @@ private void syncMenuItemList() { lineBold.Add(item.IsBold); topPx += lineSize.Y; } - bounds = new Rectangle(0, 0, (int)(usedWidth + marginLeft + marginRight), (int)topPx + marginBottom); + bounds = new Rectangle(config.offsetX, config.offsetY, (int)(usedWidth + marginLeft + marginRight), (int)topPx + marginBottom); } private void OnListChanged(object sender, List e) { syncMenuItemList(); @@ -110,22 +112,22 @@ private void OnRenderedWorld(object sender, RenderedWorldEventArgs e) { if (Game1.eventUp || Game1.farmEvent != null) return; if (config.hideAtFestivals && Game1.isFestival()) return; var spriteBatch = e.SpriteBatch; - float topPx = marginTop; Rectangle effectiveBounds = bounds; if (Game1.CurrentMineLevel > 0 || Game1.currentLocation is VolcanoDungeon vd && vd.level > 0) { - topPx += 80; effectiveBounds.Y += 80; } + float topPx = effectiveBounds.Y + marginTop; + float leftPx = effectiveBounds.X + marginLeft; spriteBatch.Draw(Game1.fadeToBlackRect, effectiveBounds, config.backgroundColor); - Utility.drawBoldText(spriteBatch, ListHeader, font, new Vector2(marginLeft, topPx), config.textColor); + Utility.drawBoldText(spriteBatch, ListHeader, font, new Vector2(leftPx, topPx), config.textColor); topPx += ListHeaderSize.Y; - spriteBatch.DrawLine(marginLeft, topPx, new Vector2(ListHeaderSize.X - 3, 1), config.textColor); + spriteBatch.DrawLine(leftPx, topPx, new Vector2(ListHeaderSize.X - 3, 1), config.textColor); for (int i = 0; i < lines.Count; i++) { topPx += lineSpacing; if (lineBold[i]) { - Utility.drawBoldText(spriteBatch, lines[i], font, new Vector2(marginLeft, topPx), config.textColor); + Utility.drawBoldText(spriteBatch, lines[i], font, new Vector2(leftPx, topPx), config.textColor); } else { - spriteBatch.DrawString(font, lines[i], new Vector2(marginLeft, topPx), config.textColor); + spriteBatch.DrawString(font, lines[i], new Vector2(leftPx, topPx), config.textColor); } topPx += lineHeights[i]; }