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 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)); }
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 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()); }
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()); }
protected override void CreateChildren() { ImIcon = new Image(); Add(ImIcon); TfLabel = PixelScene.CreateMultiline(FontSize); TfLabel.Hardlight(Window.TitleColor); Add(TfLabel); }
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))); }
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); }
public WndBalance(Weapon weapon) { var titlebar = new IconTitle(weapon); titlebar.SetRect(0, 0, WIDTH, 0); Add(titlebar); var tfMesage = PixelScene.CreateMultiline(Utils.Format(TXT_CHOICE, weapon.Name), 8); tfMesage.MaxWidth = WIDTH - MARGIN * 2; tfMesage.Measure(); tfMesage.X = MARGIN; tfMesage.Y = titlebar.Bottom() + MARGIN; Add(tfMesage); var pos = tfMesage.Y + tfMesage.Height; if (weapon.imbue != Weapon.Imbue.Speed) { var btnSpeed = new RedButton(TXT_SPEED); btnSpeed.ClickAction = button => { Hide(); Apply(weapon, true); }; btnSpeed.SetRect(MARGIN, pos + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT); Add(btnSpeed); pos = btnSpeed.Bottom(); } if (weapon.imbue != Weapon.Imbue.Accuracy) { var btnAccuracy = new RedButton(TXT_ACCURACY); btnAccuracy.ClickAction = button => { Hide(); Apply(weapon, false); }; btnAccuracy.SetRect(MARGIN, pos + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT); Add(btnAccuracy); pos = btnAccuracy.Bottom(); } var btnCancel = new RedButton(TXT_CANCEL); btnCancel.ClickAction = button => Hide(); btnCancel.SetRect(MARGIN, pos + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT); Add(btnCancel); Resize(WIDTH, (int)btnCancel.Bottom() + MARGIN); }
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(); }
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()); }
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()); }
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)); }
public PerksTab(HeroClass cl) { float dotWidth = 0; var items = cl.Perks(); float pos = MARGIN; for (var i = 0; i < items.Length; i++) { if (i > 0) { pos += GAP; } var dot = PixelScene.CreateText(DOT, 6); dot.X = MARGIN; dot.Y = pos; if (dotWidth == 0) { dot.Measure(); dotWidth = dot.Width; } Add(dot); var item = PixelScene.CreateMultiline(items[i], 6); item.X = dot.X + dotWidth; item.Y = pos; item.MaxWidth = (int)(WIDTH - MARGIN * 2 - dotWidth); item.Measure(); Add(item); pos += item.Height; var w = item.Width; if (w > Width) { Width = w; } } Width += MARGIN + dotWidth; Height = pos + MARGIN; }
public WndList(IList <string> items) { float pos = Margin; float dotWidth = 0; float maxWidth = 0; for (var i = 0; i < items.Count; i++) { if (i > 0) { pos += Gap; } var dot = PixelScene.CreateText(Dot, 6); dot.X = Margin; dot.Y = pos; if (Math.Abs(dotWidth) < 0.0001) { dot.Measure(); dotWidth = dot.Width; } Add(dot); var item = PixelScene.CreateMultiline(items[i], 6); item.X = dot.X + dotWidth; item.Y = pos; item.MaxWidth = (int)(LocalWidth - Margin * 2 - dotWidth); item.Measure(); Add(item); pos += item.Height; var w = item.Width; if (w > maxWidth) { maxWidth = w; } } Resize((int)(maxWidth + dotWidth + Margin * 2), (int)(pos + Margin)); }
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)); }
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)); }
public WndOptions(string title, string message, params string[] options) { var tfTitle = PixelScene.CreateMultiline(title, 9); tfTitle.Hardlight(TitleColor); tfTitle.X = tfTitle.Y = Margin; tfTitle.MaxWidth = WIDTH - Margin * 2; tfTitle.Measure(); Add(tfTitle); var tfMesage = PixelScene.CreateMultiline(message, 8); tfMesage.MaxWidth = WIDTH - Margin * 2; tfMesage.Measure(); tfMesage.X = Margin; tfMesage.Y = tfTitle.Y + tfTitle.Height + Margin; Add(tfMesage); var pos = tfMesage.Y + tfMesage.Height + Margin; var i = 0; foreach (var option in options) { var btn = new RedButton(option); btn.Index = 1; btn.ClickAction = (button) => { Hide(); OnSelect(button.Index); }; btn.SetRect(Margin, pos, WIDTH - Margin * 2, ButtonHeight); Add(btn); pos += ButtonHeight + Margin; i++; } Resize(WIDTH, (int)pos); }
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()); }
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)); }