コード例 #1
0
        public WndWandmaker(Wandmaker wandmaker, Item item)
        {
            _wandmaker = wandmaker;
            _item      = item;
            var titlebar = new IconTitle();

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

            var message = PixelScene.CreateMultiline(TxtMessage, 6);

            message.MaxWidth = WIDTH;
            message.Measure();
            message.Y = titlebar.Bottom() + Gap;
            Add(message);


            var btnBattle = new RedButton(TxtBattle);

            btnBattle.ClickAction = BattleAction;
            btnBattle.SetRect(0, message.Y + message.Height + Gap, WIDTH, BtnHeight);
            Add(btnBattle);

            var btnNonBattle = new RedButton(TxtNonBattle);

            btnNonBattle.ClickAction = NonBattleAction;
            btnNonBattle.SetRect(0, btnBattle.Bottom() + Gap, WIDTH, BtnHeight);
            Add(btnNonBattle);

            Resize(WIDTH, (int)btnNonBattle.Bottom());
        }
コード例 #2
0
ファイル: WndSadGhost.cs プロジェクト: zvinch/SharpDungeon
        public WndSadGhost(Ghost ghost, Item item)
        {
            _ghost = ghost;
            _item  = item;
            var titlebar = new IconTitle();

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

            BitmapTextMultiline message = PixelScene.CreateMultiline(item is DriedRose ? TxtRose : TxtRat, 6);

            message.MaxWidth = WIDTH;
            message.Measure();
            message.Y = titlebar.Bottom() + GAP;
            Add(message);

            var btnWeapon = new RedButton(TxtWeapon);

            btnWeapon.ClickAction = WeaponClick;
            btnWeapon.SetRect(0, message.Y + message.Height + GAP, WIDTH, BTN_HEIGHT);
            Add(btnWeapon);

            var btnArmor = new RedButton(TxtArmor);

            btnArmor.ClickAction = ArmorClick;
            btnArmor.SetRect(0, btnWeapon.Bottom() + GAP, WIDTH, BTN_HEIGHT);
            Add(btnArmor);

            Resize(WIDTH, (int)btnArmor.Bottom());
        }
コード例 #3
0
        public WndImp(Imp imp, DwarfToken tokens)
        {
            _imp    = imp;
            _tokens = tokens;
            var titlebar = new IconTitle();

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

            BitmapTextMultiline message = PixelScene.CreateMultiline(TxtMessage, 6);

            message.MaxWidth = WIDTH;
            message.Measure();
            message.Y = titlebar.Bottom() + Gap;
            Add(message);

            var btnReward = new RedButton(TxtReward);

            btnReward.ClickAction = RewardClickAction;
            btnReward.SetRect(0, message.Y + message.Height + Gap, WIDTH, BtnHeight);
            Add(btnReward);

            Resize(WIDTH, (int)btnReward.Bottom());
        }
コード例 #4
0
ファイル: WndTradeItem.cs プロジェクト: zvinch/SharpDungeon
        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);
        }
コード例 #5
0
ファイル: WndItem.cs プロジェクト: zvinch/SharpDungeon
        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)));
        }
コード例 #6
0
        public WndBlacksmith(Blacksmith troll, Hero hero)
        {
            ItemSelector = new BlacksmithItemSelector(this);

            var titlebar = new IconTitle();

            titlebar.Icon(troll.Sprite);
            titlebar.Label(Utils.Capitalize(troll.Name));
            titlebar.SetRect(0, 0, WIDTH, 0);
            Add(titlebar);

            var message = PixelScene.CreateMultiline(TxtPrompt, 6);

            message.MaxWidth = WIDTH;
            message.Measure();
            message.Y = titlebar.Bottom() + Gap;
            Add(message);

            BtnItem1             = new ItemButton();
            BtnItem1.ClickAction = () =>
            {
                BtnPressed = BtnItem1;
                GameScene.SelectItem(ItemSelector, WndBag.Mode.UPGRADEABLE, TxtSelect);
            };
            BtnItem1.SetRect((WIDTH - BtnGap) / 2 - BtnSize, message.Y + message.Height + BtnGap, BtnSize, BtnSize);
            Add(BtnItem1);

            BtnItem2             = new ItemButton();
            BtnItem2.ClickAction = () =>
            {
                BtnPressed = BtnItem2;
                GameScene.SelectItem(ItemSelector, WndBag.Mode.UPGRADEABLE, TxtSelect);
            };
            BtnItem2.SetRect(BtnItem1.Right() + BtnGap, BtnItem1.Top(), BtnSize, BtnSize);
            Add(BtnItem2);

            BtnReforge             = new RedButton(TxtReforge);
            BtnReforge.ClickAction = button =>
            {
                troll.Upgrade(BtnItem1.Item, BtnItem2.Item);
                Hide();
            };
            BtnReforge.Enable(false);
            BtnReforge.SetRect(0, BtnItem1.Bottom() + BtnGap, WIDTH, 20);
            Add(BtnReforge);


            Resize(WIDTH, (int)BtnReforge.Bottom());
        }
コード例 #7
0
        public WndResurrect(Ankh ankh, object causeOfDeath)
        {
            Instance     = this;
            CauseOfDeath = causeOfDeath;

            var titlebar = new IconTitle();

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

            var message = PixelScene.CreateMultiline(TxtMessage, 6);

            message.MaxWidth = WIDTH;
            message.Measure();
            message.Y = titlebar.Bottom() + Gap;
            Add(message);


            var btnYes = new RedButton(TxtYes);

            btnYes.ClickAction = button =>
            {
                Hide();
                Statistics.AnkhsUsed++;
                InterlevelScene.mode = InterlevelScene.Mode.RESURRECT;
                Game.SwitchScene <InterlevelScene>();
            };
            btnYes.SetRect(0, message.Y + message.Height + Gap, WIDTH, BtnHeight);
            Add(btnYes);

            var btnNo = new RedButton(TxtNo);

            btnNo.ClickAction = button =>
            {
                Hide();
                Rankings.Instance.Submit(false);
                Hero.ReallyDie(causeOfDeath);
            };
            btnNo.SetRect(0, btnYes.Bottom() + Gap, WIDTH, BtnHeight);
            Add(btnNo);


            Resize(WIDTH, (int)btnNo.Bottom());
        }
コード例 #8
0
ファイル: WndRanking.cs プロジェクト: zvinch/SharpDungeon
            public StatsTab()
            {
                var heroClass = Dungeon.Hero.ClassName();

                var title = new IconTitle();

                title.Icon(HeroSprite.Avatar(Dungeon.Hero.heroClass, Dungeon.Hero.Tier()));
                title.Label(Utils.Format(TxtTitle, Dungeon.Hero.Lvl, heroClass).ToUpper(CultureInfo.CurrentCulture));
                title.SetRect(0, 0, WIDTH, 0);
                Add(title);

                float pos = title.Bottom();

                if (Dungeon.Challenges > 0)
                {
                    var btnCatalogus = new RedButton(TxtChallenges);
                    btnCatalogus.ClickAction = button => Game.Scene.Add(new WndChallenges(Dungeon.Challenges, false));
                    btnCatalogus.SetRect(0, pos + Gap, btnCatalogus.ReqWidth() + 2, btnCatalogus.ReqHeight() + 2);
                    Add(btnCatalogus);

                    pos = btnCatalogus.Bottom();
                }

                pos += Gap + Gap;

                pos = StatSlot(this, TxtStr, Dungeon.Hero.STR.ToString(), pos);
                pos = StatSlot(this, TxtHealth, Dungeon.Hero.HT.ToString(), pos);

                pos += Gap;

                pos = StatSlot(this, TxtDuration, ((int)Statistics.Duration).ToString(), pos);

                pos += Gap;

                pos = StatSlot(this, TxtDepth, Statistics.DeepestFloor.ToString(), pos);
                pos = StatSlot(this, TxtEnemies, Statistics.EnemiesSlain.ToString(), pos);
                pos = StatSlot(this, TxtGold, Statistics.GoldCollected.ToString(), pos);

                pos += Gap;

                pos = StatSlot(this, TxtFood, Statistics.FoodEaten.ToString(), pos);
                pos = StatSlot(this, TxtAlchemy, Statistics.PotionsCooked.ToString(), pos);
                pos = StatSlot(this, TxtAnkhs, Statistics.AnkhsUsed.ToString(), pos);
            }
コード例 #9
0
ファイル: WndInfoItem.cs プロジェクト: zvinch/SharpDungeon
        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));
        }
コード例 #10
0
ファイル: WndInfoPlant.cs プロジェクト: zvinch/SharpDungeon
        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));
        }
コード例 #11
0
ファイル: WndChooseWay.cs プロジェクト: zvinch/SharpDungeon
        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());
        }
コード例 #12
0
ファイル: WndInfoCell.cs プロジェクト: zvinch/SharpDungeon
        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));
        }