Ejemplo n.º 1
0
            public RecordButton(int pos, bool latest, Record rec)
            {
                _rec = rec;

                if (latest)
                {
                    _flare = new Flare(6, 24);
                    _flare.AngularSpeed = 90;
                    _flare.Color(rec.win ? FlareWin : FlareLose);
                    AddToBack(_flare);
                }

                _position.Text((pos + 1).ToString());
                _position.Measure();

                _desc.Text(rec.info);
                _desc.Measure();

                if (rec.win)
                {
                    _shield.View(ItemSpriteSheet.AMULET, null);
                    _position.Hardlight(TextWin);
                    _desc.Hardlight(TextWin);
                }
                else
                {
                    _position.Hardlight(TextLose);
                    _desc.Hardlight(TextLose);
                }

                _classIcon.Copy(IconsExtensions.Get(rec.heroClass));
            }
Ejemplo n.º 2
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());
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
0
        protected override void Layout()
        {
            ImIcon.X = 0;
            ImIcon.Y = 0;

            TfLabel.X        = PixelScene.Align(PixelScene.uiCamera, ImIcon.X + ImIcon.Width + Gap);
            TfLabel.MaxWidth = (int)(Width - TfLabel.X);
            TfLabel.Measure();
            TfLabel.Y = PixelScene.Align(PixelScene.uiCamera, ImIcon.Height > TfLabel.Height ? (ImIcon.Height - TfLabel.BaseLine()) / 2 : ImIcon.Y);

            _Height = Math.Max(ImIcon.Y + ImIcon.Height, TfLabel.Y + TfLabel.Height);
        }
Ejemplo n.º 7
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));
        }
Ejemplo n.º 8
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();
        }