예제 #1
0
void ShowPlayerSettings(MI0283QT9 lcd, MENUOBJECTS obj, MY_USART serial){
	while(1){
		lcd.drawText(0, 15, "Player", OBJECTCOLOR, BACKGROUND, 3);
		
		if(obj.drawButton(lcd, "Difficulty", 20, 75, 200, 40))
		{
			lcd.fillScreen(BACKGROUND);
			showDifficulty(lcd, obj, serial);
		}
		
		if(obj.drawButton(lcd, "Color", 20, 135, 200, 40))
		{
			lcd.fillScreen(BACKGROUND);
			showPlayerColor(lcd, obj, serial);
		}
		
		if(obj.drawButton(lcd, "Sensitivity", 20, 195, 200, 40))
		{
			lcd.fillScreen(BACKGROUND);
			showSensitivity(lcd, obj, serial);
		}
		if(obj.drawButton(lcd, "Back", 20, 270, 200, 40)){
			lcd.fillScreen(BACKGROUND);
			break;
		}
		
	}
}
예제 #2
0
void ShowPlayerSettings(MI0283QT9 lcd){
	while(1){
		if(returnToMain){
			break;
		}
		
		lcd.drawText(0, 15, "Player", OBJECTCOLOR, BACKGROUND, 3);
		
		if(drawButton(lcd, "Difficulty", 20, 75, 200, 40))
		{
			lcd.fillScreen(BACKGROUND);
			showDifficulty(lcd);
		}
		
		if(drawButton(lcd, "Color", 20, 135, 200, 40))
		{
			lcd.fillScreen(BACKGROUND);
			showPlayerColor(lcd);
		}
		
		if(drawButton(lcd, "NunChuck", 20, 195, 200, 40))
		{
			lcd.fillScreen(BACKGROUND);
			showController(lcd);
		}
		if(drawButton(lcd,"H", 20,270, 95, 40)){
			returnToMain = 1;
		}
		
		if(drawButton(lcd, "B", 125, 270, 95, 40)){
			lcd.fillScreen(BACKGROUND);
			break;
		}
		
	}
}
예제 #3
0
void ScoresTable::updateInformation()
{
    QFile scoresFile("scores_table.sapst");
    bool fileHasOpened = scoresFile.open(QIODevice::ReadOnly);
    if (!fileHasOpened)
    {
        if(!scoresFile.exists())
        {
            QMessageBox::information(this,
                                     tr("Information"),
                                     tr("Scores table file not found.\n"
                                        "It will be created automatically."),
                                     QMessageBox::Ok);
            bool fileHasCreated = scoresFile.open(QIODevice::WriteOnly);
            if (!fileHasCreated)
            {
                QMessageBox::warning(this,
                                     tr("Error"),
                                     tr("Cannot create scores table file."),
                                     QMessageBox::Ok);
                return;
            }
        }
        else
        {
            QMessageBox::warning(this,
                                 tr("Error"),
                                 tr("Cannot open scores table file."),
                                 QMessageBox::Ok);
            return;
        }
    }

    QString data = QString(QByteArray::fromHex(scoresFile.readAll()));
    scoresFile.close();

    if (data.size() % 70 != 0)
    {
        QMessageBox::warning(this,
                             tr("Error"),
                             tr("Scores table file was corrupted. "
                                "It will be cleared."),
                             QMessageBox::Ok);
        clearTable();
        return;
    }

    int nRecords = data.size() / 70;
    if (nRecords != tableWidget_->rowCount())
        tableWidget_->setRowCount(nRecords);

    int gameTime;
    QDateTime dateTime;
    QString name, difficulty;
    QTableWidgetItem *item;
    for (int i = 0; i < nRecords; i++)
    {
        //inserting player name in table
        name = data.mid(70*i+20, 30);
        item = tableWidget_->item(i, 0);
        if (item == 0)
        {
            item = new QTableWidgetItem;
            tableWidget_->setItem(i, 0, item);
        }
        item->setData(Qt::DisplayRole, name);

        //inserting game time in table
        gameTime = data.mid(70*i+50, 10).toInt();
        item = tableWidget_->item(i, 1);
        if (item == 0)
        {
            item = new QTableWidgetItem;
            tableWidget_->setItem(i, 1, item);
        }
        item->setData(Qt::DisplayRole, gameTime);

        //inserting difficulty in table
        difficulty = data.mid(70*i+60, 10);
        item = tableWidget_->item(i, 2);
        if (item == 0)
        {
            item = new QTableWidgetItem;
            tableWidget_->setItem(i, 2, item);
        }
        item->setData(Qt::DisplayRole, difficulty);

        //inserting date in table
        dateTime = QDateTime::fromMSecsSinceEpoch(data.mid(70*i, 20).toLongLong());
        item = tableWidget_->item(i, 3);
        if (item == 0)
        {
            item = new QTableWidgetItem;
            tableWidget_->setItem(i, 3, item);
        }
        item->setData(Qt::DisplayRole, dateTime.toString(Qt::SystemLocaleShortDate));
    }
    tableWidget_->sortByColumn(sortIndicator_.first, sortIndicator_.second);
    showDifficulty(difficultyLevelComboBox_->currentIndex());
}