void GameWidget::slotNeedNewGameYes() { delete need_new_game_widget; game->slotGetNewGameDecision(true); if (type == PlVsNet) { emit signalSendMessage("player vs net game started"); } if (type == PlVsCPU) { emit signalSendMessage("player vs cpu game started"); } if (type == PlVsPl) { emit signalSendMessage("player vs player game started"); } }
void GameWidget::slotSetPlayerVsNet() { emit signalSendMessage("player vs net game started"); input_ip_and_port = new QWidget; QLabel* ip_label = new QLabel("ip"); QLabel* port_label = new QLabel("port"); ip_line = new QLineEdit; ip_line->setText("localhost"); port_line = new QLineEdit; port_line->setText("8080"); QPushButton* button = new QPushButton("Ok"); QVBoxLayout* main_layout = new QVBoxLayout; QHBoxLayout* ip_layout = new QHBoxLayout; QHBoxLayout* port_layout = new QHBoxLayout; connect(button, SIGNAL(clicked()), this, SLOT(slotSetIpAndPort())); connect(input_ip_and_port, SIGNAL(destroyed()), this, SLOT(slotCreatePlayerVsNetGame())); ip_layout->addWidget(ip_label); ip_layout->addWidget(ip_line); port_layout->addWidget(port_label); port_layout->addWidget(port_line); main_layout->addLayout(ip_layout); main_layout->addLayout(port_layout); main_layout->addWidget(button); input_ip_and_port->setLayout(main_layout); input_ip_and_port->show(); }
void GameWidget::endGame(GameState result) { qDebug() << "GameWidget::endGame" << sender(); if (result == PLAYER_ONE_WIN) { emit signalSendMessage("player one win"); } if (result == PLAYER_TWO_WIN) { emit signalSendMessage("player two win"); } if (result == DRAW) { emit signalSendMessage("draw"); } showNeedNewGameWindow(); emit signalEndGame(result); }
void GameWidget::slotSetPlayerVsCPU() { emit signalSendMessage("player vs cpu game started"); delete game; game = new CPUGame(this, field_size); connect(this, SIGNAL(signalMouseClicked(Position)), game, SLOT(slotGetUserTurn(Position))); type = PlVsCPU; clear(); }
void Dialog::keyPressEvent(QKeyEvent *event) { if ( event->key() == Qt::Key_Return) { if(event->modifiers() & Qt::CTRL){ qDebug()<<"Hажата ентер"; onMessageToGui("admin",ui->te_inputMess->toPlainText()); emit signalSendMessage("admin",ui->te_inputMess->toPlainText()); ui->te_inputMess->clear(); } } }
void CClientComWorker::sendMessage( qint32 handle, QByteArray* pMessage ) { MYLOG4CPP_DEBUG<<" " <<" "<<"class:"<<" "<<"CClientComWorker" <<" "<<"fun:"<<" "<<"sendMessage" <<" "<<"emit:"<<" "<<"signalSendMessage" <<" "<<"param:"<<" "<<"handle="<<handle <<" "<<"param:"<<" "<<"pMessage=0x"<<pMessage; emit signalSendMessage(handle, pMessage); }
void Dialog::slotSendMessae() { onMessageToGui("admin",ui->te_inputMess->toPlainText()); emit signalSendMessage("admin",ui->te_inputMess->toPlainText()); ui->te_inputMess->clear(); }
void GameWidget::emitSendMessage(const QString& text) { emit signalSendMessage(text); }
void GameWidget::slotNeedNewGameNo() { delete need_new_game_widget; game->slotGetNewGameDecision(false); emit signalNoGame(); emit signalSendMessage("no game"); }
/*Write paskage to TOO*/ void ftdiChip::on_Machine() { static QQueue<QByteArray> templistCMD; static quint16 retAnswer; static int CurrentValue,ValueMax; switch(stat) { case stOpen: if(!listCMD.isEmpty()){ if(Open()==retOk){ stat=stCounter; disconnect(this,SIGNAL(signalStart()),this,SIGNAL(signalStep())); setParametersUSB(parameter.retSpeed(),parameter.retDataBit(),parameter.retStopBit(),parameter.retParity()); timerRead->setInterval(parameter.retTimeDelay()); templistCMD = listCMD; CurrentValue = 0; ValueMax = 3*templistCMD.count(); emit signalProgressRange(0,ValueMax); emit signalStep(); }else { emit signalMessageError(tr("<CENTER><b>Not found KIT USN_RS485!</CENTER></b>")); emit signalStop(); } } listCMD.clear(); return; case stCounter: if(!templistCMD.isEmpty()){ emit signalProgressValue(++CurrentValue,true); stat=stWrite; }else{ stat=stClose; } emit signalStep(); return; case stWrite: { QByteArray cmd(templistCMD.dequeue());//long Time; quint16 result = Bit8Write(cmd,1); emit signalSendMessage(false,cmd,Qt::green); if(result!=retOk){ templistCMD.clear();stat=stCounter;emit signalStep();} stat=stRead; timerRead->start(); emit signalProgressValue(++CurrentValue,true); } return; case stRead: { QByteArray resBuff; quint16 retRead =Read(resBuff); emit signalSendMessage(true,resBuff,Qt::darkBlue); retAnswer = CheckingReceivedPacket(resBuff); if(retAnswer&ANWR_PROTOCOL::retGet){ return; // next package } if((retAnswer&(~(ANWR_PROTOCOL::retOK))) && (retRead&(ftdiChip::retErr|ftdiChip::retBusyDevice))){// stop sending templistCMD.clear(); } stat=stCounter; timerRead->stop(); emit signalProgressValue(++CurrentValue,true); emit signalStep(); } return; case stClose: Close(); connect(this,SIGNAL(signalStart()),this,SIGNAL(signalStep()),Qt::DirectConnection); default: emit signalEnd(true); stat = stOpen; timerRead->stop(); emit signalProgressValue(0,false); if(retAnswer&(ANWR_PROTOCOL::retOK)) // it is not error emit signalStatusOk(tr("Data is written successfully!")); if(retAnswer&ANWR_PROTOCOL::retError) // it is error emit signalStatusError(tr("Error response!"),false); if(retAnswer&ANWR_PROTOCOL::retNoAnsError) // it is error emit signalStatusError(tr("Device does not answer!"),false); if(retAnswer&ANWR_PROTOCOL::retIncorData) emit signalStatusError(tr("Data is incorrect!"),false); emit signalStep(); return; } }