Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed bug in Unix background color for the console. Update CuiTetris.

  • Loading branch information...
commit 4dba0e5fac7ff70807aefb8f618de19e15f8be8f 1 parent 64f9bd4
@wilkie authored
View
8 examples/CuiTetris/app.d
@@ -1,5 +1,7 @@
import cui.application;
+import djehuty;
+
import io.console;
import gamewindow;
@@ -22,13 +24,13 @@ class TermTetris : CuiApplication {
override void onApplicationEnd() {
Console.clear();
- Console.setColor(fgColor.White);
+ Console.forecolor = Color.White;
Console.put("Your Score was: ");
- Console.setColor(fgColor.BrightYellow);
+ Console.forecolor = Color.Yellow;
Console.putln(gameWindow.getScore());
Console.putln("");
- Console.setColor(fgColor.White);
+ Console.forecolor = Color.Gray;
Console.putln("Thank you for playing!");
}
View
23 examples/CuiTetris/gamecontrol.d
@@ -118,7 +118,7 @@ class GameControl : CuiWidget {
if (clr != board[i,j]) {
clr = board[i,j];
- Console.setColor(cast(bgColor)clr);
+ Console.backcolor = colors[clr];
}
Console.putAt(i*4, (j*2) + o, " ");
@@ -128,11 +128,21 @@ class GameControl : CuiWidget {
}
}
+ static Color colors[] = [
+ Color.Black,
+ Color.Red,
+ Color.Blue,
+ Color.Green,
+ Color.Yellow,
+ Color.Magenta,
+ Color.Cyan,
+ Color.White
+ ];
+
void drawPiece() {
synchronized(this) {
lastPiece = new Coord[](4);
-
- Console.setColor(cast(bgColor)(board.getPieceType() + 1));
+ Console.backcolor = colors[board.getPieceType() + 1];
foreach(i, pt; board.getPiece()) {
Coord curPt;
@@ -149,13 +159,14 @@ class GameControl : CuiWidget {
}
}
- Console.setColor(fgColor.White);
+ Console.forecolor = Color.Gray;
}
}
void clearPiece() {
synchronized(this) {
- Console.setColor(fgColor.Blue, bgColor.Black);
+ Console.forecolor = Color.Blue;
+ Console.backcolor = Color.Black;
foreach(pt; lastPiece) {
if (pt.x >= 0 && pt.y >= 0 && pt.x < 40 && pt.y < 40) {
//Console.position(pt.x, pt.y);
@@ -164,7 +175,7 @@ class GameControl : CuiWidget {
Console.putAt(pt.x, pt.y + 1, " ");
}
}
- Console.setColor(fgColor.White);
+ Console.forecolor = Color.Gray;
}
}
View
2  examples/CuiTetris/gamewindow.d
@@ -13,7 +13,7 @@ class GameWindow : CuiWindow {
game = new GameControl();
push(scoreLabel);
- push(new CuiLabel(2, 3, 10, "Score", fgColor.BrightYellow));
+ push(new CuiLabel(2, 3, 10, "Score", Color.Yellow));
push(game);
}
View
1  platform/unix/scaffold/console.d
@@ -116,6 +116,7 @@ void ConsoleSetColors(Color fg, Color bg) {
fgidx %= 8;
bright = 1;
}
+ bgidx %= 8;
if (ApplicationController.instance.usingCurses) {
int idx = fgidx << 3;
idx |= bgidx;
Please sign in to comment.
Something went wrong with that request. Please try again.