void MainWindow::timeIsOut() { if(ui->checkBox->isChecked()&&++currentSegIndex<segTime.count()){ timer->stop(); ui->listWidget->setCurrentRow(currentSegIndex); on_start_clicked(); ui->label_4->setText(QString::number(currentSegIndex+1)); } else if(ui->checkBox_2->isChecked()&&++currentSegIndex<segTime.count()){ timer->stop(); if(fnames.count()>0) player.play(); ui->start->setText(QString::fromLocal8Bit("開始")); ui->listWidget->setCurrentRow(currentSegIndex); } else{ timer->stop(); if(fnames.count()>0) player.play(); if(ui->listWidget->currentRow()>=0){ ui->spinBox->setEnabled(true); ui->spinBox_2->setEnabled(true); ui->spinBox_3->setEnabled(true); } ui->checkBox->setEnabled(true); ui->start->setText(QString::fromLocal8Bit("開始")); currentSegSec=0; currentSegIndex=-1; } }
void MainInterface::Init() { QFont ft; ft.setPointSize(30); QPalette pa; pa.setColor(QPalette::WindowText,Qt::white); time=20; MoveDistance=0; m_pickingCardTimer=new QTimer(this); m_pickingCardTimer->setInterval(8); connect(m_pickingCardTimer,SIGNAL(timeout()),this,SLOT(PickingCards())); /*****设置移动的牌和放在中间不动的牌***********/ m_AllCardsPic.load(":/img/res/card2.png"); m_cardBackPic = m_AllCardsPic.copy(160,4*105,80,105); m_basecardPos = QPoint( (width()-card_width)/2, height()/2-100 ); m_movingcard=new CardPicture(this); m_basecard=new CardPicture(this); m_movingcard->setPic(m_cardBackPic); m_basecard->setPic(m_cardBackPic); m_movingcard->move(m_basecardPos); m_basecard->move(m_basecardPos); //闹钟图片 m_clock=new QLabel(this); m_clock->setPixmap(QPixmap(":/img/res/clock.png")); m_clock->move((width()-m_clock->width())/2+20,(height()-m_clock->width())/2-50); m_clock->hide(); m_rePickingCards = new QLabel(this); m_rePickingCards->setText("重新发牌"); m_rePickingCards->setFont(ft); m_rePickingCards->setPalette(pa); m_rePickingCards->move((width()-m_clock->width())/2-50,(height()-m_clock->height())/2); m_rePickingCards->hide(); m_timeLabel=new QLabel(this); m_timeLabel->setFont(ft); m_timeLabel->setPalette(pa); m_timeLabel->move(490,350); m_timeLabel->hide(); timer=new QTimer(this); timer->setInterval(1000); connect(timer,SIGNAL(timeout()),this,SLOT(timeDisplay())); /**********按钮初始化*****************/ /*开始按钮*/ m_start= new QPushButton(this); m_start->setText("开始游戏"); m_start->move((width()-m_start->width())/2+10,height()-card_height-20); connect(m_start,SIGNAL(clicked()),this,SLOT(on_start_clicked())); /*叫地主按钮*/ m_bet0=new QPushButton(this); m_bet1=new QPushButton(this); m_bet2=new QPushButton(this); m_bet3=new QPushButton(this); m_bet0->hide(); m_bet1->hide(); m_bet2->hide(); m_bet3->hide(); m_bet0->setText("不叫地主"); m_bet1->setText("1分"); m_bet2->setText("2分"); m_bet3->setText("3分"); m_bet0->move(320,height()-card_height-40); m_bet1->move(420,height()-card_height-40); m_bet2->move(520,height()-card_height-40); m_bet3->move(620,height()-card_height-40); connect(m_bet0,SIGNAL(clicked()),this,SLOT(on_bet0_clicked())); connect(m_bet1,SIGNAL(clicked()),this,SLOT(on_bet1_clicked())); connect(m_bet2,SIGNAL(clicked()),this,SLOT(on_bet2_clicked())); connect(m_bet3,SIGNAL(clicked()),this,SLOT(on_bet3_clicked())); /*出牌,提示和要不起按钮*/ m_playhand=new QPushButton(this); m_pass = new QPushButton(this); m_tip = new QPushButton(this); m_playhand->hide(); m_pass->hide(); m_tip->hide(); m_playhand->setText("出牌"); m_pass->setText("要不起"); m_tip->setText("提示"); m_pass->move(width()/2-120,height()-card_height-40); m_playhand->move(width()/2-20,height()-card_height-40); m_tip->move(width()/2+80,height()-card_height-40); connect(m_playhand,SIGNAL(clicked()),this,SLOT(on_playhand_clicked())); connect(m_pass,SIGNAL(clicked()),this,SLOT(on_pass_clicked())); connect(m_tip,SIGNAL(clicked()),this,SLOT(on_tip_clicked())); /*继续按钮*/ m_continue= new QPushButton(this); m_continue->hide(); m_continue->setText("继续游戏"); m_continue->move((width()-m_continue->width())/2+10,height()-card_height-40); connect(m_continue,SIGNAL(clicked()),this,SLOT(on_continue_clicked())); /*音效*/ bkMusic=new QSound(":/sound/res/bkMusic.wav",this); winMusic=new QSound(":/sound/res/win.wav",this); loseMusic=new QSound(":/sound/res/loseMusic.wav",this); shuffleCardsMusic=new QSound(":/sound/res/shuffleCardsMusic.wav",this); noCallMusic=new QSound(":/sound/res/bujiao.wav",this); callLordMusic=new QSound(":/sound/res/jiaodizhu.wav",this); bkMusic->play(); bkMusic->setLoops(-1); /*叫分标识*/ m_gameprocess->getDownPlayer()->betLabel=new QLabel(this); m_gameprocess->getDownPlayer()->betLabel->setFont(ft); m_gameprocess->getDownPlayer()->betLabel->setPalette(pa); m_gameprocess->getDownPlayer()->betLabel->move(width()/2-20,(height()-card_height-70)); m_gameprocess->getLeftPlayer()->betLabel=new QLabel(this); m_gameprocess->getLeftPlayer()->betLabel->setFont(ft); m_gameprocess->getLeftPlayer()->betLabel->setPalette(pa); m_gameprocess->getLeftPlayer()->betLabel->move(150,m_basecardPos.y()); m_gameprocess->getRightPlayer()->betLabel=new QLabel(this); m_gameprocess->getRightPlayer()->betLabel->setFont(ft); m_gameprocess->getRightPlayer()->betLabel->setPalette(pa); m_gameprocess->getRightPlayer()->betLabel->move(width()-250,m_basecardPos.y()); /*要不起的标识*/ m_gameprocess->getDownPlayer()->passLabel=new QLabel(this); m_gameprocess->getDownPlayer()->passLabel->setText("要不起"); m_gameprocess->getDownPlayer()->passLabel->move(width()/2-50,(height()-card_height-100)); m_gameprocess->getDownPlayer()->passLabel->setFont(ft); m_gameprocess->getDownPlayer()->passLabel->setPalette(pa); m_gameprocess->getDownPlayer()->passLabel->hide(); m_gameprocess->getLeftPlayer()->passLabel=new QLabel(this); m_gameprocess->getLeftPlayer()->passLabel->setText("要不起"); m_gameprocess->getLeftPlayer()->passLabel->move(150,m_basecardPos.y()); m_gameprocess->getLeftPlayer()->passLabel->setFont(ft); m_gameprocess->getLeftPlayer()->passLabel->setPalette(pa); m_gameprocess->getLeftPlayer()->passLabel->hide(); m_gameprocess->getRightPlayer()->passLabel=new QLabel(this); m_gameprocess->getRightPlayer()->passLabel->setText("要不起"); m_gameprocess->getRightPlayer()->passLabel->move(width()-250,m_basecardPos.y()); m_gameprocess->getRightPlayer()->passLabel->setFont(ft); m_gameprocess->getRightPlayer()->passLabel->setPalette(pa); m_gameprocess->getRightPlayer()->passLabel->hide(); /*角色标识*/ m_gameprocess->getDownPlayer()->roleLabel=new QLabel(this); m_gameprocess->getDownPlayer()->roleLabel->move(700,400); m_gameprocess->getDownPlayer()->roleLabel->hide(); m_gameprocess->getLeftPlayer()->roleLabel=new QLabel(this); m_gameprocess->getLeftPlayer()->roleLabel->move(110,50); m_gameprocess->getLeftPlayer()->roleLabel->hide(); m_gameprocess->getRightPlayer()->roleLabel=new QLabel(this); m_gameprocess->getRightPlayer()->roleLabel->move(820,50); m_gameprocess->getRightPlayer()->roleLabel->hide(); }