public static void DrawPaladinChoice(Rectangle rectangle, bool multipleChoice, List <CharacterSheet> allPaladins, List <CharacterSheet> selectedPaladins) { Primitives.DrawAndFillRectangle(rectangle, Color.LightBlue, Color.Blue, 1); int y = rectangle.Y + 2; foreach (var paladin in allPaladins) { Rectangle rectThis = new Rectangle(rectangle.X + 2, y, rectangle.Width - 4, 80); var isSelected = selectedPaladins.Contains(paladin); Primitives.DrawAndFillRectangle(rectThis, isSelected ? Color.White : Color.Wheat, Color.Blue, isSelected ? 4 : 1); Writer.DrawString(paladin.DescribeSelf(), rectThis.Extend(-6, -6), degrading: true); if (Root.IsMouseOver(rectThis)) { if (isSelected) { UX.MouseOverAction = () => { selectedPaladins.Remove(paladin); }; } else { UX.MouseOverAction = () => { if (!multipleChoice) { selectedPaladins.Clear(); } selectedPaladins.Add(paladin); }; } } y += 80; } }
public void Draw() { mouseOverItem = null; Primitives.DrawAndFillRectangle(rectangle, Color.Brown, Color.Black, 1); int y = rectangle.Y; int x = rectangle.X; int width = rectangle.Width; int height = ITEMHEIGHT; for (int index = 0; index < Items.Count; index++) { Rectangle rectThisItem = new Rectangle(x, y, width, height); Color colorInner = Color.SandyBrown; ContextMenuItem item = Items[index]; if (Root.IsMouseOver(rectThisItem)) { colorInner = Color.White; mouseOverItem = item; // Tooltip if (item.Tooltip != null) { Tooltip.DrawTooltip(item.OptimumTooltipRectangle, item.Tooltip); } } Primitives.DrawAndFillRectangle(rectThisItem, colorInner, Color.Black, 1); Primitives.DrawImage(item.Icon, new Rectangle(rectThisItem.X + 2, rectThisItem.Y + 2, rectThisItem.Height - 4, rectThisItem.Height - 4)); Writer.DrawString(item.Name, new Rectangle(rectThisItem.X + rectThisItem.Height + 4, rectThisItem.Y, rectThisItem.Width - rectThisItem.Height - 6, rectThisItem.Height), Color.Black, font, Writer.TextAlignment.Left); y += height; } if (!Root.IsMouseOver(rectangle.Extend(40, 40))) { this.ScheduledForElimination = true; } }
private void DrawBottomBar() { Rectangle rectBottomBar = new Rectangle(0, Root.ScreenHeight - 200, Root.ScreenWidth, 200); Primitives.DrawAndFillRectangle(rectBottomBar, Color.Wheat, Color.Blue); if (SelectedCharacter == null) { Writer.DrawString("Left-click a character to select, then right-click to interact.", rectBottomBar, alignment: Writer.TextAlignment.Middle); } else { Writer.DrawString(SelectedCharacter.DescribeSelf(), new Rectangle(rectBottomBar.X + 100, rectBottomBar.Y + 5, 600, 180)); Writer.DrawProgressBar(new Rectangle(rectBottomBar.X + 400, rectBottomBar.Y + 5, 300, 50), Color.Lime, SelectedCharacter.HP, SelectedCharacter.MaxHP, "Health"); var activity = SelectedCharacter.ImmediateActivity; if (activity != null) { Writer.DrawProgressBar(new Rectangle(rectBottomBar.X + 400, rectBottomBar.Y + 55, 300, 50), Color.Yellow, activity.SecondsProgressed, activity.SecondsToComplete, activity.Progress); } if (SelectedCharacter.HeldItems.Count > 0) { Writer.DrawString("Held items:\n" + string.Join("\n", SelectedCharacter.HeldItems.Select(hi => hi.DescribeSelf())), new Rectangle(rectBottomBar.X + 710, rectBottomBar.Y + 5, 400, 200), degrading: true); } } }
public static void DrawPower(PowerName powerName, Rectangle rectangle) { Primitives.DrawAndFillRectangle(rectangle, Color.LightBlue, Color.DarkBlue, 1); Power power = PowerDb.GetPower(powerName); Writer.DrawString("{b}" + power.Name + "{/b}\n" + power.Description, rectangle.Extend(-5, -5), Color.Black, degrading: true); }
protected override void Draw(SpriteBatch sb, Game game, float elapsedSeconds) { Primitives.FillRectangle(Root.Screen, Colors.TotalBackground); Primitives.DrawImage(Assets.Blue, Root.Screen); Primitives.DrawAndFillRectangle(rectLeftBar, Colors.HighlightBack, Colors.Front); Primitives.DrawAndFillRectangle(rectRightBar, Colors.HighlightBack, Colors.Front); Primitives.DrawAndFillRectangle(rectBottomBar, Colors.HighlightBack, Colors.Front); Primitives.DrawMultiLineText("Year " + Session.Year, new Rectangle(rectBottomBar.Right - 500, rectBottomBar.Y, 120, rectBottomBar.Height), Colors.Front, FontFamily.Small, Primitives.TextAlignment.Middle); // Right bar foreach (var rb in RightBarButtons) { rb.Draw(); } // Attitude changes int y = 180; foreach (var att in Session.AttitudeChanges) { var r = new Rectangle(0, y, 200, 80); Primitives.DrawAndFillRectangle(r, att.Up ? Color.LightGreen : Color.Pink, Color.Black); Primitives.DrawMultiLineText(att.Up ? "Attitude improves" : "Attitude worsens", r.Extend(-2, -2), Color.Black); Primitives.DrawMultiLineText("{b}" + att.Actor + "{/b}", new Rectangle(r.X + 2, r.Y + 30, r.Width, r.Height), Color.Black); Primitives.DrawMultiLineText("Now {i}" + att.NewAttitude + "{/i}", new Rectangle(r.X + 2, r.Y + 50, r.Width, r.Height), Color.Black); y += 80; } ActiveWindow?.Draw(sb, rectMiddleWindow, elapsedSeconds); base.Draw(sb, game, elapsedSeconds); }
/// <summary> /// Draws the control. /// </summary> public override void Draw() { mouseOverIndex = -1; Color outerBorderColor = Skin.OuterBorderColor; Color innerBorderColor = Skin.InnerBorderColor; Color innerButtonColor = Skin.WhiteBackgroundColor; Primitives.FillRectangle(Rectangle, this.IsActive ? Skin.InnerBorderColorMouseOver : innerBorderColor); Primitives.DrawRectangle(Rectangle, outerBorderColor, Skin.OuterBorderThickness); Primitives.DrawAndFillRectangle(InnerRectangleWithBorder, innerButtonColor, outerBorderColor, Skin.OuterBorderThickness); int maxItems = InnerRectangle.Height / Skin.ListItemHeight; int colsize = (InnerRectangle.Width - 2) / 3; for (int i = TopOfList; i < Items.Count; i++) { Rectangle rectItem = new Rectangle(InnerRectangle.X + 1, InnerRectangle.Y + Skin.ListItemHeight * (i - TopOfList) + 1, InnerRectangle.Width - 2, Skin.ListItemHeight); if (ThreeColumn) { if (i < maxItems) { rectItem = new Rectangle(InnerRectangle.X + 1, InnerRectangle.Y + Skin.ListItemHeight * (i - TopOfList) + 1, colsize, Skin.ListItemHeight); } else if (i < maxItems * 2) { rectItem = new Rectangle(InnerRectangle.X + 1 + colsize, InnerRectangle.Y + Skin.ListItemHeight * (i - TopOfList - maxItems) + 1, colsize, Skin.ListItemHeight); } else { rectItem = new Rectangle(InnerRectangle.X + 1 + colsize * 2, InnerRectangle.Y + Skin.ListItemHeight * (i - TopOfList - maxItems * 2) + 1, colsize, Skin.ListItemHeight); } } if (Root.IsMouseOver(rectItem)) { mouseOverIndex = i; } if (selectedIndex == i || (Multiselect && SelectedIndices.Contains(i))) { Primitives.FillRectangle(rectItem, Skin.ItemSelectedBackgroundColor); } else if (mouseOverIndex == i) { Primitives.FillRectangle(rectItem, Skin.ItemMouseOverBackgroundColor); } if ((Multiselect && SelectedIndices.Contains(i))) { Primitives.FillCircleQuick(new Vector2(rectItem.Right - rectItem.Height / 2 - 4, rectItem.Y + rectItem.Height / 2), rectItem.Height / 2 - 1, Color.Black); } Primitives.DrawSingleLineText(Items[i].ToString(), new Vector2(rectItem.X + 4, rectItem.Y + 1), Skin.TextColor, Skin.Font); Primitives.DrawLine(new Vector2(rectItem.X - 1, rectItem.Bottom - 1), new Vector2(rectItem.Right + 1, rectItem.Bottom - 1), outerBorderColor, Skin.OuterBorderThickness); } }
protected override void Draw(SpriteBatch sb, Game game, float elapsedSeconds) { base.Draw(sb, game, elapsedSeconds); Rectangle rectHelp = new Rectangle(Root.ScreenWidth / 2 - 500, Root.ScreenHeight / 2 - 450, 1000, 800); Primitives.DrawAndFillRectangle(rectHelp, Color.Wheat, Color.Black, 3); string helpString = ComposeHelpString(); Writer.DrawString(helpString, rectHelp.Extend(-7, -7), Color.Black, degrading: true); }
/// <summary> /// Draws the button. /// </summary> public override void Draw() { isMouseOverThis = Root.IsMouseOver(Rectangle); bool pressed = isMouseOverThis && Root.Mouse_NewState.LeftButton == ButtonState.Pressed; Color outerBorderColor = isMouseOverThis ? Skin.OuterBorderColorMouseOver : (this.IsActive ? Skin.InnerBorderColorMouseOver : Skin.OuterBorderColor); Color innerBorderColor = pressed ? Skin.InnerBorderColorMousePressed : (isMouseOverThis || this.IsActive ? Skin.InnerBorderColorMouseOver : Skin.InnerBorderColor); Color innerButtonColor = isMouseOverThis ? Skin.GreyBackgroundColorMouseOver: Skin.GreyBackgroundColor; Color textColor = isMouseOverThis ? Skin.TextColorMouseOver : Skin.TextColor; Primitives.FillRectangle(Rectangle, innerBorderColor); Primitives.DrawRectangle(Rectangle, outerBorderColor, Skin.OuterBorderThickness); Primitives.DrawAndFillRectangle(InnerRectangleWithBorder, innerButtonColor, outerBorderColor, Skin.OuterBorderThickness); Primitives.DrawMultiLineText(Caption, InnerRectangle, textColor, FontFamily.Normal, Primitives.TextAlignment.Middle); }
public static void DrawButton(string caption, Rectangle rectangle, Action action, string tooltip = null, bool disabled = false) { bool mo = Root.IsMouseOver(rectangle) && !disabled; bool clicking = mo && Root.Mouse_NewState.LeftButton == ButtonState.Pressed; Primitives.FillRectangle(rectangle, clicking ? Color.Blue : (disabled ? Color.Gray : Color.CornflowerBlue)); Primitives.DrawRectangle(rectangle, disabled ? Color.DarkGray : Color.Blue, 1); Primitives.DrawAndFillRectangle(rectangle.Extend(-2, -2), mo ? Color.White : Color.LightBlue, Color.Blue, 1); Writer.DrawString(caption, rectangle.Extend(-5, 0), (disabled ? Color.DarkGray : Color.Black), BitmapFontGroup.Mia24Font, Writer.TextAlignment.Left, degrading: true); if (mo) { MouseOverAction = action; if (tooltip != null) { Tooltip.DrawTooltipAround(rectangle, tooltip); } } }
/// <summary> /// Draws the button. /// </summary> public override void Draw() { this._isMouseOverThis = Root.IsMouseOver(Rectangle); bool pressed = this._isMouseOverThis && Root.Mouse_NewState.LeftButton == ButtonState.Pressed; Rectangle rectSquare = new Rectangle(Rectangle.X, Rectangle.Y, Rectangle.Height, Rectangle.Height); Primitives.DrawAndFillRectangle(rectSquare, pressed ? Color.Red : (this._isMouseOverThis ? Color.Yellow : (this.IsActive ? Color.Yellow : Color.White)), Color.Black); if (Checked) { Primitives.FillRectangle(rectSquare.Extend(-2, -2), Color.Black); } Primitives.DrawMultiLineText(Caption, new Rectangle(Rectangle.X + Rectangle.Height + 2, Rectangle.Y, Rectangle.Width - Rectangle.Height - 2, Rectangle.Height), Color.Black, FontFamily.Normal, Primitives.TextAlignment.Left); Primitives.DrawMultiLineText(Caption, new Rectangle(Rectangle.X + Rectangle.Height + 2 + 2, Rectangle.Y + 2, Rectangle.Width - Rectangle.Height - 2, Rectangle.Height), Color.White, FontFamily.Normal, Primitives.TextAlignment.Left); /* * Primitives.FillRectangle(Rectangle, innerBorderColor); * Primitives.DrawRectangle(Rectangle, outerBorderColor, Skin.OuterBorderThickness); * Primitives.DrawAndFillRectangle(InnerRectangleWithBorder, innerButtonColor, outerBorderColor, Skin.OuterBorderThickness); * Primitives.DrawMultiLineText(Caption, InnerRectangle, textColor, Skin.Font, Primitives.TextAlignment.Middle); */ }
/// <summary> /// Draws the textbox. /// </summary> public override void Draw() { string txt = Text; if (IsPassword) { txt = ""; for (int i = 0; i < Text.Length; i++) { txt += "*"; } } Color outerBorderColor = Skin.OuterBorderColor; Color innerBorderColor = Skin.InnerBorderColor; Color innerButtonColor = Skin.WhiteBackgroundColor; Color textColor = Skin.TextColor; Primitives.FillRectangle(Rectangle, innerBorderColor); Primitives.DrawRectangle(Rectangle, outerBorderColor, Skin.OuterBorderThickness); Primitives.DrawAndFillRectangle(InnerRectangleWithBorder, innerButtonColor, outerBorderColor, Skin.OuterBorderThickness); Primitives.DrawMultiLineText(txt + (Root.SecondsSinceStartInt % 2 == 0 && IsActive ? "|" : ""), new Rectangle(InnerRectangle.X + 8, InnerRectangle.Y + 3, InnerRectangle.Width - 10, InnerRectangle.Height - 4), textColor, FontFamily.Normal); }
protected override void Draw(SpriteBatch sb, Game game, float elapsedSeconds) { base.Draw(sb, game, elapsedSeconds); Primitives.FillRectangle(Root.Screen, Color.CornflowerBlue); Writer.DrawString("Your rescue team:", new Rectangle(5, 5, 600, 40), alignment: Writer.TextAlignment.Left); Rectangle paladinChoiceR = new Rectangle(5, 45, 400, Root.ScreenHeight - 300); UX.DrawPaladinChoice(paladinChoiceR, true, allPaladins, chosenPaladins); UX.DrawButton("Difficulty: Easy", new Rectangle(5, paladinChoiceR.Bottom + 5, paladinChoiceR.Width, 60), () => { this.ChosenDifficulty = Difficulty.Easy; }, null, ChosenDifficulty == Difficulty.Easy); UX.DrawButton("Difficulty: Normal", new Rectangle(5, paladinChoiceR.Bottom + 65, paladinChoiceR.Width, 60), () => { this.ChosenDifficulty = Difficulty.Normal; }, null, ChosenDifficulty == Difficulty.Normal); UX.DrawButton("Difficulty: Meaningful", new Rectangle(5, paladinChoiceR.Bottom + 125, paladinChoiceR.Width, 60), () => { this.ChosenDifficulty = Difficulty.Meaningful; }, null, ChosenDifficulty == Difficulty.Meaningful); Rectangle missionDescRect = new Rectangle(410, 300, Root.ScreenWidth - 420, 500); Writer.DrawString("{b}Emergency: " + Ls.Name + "{/b}", new Rectangle(missionDescRect.X, missionDescRect.Top - 200, missionDescRect.Width, 200), font: BitmapFontGroup.MiaFont, alignment: Writer.TextAlignment.Middle); Primitives.DrawAndFillRectangle(missionDescRect, Color.LightBlue, Color.DarkBlue); string desc = Ls.Intro + "\n\n{b}Difficulty: " + ChosenDifficulty + ".{/b} {i}" + DescribeDifficulty(ChosenDifficulty) + "{/i}"; Writer.DrawString(desc, missionDescRect.Extend(-3, -3), degrading: true); bool goAhead = true; string caption = "{b}Respond to this emergency{/b}"; if (chosenPaladins.Count == 0) { goAhead = false; caption = "Select at least one paladin"; } else if (chosenPaladins.Count < Ls.NumberOfPaladins) { goAhead = true; caption = "Respond to this emergency (understaffed)"; } if (chosenPaladins.Count > Ls.NumberOfPaladins) { goAhead = false; caption = "You can't have more than " + Ls.NumberOfPaladins + " paladins."; } UX.DrawButton( caption, new Rectangle(410, Root.ScreenHeight - 80, 390, 75), () => { Root.PopFromPhase(); Root.PushPhase(new EmergencyPhase(Ls, chosenPaladins, ChosenDifficulty)); }, null, disabled: !goAhead ); UX.DrawButton( "Return to Main Menu", new Rectangle(800, Root.ScreenHeight - 80, 400, 75), () => { Root.PopFromPhase(); }); }
protected override void Draw(GameTime gameTime) { Color clrFluttershy = Color.FromNonPremultiplied(248, 247, 152, 255); GraphicsDevice.Clear(Color.White);//248,247,152 Color clrPink = Color.FromNonPremultiplied(248, 185, 206, 255); Color clrButterscotch = Color.FromNonPremultiplied(226, 187, 50, 255); spriteBatch.Begin(); // Console output Primitives.DrawAndFillRectangle(rectConsoleTop, clrFluttershy, Color.Black, 2); for (int i = 0; i < ConsoleMaxLines; i++) { int lineID = i + ConsoleOutputCurrentLine; if (lineID >= Session.ConsoleTotalLines) { break; } Primitives.DrawSingleLineText(Session.ConsoleOutput[lineID], new Vector2(rectConsoleTopInner.X, rectConsoleTopInner.Y + Library.FontConsoleNormal.LineSpacing * i), lineID < GreyOutputUntil ? Color.Black.Alpha(50) : Color.Black, null, 1); } // Inputbox Primitives.DrawAndFillRectangle(rectInputLine, clrFluttershy, Color.Black, 2); InputTextBox.Draw(); // Suggestions Primitives.DrawAndFillRectangle(rectSuggestions, clrFluttershy, Color.Black, 2); List <Command> suggestions = CurrentSuggestions; int lnSpacing = Library.FontConsoleNormal.LineSpacing + 2; maxsuggestioncount = rectSuggestions.Height / lnSpacing; if (ChosenSuggestion < 0) { ChosenSuggestion = maxsuggestioncount - 1; } if (ChosenSuggestion > maxsuggestioncount - 1) { ChosenSuggestion = 0; } for (int i = 0; i < maxsuggestioncount; i++) { if (suggestions.Count <= i) { break; } Command c = suggestions[i]; Rectangle rectSuggestion = new Rectangle(rectSuggestions.X + 3, rectSuggestions.Y + 2 + i * lnSpacing, rectSuggestions.Width - 6, lnSpacing); Primitives.DrawSingleLineText(c.TotalString, new Vector2(rectSuggestion.X + 5, rectSuggestion.Y + 1), Color.Black); if (ChosenSuggestion == i) { Primitives.FillRectangle(rectSuggestion, clrPink); Primitives.DrawSingleLineText(c.TotalString, new Vector2(rectSuggestion.X + 5, rectSuggestion.Y + 1), Color.Black); } } if (maxsuggestioncount < suggestions.Count) { Primitives.DrawSingleLineText((suggestions.Count - maxsuggestioncount) + " more suggestions are hidden", new Vector2(rectSuggestions.X + rectSuggestions.Width - 8 - Library.FontConsoleNormal.MeasureString((suggestions.Count - maxsuggestioncount) + " more suggestions are hidden").X, rectSuggestions.Y + rectSuggestions.Height - lnSpacing), Color.Black); } // Fluttershy Primitives.DrawAndFillRectangle(rectRecommendedCommands, clrFluttershy, Color.Black, 2); Primitives.DrawImage(ImageFluttershy, new Rectangle(rectRecommendedCommands.X + 5, rectRecommendedCommands.Y + 5, rectRecommendedCommands.Width - 10, rectRecommendedCommands.Height - 10), Color.White, true, true, Color.Transparent); Root.Draw(gameTime); spriteBatch.End(); base.Draw(gameTime); }
public static void DrawNumberInRectangle(string caption, Rectangle rectangle, Color?innerColor = null) { Primitives.DrawAndFillRectangle(rectangle, innerColor ?? Color.LightBlue, Color.DarkBlue, 2); Writer.DrawString(caption.ToString(), rectangle, alignment: TextAlignment.Middle, degrading: true); }