Bläddra i källkod

Merge branch 'master' into 'master'

Master

See merge request Bepsi/NTERA!3
Bepsi 6 år sedan
förälder
incheckning
c838fe4590

+ 23 - 7
NTERA.Engine/Runtime/Base/Keywords.cs

@@ -116,17 +116,14 @@ namespace NTERA.Engine.Runtime.Base
 			runtime.Console.Alignment = alignmentValue;
 		}
 
-		[Keyword("SETCOLOR")]
-		public static void SetColor(EraRuntime runtime, StackFrame context, ExecutionNode node)
+		private static Color ParseColorArguments(EraRuntime runtime, StackFrame context, ExecutionNode node)
 		{
 			if (node.SubNodes.Length == 1)
 			{
 				uint argb = (uint)runtime.ComputeExpression(context, node[0]).Real;
 				argb |= 0xFF000000U;
 
-				Color c = Color.FromArgb((int)argb);
-
-				runtime.Console.SetStringStyle(c);
+				return Color.FromArgb((int)argb);
 			}
 			else if (node.SubNodes.Length == 3)
 			{
@@ -134,18 +131,37 @@ namespace NTERA.Engine.Runtime.Base
 				int g = (int)runtime.ComputeExpression(context, node[1]).Real;
 				int b = (int)runtime.ComputeExpression(context, node[2]).Real;
 
-				runtime.Console.SetStringStyle(Color.FromArgb(r, g, b));
+				return Color.FromArgb(r, g, b);
 			}
 			else
 				throw new EraRuntimeException("Unable to parse color");
 		}
 
+		[Keyword("SETCOLOR")]
+		public static void SetColor(EraRuntime runtime, StackFrame context, ExecutionNode node)
+		{
+			runtime.Console.SetStringStyle(ParseColorArguments(runtime, context, node));
+		}
+
 		[Keyword("RESETCOLOR")]
 		public static void ResetColor(EraRuntime runtime, StackFrame context, ExecutionNode node)
 		{
 			runtime.Console.ResetStyle();
 		}
 
+		[Keyword("SETBGCOLOR")]
+		public static void SetBgColor(EraRuntime runtime, StackFrame context, ExecutionNode node)
+		{
+
+			runtime.Console.SetBgColor(ParseColorArguments(runtime, context, node));
+		}
+
+		[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)
 		{
@@ -215,4 +231,4 @@ namespace NTERA.Engine.Runtime.Base
 			runtime.Console.PrintSingleLine(value.ToString());
 		}
 	}
-}
+}

+ 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)

+ 3 - 3
README.md

@@ -30,11 +30,11 @@ Build with:
 
     msbuild
 
-# Running:
+## Running:
 
-You can run with:
+You can run with (note the MONO_IOMAP=all to make it treat files case insensitive):
 
-    ERA=/path/to/eragame mono NTERA/bin/Debug/NTERA.exe
+    ERA=/path/to/eragame MONO_IOMAP=all mono NTERA/bin/Debug/NTERA.exe
 
 ## Development