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()); }
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 WndTradeItem(Heap heap, bool canBuy) { _heap = heap; var item = heap.Peek(); var pos = CreateDescription(item, true); var price = Price(item); if (canBuy) { var btnBuy = new RedButton(Utils.Format(TxtBuy, price)); btnBuy.ClickAction = BuyAction; btnBuy.SetRect(0, pos + Gap, WIDTH, BtnHeight); btnBuy.Enable(price <= Dungeon.Gold); Add(btnBuy); var btnCancel = new RedButton(TxtCancel); btnCancel.ClickAction = CancelAction; btnCancel.SetRect(0, btnBuy.Bottom() + Gap, WIDTH, BtnHeight); Add(btnCancel); Resize(WIDTH, (int)btnCancel.Bottom()); } else { Resize(WIDTH, (int)pos); } }
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 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()); }
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); }
public WndTradeItem(Shopkeeper keeper, Item item, WndBag owner) { _keeper = keeper; _item = item; _owner = owner; var pos = CreateDescription(item, false); if (item.Quantity() == 1) { var btnSell = new RedButton(Utils.Format(TxtSell, item.Price())); btnSell.ClickAction = SellAction; btnSell.SetRect(0, pos + Gap, WIDTH, BtnHeight); Add(btnSell); pos = btnSell.Bottom(); } else { var priceAll = item.Price(); var btnSell1 = new RedButton(Utils.Format(TxtSell1, priceAll / item.Quantity())); btnSell1.ClickAction = SellOneAction; btnSell1.SetRect(0, pos + Gap, WIDTH, BtnHeight); Add(btnSell1); var btnSellAll = new RedButton(Utils.Format(TxtSellAll, priceAll)); btnSellAll.ClickAction = SellAction; btnSellAll.SetRect(0, btnSell1.Bottom() + Gap, WIDTH, BtnHeight); Add(btnSellAll); pos = btnSellAll.Bottom(); } var btnCancel = new RedButton(TxtCancel); btnCancel.ClickAction = CancelAction; btnCancel.SetRect(0, pos + Gap, WIDTH, BtnHeight); Add(btnCancel); Resize(WIDTH, (int)btnCancel.Bottom()); }
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 StatsTab(WndHero wndHero) { _wndHero = wndHero; var hero = Dungeon.Hero; var title = PixelScene.CreateText(Utils.Format(TXT_TITLE, hero.Lvl, hero.ClassName()).ToUpper(), 9); title.Hardlight(TitleColor); title.Measure(); Add(title); var btnCatalogus = new RedButton(TXT_CATALOGUS); btnCatalogus.ClickAction = CatalogusClickAction; btnCatalogus.SetRect(0, title.Y + title.Height, btnCatalogus.ReqWidth() + 2, btnCatalogus.ReqHeight() + 2); Add(btnCatalogus); var btnJournal = new RedButton(TXT_JOURNAL); btnJournal.ClickAction = JournalClickAction; btnJournal.SetRect(btnCatalogus.Right() + 1, btnCatalogus.Top(), btnJournal.ReqWidth() + 2, btnJournal.ReqHeight() + 2); Add(btnJournal); pos = btnCatalogus.Bottom() + GAP; StatSlot(TXT_STR, hero.STR); StatSlot(TXT_HEALTH, hero.HP + "/" + hero.HT); StatSlot(TXT_EXP, hero.Exp + "/" + hero.MaxExp()); pos += GAP; StatSlot(TXT_GOLD, Statistics.GoldCollected); StatSlot(TXT_DEPTH, Statistics.DeepestFloor); pos += GAP; }
public WndSettings(bool inGame) { CheckBox btnImmersive = null; if (inGame) { var w = BtnHeight; _btnZoomOut = new RedButton(TxtZoomOut); _btnZoomOut.ClickAction = button => Zoom(pdsharp.noosa.Camera.Main.Zoom - 1); Add(_btnZoomOut.SetRect(0, 0, w, BtnHeight)); _btnZoomIn = new RedButton(TxtZoomIn); _btnZoomIn.ClickAction = button => Zoom(pdsharp.noosa.Camera.Main.Zoom + 1); Add(_btnZoomIn.SetRect(WIDTH - w, 0, w, BtnHeight)); var btnZoomDefault = new RedButton(TxtZoomDefault); btnZoomDefault.ClickAction = button => Zoom(PixelScene.defaultZoom); btnZoomDefault.SetRect(_btnZoomOut.Right(), 0, WIDTH - _btnZoomIn.Width - _btnZoomOut.Width, BtnHeight); Add(btnZoomDefault); } else { var btnScaleUp = new CheckBox(TxtScaleUp); btnScaleUp.ClickAction = ScaleUpClick; btnScaleUp.SetRect(0, 0, WIDTH, BtnHeight); btnScaleUp.SetChecked(PixelDungeon.ScaleUp()); Add(btnScaleUp); btnImmersive = new CheckBox(TxtImmersive); btnImmersive.ClickAction = ImmersiveClick; btnImmersive.SetRect(0, btnScaleUp.Bottom() + Gap, WIDTH, BtnHeight); btnImmersive.SetChecked(PixelDungeon.Immersed()); btnImmersive.Enable(Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat); Add(btnImmersive); } var btnMusic = new CheckBox(TxtMusic); btnMusic.ClickAction = button => { var checkBox = button as CheckBox; PixelDungeon.Music(checkBox != null && checkBox.Checked()); }; btnMusic.SetRect(0, (btnImmersive != null ? btnImmersive.Bottom() : BtnHeight) + Gap, WIDTH, BtnHeight); btnMusic.SetChecked(PixelDungeon.Music()); Add(btnMusic); var btnSound = new CheckBox(TxtSound); btnSound.ClickAction = SoundClick; btnSound.SetRect(0, btnMusic.Bottom() + Gap, WIDTH, BtnHeight); btnSound.SetChecked(PixelDungeon.SoundFx()); Add(btnSound); if (!inGame) { var btnOrientation = new RedButton(OrientationText()); btnOrientation.ClickAction = OrientationClick; btnOrientation.SetRect(0, btnSound.Bottom() + Gap, WIDTH, BtnHeight); Add(btnOrientation); Resize(WIDTH, (int)btnOrientation.Bottom()); } else { var btnBrightness = new CheckBox(TxtBrightness); btnBrightness.ClickAction = button => { var checkBox = button as CheckBox; PixelDungeon.Brightness(checkBox != null && checkBox.Checked()); }; btnBrightness.SetRect(0, btnSound.Bottom() + Gap, WIDTH, BtnHeight); btnBrightness.SetChecked(PixelDungeon.Brightness()); Add(btnBrightness); Resize(WIDTH, (int)btnBrightness.Bottom()); } }
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()); }
private void AddButton(RedButton btn) { Add(btn); btn.SetRect(0, _pos > 0 ? _pos += Gap : 0, WIDTH, BtnHeight); _pos += BtnHeight; }