private void DrawUnlockedAmmo(SpriteBatch spriteBatch, EndlessAmmoPlayer modPlayer, ref string mouseText, ref Item hoverAmmo) { Vector2 stringScale = Vector2.One * 0.75f; int dx = LeftX; Color titleColor = new Color(Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor); Point mousePoint = new Point(Main.mouseX, Main.mouseY); string EndlessAmmoLabel = "Endless Ammo"; ChatManager.DrawColorCodedString(spriteBatch, Main.fontMouseText, EndlessAmmoLabel, new Vector2(dx, 84f), titleColor, 0, Vector2.Zero, stringScale); Rect checkboxRect = new Rect(dx, 84, 16, 16); checkboxRect.X += (Main.fontMouseText.MeasureString(EndlessAmmoLabel) * stringScale).X + 4; EndlessAmmoInventory.SmallItemSlotTexture.Draw(spriteBatch, checkboxRect, Color.White, Main.inventoryScale); if (modPlayer.useEndlessAmmoFirst) { string checkmark = "✓"; Vector2 stringRect = Main.fontMouseText.MeasureString(checkmark) * stringScale; ChatManager.DrawColorCodedStringWithShadow( spriteBatch, Main.fontMouseText, checkmark, checkboxRect.Center(), Color.White, 0f, stringRect / 2, stringScale ); } if (checkboxRect.Contains(mousePoint)) { Main.LocalPlayer.mouseInterface = true; mouseText = "Use endless ammo first."; if (Main.mouseLeft && Main.mouseLeftRelease) { Main.PlaySound(SoundID.MenuTick); modPlayer.useEndlessAmmoFirst = !modPlayer.useEndlessAmmoFirst; } } Rect slotRect = new Rect(52, 52); slotRect.Dimensions *= Main.inventoryScale; int typeCount = DataContainer.EndlessAmmoTypes.Length; for (int i = 0; i < typeCount; i++) { int x = i / 4; int y = i % 4; slotRect.X = dx + x * DeltaX; slotRect.Y = (int)(105f + y * 56 * Main.inventoryScale); EndlessAmmoType AmmoType = DataContainer.EndlessAmmoTypes[i]; Item ammo = modPlayer.GetItemForEndlessAmmoType(AmmoType.Type); if (ammo.type == ItemID.None) { Item refItem = new Item(); refItem.SetDefaults(AmmoType.PreviewItemType); ScalableItemSlot.DrawPanel(spriteBatch, slotRect, Main.inventoryScale); ScalableItemSlot.DrawItem(spriteBatch, slotRect, refItem, PreviewColor, Main.inventoryScale); } else { ScalableItemSlot.DrawPanel(spriteBatch, slotRect, Main.inventoryScale); ScalableItemSlot.DrawItem(spriteBatch, slotRect, ammo, Main.inventoryBack, Main.inventoryScale); } if (modPlayer.CanUnlockAmmoForType(AmmoType.Type)) { Vector2 hPosition = slotRect.ClonePosition(); hPosition.X += 24; hPosition.Y += 4; ChatManager.DrawColorCodedStringWithShadow( spriteBatch, Main.fontMouseText, "!", hPosition, UnlockColor, 0f, Vector2.Zero, Vector2.One * 0.6f ); } if (AmmoPicker == AmmoID.None && slotRect.Contains(mousePoint)) { Main.LocalPlayer.mouseInterface = true; if (ammo.type != ItemID.None) { hoverAmmo = ammo; } else { mouseText = DataContainer.EndlessAmmoTypes[i].NoSelected; } if (Main.mouseLeft && Main.mouseLeftRelease) { Main.PlaySound(SoundID.MenuOpen); AmmoPicker = AmmoType.Type; } } } }
public override void Draw(SpriteBatch spriteBatch) { DaesPlayer modPlayer = Main.LocalPlayer.GetModPlayer <DaesPlayer>(); if (!modPlayer.hasEndlessAmmo) { base.Draw(spriteBatch); return; } Main.inventoryScale = 0.6f; if (AmmoPicker != AmmoID.None) { DrawAmmoPicker(spriteBatch, modPlayer); base.Draw(spriteBatch); return; } else { AmmoPickerScroll = 0; } int dx = LeftX; Color titleColor = new Color(Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor); Point mousePoint = new Point(Main.mouseX, Main.mouseY); Rect checkboxRect = new Rect(dx, 84f, 16, 16); LargeItemSlot.DrawPanel(spriteBatch, checkboxRect, Main.inventoryScale); string EndlessAmmoLabel = "∞ Ammo"; ChatManager.DrawColorCodedString(spriteBatch, Main.fontMouseText, EndlessAmmoLabel, new Vector2(dx + 20, 84f), titleColor, 0, Vector2.Zero, Vector2.One * 0.75f); Rect slotRect = new Rect(52, 52); slotRect.Scale(Main.inventoryScale); int hoverSlot = -1; int hoverAmmoType = 0; Item hoverAmmo = new Item(); for (int i = 0; i < DataContainer.EndlessAmmoTypes.Length; i++) { int x = i / 4; int y = i % 4; slotRect.X = dx + x * DeltaX; slotRect.Y = (int)(105f + y * 56 * Main.inventoryScale); EndlessAmmoType AmmoType = DataContainer.EndlessAmmoTypes[i]; Item ammo = modPlayer.GetItemForEndlessAmmoType(AmmoType.Type); LargeItemSlot.DrawPanel(spriteBatch, slotRect, Main.inventoryScale); if (ammo.type != ItemID.None) { LargeItemSlot.DrawItem(spriteBatch, slotRect, ammo, Main.inventoryScale); } else { Texture2D texture = AmmoType.Texture; Vector2 position = slotRect.Center() - texture.Size() * Main.inventoryScale / 2f; spriteBatch.Draw(texture, position, texture.Frame(), PreviewColor, 0f, Vector2.Zero, Main.inventoryScale, SpriteEffects.None, 0f); } if (modPlayer.CanUnlockAmmoForType(AmmoType.Type)) { Vector2 hPosition = slotRect.Position(); hPosition.X += 24; hPosition.Y += 4; ChatManager.DrawColorCodedStringWithShadow( spriteBatch, Main.fontMouseText, "!", hPosition, UnlockColor, 0f, Vector2.Zero, Vector2.One * 0.6f ); } if (AmmoPicker == AmmoID.None && slotRect.Contains(mousePoint)) { hoverSlot = i; hoverAmmo = ammo; hoverAmmoType = AmmoType.Type; } } if (hoverSlot > -1) { Main.LocalPlayer.mouseInterface = true; if (hoverAmmo.type != ItemID.None) { Main.HoverItem = hoverAmmo.Clone(); Main.HoverItem.ammo = 0; Main.HoverItem.material = false; Main.HoverItem.consumable = false; Main.instance.MouseText(hoverAmmo.Name, hoverAmmo.rare, 0); } else { Main.instance.MouseText(DataContainer.EndlessAmmoTypes[hoverSlot].NoSelected); } if (Main.mouseLeft && Main.mouseLeftRelease) { Main.PlaySound(SoundID.MenuOpen); AmmoPicker = hoverAmmoType; } } if (checkboxRect.Contains(mousePoint)) { Main.LocalPlayer.mouseInterface = true; Main.instance.MouseText("Use endless ammo first."); if (Main.mouseLeft && Main.mouseLeftRelease) { Main.PlaySound(SoundID.MenuTick); modPlayer.useEndlessAmmoFirst = !modPlayer.useEndlessAmmoFirst; } } if (modPlayer.useEndlessAmmoFirst) { Vector2 position = checkboxRect.Center(); position.X += 2; position.Y -= 2; ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontMouseText, "✓", position, Color.White, 0f, checkboxRect.Dimensions() / 2, Vector2.One * Main.inventoryScale); } base.Draw(spriteBatch); }