public TaskEntryMenu(TaskEntryComponent entry, ITask task, ITranslationHelper translation) : base() { xPositionOnScreen = entry.bounds.X; yPositionOnScreen = entry.bounds.Y; width = entry.bounds.Width; height = entry.bounds.Height; _translation = translation; _entry = entry; _task = task; _hoverText = ""; checkbox = _entry.checkbox; checkbox.myID = 100; checkbox.rightNeighborID = 101; removeButton = _entry.removeButton; removeButton.myID = 102; removeButton.leftNeighborID = 101; editbox = new ClickableComponent(new Rectangle(_entry.bounds.Center.X, checkbox.bounds.Y, checkbox.bounds.Width, checkbox.bounds.Height), "") { myID = 101, rightNeighborID = 102, leftNeighborID = 100 }; Game1.playSound("smallSelect"); }
public override void receiveLeftClick(int x, int y, bool playSound = true) { if (ChildHasFocus()) { _childMenu.receiveLeftClick(x, y, playSound); return; } if (_dragging) { return; } else if (addTaskButton.containsPoint(x, y)) { OpenAddTaskMenu(); return; } else if (moneyButton.containsPoint(x, y)) { _config.MoneyViewNetWealth = !_config.MoneyViewNetWealth; RefreshMoneyDial(); } else { IReadOnlyList <ITask> tasks = _taskManager.Tasks; int scrollOffset = scrollComponent.ScrollAmount / scrollComponent.ScrollDistance; for (int i = 0; i < taskEntries.Count && i + scrollOffset < tasks.Count; i++) { TaskEntryComponent entry = taskEntries[i]; ITask task = tasks[i + scrollOffset]; if (entry.containsPoint(x, y)) { if (entry.checkbox.containsPoint(x, y)) { if (task.Active) { task.Complete = !task.Complete; task.MarkAsViewed(); Game1.playSoundPitched("tinyWhip", task.Complete ? 2000 : 1000); } else { task.Active = true; Game1.playSound("newRecipe"); } } else if (entry.removeButton.containsPoint(x, y)) { RemoveTaskAt(i + scrollOffset); Game1.playSound("trashcan"); } else { _selectedTaskIndex = i + scrollOffset; } return; } } if (!scrollComponent.CanScroll() || !_boundsWithScrollBar.Contains(x, y)) { Game1.activeClickableMenu?.exitThisMenu(); } } scrollComponent.ReceiveLeftClick(x, y, playSound); }
public override void performHoverAction(int x, int y) { base.performHoverAction(x, y); if (ChildHasFocus()) { _childMenu.performHoverAction(x, y); return; } _moneyButtonVisible = moneyButton.containsPoint(x, y); if (_moneyButtonVisible) { HoverText = Translation.Get("ui.tasks.moneybutton.hover"); } else if (moneyBox.containsPoint(x, y)) { HoverText = Translation.Get("ui.tasks.moneybox." + (_config.MoneyViewNetWealth ? "hover1" : "hover0")); } else if (addTaskButton.containsPoint(x, y)) { HoverText = Translation.Get("ui.tasks.addbutton.hover"); } IReadOnlyList <ITask> tasks = _taskManager.Tasks; int scrollOffset = scrollComponent.ScrollAmount / scrollComponent.ScrollDistance; for (int i = 0; i < taskEntries.Count; i++) { TaskEntryComponent entry = taskEntries[i]; if (entry.TryHover(x, y) && i + scrollOffset < tasks.Count && !_dragging) { tasks[i + scrollOffset].MarkAsViewed(); if (!entry.containsPoint(Game1.getOldMouseX(), Game1.getOldMouseY())) { Game1.playSound("Cowboy_gunshot"); } if (HoverText.Length == 0) { if (entry.checkbox.containsPoint(x, y) && !tasks[i + scrollOffset].Active) { HoverText = Translation.Get("ui.tasks.renewbutton.hover"); } else if (entry.removeButton.containsPoint(x, y)) { HoverText = Translation.Get("ui.tasks.removebutton.hover"); } else if (entry.IsNameTruncated() && entry.TimeHovering() > 1.0) { HoverText = tasks[i + scrollOffset].Name; } } } } moneyButton.tryHover(x, y); addTaskButton.tryHover(x, y); }
private void OpenTaskEntryMenu(TaskEntryComponent entry, ITask task) { SetSnappyChildMenu(new TaskEntryMenu(entry, task, Translation)); }