public SpecialCurrencyDisplay() { _moneyDial = new MoneyDial(3); _moneyDial.onPlaySound = null; drawSprite = null; registeredCurrencyDisplays = new Dictionary <string, CurrencyDisplayType>(); }
internal static void Prefix(ref MoneyDial __instance, ref int target) { CapitalismMoneyDial.drawCounter = 0; CapitalismMoneyDial.currentValue = __instance.currentValue; CapitalismMoneyDial.targetValue = Convert.ToDecimal(target); int maxDigits = 8; if (Game1.activeClickableMenu is ShippingMenu) { maxDigits = 6; } int maxValue = (int)Math.Pow(10, maxDigits - 1) - 1; if (target > maxValue) { CapitalismMoneyDial.maxed = true; target /= 1000; } if (target > maxValue) { target = maxValue; } if (target < 10) { target *= 10; } if (target < 100) { target *= 10; } target *= 10; }
static bool Prefix(SpriteBatch b, Vector2 position, int target, MoneyDial __instance, bool ___playSounds) { if (__instance.previousTargetValue != target) { speed = (target - __instance.currentValue) / 100; __instance.previousTargetValue = target; soundTimer = Math.Max(6, 100 / (Math.Abs(speed) + 1)); } if (moneyShineTimer > 0 && __instance.currentValue == target) { moneyShineTimer -= Game1.currentGameTime.ElapsedGameTime.Milliseconds; } if (moneyMadeAccumulator > 0) { moneyMadeAccumulator -= (Math.Abs(speed / 2) + 1) * (__instance.animations.Count <= 0 ? 100 : 1); if (moneyMadeAccumulator <= 0) { moneyShineTimer = __instance.numDigits * 60; } } if (moneyMadeAccumulator > 2000) { Game1.dayTimeMoneyBox.moneyShakeTimer = 100; } if (__instance.currentValue != target) { __instance.currentValue += speed + (__instance.currentValue < target ? 1 : -1); if (__instance.currentValue < target) { moneyMadeAccumulator += Math.Abs(speed); } --soundTimer; if (Math.Abs(target - __instance.currentValue) <= speed + 1 || speed != 0 && Math.Sign(target - __instance.currentValue) != Math.Sign(speed)) { __instance.currentValue = target; } if (soundTimer <= 0) { if (___playSounds && __instance.onPlaySound != null) { __instance.onPlaySound(Math.Sign(target - __instance.currentValue)); } soundTimer = Math.Max(6, 100 / (Math.Abs(speed) + 1)); if (Game1.random.NextDouble() < 0.4) { if (target > __instance.currentValue) { __instance.animations.Add(new TemporaryAnimatedSprite(Game1.random.Next(10, 12), position + new Vector2((float)Game1.random.Next(30, 190), (float)Game1.random.Next(-32, 48)), Color.Gold)); } else if (target < __instance.currentValue) { __instance.animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(356, 449, 1, 1), 999999f, 1, 44, position + new Vector2((float)Game1.random.Next(160), (float)Game1.random.Next(-32, 32)), false, false, 1f, 0.01f, Color.White, (float)(Game1.random.Next(1, 3) * 4), -1f / 1000f, 0.0f, 0.0f) { motion = new Vector2((float)Game1.random.Next(-30, 40) / 10f, (float)Game1.random.Next(-30, -5) / 10f), acceleration = new Vector2(0.0f, 0.25f) }); } } } } for (int index = __instance.animations.Count - 1; index >= 0; --index) { if (__instance.animations[index].update(Game1.currentGameTime)) { __instance.animations.RemoveAt(index); } else { __instance.animations[index].draw(b, true); } } int num1 = 0; int num2 = (int)Math.Pow(10.0, (double)(__instance.numDigits - 1)); bool flag = false; for (int index = 0; index < __instance.numDigits; ++index) { int num3 = __instance.currentValue / num2 % 10; if (num3 > 0 || index == __instance.numDigits - 1) { flag = true; } if (flag) { b.Draw(Game1.mouseCursors, position + new Vector2((float)num1, Game1.activeClickableMenu == null || !(Game1.activeClickableMenu is ShippingMenu) || __instance.currentValue < 1000000 ? 0.0f : (float)Math.Sin(Game1.currentGameTime.TotalGameTime.TotalMilliseconds / 100.530967712402 + (double)index) * (float)(__instance.currentValue / 1000000)), new Rectangle?(new Rectangle(286, 502 - num3 * 8, 5, 8)), Color.White, 0.0f, Vector2.Zero, (float)(4.0 + (moneyShineTimer / 60 == __instance.numDigits - index ? 0.300000011920929 : 0.0)), SpriteEffects.None, 1f); } num1 += 24; num2 /= 10; } return(false); }
public TasksPage(string name, string title, int x, int y, int width, int height, Texture2D tabTexture, Rectangle tabSourceRect, ITranslationHelper translation) : base(name, title, x, y, width, height, tabTexture, tabSourceRect, translation) { if (DeluxeJournalMod.Instance?.Config is not Config config) { throw new InvalidOperationException("TasksPage created before mod entry."); } if (DeluxeJournalMod.Instance?.TaskManager is not TaskManager taskManager) { throw new InvalidOperationException("TasksPage created before instantiation of TaskManager"); } _config = config; _taskManager = taskManager; _dragScrollInterval = 0.16; _dragScrollStartTime = 0; _currentlySnappedEntry = 0; _selectedTaskIndex = -1; _dragging = false; taskEntries = new List <TaskEntryComponent>(); moneyDial = new MoneyDial(8, false); Rectangle bounds = new Rectangle(x + 16, y + 16, width - 32, (height - 32) / maxEntries); for (int i = 0; i < maxEntries; i++) { bounds.Y = y + 20 + i * bounds.Height; taskEntries.Add(new TaskEntryComponent(bounds, i.ToString(), Translation) { myID = i, upNeighborID = CUSTOM_SNAP_BEHAVIOR, downNeighborID = CUSTOM_SNAP_BEHAVIOR, rightNeighborID = CUSTOM_SNAP_BEHAVIOR, leftNeighborID = CUSTOM_SNAP_BEHAVIOR, fullyImmutable = true }); } addTaskButton = new ClickableTextureComponent( new Rectangle(x + width - 336, y + height, 60, 60), DeluxeJournalMod.UiTexture, new Rectangle(0, 32, 15, 17), 4f) { myID = 1000, upNeighborID = CUSTOM_SNAP_BEHAVIOR, leftNeighborID = CUSTOM_SNAP_BEHAVIOR, rightNeighborID = 1001, rightNeighborImmutable = true }; moneyButton = new ClickableTextureComponent( new Rectangle(x + width - 260, y + height + 20, 24, 36), DeluxeJournalMod.UiTexture, new Rectangle(85, 37, 6, 9), 4f) { myID = 1001, upNeighborID = CUSTOM_SNAP_BEHAVIOR, rightNeighborID = 1002, leftNeighborID = 1000, fullyImmutable = true }; moneyBox = new ClickableComponent(new Rectangle(x + width - 236, y + height, 236, 68), "moneyBox") { myID = 1002, upNeighborID = CUSTOM_SNAP_BEHAVIOR, leftNeighborID = 1001, fullyImmutable = true }; Rectangle scrollBarBounds = new Rectangle(x + width + 16, y + 148, 24, height - 216); Rectangle scrollContentBounds = new Rectangle(x, y + 16, width, height - 32); scrollComponent = new ScrollComponent(scrollBarBounds, scrollContentBounds, (height - 32) / 8, true); scrollComponent.ContentHeight = _taskManager.Tasks.Count * scrollComponent.ScrollDistance; _boundsWithScrollBar = new Rectangle(x, y, scrollBarBounds.Right - x + 16, height); RefreshMoneyDial(); }
internal static void Postfix(ref MoneyDial __instance, ref int target) { CapitalismMoneyDial.maxed = false; CapitalismMoneyDial.drawCounter = -1; }
private static void DrawMoneyDial(MoneyDial moneyDial, SpriteBatch b, Vector2 position, long target) { int numDigits = currentValue.ToString().Length; if (previousTargetValue != target) { speed = (int)(target - currentValue) / 100; previousTargetValue = target; soundTimer = Math.Max(6, 100 / (Math.Abs(speed) + 1)); } if (AccessTools.FieldRefAccess <MoneyDial, int>(moneyDial, "moneyShineTimer") > 0 && currentValue == target) { AccessTools.FieldRefAccess <MoneyDial, int>(moneyDial, "moneyShineTimer") -= Game1.currentGameTime.ElapsedGameTime.Milliseconds; } if (AccessTools.FieldRefAccess <MoneyDial, int>(moneyDial, "moneyMadeAccumulator") > 0) { AccessTools.FieldRefAccess <MoneyDial, int>(moneyDial, "moneyMadeAccumulator") -= (int)(Math.Abs(speed / 2) + 1) * ((moneyDial.animations.Count <= 0) ? 100 : 1); if (AccessTools.FieldRefAccess <MoneyDial, int>(moneyDial, "moneyMadeAccumulator") <= 0) { AccessTools.FieldRefAccess <MoneyDial, int>(moneyDial, "moneyShineTimer") = numDigits * 60; } } if (AccessTools.FieldRefAccess <MoneyDial, int>(moneyDial, "moneyMadeAccumulator") > 2000) { Game1.dayTimeMoneyBox.moneyShakeTimer = 100; } if (currentValue != target) { currentValue += speed + ((currentValue < target) ? 1 : -1); if (currentValue < target) { AccessTools.FieldRefAccess <MoneyDial, int>(moneyDial, "moneyMadeAccumulator") += (int)Math.Abs(speed); } soundTimer--; if (Math.Abs(target - currentValue) <= speed + 1 || (speed != 0 && Math.Sign(target - currentValue) != Math.Sign(speed))) { currentValue = target; } if (soundTimer <= 0) { if (moneyDial.onPlaySound != null) { moneyDial.onPlaySound(Math.Sign(target - currentValue)); } soundTimer = Math.Max(6, 100 / (Math.Abs(speed) + 1)); if (Game1.random.NextDouble() < 0.4) { if (target > currentValue) { moneyDial.animations.Add(new TemporaryAnimatedSprite(Game1.random.Next(10, 12), position + new Vector2((float)Game1.random.Next(30, 190), (float)Game1.random.Next(-32, 48)), Color.Gold, 8, false, 100f, 0, -1, -1f, -1, 0)); } else if (target < currentValue) { moneyDial.animations.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(356, 449, 1, 1), 999999f, 1, 44, position + new Vector2((float)Game1.random.Next(160), (float)Game1.random.Next(-32, 32)), false, false, 1f, 0.01f, Color.White, (float)(Game1.random.Next(1, 3) * 4), -0.001f, 0f, 0f, false) { motion = new Vector2((float)Game1.random.Next(-30, 40) / 10f, (float)Game1.random.Next(-30, -5) / 10f), acceleration = new Vector2(0f, 0.25f) }); } } } } for (int i = moneyDial.animations.Count - 1; i >= 0; i--) { if (moneyDial.animations[i].update(Game1.currentGameTime)) { moneyDial.animations.RemoveAt(i); } else { moneyDial.animations[i].draw(b, true, 0, 0, 1f); } } int xPosition = 0; if (numDigits > 8) { xPosition -= (numDigits - 8) * 24; } else { xPosition += (8 - numDigits) * 24; } bool significant = false; numDigits = currentValue.ToString().Length; for (int j = 0; j < numDigits; j++) { int currentDigit = int.Parse(currentValue.ToString()[j].ToString()); if (currentDigit > 0 || j == numDigits - 1) { significant = true; } if (significant) { b.Draw(Game1.mouseCursors, position + new Vector2(xPosition, 0f), new Rectangle?(new Rectangle(286, 502 - (currentDigit) * 8, 5, 8)), Color.Maroon, 0f, Vector2.Zero, 4f + ((AccessTools.FieldRefAccess <MoneyDial, int>(moneyDial, "moneyShineTimer") / 60 == numDigits - j) ? 0.3f : 0f), SpriteEffects.None, 1f); } xPosition += 24; } }