示例#1
0
        private float CreateDescription(Item item, bool forSale)
        {
            // Title
            var titlebar = new IconTitle();

            titlebar.Icon(new ItemSprite(item.Image, item.Glowing()));
            titlebar.Label(forSale ? Utils.Format(TxtSale, item.ToString(), Price(item)) : Utils.Capitalize(item.ToString()));
            titlebar.SetRect(0, 0, WIDTH, 0);
            Add(titlebar);

            // Upgraded / degraded
            if (item.levelKnown && item.level > 0)
            {
                titlebar.Color(ItemSlot.Upgraded);
            }
            else
            if (item.levelKnown && item.level < 0)
            {
                titlebar.Color(ItemSlot.Degraded);
            }

            // Description
            var info = PixelScene.CreateMultiline(item.Info(), 6);

            info.MaxWidth = WIDTH;
            info.Measure();
            info.X = titlebar.Left();
            info.Y = titlebar.Bottom() + Gap;
            Add(info);

            return(info.Y + info.Height);
        }
示例#2
0
        public WndItem(WndBag owner, Item item)
        {
            var titlebar = new IconTitle();

            titlebar.Icon(new ItemSprite(item.image, item.Glowing()));
            titlebar.Label(Utils.Capitalize(item.ToString()));
            titlebar.SetRect(0, 0, WIDTH, 0);
            Add(titlebar);

            if (item.levelKnown && item.level > 0)
            {
                titlebar.Color(ItemSlot.Upgraded);
            }
            else
            if (item.levelKnown && item.level < 0)
            {
                titlebar.Color(ItemSlot.Degraded);
            }

            var info = PixelScene.CreateMultiline(item.Info(), 6);

            info.MaxWidth = WIDTH;
            info.Measure();
            info.X = titlebar.Left();
            info.Y = titlebar.Bottom() + Gap;
            Add(info);

            var   y = info.Y + info.Height + Gap;
            float x = 0;

            if (Dungeon.Hero.IsAlive && owner != null)
            {
                foreach (var action in item.Actions(Dungeon.Hero))
                {
                    var btn = new RedButton(action);
                    btn.ClickAction = button =>
                    {
                        item.Execute(Dungeon.Hero, action);
                        Hide();
                        owner.Hide();
                    };
                    btn.SetSize(Math.Max(ButtonWidth, btn.ReqWidth()), ButtonHeight);
                    if (x + btn.Width > WIDTH)
                    {
                        x  = 0;
                        y += ButtonHeight + Gap;
                    }
                    btn.SetPos(x, y);
                    Add(btn);

                    x += btn.Width + Gap;
                }
            }

            Resize(WIDTH, (int)(y + (x > 0 ? ButtonHeight : 0)));
        }
示例#3
0
        private void FillFields(int image, ItemSprite.Glowing glowing, int titleColor, string title, string info)
        {
            var titlebar = new IconTitle();

            titlebar.Icon(new ItemSprite(image, glowing));
            titlebar.Label(Utils.Capitalize(title), titleColor);
            titlebar.SetRect(0, 0, WIDTH, 0);
            Add(titlebar);

            var txtInfo = PixelScene.CreateMultiline(info, 6);

            txtInfo.MaxWidth = WIDTH;
            txtInfo.Measure();
            txtInfo.X = titlebar.Left();
            txtInfo.Y = titlebar.Bottom() + Gap;
            Add(txtInfo);

            Resize(WIDTH, (int)(txtInfo.Y + txtInfo.Height));
        }
示例#4
0
        public WndInfoPlant(Plant plant)
        {
            var titlebar = new IconTitle();

            titlebar.Icon(new PlantSprite(plant.Image));
            titlebar.Label(plant.PlantName);
            titlebar.SetRect(0, 0, WIDTH, 0);
            Add(titlebar);

            var info = PixelScene.CreateMultiline(6);

            Add(info);

            info.Text(plant.Desc());
            info.MaxWidth = WIDTH;
            info.Measure();
            info.X = titlebar.Left();
            info.Y = titlebar.Bottom() + Gap;

            Resize(WIDTH, (int)(info.Y + info.Height));
        }
示例#5
0
        public WndChooseWay(TomeOfMastery tome, HeroSubClass way1, HeroSubClass way2)
        {
            var titlebar = new IconTitle();

            titlebar.Icon(new ItemSprite(tome.Image, null));
            titlebar.Label(tome.Name);
            titlebar.SetRect(0, 0, WIDTH, 0);
            Add(titlebar);

            var hl = new Highlighter(way1.Desc + "\\Negative\\Negative" + way2.Desc + "\\Negative\\Negative" + TxtMessage);

            var normal = PixelScene.CreateMultiline(hl.Text, 6);

            normal.MaxWidth = WIDTH;
            normal.Measure();
            normal.X = titlebar.Left();
            normal.Y = titlebar.Bottom() + Gap;
            Add(normal);

            if (hl.IsHighlighted)
            {
                normal.Mask = hl.Inverted();

                var highlighted = PixelScene.CreateMultiline(hl.Text, 6);
                highlighted.MaxWidth = normal.MaxWidth;
                highlighted.Measure();
                highlighted.X = normal.X;
                highlighted.Y = normal.Y;
                Add(highlighted);

                highlighted.Mask = hl.Mask;
                highlighted.Hardlight(TitleColor);
            }

            var btnWay1 = new RedButton(Utils.Capitalize(way1.Title));

            btnWay1.ClickAction = button =>
            {
                Hide();
                tome.Choose(way1);
            };
            btnWay1.SetRect(0, normal.Y + normal.Height + Gap, (WIDTH - Gap) / 2, BtnHeight);
            Add(btnWay1);

            var btnWay2 = new RedButton(Utils.Capitalize(way2.Title));

            btnWay2.ClickAction = button =>
            {
                Hide();
                tome.Choose(way2);
            };
            btnWay2.SetRect(btnWay1.Right() + Gap, btnWay1.Top(), btnWay1.Width, BtnHeight);
            Add(btnWay2);

            var btnCancel = new RedButton(TxtCancel);

            btnCancel.ClickAction = button => Hide();
            btnCancel.SetRect(0, btnWay2.Bottom() + Gap, WIDTH, BtnHeight);
            Add(btnCancel);

            Resize(WIDTH, (int)btnCancel.Bottom());
        }
示例#6
0
        public WndInfoCell(int cell)
        {
            var tile = Dungeon.Level.map[cell];

            if (Level.water[cell])
            {
                tile = Terrain.WATER;
            }
            else
            if (Level.pit[cell])
            {
                tile = Terrain.CHASM;
            }

            var titlebar = new IconTitle();

            if (tile == Terrain.WATER)
            {
                var water = new Image(Dungeon.Level.WaterTex());
                water.Frame(0, 0, DungeonTilemap.Size, DungeonTilemap.Size);
                titlebar.Icon(water);
            }
            else
            {
                titlebar.Icon(DungeonTilemap.Tile(tile));
            }

            titlebar.Label(Dungeon.Level.TileName(tile));
            titlebar.SetRect(0, 0, WIDTH, 0);
            Add(titlebar);

            var info = PixelScene.CreateMultiline(6);

            Add(info);

            var desc = new StringBuilder(Dungeon.Level.TileDesc(tile));

            const string newLine = "\\Negative";

            foreach (var blob in Dungeon.Level.Blobs.Values)
            {
                if (blob.Cur[cell] <= 0 || blob.TileDesc() == null)
                {
                    continue;
                }

                if (desc.Length() > 0)
                {
                    desc.Append(newLine);
                }

                desc.Append(blob.TileDesc());
            }

            info.Text(desc.Length() > 0 ? desc.ToString() : TxtNothing);
            info.MaxWidth = WIDTH;
            info.Measure();
            info.X = titlebar.Left();
            info.Y = titlebar.Bottom() + Gap;

            Resize(WIDTH, (int)(info.Y + info.Height));
        }