优化界面友好性

This commit is contained in:
CalciteM 2019-06-23 23:23:57 +08:00
parent cee5cc0efa
commit ab350e0008
5 changed files with 31 additions and 28 deletions

View File

@ -269,7 +269,7 @@
</font>
</property>
<property name="text">
<string>玩家1</string>
<string>黑方 (先手)</string>
</property>
</widget>
</item>
@ -350,7 +350,7 @@
</font>
</property>
<property name="text">
<string>玩家2</string>
<string>白方 (后手)</string>
</property>
</widget>
</item>

View File

@ -47,7 +47,7 @@ void AiThread::run()
int iTemp = 0;
#endif
// 设一个标识1号线程只管玩家12号线程只管玩家2
// 设一个标识1号线程只管玩家1即黑方2号线程只管玩家2即白方
int i = 0;
qDebug() << "Thread" << id << "start";

View File

@ -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),
@ -291,9 +291,9 @@ void GameController::setAnimation(bool arg)
{
hasAnimation = arg;
// 默认动画时间250ms
// 默认动画时间500ms
if (hasAnimation)
durationTime = 250;
durationTime = 500;
else
durationTime = 0;
}
@ -495,7 +495,7 @@ void GameController::timerEvent(QTimerEvent *event)
emit statusBarChanged(message);
// 播放音效
//playSound(":/sound/resources/sound/win.wav");
playSound(":/sound/resources/sound/win.wav");
}
// 测试用代码

View File

@ -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;
@ -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;
@ -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;
@ -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!");
@ -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;
@ -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:

View File

@ -190,6 +190,9 @@ void NineChessWindow::initialize()
// 为状态栏添加一个正常显示的标签
QLabel *statusBarlabel = new QLabel(this);
QFont statusBarFont;
statusBarFont.setPointSize(16);
statusBarlabel->setFont(statusBarFont);
ui.statusBar->addWidget(statusBarlabel);
// 更新状态栏
@ -664,7 +667,7 @@ 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);
@ -672,7 +675,7 @@ void NineChessWindow::on_actionEngine_E_triggered()
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);