Quellcode durchsuchen

Implement RESETBGCOLOR command

StuffedAnon vor 6 Jahren
Ursprung
Commit
d407d8a528

+ 6 - 0
NTERA.Engine/Runtime/Base/Keywords.cs

@@ -146,6 +146,12 @@ namespace NTERA.Engine.Runtime.Base
 			runtime.Console.ResetStyle();
 		}
 
+		[Keyword("RESETBGCOLOR")]
+		public static void ResetBgColor(EraRuntime runtime, StackFrame context, ExecutionNode node)
+		{
+			runtime.Console.SetBgColor(Color.Black);
+		}
+
 		[Keyword("CLEARLINE")]
 		public static void ClearLine(EraRuntime runtime, StackFrame context, ExecutionNode node)
 		{

+ 3 - 2
NTERA/Console/ConsoleControl.cs

@@ -5,11 +5,12 @@ namespace NTERA.Console
 {
 	public partial class ConsoleControl : UserControl
 	{
-		public readonly ConsoleRenderer Renderer = new ConsoleRenderer();
-		
+		public readonly ConsoleRenderer Renderer;
+
 		public ConsoleControl()
 		{
 			InitializeComponent();
+			Renderer = new ConsoleRenderer(this);
 
 	//		Renderer.Items.Add(new TextRenderItem("Sia - Chandelier (Alternative♂Version)"));
 	//		Renderer.Items.Add(new TextRenderItem("【本格的LatinPop】Livin' la Mara Loca - 嗶哩嗶哩 - ( ゜- ゜)つロ 乾杯~."));

+ 14 - 2
NTERA/Console/ConsoleRenderer.cs

@@ -22,8 +22,13 @@ namespace NTERA.Console
 		public delegate void AddedItemEventHandler(IRenderItem item);
 		public event AddedItemEventHandler AddedItem;
 
-		public ConsoleRenderer()
+		private Brush backgroundBrush = new SolidBrush(Color.Black);
+
+		private Control control;
+
+		public ConsoleRenderer(Control control)
 		{
+			this.control = control;
 			Items.Add(new List<IRenderItem>());
 			LineHeight = (int)(new Font("MS UI Gothic", 12)).GetHeight();
 		}
@@ -61,14 +66,21 @@ namespace NTERA.Console
 			AddedItem?.Invoke(item);
 		}
 
+		public void SetBgColor(Color color)
+		{
+			backgroundBrush = new SolidBrush(color);
+			control.Invalidate();
+		}
+
 		public int Render(Graphics graphics, Rectangle clientArea, Rectangle invalidateArea, Point mousePointer)
 		{
+			graphics.FillRectangle(backgroundBrush, invalidateArea);
 			int lastItem = Items.Count - offset;
 
 			int screenLineCount = (int)Math.Ceiling(clientArea.Height / (float)LineHeight);
 
 			int firstItem = Math.Max(0, lastItem - screenLineCount);
-			
+
 			for (int i = firstItem; i < lastItem; i++)
 			{
 				int x = 0;

+ 2 - 0
NTERA/Console/EraConsoleInstance.cs

@@ -287,6 +287,8 @@ namespace NTERA.Console
 
 		public void SetBgColor(Color color)
 		{
+			bgColor = color;
+			Renderer.SetBgColor(bgColor);
 		}
 
 		public void SetToolTipColor(Color fc, Color bc)