diff --git a/src/kernel/Log.hx b/src/kernel/Log.hx index 22b9be6..5017005 100644 --- a/src/kernel/Log.hx +++ b/src/kernel/Log.hx @@ -60,7 +60,7 @@ class Log { } public static function silly(msg:Dynamic, ?pos:haxe.PosInfos) { - writer.writeLn(logLine("SILY",pos,msg), LightGrey); + writer.writeLn(logLine("SILY",pos,msg), LightGray); #if webconsole Debug.printWeb(logLine("SILY",pos,msg)); #end diff --git a/src/kernel/MainTerm.hx b/src/kernel/MainTerm.hx index 991a959..59c5c14 100644 --- a/src/kernel/MainTerm.hx +++ b/src/kernel/MainTerm.hx @@ -77,19 +77,19 @@ class MainTerm implements TermWriteable { } public function getTextColor():Color { - return ColorConvert.ccToColor(Term.getTextColor()); + return Term.getTextColor(); } - public function setTextColor(colour:Color) { - Term.setTextColor(ColorConvert.colorToCC(colour)); + public function setTextColor(color:Color) { + Term.setTextColor(color); } public function getBackgroundColor():Color { - return ColorConvert.ccToColor(Term.getBackgroundColor()); + return Term.getBackgroundColor(); } public function setBackgroundColor(color:Color) { - Term.setBackgroundColor(ColorConvert.colorToCC(color)); + Term.setBackgroundColor(color); } public function isColor():Bool { diff --git a/src/kernel/peripherals/Screen.hx b/src/kernel/peripherals/Screen.hx index 9526098..7aeb9a8 100644 --- a/src/kernel/peripherals/Screen.hx +++ b/src/kernel/peripherals/Screen.hx @@ -90,19 +90,19 @@ class Screen implements TermWriteable implements IPeripheral { } public function getTextColor():Color { - return ColorConvert.ccToColor(nativ.getTextColor()); + return nativ.getTextColor(); } - public function setTextColor(colour:Color) { - nativ.setTextColor(ColorConvert.colorToCC(colour)); + public function setTextColor(color:Color) { + nativ.setTextColor(color); } public function getBackgroundColor():Color { - return ColorConvert.ccToColor(nativ.getBackgroundColor()); + return nativ.getBackgroundColor(); } public function setBackgroundColor(color:Color) { - nativ.setBackgroundColor(ColorConvert.colorToCC(color)); + nativ.setBackgroundColor(color); } public function isColor():Bool { diff --git a/src/kernel/ui/TermBuffer.hx b/src/kernel/ui/TermBuffer.hx index 5a28c71..5619c98 100644 --- a/src/kernel/ui/TermBuffer.hx +++ b/src/kernel/ui/TermBuffer.hx @@ -158,8 +158,8 @@ class TermBuffer implements TermWriteable { return currentTextColor; } - public function setTextColor(colour:Color) { - currentTextColor = colour; + public function setTextColor(color:Color) { + currentTextColor = color; } public function getBackgroundColor():Color { diff --git a/src/kernel/ui/TermWriteable.hx b/src/kernel/ui/TermWriteable.hx index 702594f..04b311f 100644 --- a/src/kernel/ui/TermWriteable.hx +++ b/src/kernel/ui/TermWriteable.hx @@ -31,12 +31,12 @@ interface TermWriteable { public function clear():Void; public function clearLine():Void; public function getTextColor():Color; - public function setTextColor(colour:Color):Void; + public function setTextColor(color:Color):Void; public function getBackgroundColor():Color; public function setBackgroundColor(color:Color):Void; public function isColor():Bool; // public function setPaletteColor(...); - // public function getPaletteColor(colour); + // public function getPaletteColor(color); /** Clears the screen, resetes the courser to (0,0) and resetes the color to Black and White. diff --git a/src/kernel/ui/VirtualTermWriter.hx b/src/kernel/ui/VirtualTermWriter.hx index ed90b01..970135f 100644 --- a/src/kernel/ui/VirtualTermWriter.hx +++ b/src/kernel/ui/VirtualTermWriter.hx @@ -150,12 +150,12 @@ class VirtualTermWriter implements TermWriteable extends TermBuffer { return super.getTextColor(); } - public override function setTextColor(colour:Color) { + public override function setTextColor(color:Color) { if (isEnabled()) { - target.setTextColor(colour); + target.setTextColor(color); } - super.setTextColor(colour); + super.setTextColor(color); } public override function getBackgroundColor():Color { diff --git a/src/kernel/ui/WindowContext.hx b/src/kernel/ui/WindowContext.hx index 36b5c6e..4611fdf 100644 --- a/src/kernel/ui/WindowContext.hx +++ b/src/kernel/ui/WindowContext.hx @@ -114,8 +114,8 @@ class WindowContext implements TermWriteable { return writer.getTextColor(); } - public function setTextColor(colour:Color) { - writer.setTextColor(colour); + public function setTextColor(color:Color) { + writer.setTextColor(color); } public function getBackgroundColor():Color { diff --git a/src/util/Color.hx b/src/util/Color.hx index aa9bf19..929826c 100644 --- a/src/util/Color.hx +++ b/src/util/Color.hx @@ -1,111 +1,20 @@ package util; -import haxe.Exception; -import cc.Colors; - -enum Color { - White; - Orange; - Magenta; - LightBlue; - Yellow; - Lime; - Pink; - Gray; - Grey; - LightGray; - LightGrey; - Cyan; - Purple; - Blue; - Brown; - Green; - Red; - Black; -} - -class ColorConvert { - public static function colorToCC(color:Color):cc.Colors.Color { - switch color { - case White: - return Colors.white; - case Orange: - return Colors.orange; - case Magenta: - return Colors.magenta; - case LightBlue: - return Colors.lightBlue; - case Yellow: - return Colors.yellow; - case Lime: - return Colors.lime; - case Pink: - return Colors.pink; - case Gray: - return Colors.gray; - case Grey: - return Colors.grey; - case LightGray: - return Colors.lightGray; - case LightGrey: - return Colors.lightGrey; - case Cyan: - return Colors.cyan; - case Purple: - return Colors.purple; - case Blue: - return Colors.blue; - case Brown: - return Colors.brown; - case Green: - return Colors.green; - case Red: - return Colors.red; - case Black: - return Colors.black; - }; - } - - public static function ccToColor(color:cc.Colors.Color):Color { - switch color { - case 0: - return White; - case 1: - return Orange; - case 2: - return Magenta; - case 3: - return LightBlue; - case 4: - return Yellow; - case 5: - return Lime; - case 6: - return Pink; - case 7: - return Gray; - case 8: - return Grey; - case 9: - return LightGray; - case 10: - return LightGrey; - case 11: - return Cyan; - case 12: - return Purple; - case 13: - return Blue; - case 14: - return Brown; - case 15: - return Green; - case 16: - return Red; - case 17: - return Black; - case _: - throw new Exception("Invalid input"); - } - } +enum abstract Color(Int) from cc.Colors.Color to cc.Colors.Color { + var White = 0x1; + var Orange = 0x2; + var Magenta = 0x4; + var LightBlue = 0x8; + var Yellow = 0x10; + var Lime = 0x20; + var Pink = 0x40; + var Gray = 0x80; + var LightGray = 0x100; + var Cyan = 0x200; + var Purple = 0x400; + var Blue = 0x800; + var Brown = 0x1000; + var Green = 0x2000; + var Red = 0x4000; + var Black = 0x8000; }