public void Draw()
{
Point scaledMouse = mouse_current.MouseCurrent;
the3d.Draw2dBitmapFile("inventory.png", InventoryStart.X, InventoryStart.Y, 512, 1024);
//the3d.Draw2dTexture(terrain, 50, 50, 50, 50, 0);
//the3d.Draw2dBitmapFile("inventory_weapon_shovel.png", 100, 100, 60 * 2, 60 * 4);
//the3d.Draw2dBitmapFile("inventory_gauntlet_gloves.png", 200, 200, 60 * 2, 60 * 2);
//main inventory
foreach (var k in inventory.Items)
{
DrawItem(new Point(CellsStart.X + k.Key.X * CellDrawSize, CellsStart.Y + k.Key.Y * CellDrawSize), k.Value, null);
}
//draw area selection
if (inventory.DragDropItem != null)
{
Point? selected = SelectedCell(scaledMouse);
if (selected != null)
{
int x = (selected.Value.X) * CellDrawSize + CellsStart.X;
int y = (selected.Value.Y) * CellDrawSize + CellsStart.Y;
Point size = dataItems.ItemSize(inventory.DragDropItem);
if (selected.Value.X + size.X <= CellCount.X
&& selected.Value.Y + size.Y <= CellCount.Y)
{
Color c;
Point[] itemsAtArea = inventoryUtil.ItemsAtArea(selected.Value, size);
if (itemsAtArea == null || itemsAtArea.Length > 1)
{
c = Color.Red;
}
else //0 or 1
{
c = Color.Green;
}
the3d.Draw2dTexture(the3d.WhiteTexture(), x, y,
CellDrawSize * size.X, CellDrawSize * size.Y,
null, Color.FromArgb(100, c));
}
}
WearPlace? selectedWear = SelectedWearPlace(scaledMouse);
if (selectedWear != null)
{
Point p = Offset(wearPlaceStart[(int)selectedWear], InventoryStart);
Point size = wearPlaceCells[(int)selectedWear];
Color c;
Item itemsAtArea = inventoryUtil.ItemAtWearPlace(selectedWear.Value, ActiveMaterial.ActiveMaterial);
if (!dataItems.CanWear(selectedWear.Value, inventory.DragDropItem))
{
c = Color.Red;
}
else //0 or 1
{
c = Color.Green;
}
the3d.Draw2dTexture(the3d.WhiteTexture(), p.X, p.Y,
CellDrawSize * size.X, CellDrawSize * size.Y,
null, Color.FromArgb(100, c));
}
}
//material selector
DrawMaterialSelector();
//wear
DrawItem(Offset(wearPlaceStart[(int)WearPlace.LeftHand], InventoryStart), inventory.LeftHand[ActiveMaterial.ActiveMaterial], null);
DrawItem(Offset(wearPlaceStart[(int)WearPlace.RightHand], InventoryStart), inventory.RightHand[ActiveMaterial.ActiveMaterial], null);
DrawItem(Offset(wearPlaceStart[(int)WearPlace.MainArmor], InventoryStart), inventory.MainArmor, null);
DrawItem(Offset(wearPlaceStart[(int)WearPlace.Boots], InventoryStart), inventory.Boots, null);
DrawItem(Offset(wearPlaceStart[(int)WearPlace.Helmet], InventoryStart), inventory.Helmet, null);
DrawItem(Offset(wearPlaceStart[(int)WearPlace.Gauntlet], InventoryStart), inventory.Gauntlet, null);
//info
if (SelectedCell(scaledMouse) != null)
{
Point selected = SelectedCell(scaledMouse).Value;
Point? itemAtCell = inventoryUtil.ItemAtCell(selected);
if (itemAtCell != null)
{
Item item = inventory.Items[new ProtoPoint(itemAtCell.Value)];
if (item != null)
{
int x = (selected.X) * CellDrawSize + CellsStart.X;
int y = (selected.Y) * CellDrawSize + CellsStart.Y;
DrawItemInfo(new Point(scaledMouse.X, scaledMouse.Y), item);
}
}
}
if (SelectedWearPlace(scaledMouse) != null)
{
WearPlace selected = SelectedWearPlace(scaledMouse).Value;
Item itemAtWearPlace = inventoryUtil.ItemAtWearPlace(selected, ActiveMaterial.ActiveMaterial);
if (itemAtWearPlace != null)
{
DrawItemInfo(new Point(scaledMouse.X, scaledMouse.Y), itemAtWearPlace);
}
}
if (SelectedMaterialSelectorSlot(scaledMouse) != null)
{
int selected = SelectedMaterialSelectorSlot(scaledMouse).Value;
Item item = inventory.RightHand[selected];
if (item != null)
{
DrawItemInfo(new Point(scaledMouse.X, scaledMouse.Y), item);
}
}
if (inventory.DragDropItem != null)
{
DrawItem(new Point(scaledMouse.X, scaledMouse.Y), inventory.DragDropItem, null);
}
}