Skip to content

Commit

Permalink
优化界面友好性
Browse files Browse the repository at this point in the history
  • Loading branch information
calcitem committed Jun 23, 2019
1 parent cee5cc0 commit ab350e0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 28 deletions.
4 changes: 2 additions & 2 deletions NineChess/ninechesswindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
</font>
</property>
<property name="text">
<string>玩家1</string>
<string>黑方 (先手)</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -350,7 +350,7 @@
</font>
</property>
<property name="text">
<string>玩家2</string>
<string>白方 (后手)</string>
</property>
</widget>
</item>
Expand Down
2 changes: 1 addition & 1 deletion NineChess/src/aithread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void AiThread::run()
int iTemp = 0;
#endif

// 设一个标识,1号线程只管玩家1,2号线程只管玩家2
// 设一个标识,1号线程只管玩家1即黑方,2号线程只管玩家2即白方
int i = 0;

qDebug() << "Thread" << id << "start";
Expand Down
8 changes: 4 additions & 4 deletions NineChess/src/gamecontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ GameController::GameController(GameScene & scene, QObject * parent) :
isEngine1(false),
isEngine2(false),
hasAnimation(true),
durationTime(250),
durationTime(500),
hasSound(true),
timeID(0),
ruleNo_(-1),
Expand Down Expand Up @@ -291,9 +291,9 @@ void GameController::setAnimation(bool arg)
{
hasAnimation = arg;

// 默认动画时间250ms
// 默认动画时间500ms
if (hasAnimation)
durationTime = 250;
durationTime = 500;
else
durationTime = 0;
}
Expand Down Expand Up @@ -495,7 +495,7 @@ void GameController::timerEvent(QTimerEvent *event)
emit statusBarChanged(message);

// 播放音效
//playSound(":/sound/resources/sound/win.wav");
playSound(":/sound/resources/sound/win.wav");
}

// 测试用代码
Expand Down
38 changes: 19 additions & 19 deletions NineChess/src/ninechess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1244,14 +1244,14 @@ bool NineChess::giveup(Player loser)
if (loser == PLAYER1) {
context.stage = GAME_OVER;
winner = PLAYER2;
tips = "玩家1投子认负,恭喜玩家2获胜";
tips = "黑方投子认负,白方获胜";
sprintf(cmdline, "Player1 give up!");
cmdlist.push_back(string(cmdline));
return true;
} else if (loser == PLAYER2) {
context.stage = GAME_OVER;
winner = PLAYER1;
tips = "玩家2投子认负,恭喜玩家1获胜";
tips = "白方投子认负,黑方获胜";
sprintf(cmdline, "Player2 give up!");
cmdlist.push_back(string(cmdline));
return true;
Expand Down Expand Up @@ -1390,7 +1390,7 @@ bool NineChess::win()
elapsedMS_1 = currentRule.maxTimeLedToLose * 60000;
winner = PLAYER2;
context.stage = GAME_OVER;
tips = "玩家1超时,恭喜玩家2获胜";
tips = "黑方超时,白方获胜";
sprintf(cmdline, "Time over. Player2 win!");
cmdlist.push_back(string(cmdline));
return true;
Expand All @@ -1400,7 +1400,7 @@ bool NineChess::win()
elapsedMS_2 = currentRule.maxTimeLedToLose * 60000;
winner = PLAYER1;
context.stage = GAME_OVER;
tips = "玩家2超时,恭喜玩家1获胜";
tips = "白方超时,黑方获胜";
sprintf(cmdline, "Time over. Player1 win!");
cmdlist.push_back(string(cmdline));
return true;
Expand Down Expand Up @@ -1455,14 +1455,14 @@ bool NineChess::win()
// 规则要求被“闷”判负,则对手获胜
if (currentRule.isLoseWhenNoWay) {
if (context.turn == PLAYER1) {
tips = "玩家1无子可走,恭喜玩家2获胜";
tips = "黑方无子可走,白方获胜";
winner = PLAYER2;
context.stage = GAME_OVER;
sprintf(cmdline, "Player1 no way to go. Player2 win!");
cmdlist.push_back(string(cmdline));
return true;
} else {
tips = "玩家2无子可走,恭喜玩家1获胜";
tips = "白方无子可走,黑方获胜";
winner = PLAYER1;
context.stage = GAME_OVER;
sprintf(cmdline, "Player2 no way to go. Player1 win!");
Expand Down Expand Up @@ -1667,35 +1667,35 @@ void NineChess::setTips()
{
switch (context.stage) {
case NineChess::GAME_NOTSTARTED:
tips = "轮到玩家1落子,剩余" + std::to_string(context.nPiecesInHand_1) + "";
tips = "轮到黑方落子,剩余" + std::to_string(context.nPiecesInHand_1) + "";
break;
case NineChess::GAME_PLACING:
if (context.action == ACTION_PLACE) {
if (context.turn == PLAYER1) {
tips = "轮到玩家1落子,剩余" + std::to_string(context.nPiecesInHand_1) + "";
tips = "轮到黑方落子,剩余" + std::to_string(context.nPiecesInHand_1) + "";
} else if (context.turn == PLAYER2) {
tips = "轮到玩家2落子,剩余" + std::to_string(context.nPiecesInHand_2) + "";
tips = "轮到白方落子,剩余" + std::to_string(context.nPiecesInHand_2) + "";
}
} else if (context.action == ACTION_CAPTURE) {
if (context.turn == PLAYER1) {
tips = "轮到玩家1去子,需去" + std::to_string(context.nPiecesNeedRemove) + "";
tips = "成三!轮到黑方去子,需去" + std::to_string(context.nPiecesNeedRemove) + "";
} else if (context.turn == PLAYER2) {
tips = "轮到玩家2去子,需去" + std::to_string(context.nPiecesNeedRemove) + "";
tips = "成三!轮到白方去子,需去" + std::to_string(context.nPiecesNeedRemove) + "";
}
}
break;
case NineChess::GAME_MOVING:
if (context.action == ACTION_PLACE || context.action == ACTION_CHOOSE) {
if (context.turn == PLAYER1) {
tips = "轮到玩家1选子移动";
tips = "轮到黑方选子移动";
} else if (context.turn == PLAYER2) {
tips = "轮到玩家2选子移动";
tips = "轮到白方选子移动";
}
} else if (context.action == ACTION_CAPTURE) {
if (context.turn == PLAYER1) {
tips = "轮到玩家1去子,需去" + std::to_string(context.nPiecesNeedRemove) + "";
tips = "成三!轮到黑方去子,需去" + std::to_string(context.nPiecesNeedRemove) + "";
} else if (context.turn == PLAYER2) {
tips = "轮到玩家2去子,需去" + std::to_string(context.nPiecesNeedRemove) + "";
tips = "成三!轮到白方去子,需去" + std::to_string(context.nPiecesNeedRemove) + "";
}
}
break;
Expand All @@ -1704,14 +1704,14 @@ void NineChess::setTips()
tips = "超出限定步数,双方平局";
else if (winner == PLAYER1) {
if (tips.find("无子可走") != tips.npos)
tips += "恭喜玩家1获胜";
tips += "黑方获胜";
else
tips = "恭喜玩家1获胜";
tips = "黑方获胜";
} else if (winner == PLAYER2) {
if (tips.find("无子可走") != tips.npos)
tips += "恭喜玩家2获胜";
tips += "白方获胜";
else
tips = "恭喜玩家2获胜";
tips = "白方获胜";
}
break;
default:
Expand Down
7 changes: 5 additions & 2 deletions NineChess/src/ninechesswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ void NineChessWindow::initialize()

// 为状态栏添加一个正常显示的标签
QLabel *statusBarlabel = new QLabel(this);
QFont statusBarFont;
statusBarFont.setPointSize(16);
statusBarlabel->setFont(statusBarFont);
ui.statusBar->addWidget(statusBarlabel);

// 更新状态栏
Expand Down Expand Up @@ -664,15 +667,15 @@ void NineChessWindow::on_actionEngine_E_triggered()
QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);

// 设置各个控件数据
groupBox1->setTitle(tr("玩家1 AI设置"));
groupBox1->setTitle(tr("黑方(玩家1) AI设置"));
label_depth1->setText(tr("深度"));
spinBox_depth1->setMinimum(1);
spinBox_depth1->setMaximum(99);
label_time1->setText(tr("限时"));
spinBox_time1->setMinimum(1);
spinBox_time1->setMaximum(3600);

groupBox2->setTitle(tr("玩家2 AI设置"));
groupBox2->setTitle(tr("白方(玩家2) AI设置"));
label_depth2->setText(tr("深度"));
spinBox_depth2->setMinimum(1);
spinBox_depth2->setMaximum(99);
Expand Down

0 comments on commit ab350e0

Please sign in to comment.