public void Draw(SpriteBatch b) { if (IsJojaMember) { Rectangle BackgroundDestination = new Rectangle(Padding, Padding, RelativeBounds.Width - Padding * 2, RelativeBounds.Height - Padding * 2).GetOffseted(TopLeftScreenPosition); b.Draw(TextureHelpers.JojaCDForm, BackgroundDestination, new Rectangle(0, 0, TextureHelpers.JojaCDForm.Width, TextureHelpers.JojaCDForm.Height - 16), Color.White); string Text = "You Traitor!"; SpriteFont Font = Game1.smallFont; Vector2 TextSize = Font.MeasureString(Text) * 2; int JojaSuxDestinationSize = 128; int BoxPadding = 32; int BoxWidth = Math.Max((int)TextSize.X, JojaSuxDestinationSize) + BoxPadding * 2; int BoxHeight = (int)TextSize.Y + BoxPadding * 2 + JojaSuxDestinationSize - JojaSuxDestinationSize / 8; Rectangle BoxDestination = new Rectangle((RelativeBounds.Width - BoxWidth) / 2, (RelativeBounds.Height - BoxHeight) / 2, BoxWidth, BoxHeight).GetOffseted(TopLeftScreenPosition); DrawHelpers.DrawBox(b, BoxDestination); Vector2 TextDestination = new Vector2(BoxDestination.X + (BoxDestination.Width - TextSize.X) / 2, BoxDestination.Y + BoxPadding); b.DrawString(Font, Text, TextDestination, Color.Black, 0f, Vector2.Zero, 2f, SpriteEffects.None, 1f); Rectangle JojaSuxSourcePosition = new Rectangle(258, 640, 32, 32); Rectangle JojaSuxDestination = new Rectangle(BoxDestination.X + (BoxDestination.Width - JojaSuxDestinationSize) / 2, BoxDestination.Bottom - BoxPadding - JojaSuxDestinationSize, JojaSuxDestinationSize, JojaSuxDestinationSize); b.Draw(Game1.mouseCursors, JojaSuxDestination, JojaSuxSourcePosition, Color.White); } else { // Draw room names foreach (KeyValuePair <BundleRoom, Rectangle> RoomHeader in RoomHeaderPositions) { bool IsCompleted = RoomHeader.Key.IsCompleted; Rectangle Position = RoomHeader.Value.GetOffseted(TopLeftScreenPosition); DrawHelpers.DrawBox(b, Position); string Text = RoomHeader.Key.DisplayName; Vector2 Size = RoomHeaderFont.MeasureString(Text) * RoomHeaderScale; b.DrawString(RoomHeaderFont, Text, new Vector2(Position.X + (Position.Width - Size.X) / 2, Position.Y + (Position.Height - Size.Y) / 2), IsCompleted ? Color.Green : Color.Black, 0f, Vector2.Zero, RoomHeaderScale, SpriteEffects.None, 1f); if (IsCompleted) { Rectangle CheckMarkDestination = new Rectangle(Position.Right - SlotSize / 6 - CheckMark.Width * CheckMarkScale, Position.Bottom - SlotSize / 6 - CheckMark.Height * CheckMarkScale, CheckMark.Width * CheckMarkScale, CheckMark.Height * CheckMarkScale); b.Draw(TextureHelpers.PlayerStatusList, CheckMarkDestination, CheckMark, Color.White); } } // Draw the backgrounds of each slot foreach (Rectangle LockedSlot in LockedSlotPositions) { b.Draw(Game1.menuTexture, LockedSlot.GetOffseted(TopLeftScreenPosition), new Rectangle(64, 896, 64, 64), Color.White); } foreach (KeyValuePair <BundleItem, Rectangle> ItemSlot in ItemSlotPositions) { Rectangle TexturePosition; if (ItemSlot.Key.IsCompleted) { TexturePosition = SlotDarkBackground; } else { Object Item = ItemPlaceholders[ItemSlot.Key]; if (Item.Stack == 0) { TexturePosition = SlotLightBackground; } else if (Item.Stack == ItemSlot.Key.Quantity) { TexturePosition = SlotDarkBackground; } else { TexturePosition = SlotMediumBackground; } } b.Draw(TextureHelpers.JunimoNoteTexture, ItemSlot.Value.GetOffseted(TopLeftScreenPosition), TexturePosition, Color.White); } foreach (KeyValuePair <BundleTask, Rectangle> TaskHeader in TaskHeaderPositions) { Rectangle TexturePosition = SlotMediumBackground; if (TaskHeader.Key.IsCompleted) { TexturePosition = SlotDarkBackground; } b.Draw(TextureHelpers.JunimoNoteTexture, TaskHeader.Value.GetOffseted(TopLeftScreenPosition), TexturePosition, Color.White); } // Draw the Task headers foreach (KeyValuePair <BundleTask, Rectangle> TaskHeader in TaskHeaderPositions) { bool IsCompleted = TaskHeader.Key.IsCompleted; // Draw a thin yellow border if mouse is hovering this slot bool IsHovered = TaskHeader.Key == HoveredBundleTask; if (IsHovered) { Rectangle Destination = TaskHeader.Value.GetOffseted(TopLeftScreenPosition); Color HighlightColor = Color.Yellow; Texture2D Highlight = TextureHelpers.GetSolidColorTexture(Game1.graphics.GraphicsDevice, HighlightColor); b.Draw(Highlight, Destination, Color.White * 0.25f); int BorderThickness = Destination.Width / 16; DrawHelpers.DrawBorder(b, Destination, BorderThickness, HighlightColor); } Rectangle Slot = TaskHeader.Value; Rectangle ScaledSlot = new Rectangle(Slot.X + Slot.Width / 6, Slot.Y + Slot.Height / 6, Slot.Width - Slot.Width / 3, Slot.Height - Slot.Height / 3); Rectangle SourceIconPosition = IsCompleted ? TaskHeader.Key.SpriteSmallIconOpenedPosition : TaskHeader.Key.SpriteSmallIconClosedPosition; b.Draw(TextureHelpers.JunimoNoteTexture, ScaledSlot.GetOffseted(TopLeftScreenPosition), SourceIconPosition, Color.White); if (IsCompleted) { Rectangle CheckMarkDestination = new Rectangle(Slot.Right - 1 - CheckMark.Width * CheckMarkScale, Slot.Bottom - 1 - CheckMark.Height * CheckMarkScale, CheckMark.Width * CheckMarkScale, CheckMark.Height * CheckMarkScale).GetOffseted(TopLeftScreenPosition); b.Draw(TextureHelpers.PlayerStatusList, CheckMarkDestination, CheckMark, Color.White); } } // Draw the items of each slot foreach (KeyValuePair <BundleItem, Rectangle> ItemSlot in ItemSlotPositions) { Rectangle Destination = ItemSlot.Value.GetOffseted(TopLeftScreenPosition); Object CurrentItem; if (!ItemPlaceholders.TryGetValue(ItemSlot.Key, out CurrentItem)) { CurrentItem = ItemSlot.Key.ToObject(); } bool IsCompleted = ItemSlot.Key.IsCompleted; // Draw a thin yellow border if mouse is hovering this slot bool IsHovered = ItemSlot.Key == HoveredBundleItem; if (IsHovered) { Color HighlightColor = Color.Yellow; Texture2D Highlight = TextureHelpers.GetSolidColorTexture(Game1.graphics.GraphicsDevice, HighlightColor); b.Draw(Highlight, Destination, Color.White * 0.25f); int BorderThickness = Destination.Width / 16; DrawHelpers.DrawBorder(b, Destination, BorderThickness, HighlightColor); } float IconScale = IsHovered ? 1.25f : 1.0f; Color Overlay = CurrentItem.Stack == 0 || IsCompleted ? Color.White * 0.30f : Color.White; bool DrawQuantity = CurrentItem.Stack > 0 && !IsCompleted && ItemSlot.Key.Quantity > 1; DrawHelpers.DrawItem(b, Destination, CurrentItem, DrawQuantity, true, IconScale, 1.0f, Overlay, CurrentItem.Stack >= ItemSlot.Key.Quantity ? Color.Green : Color.White); if (IsCompleted) { Rectangle CheckMarkDestination = new Rectangle(Destination.Right - 1 - CheckMark.Width * CheckMarkScale, Destination.Bottom - 1 - CheckMark.Height * CheckMarkScale, CheckMark.Width * CheckMarkScale, CheckMark.Height * CheckMarkScale); b.Draw(TextureHelpers.PlayerStatusList, CheckMarkDestination, CheckMark, Color.White); } } } }
public void InitializeLayout(int ResizeIteration) { if (BundleBag == null) { return; } if (ResizeIteration > 1) { this.SlotSize = Math.Min(OriginalSlotSize, Math.Max(24, OriginalSlotSize - (ResizeIteration - 1) * 8)); } if (IsJojaMember) { this.RelativeBounds = new Rectangle(0, 0, 640 + Padding * 2, 288 + Padding * 2); } else { HoveredBundleTask = null; HoveredBundleItem = null; SecondaryActionButtonPressedTime = null; SecondaryActionButtonPressedItem = null; int RoomBottomMargin = 12; int RoomRightMargin = 8; int StartX = Padding; int StartY = Padding; CommunityCenterBundles CC = CommunityCenterBundles.Instance; this.RoomHeaderPositions = new Dictionary <BundleRoom, Rectangle>(); this.RoomSlotPositions = new Dictionary <BundleRoom, List <Rectangle> >(); this.TaskHeaderPositions = new Dictionary <BundleTask, Rectangle>(); this.TaskSlotPositions = new Dictionary <BundleTask, List <Rectangle> >(); this.ItemSlotPositions = new OrderedDictionary <BundleItem, Rectangle>(); this.LockedSlotPositions = new List <Rectangle>(); int RoomNameWidth = CC.Rooms.Select(x => (int)(RoomHeaderFont.MeasureString(x.DisplayName).X *RoomHeaderScale)).DefaultIfEmpty(100).Max() + 32; int CurrentRow = 0; int CurrentColumn = 0; int RoomIndex = 0; foreach (BundleRoom Room in CC.Rooms) { if (BundleBag.InvalidRooms[BundleBag.Size].Contains(Room.Name)) { continue; } Rectangle RoomHeader = new Rectangle(StartX, StartY + CurrentRow * SlotSize + RoomIndex * RoomBottomMargin, RoomNameWidth, SlotSize); RoomHeaderPositions.Add(Room, RoomHeader); List <Rectangle> CurrentRoomSlotPositions = new List <Rectangle>(); RoomSlotPositions.Add(Room, CurrentRoomSlotPositions); foreach (BundleTask Task in Room.Tasks) { if (CurrentColumn == ColumnCount) { CurrentColumn = 0; CurrentRow++; } Rectangle TaskHeader = new Rectangle(StartX + RoomNameWidth + RoomRightMargin + CurrentColumn * SlotSize, StartY + CurrentRow * SlotSize + RoomIndex * RoomBottomMargin, SlotSize, SlotSize); TaskHeaderPositions.Add(Task, TaskHeader); CurrentRoomSlotPositions.Add(TaskHeader); List <Rectangle> CurrentTaskSlotPositions = new List <Rectangle>(); TaskSlotPositions.Add(Task, CurrentTaskSlotPositions); CurrentColumn++; foreach (BundleItem Item in Task.Items) { if (!BundleTask.IsValidItemId(Item.Id)) { continue; } if (CurrentColumn == ColumnCount) { CurrentColumn = 0; CurrentRow++; } Rectangle Slot = new Rectangle(StartX + RoomNameWidth + RoomRightMargin + CurrentColumn * SlotSize, StartY + CurrentRow * SlotSize + RoomIndex * RoomBottomMargin, SlotSize, SlotSize); CurrentRoomSlotPositions.Add(Slot); CurrentTaskSlotPositions.Add(Slot); ItemSlotPositions.Add(Item, Slot); CurrentColumn++; } } if (ShowLockedSlots) { while (CurrentColumn < ColumnCount) { Rectangle LockedSlot = new Rectangle(StartX + RoomNameWidth + RoomRightMargin + CurrentColumn * SlotSize, StartY + CurrentRow * SlotSize + RoomIndex * RoomBottomMargin, SlotSize, SlotSize); LockedSlotPositions.Add(LockedSlot); CurrentColumn++; } } CurrentColumn = 0; CurrentRow++; RoomIndex++; } this.RelativeBounds = new Rectangle(0, 0, Padding + RoomNameWidth + RoomRightMargin + ColumnCount * SlotSize + Padding, Padding + CurrentRow * SlotSize + Padding + (RoomIndex - 1) * RoomBottomMargin); } }