Skip to content

Commit

Permalink
Add offset{X,Y} config properties for overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
jltaylor-us committed Jun 23, 2021
1 parent 536f427 commit 40484ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 9 additions & 7 deletions ToDew/ToDoOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<OverlayConfig> 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);
Expand Down Expand Up @@ -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<ToDoList.ListItem> e) {
syncMenuItemList();
Expand All @@ -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];
}
Expand Down

0 comments on commit 40484ab

Please sign in to comment.