示例#1
0
HistoryDialog::HistoryDialog(const QString &playerName, MainWindow *window, QWidget *parent) :QDialog(parent) {
    resize(340, 229);

    mainWindow = window;

    tablewidget = new QTableWidget(this);
    tablewidget->setColumnCount(3);

    QTableWidgetItem *hItem0 = new QTableWidgetItem();
    hItem0->setText("Date");
    tablewidget->setHorizontalHeaderItem(0, hItem0);

    QTableWidgetItem *hItem1 = new QTableWidgetItem();
    hItem1->setText(playerName);
    tablewidget->setHorizontalHeaderItem(1,hItem1);

    QTableWidgetItem *hItem2 = new QTableWidgetItem();
    hItem2->setText("Computer");
    tablewidget->setHorizontalHeaderItem(2,hItem2);

    tablewidget->setGeometry(QRect(10, 10, 311, 188));

    closeButton = new QPushButton("Close", this);
    closeButton->setGeometry(QRect(130, 200, 77, 27));

    connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));

    setWindowTitle("Score History");

    loadScores();
}
示例#2
0
	void loadAssets()
	{
		log("loading fonts"); 		loadFonts();
		log("loading sounds"); 		loadSounds();
		log("loading music"); 		loadMusic();
		log("loading music data"); 	loadMusicData();
		log("loading style data"); 	loadStyleData();
		log("loading level data");	loadLevelData();
		log("loading scores"); 		loadScores();
	}
示例#3
0
GameWidget::GameWidget(QWidget *parent)
:QLabel(parent), m_gunX(32), m_shipXHeading(1), m_soser(250, 65)
{
    srand(QDateTime::currentDateTime().toTime_t());

    m_shipTimeInt = 200.0;

    m_shottimer = new QTimer(this);
    connect(m_shottimer, SIGNAL(timeout()), this, SLOT(shotTimeout()));
    m_shottimer->start(30);
    m_shiptimer = new QTimer(this);
    connect(m_shiptimer, SIGNAL(timeout()), this, SLOT(shipTimeout()));
    m_shiptimer->start((int)m_shipTimeInt);
    m_soserShowTimer = new QTimer(this);
    connect(m_soserShowTimer, SIGNAL(timeout()), this, SLOT(soserShowTimeout()));
    m_soserShowTimer->setSingleShot(false);
    int tm = (((rand() % 6) + 5) * 1000);
    m_soserShowTimer->start(tm);
    m_soserMoveTimer = new QTimer(this);
    connect(m_soserMoveTimer, SIGNAL(timeout()), this, SLOT(soserMoveTimeout()));
    m_levelFinTimer = new QTimer(this);
    connect(m_levelFinTimer, SIGNAL(timeout()), this, SLOT(levelFinTimeout()));

    setMouseTracking(true);

    // draw soser pixmap
    m_soser.fill(Qt::transparent);
    QPainter p(&m_soser);
    QPixmap a = PicBucket::instance().getPic(4, 0).pixmap;
    QPixmap b = PicBucket::instance().getPic(4, 3).pixmap;
    p.drawPixmap(0, 0, a);
    p.drawPixmap(51, 0, b.transformed(QMatrix().rotate(270), Qt::SmoothTransformation).transformed(
        QMatrix(QMatrix(1, 0, 0, -1, 0, 0)), Qt::SmoothTransformation)); // flip it, looks better
    p.drawPixmap(102, 0, b);
    p.drawPixmap(153, 0, a.transformed(QMatrix(-1, 0, 0, 1, 0, 0), Qt::SmoothTransformation));
    p.end();
    m_soser = m_soser.scaled(QSize(170, 43), Qt::KeepAspectRatio, Qt::SmoothTransformation);
    m_soserMask = QRegion(m_soser.mask());

    m_score = 0;
    m_level = 1;
    m_lives = 3;
    m_soserX = 0;

    sizeY = 9999;

    loadScores();
    initLevel(m_level);

}
SM_Scores::SM_Scores(S_StateManager* stateManager, SDL_Renderer* renderer, C_Vec2 dimensions, C_Music* backgroundMusic)
	: S_State(stateManager, renderer, dimensions),
	backgroundMusic(backgroundMusic),
	background(new C_Texture("Assets/Images/nongamebackground.png", renderer)),
	scoresBackground(new C_Texture("Assets/Images/scoresBackground.png", renderer)),
	buttonBackground(new C_Texture("Assets/Images/buttonBackground981x174.png", renderer)),
	coin(new C_Texture("Assets/Images/coin.png", renderer)),
	coinDim(C_Vec2(dimensions.y * 0.125f, dimensions.y * 0.125f)),
	buttonYPos((dimensions.y * 0.075f) * 11.0f)
{
	//Initialise universal speed
	universalSpeed = new float(0.0f);

	//Initialise Button
	exitButton =
		new UI_Button(
		buttonBackground, //Button Sprite
		C_Vec2(981.0f, 174.0f), //Sprite Dimensions
		C_Vec2(dimensions.x * 0.3f, buttonYPos), //Position
		"Back", "Assets/Font/MonogramsToolbox.ttf", //Text & font location
		(int)(dimensions.y * 0.06f), //Font size
		206, 158, 0, //Font colour
		renderer, //The renderer
		dimensions.y * 0.025f, //Border
		C_Vec2(dimensions.x * 0.4f, dimensions.y * 0.125f), //Minimum dimensions of the button
		universalSpeed //Universal Speed
		);

	//Load the scores
	loadScores();

	//Initialise score text
	for (int i = 0; i < 5; i++)
	{
		scoresText.push_back(new C_Text(scores[i], "Assets/Font/MonogramsToolbox.ttf", (int)(dimensions.y * 0.075f), renderer, 206, 158, 0));
	}
}
示例#5
0
int main(int argc, char *argv[])
{
	int i, result;

	progname = strrchr(argv[0], '/');
	if (progname == NULL)
		progname = argv[0];
	else
		progname++;
	if (argc == 1)
		usage();

	for (i = 0; i < MAX_SCORES; i++) {
		scoreNames[i] = NULL;
		scores[i] = NULL;
	}

	for (i = 1; i < argc; i++) {
		char *arg = argv[i];
		if (arg[0] == '-') {
			switch (arg[1]) {
				case 'a':
					if (++i >= argc)
						usage();
					rescaleFactor = atof(argv[i]);
					if (fabs(rescaleFactor) > 2.0)
						rescaleFactor = 2.0;
					break;
				case 'B':
					if (++i >= argc)
						usage();
					framesPerBuffer = atof(argv[i]);
					if (framesPerBuffer < MIN_FRAMES_PER_BUF)
						framesPerBuffer = MIN_FRAMES_PER_BUF;
					break;
				case 'c':
					if (++i >= argc)
						usage();
					numOutChannels = atof(argv[i]);
					if (numOutChannels < 1)
						numOutChannels = 1;
					break;
				case 'd':
					if (++i >= argc)
						usage();
					totalDuration = atof(argv[i]);
					if (totalDuration < 0.0)
						totalDuration = 0.0;	// kinda stupid
					break;
				case 'h':
					usage();
					break;
#ifdef HAVE_PORTAUDIO
				case 'n':
					withAudio = 0;
					scoreDelayTime = 0.0;
					break;
#endif
				case 'q':
					printJobOutput = 0;
					break;
				case 'r':
					if (++i >= argc)
						usage();
					sampleRate = atof(argv[i]);
					if (sampleRate < 8000) // be more stringent?
						sampleRate = 8000;
					break;
				case 'v':
					verbose = 1;
					break;
				case 'y':
					if (++i >= argc)
						usage();
					scoreDelayTime = atof(argv[i]);
					if (scoreDelayTime < 0.0)
						scoreDelayTime = 0.0;
					break;
//FIXME: others: call flush after each score? call destroy after each?
				default:
					usage();
			}
		}
		else {
			const char *name = arg;

			/* verify that filename ends in ".sco" */
			char *p = strrchr(name, '.');
			if (p == NULL || strncmp(p, ".sco", 4L)) {
				fprintf(stderr, "Score names must end in \".sco\" (%s).\n", name);
				exit(-1);
			}

			if (numScores < MAX_SCORES) {
				scoreNames[numScores] = name;
				numScores++;
			}
			else {
				fprintf(stderr, "No more than %d scores allowed.\n", MAX_SCORES);
				exit(-1);
			}
		}
	}

#ifdef HAVE_PORTAUDIO
	if (withAudio) {
		result = initAudio();
		if (result)
			return -1;
	}
#endif

	result = initRTcmix();
	if (result)
		return -1;

	result = loadScores();
	if (result)
		return -1;

	printSettings();

	playScores();

	for (i = 0; i < numScores; i++)
		if (scores[i])
			free(scores[i]);

	result = deleteRTcmix();

#ifdef HAVE_PORTAUDIO
	if (withAudio)
		result = deleteAudio();
#endif

	return result;
}
示例#6
0
void GameScores::reset()
{
    loadScores("data/reset_scores.dat");
    saveScores();
}
示例#7
0
void GameScores::loadScores()
{
    loadScores("data/scores.dat");
}
示例#8
0
GameScores::GameScores()
{
    currentScore=-1;
    loadScores();
}
示例#9
0
void Album::print()
      {
      if (_scores.isEmpty())
            return;
      loadScores();
      QPrinter printer(QPrinter::HighResolution);

      Score* score = _scores[0]->score;
      printer.setCreator("MuseScore Version: " MSC_VERSION);
      printer.setFullPage(true);
      printer.setColorMode(QPrinter::Color);
      printer.setDoubleSidedPrinting(score->pageFormat()->twosided());
      printer.setOutputFormat(QPrinter::NativeFormat);

      QPrintDialog pd(&printer, 0);
      if (!pd.exec())
            return;

      QPainter painter(&printer);
      painter.setRenderHint(QPainter::Antialiasing, true);
      painter.setRenderHint(QPainter::TextAntialiasing, true);
      double mag = printer.logicalDpiX() / MScore::DPI;
      painter.scale(mag, mag);

      int fromPage = printer.fromPage() - 1;
      int toPage   = printer.toPage()   - 1;
      if (fromPage < 0)
            fromPage = 0;
      if (toPage < 0)
            toPage = 100000;

      //
      // start pageOffset with configured offset of
      // first score
      //
      int pageOffset = 0;
      if (_scores[0]->score)
            pageOffset = _scores[0]->score->pageNumberOffset();

      foreach(AlbumItem* item, _scores) {
            Score* score = item->score;
            if (score == 0)
                  continue;
            score->setPrinting(true);
            //
            // here we ignore the configured page offset
            //
            int oldPageOffset = score->pageNumberOffset();
            score->setPageNumberOffset(pageOffset);
            score->doLayout();
            const QList<Page*> pl = score->pages();
            int pages    = pl.size();
            for (int n = 0; n < pages; ++n) {
                  if (n)
                        printer.newPage();
                  Page* page = pl.at(n);

                  QRectF fr = page->abbox();
                  QList<Element*> ell = page->items(fr);
                  qStableSort(ell.begin(), ell.end(), elementLessThan);
                  foreach(const Element* e, ell) {
                        e->itemDiscovered = 0;
                        if (!e->visible())
                              continue;
                        QPointF pos(e->pagePos());
                        painter.translate(pos);
                        e->draw(&painter);
                        painter.translate(-pos);
                        }
                  }
示例#10
0
bool Album::createScore(const QString& fn)
      {
      loadScores();

      Score* firstScore = _scores[0]->score;
      if (!firstScore) {
            qDebug("First score is NULL. Will not attempt to join scores.");
            return false;
            }

      // do layout for first score's root and excerpt scores
      firstScore->doLayout();
      for (int i = 0; i < firstScore->excerpts().count(); i++) {
            if (firstScore->excerpts().at(i)->partScore()) {
                  firstScore->excerpts().at(i)->partScore()->doLayout();
                  }
            else {
                  qDebug("First score has excerpts, but excerpt %d is NULL.  Will not attempt to join scores.", i);
                  return false;
                  }
            }

      Score* score = firstScore->clone();

      int excerptCount = firstScore->excerpts().count();
      bool joinExcerpt = true;
	for (AlbumItem* item : _scores) {
            if (item->score == 0 || item->score == firstScore)
                  continue;
            if (item->score->excerpts().count() != excerptCount) {
                  joinExcerpt = false;
                  qDebug("Will not join parts. Album item \"%s\".  Mismatch between number of excerpts with first album item \"%s\"", qPrintable(item->name), qPrintable(_scores[0]->name));
                  break;
                  }
            }
      if (!joinExcerpt) {
            for (Excerpt* ex : score->excerpts())
                  score->removeExcerpt(ex->partScore());
            }

      for (AlbumItem* item : _scores) {

            if (item->score == 0 || item->score == firstScore)
                  continue;

            // try to append root score
            item->score->doLayout();
            if (!score->appendScore(item->score)) {
                  qDebug("Cannot append root score of album item \"%s\".", qPrintable(item->name));
                  delete score;
                  return false;
                  }

            // try to append each excerpt
            if (joinExcerpt) {
                  for (int i = 0; i < score->excerpts().count(); i++) {
                        Score* currentScoreExcerpt = item->score->excerpts().at(i)->partScore();
                        if (currentScoreExcerpt) {
                              currentScoreExcerpt->doLayout();
                              if (!score->excerpts().at(i)->partScore()->appendScore(currentScoreExcerpt)) {
                                    qDebug("Cannot append excerpt %d of album item \"%s\".", i, qPrintable(item->name));
                                    delete score;
                                    return false;
                                    }
                              }
                        else {
                              qDebug("First score has excerpts, but excerpt %d of album item \"%s\" is NULL.  Will not attempt to join scores.",
                                          i, qPrintable(item->name));
                              delete score;
                              return false;
                              }
                        }
                  }
            }

      score->fileInfo()->setFile(fn);
      qDebug("Album::createScore: save file");
      try {
            QString suffix  = score->fileInfo()->suffix().toLower();
            if (suffix == "mscz")
                  score->saveCompressedFile(*score->fileInfo(), false);
            else if (suffix == "mscx")
                  score->saveFile(*score->fileInfo());
            }
      catch (QString s) {
            delete score;
            return false;
            }
      delete score;
      return true;
      }