private static void DisplayBadge(Badge badge) { if (badge == null) { return; } if (_global.Contains(badge)) { if (!badge.Meta) { GLog.Highlight("Badge endorsed: {0}", badge.Description); } } else { _global.Add(badge); _saveNeeded = true; if (badge.Meta) { GLog.Highlight("New super badge: {0}", badge.Description); } else { GLog.Highlight("New badge: {0}", badge.Description); } PixelScene.ShowBadge(badge); } }
public static void ValidateSupporter() { _global.Add(SUPPORTER); _saveNeeded = true; PixelScene.ShowBadge(SUPPORTER); }
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); }
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 WndChallenges(int isChecked, bool editable) { _editable = editable; var title = PixelScene.CreateText(Title, 9); title.Hardlight(TitleColor); title.Measure(); title.X = PixelScene.Align(Camera, (WIDTH - title.Width) / 2); Add(title); _boxes = new List <CheckBox>(); var pos = title.Height + Gap; for (var i = 0; i < Challenges.NAMES.Length; i++) { var cb = new CheckBox(Challenges.NAMES[i]); cb.SetChecked((isChecked & Challenges.MASKS[i]) != 0); cb.Active = editable; if (i > 0) { pos += Gap; } cb.SetRect(0, pos, WIDTH, BtnHeight); pos = cb.Bottom(); Add(cb); _boxes.Add(cb); } Resize(WIDTH, (int)pos); }
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()); }
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)); }
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()); }
protected override void Layout() { _Height = 32; _shield.Size(Width, _shield.Height); _avatar.X = PixelScene.Align(Camera, _shield.X + 15 - _avatar.Width / 2); _avatar.Y = PixelScene.Align(Camera, _shield.Y + 16 - _avatar.Height / 2); _compass.X = _avatar.X + _avatar.Width / 2 - _compass.Origin.X; _compass.Y = _avatar.Y + _avatar.Height / 2 - _compass.Origin.Y; _hp.X = 30; _hp.Y = 3; _depth.X = Width - 24 - _depth.Width - 18; _depth.Y = 6; _keys.Y = 6; _danger.SetPos(Width - _danger.Width, 20); _loot.SetPos(Width - _loot.Width, _danger.Bottom() + 2); _buffs.SetPos(32, 11); _btnMenu.SetPos(Width - _btnMenu.Width, 1); }
public WndBadge(Badge badge) { var icon = BadgeBanner.Image(badge.Image); icon.Scale.Set(2); Add(icon); var info = PixelScene.CreateMultiline(badge.Description, 8); info.MaxWidth = WIDTH - MARGIN * 2; info.Measure(); var w = Math.Max(icon.Width, info.Width) + MARGIN * 2; icon.X = (w - icon.Width) / 2; icon.Y = MARGIN; var pos = icon.Y + icon.Height + MARGIN; foreach (var line in new LineSplitter(info.Font, info.Scale, info.Text()).Split()) { line.Measure(); line.X = PixelScene.Align((w - line.Width) / 2); line.Y = PixelScene.Align(pos); Add(line); pos += line.Height; } Resize((int)w, (int)(pos + MARGIN)); BadgeBanner.Highlight(icon, badge.Image); }
public WndJournal() { Resize(WIDTH, HEIGHT); txtTitle = PixelScene.CreateText(TxtTitle, 9); txtTitle.Hardlight(TitleColor); txtTitle.Measure(); txtTitle.X = PixelScene.Align(PixelScene.uiCamera, (WIDTH - txtTitle.Width) / 2); Add(txtTitle); var content = new Component(); Collections.Sort(Journal.Records); float pos = 0; foreach (var rec in Journal.Records) { var item = new ListItem(rec.feature, rec.depth); item.SetRect(0, pos, WIDTH, ItemHeight); content.Add(item); pos += item.Height; } content.SetSize(WIDTH, pos); list = new ScrollPane(content); Add(list); list.SetRect(0, txtTitle.Height, WIDTH, HEIGHT - txtTitle.Height); }
public WndCatalogus() { Resize(WIDTH, HEIGHT); _txtTitle = PixelScene.CreateText(TxtTitle, 9); _txtTitle.Hardlight(TitleColor); _txtTitle.Measure(); Add(_txtTitle); _list = new ScrollPane(new Component()); _list.ClickAction = ListClick; Add(_list); _list.SetRect(0, _txtTitle.Height, WIDTH, HEIGHT - _txtTitle.Height); var potionTab = new LabeledTab(this, TxtPotions); potionTab.SelectAction = PotionTabSelect; Tabs.Add(potionTab); var scrollTab = new LabeledTab(this, TxtPotions); scrollTab.SelectAction = ScrollTabSelect; Tabs.Add(potionTab); foreach (var tab in Tabs) { tab.SetSize(TabWidth, TabHeight()); Add(tab); } Select(ShowPotions ? 0 : 1); }
protected override void Layout() { _sprite.Y = PixelScene.Align(Y + (Height - _sprite.Height) / 2); _label.X = _sprite.X + _sprite.Width; _label.Y = PixelScene.Align(Y + (Height - _label.BaseLine()) / 2); }
private void UpdateList() { _txtTitle.Text(Utils.Format(TxtTitle, ShowPotions ? TxtPotions : TxtScrolls)); _txtTitle.Measure(); _txtTitle.X = PixelScene.Align(PixelScene.uiCamera, (WIDTH - _txtTitle.Width) / 2); _items.Clear(); var content = _list.Content(); content.Clear(); _list.ScrollTo(0, 0); float pos = 0; HashSet <Type> known; if (ShowPotions) { known = Potion.GetKnown; } else { known = Scroll.GetKnown; } foreach (var itemClass in known) { var item = new ListItem(itemClass); item.SetRect(0, pos, WIDTH, ItemHeight); content.Add(item); _items.Add(item); pos += item.Height; } HashSet <Type> unknown; if (ShowPotions) { unknown = Potion.GetUnknown; } else { unknown = Scroll.GetUnknown; } foreach (var itemClass in unknown) { var item = new ListItem(itemClass); item.SetRect(0, pos, WIDTH, ItemHeight); content.Add(item); _items.Add(item); pos += item.Height; } content.SetSize(WIDTH, pos); }
public FloatingText() { PixelScene.ChooseFont(9); font = PixelScene.font; Scale.Set(PixelScene.scale); Speed.Y = -Distance / Lifespan; }
protected override void CreateChildren() { _icon = new Image(); Add(_icon); _label = PixelScene.CreateText(6); Add(_label); }
protected override void CreateChildren() { base.CreateChildren(); _btLabel = PixelScene.CreateText(9); Add(_btLabel); }
protected override void Layout() { _icon.X = X; _icon.Y = PixelScene.Align(Y + (Height - _icon.Height) / 2); _label.X = _icon.X + _icon.Width + 2; _label.Y = PixelScene.Align(Y + (Height - _label.BaseLine()) / 2); }
protected override void CreateChildren() { _sprite = new ItemSprite(); Add(_sprite); _label = PixelScene.CreateText(8); Add(_label); }
protected override void CreateChildren() { ImIcon = new Image(); Add(ImIcon); TfLabel = PixelScene.CreateMultiline(FontSize); TfLabel.Hardlight(Window.TitleColor); Add(TfLabel); }
protected override void Layout() { base.Layout(); slot.Fill(this); _crossB.X = PixelScene.Align(X + (Width - _crossB.Width) / 2); _crossB.Y = PixelScene.Align(Y + (Height - _crossB.Height) / 2); }
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))); }
protected override void CreateChildren() { base.CreateChildren(); Bg = Chrome.Get(Chrome.Type.BUTTON); Add(Bg); InternalText = PixelScene.CreateText(9); Add(InternalText); }
public MasteryTab(HeroClass cl) { string text = null; switch (cl.Ordinal()) { case HeroClassType.Warrior: text = HeroSubClass.GLADIATOR.Desc + "\\Negative\\Negative" + HeroSubClass.BERSERKER.Desc; break; case HeroClassType.Mage: text = HeroSubClass.BATTLEMAGE.Desc + "\\Negative\\Negative" + HeroSubClass.WARLOCK.Desc; break; case HeroClassType.Rogue: text = HeroSubClass.FREERUNNER.Desc + "\\Negative\\Negative" + HeroSubClass.ASSASSIN.Desc; break; case HeroClassType.Huntress: text = HeroSubClass.SNIPER.Desc + "\\Negative\\Negative" + HeroSubClass.WARDEN.Desc; break; default: throw new ArgumentOutOfRangeException(); } var hl = new Highlighter(text); var normal = PixelScene.CreateMultiline(hl.Text, 6); normal.MaxWidth = WIDTH - MARGIN * 2; normal.Measure(); normal.X = MARGIN; normal.Y = MARGIN; 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); } Height = normal.Y + normal.Height + MARGIN; Width = normal.X + normal.Width + MARGIN; }
public WndMessage(string text) { var info = PixelScene.CreateMultiline(text, 6); info.MaxWidth = WIDTH - MARGIN * 2; info.Measure(); info.X = info.Y = MARGIN; Add(info); Resize((int)info.Width + MARGIN * 2, (int)info.Height + MARGIN * 2); }
protected override void CreateChildren() { _feature = PixelScene.CreateText(9); Add(_feature); _depth = new BitmapText(PixelScene.font1x); Add(_depth); _icon = Icons.DEPTH.Get(); Add(_icon); }
protected override void Layout() { base.Layout(); float margin = (Height - InternalText.BaseLine()) / 2; InternalText.X = PixelScene.Align(PixelScene.uiCamera, X + margin); InternalText.Y = PixelScene.Align(PixelScene.uiCamera, Y + margin); InternalIcon.X = PixelScene.Align(PixelScene.uiCamera, X + Width - margin - InternalIcon.Width); InternalIcon.Y = PixelScene.Align(PixelScene.uiCamera, Y + (Height - InternalIcon.Height) / 2); }
protected override void Layout() { base.Layout(); _btLabel.X = PixelScene.Align(X + (Width - _btLabel.Width) / 2); _btLabel.X = PixelScene.Align(Y + (Height - _btLabel.BaseLine()) / 2) - 1; if (!Selected) { _btLabel.Y -= 2; } }
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(); }
protected override void Layout() { _icon.X = Width - _icon.Width; _depth.X = _icon.Y - 1 - _depth.Width; _depth.Y = PixelScene.Align(Y + (Height - _depth.Height) / 2); _icon.Y = _depth.Y - 1; _feature.Y = PixelScene.Align(_depth.Y + _depth.BaseLine() - _feature.BaseLine()); }