最后是 ui.cpp 修改的部分。
ui.cpp (节选)
void printVersionInfo(void)
{
printf_ex(Coord(WORD_X, 22), BLACK_BACK_WHITE_CHAR, "Wuzi (build %d), by ET-16G", BUILD_NUMBER);
return;
}
void paintBasicElements(void)
{
paintBlackRect(Rect(Coord(SPILT_LINE_X, 0), Coord(CONSOLE_WIDTH-1, CONSOLE_HEIGHT-1)));
paintVerticalStick(SPILT_LINE_X, 0, CONSOLE_HEIGHT);
printVersionInfo();
return;
}
void paintMainMenu(void)
{
paintBasicElements();
printf_ex(Coord(WORD_X, 3), BLACK_BACK_WHITE_CHAR, "Wuzi is a board game that widely popular in China,");
printf_ex(Coord(WORD_X, 4), BLACK_BACK_WHITE_CHAR, "Japan and Korea. ");
printf_ex(Coord(WORD_X, 6), BLACK_BACK_WHITE_CHAR, "During the game, players take turns placing black");
printf_ex(Coord(WORD_X, 7), BLACK_BACK_WHITE_CHAR, "and white (in this program, is blue and green)");
printf_ex(Coord(WORD_X, 8), BLACK_BACK_WHITE_CHAR, "pieces on the board with the goal of creating");
printf_ex(Coord(WORD_X, 9), BLACK_BACK_WHITE_CHAR, "an unbroken line of five pieces in any direction.");
return;
}
void paintChooseMenu(int highLight)
{
std::string option[3] = {
"1 Player ",
"2 Plyaers ",
"Quit "
};
paintBlackRect(Rect(Coord(WORD_X, 13), Coord(43, 15)));
int k = highLight-1;
int color;
for(int i = 0; i < 3; i++) {
if(i == k) {
color = WHITE_BACK_BLACK_CHAR;
} else {
color = BLACK_BACK_WHITE_CHAR;
}
printf_ex(Coord(WORD_X, 13+i), color, option[i].c_str());
}
putchar_ex(Coord(42, 13+k), WHITE_BACK_BLACK_CHAR, '<');
gotoXY(Coord(42, 13+k));
return;
}
void paintGamePanel(void)
{
paintBasicElements();
printf_ex(Coord(WORD_X, 3), BLACK_BACK_WHITE_CHAR, "Press arrow keys to move your cursor.");
printf_ex(Coord(WORD_X, 4), BLACK_BACK_WHITE_CHAR, "Press enter key to placing piece.");
printf_ex(Coord(WORD_X, 5), BLACK_BACK_WHITE_CHAR, "Press esc key to quit.");
return;
}
void paintMoverPanel(Player player)
{
int p = (int)player;
paintBlackRect(Rect(Coord(WORD_X, 7), Coord(59, 8)));
printf_ex(Coord(WORD_X, 7), BLACK_BACK_WHITE_CHAR, "Player %d is placing piece...", p);
return;
}
void paintWinnerPanel(Player winner)
{
int p = (int)winner;
paintBasicElements();
printf_ex(Coord(WORD_X, 7), BLACK_BACK_WHITE_CHAR, "Player %d is the winner! Congratulation!", p);
printf_ex(Coord(WORD_X, 8), BLACK_BACK_WHITE_CHAR, "Press any key to quit.", p);
return;
}
void paintQuitMenu(bool isQuit)
{
std::string option[2] = {
"No ",
"Yes "
};
paintBlackRect(Rect(Coord(WORD_X, 11), Coord(50, 15)));
paintBox(Rect(Coord(QUIT_BOX_X_UL, QUIT_BOX_Y_UL), Coord(QUIT_BOX_X_LR, QUIT_BOX_Y_LR)));
printf_ex(Coord(WORD_X, 11), 0x07, "Are confirm to quit?");
int color;
for(int i = 0; i < 2; i++) {
if(i == (int)isQuit) {
color = 0x70;
} else {
color = 0x07;
}
printf_ex(Coord(30, 14+i), color, option[i].c_str());
}
putchar_ex(Coord(39, 14+((int) isQuit)), 0x70, '<');
gotoXY(Coord(39, 14+((int) isQuit)));
return;
}
这样,这个Stage就完美结束了。