private void colorsListBox_SelectedItemChanged(object sender, ListBox.SelectedItemEventArgs e) { if (e.Item != null) { _colorShadeText = new ColoredString(new string((char)303, 8)); Color color = ((ValueTuple <Color, string>)e.Item).Item1; _colorShadeText.SetForeground(color.GetBrightest()); _colorShadeFieldBrightest.Print(_colorShadeText); _colorShadeText.SetForeground(color.GetBright()); _colorShadeFieldBrighter.Print(_colorShadeText); _colorShadeText.SetForeground(color); _colorShadeFieldNormal.Print(_colorShadeText); _colorShadeText.SetForeground(color.GetDark()); _colorShadeFieldDarker.Print(_colorShadeText); _colorShadeText.SetForeground(color.GetDarkest()); _colorShadeFieldDarkest.Print(_colorShadeText); } }
public void DrawMonsterStats(Monster monster, int position) { // Start at Y=9 which is below the player stats. //Multiply the position by 2 to leave a space between each stat. int yPosition = 9 + (position * 2); // Begin the line by printing the symbol of the monster in the appropriate colour. Print(1, yPosition, monster.Symbol.ToString(), monster.color); // Figure out the width of the health bar by dividing the current health by max health. int width = Convert.ToInt32(((double)monster.Health / monster.MaxHealth) * 16.0); int remainingWidth = 16 - width; // Set the background colours of the health bars to show how damaged the monster is. ColoredString currentHealth = new ColoredString(width); ColoredString lostHealth = new ColoredString(remainingWidth); currentHealth.SetForeground(Swatch.Primary); lostHealth.SetBackground(Swatch.PrimaryDarkest); Print(3, yPosition, currentHealth); Print(3 + width, yPosition, lostHealth); // Print the monster's name over the top of the health bar. Print(2, yPosition, $": {monster.Name}", Swatch.DbLight); }
public GameWindow(int width, int height) : base(width, height) { // print game title at the top ColoredString tStr = new ColoredString($" {Constants.GameTitle} "); tStr.SetForeground(Color.White); tStr.SetBackground(Color.DarkGreen); Print(Width / 8, 0, tStr); Print(Width - 20, 0, Constants.Build, Color.Gray); SadConsole.Game.Instance.Window.Title = Constants.GameTitle; Global.CurrentScreen = this; }
private void DrawThemeParts() { SadConsole.UI.Colors colors = Controls.GetThemeColors(); Surface.Clear(_themePartsArea); int y = _themePartsArea.Y; int themeY = 0; UpdateColors(); AdjustableColor selectedSetting = _themeParts[_themePartSelectedIndex]; for (int i = 0; i < _themeParts.Length; i++) { int row = y + i; if (i == _themePartSelectedIndex) { themeY = row; Surface.Print(3, row, ColoredString.Parse(GetThemePartString(selectedSetting.ComputedColor, selectedSetting.Name.Replace("Control ", "")))); Surface.SetGlyph(2, row, ICellSurface.ConnectedLineThin[0], colors.Lines); Surface.DrawLine(new Point(2, row + 1), (_themePartsArea.MaxExtentX, row + 1), ICellSurface.ConnectedLineThin[0], colors.Lines); Surface.DrawLine(new Point(_themePartsArea.MaxExtentX, row + 1), new Point(_themePartsArea.MaxExtentX, row + _themePartSelectedAreaSize), ICellSurface.ConnectedLineThin[0], colors.Lines); Surface.DrawLine(new Point(_themePartsArea.MaxExtentX, row + _themePartSelectedAreaSize + 1), new Point(2, row + _themePartSelectedAreaSize + 1), ICellSurface.ConnectedLineThin[0], colors.Lines); y += _themePartSelectedAreaSize + 1; } else { Surface.Print(3, row, ColoredString.Parse(GetThemePartString(_themeParts[i].ComputedColor, _themeParts[i].Name.Replace("Control ", "")))); Surface.SetGlyph(2, row, ICellSurface.ConnectedLineThin[0], colors.Lines); } } // Connect all the lines for the selected theme area Surface.ConnectLines(ICellSurface.ConnectedLineThin, _themePartsArea); // Draw the shade selection area _themePartsShadeBoxes = new TextField(new Point(_themePartsArea.MaxExtentX - 10, themeY + 3), 10, Surface); var colorPreviewText = new TextField(_themePartsShadeBoxes.Position.WithY(themeY + 2), 5, Surface); var colorPreviewBarsText = new TextField(new Point(colorPreviewText.Position.X + colorPreviewText.Width, themeY + 2), 5, Surface); var shadePreviewBarsText = new TextField(_themePartsShadeBoxes.Position.WithY(themeY + 4), 5, Surface); var shadePreviewText = new TextField(new Point(shadePreviewBarsText.Position.X + shadePreviewBarsText.Width, themeY + 4), 5, Surface); var intoColorPreviewText = new TextField(new Point(colorPreviewText.Position.X - 3, colorPreviewText.Position.Y), 3, Surface); var intoColorPreviewString = new ColoredString(3); intoColorPreviewString.SetForeground(colors.Lines); intoColorPreviewString.SetGlyph(ICellSurface.ConnectedLineThin[(int)ICellSurface.ConnectedLineIndex.Top]); var colorPreviewString = new ColoredString(5); colorPreviewString.SetForeground(selectedSetting.BaseColor); colorPreviewString[0].Glyph = 301; colorPreviewString[1].Glyph = 303; colorPreviewString[2].Glyph = 303; colorPreviewString[3].Glyph = 303; colorPreviewString[4].Glyph = 302; var colorPreviewBarsString = new ColoredString(5); colorPreviewBarsString.SetForeground(colors.Lines); colorPreviewBarsString.SetGlyph(ICellSurface.ConnectedLineThin[(int)ICellSurface.ConnectedLineIndex.Top]); colorPreviewBarsString[4].Glyph = ICellSurface.ConnectedLineThin[(int)ICellSurface.ConnectedLineIndex.TopRight]; var shadeBarsString = new ColoredString(10); shadeBarsString[0].Glyph = 299; shadeBarsString[0].Foreground = selectedSetting.BaseColor.GetBrightest(); shadeBarsString[1].Glyph = 300; shadeBarsString[1].Foreground = selectedSetting.BaseColor.GetBrightest(); shadeBarsString[2].Glyph = 299; shadeBarsString[2].Foreground = selectedSetting.BaseColor.GetBright(); shadeBarsString[3].Glyph = 300; shadeBarsString[3].Foreground = selectedSetting.BaseColor.GetBright(); shadeBarsString[4].Glyph = 299; shadeBarsString[4].Foreground = selectedSetting.BaseColor; shadeBarsString[5].Glyph = 300; shadeBarsString[5].Foreground = selectedSetting.BaseColor; shadeBarsString[6].Glyph = 299; shadeBarsString[6].Foreground = selectedSetting.BaseColor.GetDark(); shadeBarsString[7].Glyph = 300; shadeBarsString[7].Foreground = selectedSetting.BaseColor.GetDark(); shadeBarsString[8].Glyph = 299; shadeBarsString[8].Foreground = selectedSetting.BaseColor.GetDarkest(); shadeBarsString[9].Glyph = 300; shadeBarsString[9].Foreground = selectedSetting.BaseColor.GetDarkest(); var shadePreviewBarsString = new ColoredString(5); shadePreviewBarsString.SetForeground(colors.Lines); shadePreviewBarsString.SetGlyph(ICellSurface.ConnectedLineThin[(int)ICellSurface.ConnectedLineIndex.Top]); shadePreviewBarsString[0].Glyph = ICellSurface.ConnectedLineThin[(int)ICellSurface.ConnectedLineIndex.BottomLeft]; var shadePreviewString = new ColoredString(5); shadePreviewString.SetForeground(selectedSetting.ComputedColor); shadePreviewString[0].Glyph = 301; shadePreviewString[1].Glyph = 303; shadePreviewString[2].Glyph = 303; shadePreviewString[3].Glyph = 303; shadePreviewString[4].Glyph = 302; intoColorPreviewText.Print(intoColorPreviewString); colorPreviewText.Print(colorPreviewString); colorPreviewBarsText.Print(colorPreviewBarsString); shadePreviewBarsText.Print(shadePreviewBarsString); shadePreviewText.Print(shadePreviewString); // Position the controls _themePartSettingColorSet.Position = (3, themeY + 2); _themePartSettingIsPredefinedColor.Position = (3, themeY + 3); _themePartSettingIsCustomColor.Position = (3, themeY + 4); _themePartSettingColorSet.IsVisible = true; _themePartSettingIsCustomColor.IsVisible = true; _themePartSettingIsPredefinedColor.IsVisible = true; // Configure controls/shade _themePartSettingIsCustomColor.IsSelected = selectedSetting.IsCustomColor; _themePartSettingIsPredefinedColor.IsSelected = !selectedSetting.IsCustomColor; switch (selectedSetting.Brightness) { case Colors.Brightness.Brightest: shadeBarsString[0].Glyph = 301; shadeBarsString[1].Glyph = 302; break; case Colors.Brightness.Bright: shadeBarsString[2].Glyph = 301; shadeBarsString[3].Glyph = 302; break; case Colors.Brightness.Normal: shadeBarsString[4].Glyph = 301; shadeBarsString[5].Glyph = 302; break; case Colors.Brightness.Dark: shadeBarsString[6].Glyph = 301; shadeBarsString[7].Glyph = 302; break; case Colors.Brightness.Darkest: shadeBarsString[8].Glyph = 301; shadeBarsString[9].Glyph = 302; break; default: break; } _themePartsShadeBoxes.Print(shadeBarsString); Controls.IsDirty = true; }