Beispiel #1
0
        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());
        }
Beispiel #2
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());
        }
        public WndTitledMessage(Component titlebar, string message)
        {
            titlebar.SetRect(0, 0, WIDTH, 0);
            Add(titlebar);

            var hl = new Highlighter(message);

            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();

                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);
            }

            Resize(WIDTH, (int)(normal.Y + normal.Height));
        }
Beispiel #4
0
        protected override void CreateChildren()
        {
            ImIcon = new Image();
            Add(ImIcon);

            TfLabel = PixelScene.CreateMultiline(FontSize);
            TfLabel.Hardlight(Window.TitleColor);
            Add(TfLabel);
        }
Beispiel #5
0
        public static BitmapTextMultiline CreateMultiline(string text, float size)
        {
            ChooseFont(size);

            var result = new BitmapTextMultiline(text, font);

            result.Scale.Set(scale);

            return(result);
        }
Beispiel #6
0
        public void OnSignal(string text)
        {
            var color = CharSprite.Default;

            if (text.StartsWith(GLog.POSITIVE))
            {
                text  = text.Substring(GLog.POSITIVE.Length);
                color = CharSprite.Positive;
            }
            else
            if (text.StartsWith(GLog.NEGATIVE))
            {
                text  = text.Substring(GLog.NEGATIVE.Length);
                color = CharSprite.Negative;
            }
            else
            if (text.StartsWith(GLog.WARNING))
            {
                text  = text.Substring(GLog.WARNING.Length);
                color = CharSprite.Warning;
            }
            else
            if (text.StartsWith(GLog.HIGHLIGHT))
            {
                text  = text.Substring(GLog.HIGHLIGHT.Length);
                color = CharSprite.Neutral;
            }

            text = Utils.Capitalize(text) + (Punctuation.Matcher(text).Matches() ? "" : ".");

            if (_lastEntry != null && color == _lastColor)
            {
                var lastMessage = _lastEntry.Text();
                _lastEntry.Text(lastMessage.Length == 0 ? text : lastMessage + " " + text);
                _lastEntry.Measure();
            }
            else
            {
                _lastEntry          = PixelScene.CreateMultiline(text, 6);
                _lastEntry.MaxWidth = (int)Width;
                _lastEntry.Measure();
                _lastEntry.Hardlight(color);
                _lastColor = color;
                Add(_lastEntry);
            }

            if (Members.Count > MaxMessages)
            {
                Remove(Members[0]);
            }

            Layout();
        }
Beispiel #7
0
            protected override void CreateChildren()
            {
                base.CreateChildren();

                _shield = new ItemSprite(ItemSpriteSheet.TOMB, null);
                Add(_shield);

                _position = new BitmapText(font1x);
                Add(_position);

                _desc = CreateMultiline(9);
                Add(_desc);

                _classIcon = new Image();
                Add(_classIcon);
            }
Beispiel #8
0
        public WndStory(string text)
            : base(0, 0, sharpdungeon.Chrome.Get(sharpdungeon.Chrome.Type.SCROLL))
        {
            _tf          = PixelScene.CreateMultiline(text, 7);
            _tf.MaxWidth = WIDTH - MARGIN * 2;
            _tf.Measure();
            _tf.RA = bgR;
            _tf.Ga = bgG;
            _tf.Ba = bgB;
            _tf.Rm = -bgR;
            _tf.Gm = -bgG;
            _tf.Bm = -bgB;
            _tf.X  = MARGIN;
            Add(_tf);

            var touchArea = new TouchArea(Chrome);

            touchArea.ClickAction = (touch) => Hide();

            Resize((int)(_tf.Width + MARGIN * 2), (int)Math.Min(_tf.Height, 180));
        }
Beispiel #9
0
 public virtual void NewLine()
 {
     _lastEntry = null;
 }
Beispiel #10
0
        public override void Create()
        {
            base.Create();

            BitmapTextMultiline text = null;

            if (!NoText)
            {
                text          = CreateMultiline(Txt, 8);
                text.MaxWidth = WIDTH;
                text.Measure();
                Add(text);
            }

            _amulet = new Image(Assets.AMULET);
            Add(_amulet);

            var btnExit = new RedButton(TxtExit);

            btnExit.ClickAction = button =>
            {
                Dungeon.Win(ResultDescriptions.WIN);
                Dungeon.DeleteGame(Dungeon.Hero.heroClass, true);
                if (NoText)
                {
                    Game.SwitchScene <TitleScene>();
                }
                else
                {
                    Game.SwitchScene <RankingsScene>();
                }
            };
            btnExit.SetSize(WIDTH, BtnHeight);
            Add(btnExit);

            var btnStay = new RedButton(TxtStay);

            btnStay.ClickAction = button => OnBackPressed();
            btnStay.SetSize(WIDTH, BtnHeight);
            Add(btnStay);

            float height;

            if (NoText)
            {
                height = _amulet.Height + LargeGap + btnExit.Height + SmallGap + btnStay.Height;

                _amulet.X = Align((Camera.Main.CameraWidth - _amulet.Width) / 2);
                _amulet.Y = Align((Camera.Main.CameraHeight - height) / 2);

                btnExit.SetPos((Camera.Main.CameraWidth - btnExit.Width) / 2, _amulet.Y + _amulet.Height + LargeGap);
                btnStay.SetPos(btnExit.Left(), btnExit.Bottom() + SmallGap);
            }
            else
            {
                height = _amulet.Height + LargeGap + text.Height + LargeGap + btnExit.Height + SmallGap + btnStay.Height;

                _amulet.X = Align((Camera.Main.CameraWidth - _amulet.Width) / 2);
                _amulet.Y = Align((Camera.Main.CameraHeight - height) / 2);

                text.X = Align((Camera.Main.CameraWidth - text.Width) / 2);
                text.Y = _amulet.Y + _amulet.Height + LargeGap;

                btnExit.SetPos((Camera.Main.CameraWidth - btnExit.Width) / 2, text.Y + text.Height + LargeGap);
                btnStay.SetPos(btnExit.Left(), btnExit.Bottom() + SmallGap);
            }

            new Flare(8, 48).Color(0xFFDDBB, true).Show(_amulet, 0).AngularSpeed = +30;

            FadeIn();
        }