protected override void Drawing(ITerminal <TGlyph, TColor> terminal) { int itemWidth = Width - 1; int i = 0; foreach (var item in _items) { if (i > Height) { throw new Exception(); } terminal.DrawString(Left + 1, Top + i, item.Glyphs.Fit(itemWidth, EllipsisGlyph), ColorTheme.Foreground, ColorTheme.Background); if (_unselectedItemIndex.HasValue && item == _items[_unselectedItemIndex.Value]) { terminal.Clear(Left, Top + i); _unselectedItemIndex = null; } if (i == _selectedItemIndex) { terminal.Draw(Left, Top + i, SelectionGlyph, ColorTheme.Foreground, ColorTheme.Background); } i++; } }
public override Task <int> Handle(CArgument argument, ParserContext parser, PipelineContext pipeline, CancellationToken cancellationToken) { ITerminal terminal = pipeline.Services.GetTerminal(); terminal.Clear(); return(Task.FromResult(0)); }
public void Clear() { if (terminal != null) { terminal.Clear(); } }
protected override void OnPaint(ITerminal terminal) { terminal = terminal[TermColor.Gray, TermColor.DarkGray]; terminal.Clear(); // write the navigation text terminal[-Screen.UI.Title.Length, 0].Write(Screen.UI.Title); terminal[0, 0].Write(Screen.Title); }
protected override void OnPaint(ITerminal terminal) { terminal = terminal[TermColor.White, TermColor.DarkGray]; terminal.Clear(); // write the instruction terminal[0, 0][TermColor.LightGray].Write("Enter a number:"); if (mReplacing) { terminal[16, 0][TermColor.Black, TermColor.Yellow].Write(mText); } else { terminal[16, 0][TermColor.Yellow].Write(mText); terminal[16 + mText.Length, 0][TermColor.Black, TermColor.Yellow].Write(" "); } Stack <KeyInstruction> instructions = new Stack <KeyInstruction>(); instructions.Push(new KeyInstruction("Increment", new KeyInfo(Key.Up), new KeyInfo(Key.Down))); instructions.Push(new KeyInstruction("Min/Max", new KeyInfo(Key.Left), new KeyInfo(Key.Right))); instructions.Push(new KeyInstruction("Enter Digit", new KeyInfo(Key.Digit0), new KeyInfo(Key.Dash), new KeyInfo(Key.Digit9))); instructions.Push(new KeyInstruction("Cancel", new KeyInfo(Key.Escape))); instructions.Push(new KeyInstruction("Accept", new KeyInfo(Key.Enter))); // write the keys from right to left int x = terminal.Size.X; while (instructions.Count > 0) { KeyInstruction instruction = instructions.Pop(); // write the text x -= instruction.Instruction.Length; terminal[x, 0].Write(instruction.Instruction); // write the glyphs x--; for (int j = instruction.Keys.Length - 1; j >= 0; j--) { Glyph[] glyphs = instruction.Keys[j].DisplayGlyphs; for (int i = glyphs.Length - 1; i >= 0; i--) { x--; terminal[x, 0][TermColor.Yellow].Write(glyphs[i]); } } // put some space between each instruction x -= 2; } }
protected override void OnPaint(ITerminal terminal) { terminal.Clear(); // write the last few entries int startIndex = Math.Max(mLog.Entries.Count - terminal.Size.Y, 0); for (int index = startIndex; index < mLog.Entries.Count; index++) { WriteLog(terminal, mLog.Entries[index]); } }
private void DisplayPurchaseOrderSummary() { bool quit = false; while (!quit) { terminal.Clear(); terminal.WriteLine("Open Purchase Orders"); terminal.WriteLine(); foreach (PurchaseOrder order in purchaseOrderService.GetAllOpenPurchaseOrders()) { terminal.WriteLine("{0} : {2:C} / {1:C} for Supplier {3}", order.Id, order.MaxValue, order.TotalSpent, order.Supplier.Name); } terminal.WriteLine(); terminal.WriteLine(); terminal.WriteLine("[L]ist order [Q]uit"); switch (Console.ReadKey(true).Key) { case ConsoleKey.L: { terminal.Write("Enter id : "); int id = int.Parse(Console.ReadLine()); DisplayPurchaseOrder(id); } break; case ConsoleKey.Q: { quit = true; } break; } } }
protected override void OnPaint(ITerminal terminal) { terminal = terminal[TermColor.White, TermColor.DarkGray]; terminal.Clear(); // write the instruction terminal[0, 0][TermColor.LightGray].Write(Title); if (mValue) { terminal[Title.Length + 1, 0][TermColor.Yellow].Write("Yes"); } else { terminal[Title.Length + 1, 0][TermColor.Yellow].Write("No"); } Stack <KeyInstruction> instructions = new Stack <KeyInstruction>(); instructions.Push(new KeyInstruction("Yes", new KeyInfo(Key.Y, true))); instructions.Push(new KeyInstruction("No", new KeyInfo(Key.N, true))); instructions.Push(new KeyInstruction("Cancel", new KeyInfo(Key.Escape))); instructions.Push(new KeyInstruction("Accept", new KeyInfo(Key.Enter))); // write the keys from right to left int x = terminal.Size.X; while (instructions.Count > 0) { KeyInstruction instruction = instructions.Pop(); // write the text x -= instruction.Instruction.Length; terminal[x, 0].Write(instruction.Instruction); // write the glyphs x--; for (int j = instruction.Keys.Length - 1; j >= 0; j--) { Glyph[] glyphs = instruction.Keys[j].DisplayGlyphs; for (int i = glyphs.Length - 1; i >= 0; i--) { x--; terminal[x, 0][TermColor.Yellow].Write(glyphs[i]); } } // put some space between each instruction x -= 2; } }
protected override Task <int> Handle(CArgument argument, IConsole console, InvocationContext context, PipelineContext pipeline, CancellationToken cancellationToken) { ITerminal terminal = console.GetTerminal(); terminal.Clear(); terminal.SetCursorPosition(0, 0); if (console is SystemConsole) { System.Console.Clear(); System.Console.SetCursorPosition(0, 0); } return(Task.FromResult(0)); }
protected override void OnPaint(ITerminal terminal) { terminal.Clear(); terminal = terminal[TermColor.DarkGray]; terminal[65, 0, 1, terminal.Size.Y].DrawBox(); terminal[0, 31, 65, 1].DrawBox(); terminal[66, 31, 54, 1].DrawBox(); terminal[65, 31].Write(Glyph.BarUpDownLeftRight); terminal[14, 0, 1, 31].DrawBox(); terminal[14, 31].Write(Glyph.BarUpLeftRight); }
protected override void OnPaint(ITerminal terminal) { terminal.Clear(); var titleColor = HasFocus ? TermColor.White : TermColor.Gray; // draw the title switch (mViewing) { case Viewing.Inventory: terminal[titleColor].Write("Inventory"); break; case Viewing.Equipment: terminal[titleColor].Write("Equipment"); break; case Viewing.Ground: terminal[titleColor].Write("On Ground"); break; case Viewing.Store: terminal[titleColor].Write(mStore.Name); break; default: throw new UnexpectedEnumValueException(mViewing); } // draw the price title if (mStore != null) { terminal[new Vec(-6, 0)][titleColor].Write("Price"); } // draw the items int index = 0; foreach (Item item in Items) { // bail if we have too many to show if (index >= Bounds.Height) { break; } PaintItem(index, item); index++; } // clear the empty space for (; index < Items.Max; index++) { Vec pos = new Vec(0, index) + 1; terminal[pos][TermColor.DarkGray].Write(GetKey(index)); } }
protected override void OnPaint(ITerminal terminal) { terminal.Clear(); //### bob: hack, just warrior is supported Warrior warrior = (Warrior)mHero.Class; int y = 5; foreach (var lore in warrior.SlayLore) { terminal[10, y].Write(lore.Group); terminal[30, y].Write(lore.Slain.ToString()); terminal[40, y].Write(lore.Level.ToString()); y++; } }
protected override void OnPaint(ITerminal terminal) { terminal.Clear(); Monster monster = mThing as Monster; if (monster != null) { // draw the object terminal.Write(GameArt.Get(monster)); // draw its name terminal[2, 0].Write(monster.NounText); // draw its health if alive if (monster.Health.Current > 0) { for (int i = 0; i < 10; i++) { if (monster.Health.Current * 10 / monster.Health.Max >= i) { terminal[-10 + i, 0][TermColor.DarkRed].Write(Glyph.Solid); } else { terminal[-10 + i, 0][TermColor.DarkGray].Write(Glyph.Gray); } } } // draw its description CharacterString text = new CharacterString(monster.GetDescription(mHero), TermColor.LightGray, TermColor.Black); int y = 1; foreach (CharacterString line in text.WordWrap(terminal.Size.X)) { // bail if we run out of room if (y >= terminal.Size.Y) { break; } terminal[0, y++].Write(line); } } }
protected override void OnPaint(ITerminal terminal) { terminal.Clear(); terminal[0, 0][TermColor.Cyan].Write(mHero.Name); terminal[0, 1][TermColor.DarkCyan].Write(mHero.Race); terminal[0, 2][TermColor.DarkCyan].Write("Adventurer"); WriteStat(terminal, 4, "Level", mHero.Level); WriteMaxStat(terminal, 5, "Exp", mHero.Experience, (max) => (max / 100).ToString()); WriteStat(terminal, 6, "Next", mHero.NextExperience, TermColor.Gray); WriteStat(terminal, 8, "Health", mHero.Health); WriteMaxStat(terminal, 9, "Max", mHero.Health); WriteStat(terminal, 11, "Strength", mHero.Stats.Strength); WriteStat(terminal, 12, "Agility", mHero.Stats.Agility); WriteStat(terminal, 13, "Stamina", mHero.Stats.Stamina); WriteStat(terminal, 14, "Will", mHero.Stats.Will); WriteStat(terminal, 15, "Intellect", mHero.Stats.Intellect); WriteStat(terminal, 16, "Charisma", mHero.Stats.Charisma); WriteStat(terminal, 18, "Armor", mHero.Armor); terminal[0, 19][TermColor.Gray].Write("Resistances"); Vec pos = new Vec(0, 20); foreach (object value in Enum.GetValues(typeof(Element))) { Element element = (Element)value; WriteResist(terminal, element, pos); pos = pos.OffsetX(1); } terminal[0, 22][TermColor.Gray].Write("Currency"); terminal[0, 23][TermColor.Gold].Write(mHero.Currency.ToString("n0").PadLeft(13)); }
protected virtual void OnPaint(ITerminal terminal) { terminal.Clear(); }
public static void Clear(ITerminal terminal) { terminal.Clear(); }
protected override void OnPaint(ITerminal terminal) { terminal.Clear(); const int StrikeX = 3; const int DamageX = 9; const int DodgeX = 16; const int ArmorX = 23; const int ElemX = 27; const int StatX = 32; const int ResistX = 51; const int LabelX = 80; // draw the table terminal[0, 0, 80, 28][TermColor.DarkGray].DrawBox(); terminal[31, 0, 1, 28][TermColor.DarkGray].DrawBox(DrawBoxOptions.DoubleLines); terminal[50, 0, 1, 28][TermColor.DarkGray].DrawBox(DrawBoxOptions.DoubleLines); terminal[31, 0][TermColor.DarkGray].Write(Glyph.BarDoubleDownSingleLeftRight); terminal[50, 0][TermColor.DarkGray].Write(Glyph.BarDoubleDownSingleLeftRight); terminal[31, 27][TermColor.DarkGray].Write(Glyph.BarDoubleUpSingleLeftRight); terminal[50, 27][TermColor.DarkGray].Write(Glyph.BarDoubleUpSingleLeftRight); // write the header terminal[14, 0][TermColor.Gray].Write("Melee"); terminal[39, 0][TermColor.Gray].Write("Stats"); terminal[60, 0][TermColor.Gray].Write("Resistances"); terminal[1, 1].Write("Strike Damage Dodge Armor Elem"); terminal[StatX, 1].Write("StrAgiStaWilIntCha"); // write the elements in color int x = ResistX; foreach (Element element in Enum.GetValues(typeof(Element))) { terminal[x, 1][GameArt.GetColor(element)].Write(GameArt.GetAbbreviation2(element)); x += 2; } int y = 2; DrawRowLine(terminal, y++); // write the base values terminal[LabelX, y].Write("Base"); // melee terminal[StrikeX, y].Write(" 0"); terminal[DamageX, y].Write("x1.0"); terminal[DodgeX, y].Write(Hero.DodgeBase.ToString()); terminal[ArmorX, y].Write(" 0"); terminal[ElemX, y][GameArt.GetColor(Element.Anima)].Write(GameArt.GetAbbreviation4(Element.Anima)); // stats x = StatX; foreach (Stat stat in mHero.Stats) { terminal[x, y].Write(stat.Base.ToString().PadLeft(2)); x += 3; } // resists terminal[ResistX, y].Write("0 0 0 0 0 0 0 0 0 0 0 0 0 0"); y++; DrawRowLine(terminal, y++); // draw the equipment for (int i = 0; i < mHero.Equipment.Count; i++) { Item item = mHero.Equipment[i]; if (item != null) { terminal[LabelX, y].Write(item.ToString()); } else { terminal[LabelX, y][TermColor.DarkGray].Write(mHero.Equipment.GetCategory(i)); } // melee stats if (item != null) { // strike WriteBonus(terminal, StrikeX, y, item.StrikeBonus); // damage float bonus = item.DamageBonus; if (bonus < 1.0f) { terminal[DamageX, y][TermColor.Red].Write("x" + bonus.ToString("F2")); } else if (bonus == 1.0f) { terminal[DamageX, y][TermColor.DarkGray].Write(" - "); } else { terminal[DamageX, y][TermColor.Green].Write("x" + bonus.ToString("F2")); } // dodge terminal[DodgeX + 1, y][TermColor.DarkGray].Write(Glyph.Dash); // armor TermColor color = TermColor.White; if (item.ArmorBonus < 0) { color = TermColor.Red; } else if (item.ArmorBonus > 0) { color = TermColor.Green; } else if (item.TotalArmor == 0) { color = TermColor.DarkGray; } if (item.TotalArmor < 0) { terminal[ArmorX, y][color].Write(Glyph.ArrowDown); terminal[ArmorX + 1, y][color].Write(Math.Abs(item.TotalArmor).ToString()); } else if (item.TotalArmor == 0) { terminal[ArmorX + 1, y][color].Write(Glyph.Dash); } else { terminal[ArmorX, y][color].Write(Glyph.ArrowUp); terminal[ArmorX + 1, y][color].Write(item.TotalArmor.ToString()); } // element if (item.Attack != null) { Element element = item.Attack.Element; terminal[ElemX, y][GameArt.GetColor(element)].Write(GameArt.GetAbbreviation4(element)); } } // stat bonuses x = StatX; foreach (Stat stat in mHero.Stats) { if (item != null) { WriteBonus(terminal, x, y, item.GetStatBonus(stat)); } x += 3; } // resists x = ResistX; foreach (Element element in Enum.GetValues(typeof(Element))) { if (item != null) { if (item.Resists(element)) { terminal[x, y][TermColor.Green].Write(Glyph.ArrowUp); } else { terminal[x, y][TermColor.DarkGray].Write(Glyph.Dash); } } x += 2; } y++; } DrawRowLine(terminal, y++); // draw the stats foreach (Stat stat in mHero.Stats) { terminal[LabelX, y].Write(stat.Name); // melee bonuses // strike if (stat == mHero.Stats.Agility) { WriteBonus(terminal, StrikeX, y, mHero.Stats.Agility.StrikeBonus); } // damage if (stat == mHero.Stats.Strength) { float bonus = mHero.Stats.Strength.DamageBonus; if (bonus < 1.0f) { terminal[DamageX, y][TermColor.Red].Write("x" + bonus.ToString("F1")); } else if (bonus == 1.0f) { terminal[DamageX, y][TermColor.DarkGray].Write(" - "); } else { terminal[DamageX, y][TermColor.Green].Write("x" + bonus.ToString("F1")); } } // dodge if (stat == mHero.Stats.Agility) { WriteBonus(terminal, DodgeX, y, mHero.Stats.Agility.StrikeBonus); } // armor y++; } DrawRowLine(terminal, y++); terminal[LabelX, y].Write("Total"); // melee totals if (mHero.MeleeStrikeBonus < 0) { terminal[StrikeX, y][TermColor.Red].Write(mHero.MeleeStrikeBonus.ToString()); } else if (mHero.MeleeStrikeBonus == 0) { terminal[StrikeX + 1, y][TermColor.DarkGray].Write(Glyph.Digit0); } else { terminal[StrikeX, y][TermColor.Green].Write(Glyph.Plus); terminal[StrikeX + 1, y][TermColor.Green].Write(mHero.MeleeStrikeBonus.ToString()); } // damage if (mHero.MeleeDamageBonus < 1.0f) { terminal[DamageX, y][TermColor.Red].Write("x" + mHero.MeleeDamageBonus.ToString("F1")); } else if (mHero.MeleeDamageBonus == 1.0f) { terminal[DamageX, y][TermColor.DarkGray].Write("x" + mHero.MeleeDamageBonus.ToString("F1")); } else { terminal[DamageX, y][TermColor.Green].Write("x" + mHero.MeleeDamageBonus.ToString("F1")); } // dodge if (mHero.GetDodge() < Hero.DodgeBase) { terminal[DodgeX, y][TermColor.Red].Write(mHero.GetDodge().ToString()); } else { terminal[DodgeX, y].Write(mHero.GetDodge().ToString()); } // armor if (mHero.Armor < 0) { terminal[ArmorX, y][TermColor.Red].Write(mHero.Armor.ToString()); } else if (mHero.Armor == 0) { terminal[ArmorX + 1, y][TermColor.DarkGray].Write("0"); } else { terminal[ArmorX + 1, y][TermColor.Green].Write(mHero.Armor.ToString()); } // stat totals x = StatX; foreach (Stat stat in mHero.Stats) { if (stat.IsLowered) { terminal[x, y][TermColor.Red].Write(stat.Current.ToString().PadLeft(2)); } else if (stat.IsRaised) { terminal[x, y][TermColor.Green].Write(stat.Current.ToString().PadLeft(2)); } else { terminal[x, y].Write(stat.Current.ToString().PadLeft(2)); } x += 3; } // resistance totals x = ResistX; foreach (Element element in Enum.GetValues(typeof(Element))) { int resists = mHero.GetNumResists(element); if (resists == 0) { terminal[x, y].Write(Glyph.Digit0); } else { terminal[x, y][TermColor.Green].Write(resists.ToString()); } x += 2; } // element Element attackElement = Element.Anima; Item weapon = mHero.Equipment.MeleeWeapon; if (weapon != null) { if (weapon.Attack != null) { attackElement = weapon.Attack.Element; } } terminal[ElemX, y][GameArt.GetColor(attackElement)].Write(GameArt.GetAbbreviation4(attackElement)); y += 2; terminal[1, y].Write("A total armor of " + mHero.Armor + " reduces damage by " + (100 - (int)(100.0f * Entity.GetArmorReduction(mHero.Armor))) + "%."); }
protected override void OnPaint(ITerminal terminal) { terminal = terminal[TermColor.White, TermColor.DarkGray]; terminal.Clear(); // write the instruction string instruction = Screen.UI.Title; IFocusable focus = Screen.FocusControl; if (focus != null) { instruction = focus.Instruction; } else if (!String.IsNullOrEmpty(Screen.UI.CurrentScreen.Title)) { instruction = Screen.UI.CurrentScreen.Title; } terminal[0, 0][TermColor.LightGray].Write(instruction); Stack <KeyInstruction> instructions = new Stack <KeyInstruction>(); // get the focused control key instructions IInputHandler input = Screen.FocusControl as IInputHandler; if (input != null) { foreach (KeyInstruction keyInstruction in input.KeyInstructions) { instructions.Push(keyInstruction); } } else { foreach (Control control in Screen.Controls) { input = control as IInputHandler; if (input != null) { foreach (KeyInstruction keyInstruction in input.KeyInstructions) { instructions.Push(keyInstruction); } } } } // get the screen control keys IInputHandler screen = Screen as IInputHandler; if (screen != null) { foreach (KeyInstruction keyInstruction in screen.KeyInstructions) { instructions.Push(keyInstruction); } } // write the keys from right to left int x = terminal.Size.X; while (instructions.Count > 0) { KeyInstruction keyInstruction = instructions.Pop(); // write the text x -= keyInstruction.Instruction.Length; terminal[x, 0].Write(keyInstruction.Instruction); // write the glyphs x--; for (int j = keyInstruction.Keys.Length - 1; j >= 0; j--) { Glyph[] glyphs = keyInstruction.Keys[j].DisplayGlyphs; for (int i = glyphs.Length - 1; i >= 0; i--) { x--; terminal[x, 0][TermColor.Yellow].Write(glyphs[i]); } } // put some space between each instruction x -= 2; } }
protected override void OnPaint(ITerminal terminal) { terminal.Clear(); terminal[0, 0, 50, 1][TermColor.DarkGray].DrawBox(); // write the conditions int x = 1; // disease if (mGame.Hero.Health.HasBonus(BonusType.Disease)) { terminal[x, 0][TermColor.Purple].Write("Disease"); x += "Disease ".Length; } // poison if (mGame.Hero.Conditions.Poison.IsActive) { terminal[x, 0][TermColor.DarkGreen].Write("Poison"); x += "Poison ".Length; } // slow if (mGame.Hero.Conditions.Slow.IsActive) { terminal[x, 0][TermColor.Brown].Write("Slow"); x += "Slow ".Length; } // freeze if (mGame.Hero.Conditions.Freeze.IsActive) { terminal[x, 0][TermColor.LightBlue].Write("Freeze"); x += "Freeze ".Length; } // haste if (mGame.Hero.Conditions.Haste.IsActive) { terminal[x, 0][TermColor.Orange].Write("Haste"); x += "Haste ".Length; } // speed int speed = mGame.Hero.Speed - Energy.NormalSpeed; if (mGame.Hero.Speed != Energy.NormalSpeed) { string speedText = String.Empty; switch (mGame.Hero.Speed) { case 0: speedText = "Slow 1/4x"; break; case 1: speedText = "Slow 1/3x"; break; case 2: speedText = "Slow 2/5x"; break; case 3: speedText = "Slow 1/2x"; break; case 4: speedText = "Slow 2/3x"; break; case 5: speedText = "Slow 5/6x"; break; case 7: speedText = "Fast 4/3x"; break; case 8: speedText = "Fast 5/3"; break; case 9: speedText = "Fast 2x"; break; case 10: speedText = "Fast 5/2x"; break; case 11: speedText = "Fast 3x"; break; case 12: speedText = "Fast 4x"; break; } if (speed > Energy.NormalSpeed) { terminal[x, 0][TermColor.Green].Write(speedText); x += speedText.Length + 1; } else { terminal[x, 0][TermColor.Orange].Write(speedText); x += speedText.Length + 1; } } // write the floor terminal[41, 0][TermColor.Gray].Write("Depth:"); terminal[47, 0][TermColor.Cyan].Write(mGame.Depth.ToString()); }
public override void Clear(int x, int y) { _terminal.Clear(x + _offsetX, y + _offsetY); }