コード例 #1
0
ファイル: GameMenu.cs プロジェクト: henon/manic_digger
 void DrawWidgets(IForm form)
 {
     for (int i = 0; i < form.Widgets.Count; i++)
     {
         Widget b = form.Widgets[i];
         if (!b.Visible)
         {
             continue;
         }
         if (b.BackgroundSingleColor != null)
         {
             d_The3d.Draw2dTexture(d_The3d.WhiteTexture(), b.Rect.X, b.Rect.Y, b.Rect.Width, b.Rect.Height,
                                   null, b.BackgroundSingleColor.Value);
         }
         if (b.IsScrollbar)
         {
             d_The3d.Draw2dTexture(d_The3d.WhiteTexture(), b.Rect.X, b.Rect.Y, b.Rect.Width, b.Rect.Height,
                                   null, Color.Gray);
             float scrollpos    = b.Rect.Y + ((float)b.ScrollbarValue / (b.ScrollbarMax + 1)) * (b.Rect.Height - 40 * 2) + 40;
             float scrollheight = (b.Rect.Height - (40 * 2)) / (b.ScrollbarMax + 1);
             d_The3d.Draw2dTexture(d_The3d.WhiteTexture(), b.Rect.X, scrollpos,
                                   b.Rect.Width, scrollheight, null, Color.Black);
             d_The3d.Draw2dText("^", b.Rect.X, b.Rect.Y, b.FontSize, Color.White);
             d_The3d.Draw2dText("v", b.Rect.X, b.Rect.Y + b.Rect.Height - 40, b.FontSize, Color.White);
         }
         string img = ((selectedWidget == i || b.selected) &&
                       b.BackgroundImageSelected != null)
             ? b.BackgroundImageSelected : b.BackgroundImage;
         if (img != null)
         {
             d_The3d.Draw2dBitmapFile(img, b.Rect.X, b.Rect.Y, b.Rect.Width, b.Rect.Height);
         }
         if (b.Text != null)
         {
             int    dx   = b.FontSize > 20 ? 49 : 20;
             string text = b.IsPassword ? PassString(b.Text) : b.Text;
             if (typingfield == i)
             {
                 text += "&7|";
             }
             d_The3d.Draw2dText(text, b.Rect.X + dx, b.Rect.Y + dx, b.FontSize,
                                (b.BackgroundImage == null && b.selected) ? Color.Red : b.TextColor);
         }
     }
 }
コード例 #2
0
        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);
            }
        }