Esempio n. 1
0
// The Rose drawFlower method
// This method prints the image of the individual rose onto the garden image.
// If a new color is specified, it changes the original color to the new color here
// Returns: Nothing
// Parameters: BMP*, int, int
void Rose::drawFlower(BMP* garden, int CoordX, int CoordY) {
	int width = flowerImage->TellWidth();
	int height = flowerImage->TellHeight();
	for (int i = 0; i < width; i++) {
		for (int j = 0; j < height; j++) {
			if (getNewColor() == NULL) {
				*((*garden)(CoordX+i, CoordY+j)) = *(*flowerImage)(i,j);
			} else {
				*((*garden)(CoordX+i, CoordY+j)) = changeColors(originColor, getNewColor(), (*flowerImage)(i,j));	
			}
		}
	}
}
Esempio n. 2
0
void OptionDialog::showChanges()
{
   // Set the right language
   int ndx = ndxToLangCode.indexOf( Brewtarget::getCurrentLanguage() );
   if( ndx >= 0 )
      comboBox_lang->setCurrentIndex(ndx);


   weightComboBox->setCurrentIndex(weightComboBox->findData(Brewtarget::weightUnitSystem));
   temperatureComboBox->setCurrentIndex(temperatureComboBox->findData(Brewtarget::tempScale));
   volumeComboBox->setCurrentIndex(volumeComboBox->findData(Brewtarget::volumeUnitSystem));
   gravityComboBox->setCurrentIndex(gravityComboBox->findData(Brewtarget::densityUnit));
   dateComboBox->setCurrentIndex(dateComboBox->findData(Brewtarget::dateFormat));
   colorComboBox->setCurrentIndex(colorComboBox->findData(Brewtarget::colorUnit));

   colorFormulaComboBox->setCurrentIndex(colorFormulaComboBox->findData(Brewtarget::colorFormula));
   ibuFormulaComboBox->setCurrentIndex(ibuFormulaComboBox->findData(Brewtarget::ibuFormula));

   // Data directory
   btStringEdit_dataDir->setText(Brewtarget::getUserDataDir().canonicalPath());

   // Backup stuff
   btStringEdit_backupDir->setText( Brewtarget::option("directory", Brewtarget::getUserDataDir().canonicalPath(), "backups").toString() );
   spinBox_numBackups->setValue( Brewtarget::option("maximum", 10, "backups").toInt() );
   spinBox_frequency->setValue( Brewtarget::option("frequency", 4, "backups").toInt() );

   // The IBU modifications. These will all be calculated from a 60 min boil. This is gonna get confusing.
   double amt = Brewtarget::toDouble(Brewtarget::option("mashHopAdjustment",0).toString(), "OptionDialog::showChanges()");
   ibuAdjustmentMashHopDoubleSpinBox->setValue(amt*100);

   amt = Brewtarget::toDouble(Brewtarget::option("firstWortHopAdjustment",1.1).toString(), "OptionDialog::showChanges()");
   ibuAdjustmentFirstWortDoubleSpinBox->setValue(amt*100);

   // Database stuff -- this looks weird, but trust me. We want SQLITE to be
   // the default for this field
   int tmp = (Brewtarget::DBTypes)Brewtarget::option("dbType",Brewtarget::SQLITE).toInt();
   comboBox_engine->setCurrentIndex(tmp);

   btStringEdit_hostname->setText(Brewtarget::option("dbHostname","localhost").toString());
   btStringEdit_portnum->setText(Brewtarget::option("dbPort","5432").toString());
   btStringEdit_schema->setText(Brewtarget::option("dbSchema","public").toString());
   btStringEdit_dbname->setText(Brewtarget::option("dbName","brewtarget").toString());
   btStringEdit_username->setText(Brewtarget::option("dbUsername","brewtarget").toString());
   btStringEdit_password->setText(Brewtarget::option("dbPassword","").toString());
   checkBox_savePassword->setChecked( Brewtarget::hasOption("dbPassword") );

   status = OptionDialog::NOCHANGE;
   changeColors();
}
Esempio n. 3
0
void OptionDialog::testConnection()
{
   bool success;
   QString hostname, schema, database, username, password;
   int port;

   Brewtarget::DBTypes newType = (Brewtarget::DBTypes)comboBox_engine->currentIndex();
   // Do nothing if nothing is required.
   if ( status == OptionDialog::NOCHANGE || status == OptionDialog::TESTPASSED)
   {
      return;
   }

   switch( newType )
   {
      case Brewtarget::PGSQL:
         hostname = btStringEdit_hostname->text();
         schema   = btStringEdit_schema->text();
         database = btStringEdit_dbname->text();
         username = btStringEdit_username->text();
         password = btStringEdit_password->text();
         port     = (btStringEdit_portnum->text()).toInt();

         success = Database::verifyDbConnection(newType,hostname,port,schema,database,username,password);
         break;
      default:
         hostname = QString("%1/%2").arg(btStringEdit_dataDir->text()).arg("database.sqlite");
         success = Database::verifyDbConnection(newType,hostname);
   }

   if ( success ) 
   {
      QMessageBox::information(0,
                           QObject::tr("Connection Test"),
                           QString(QObject::tr("Connection to database was successful"))
                           );
      status = OptionDialog::TESTPASSED;
   }
   else 
   {
      // Database::testConnection already popped the dialog
      status = OptionDialog::TESTFAILED;
   }
   changeColors();
}
Esempio n. 4
0
File: game.c Progetto: dougvk/CS223
int executeGame(Hexboard hb, FILE* input, int lineNumber, CellContents* redOrBlue)
{
	int x,y,row,col;
	x = -1;
	y = -1;
	if(getInput(&x,&y,input,lineNumber) == EOF) return EOF;

	Status pointStatus;
 	CellContents contents;

	pointStatus = findHex(hb,x,y,&row,&col);

	if(pointStatus == OffBoard)
	{
		printf("Point (%i,%i) is off the board\n\n", x, y);
		return 0;
	} else
	{
		printf("Point (%i,%i) belongs to cell [%i,%i]\n", x, y, row, col);

		getCellHex(hb,row,col,&contents);

		if(contents != Empty) 
		{
			printf("Cell occupied, point ignored\n\n");
			return 0;
		} else
		{
			putCellHex(hb,row,col,*redOrBlue);

			if(*redOrBlue == Red) printf("Playing red (r) in cell [%i,%i]\n",row,col);
			else printf("Playing blue (b) in cell [%i,%i]\n",row,col);

			displayBoardHex(hb);
			changeColors(redOrBlue);
		}
	}

	return 0;
}
Esempio n. 5
0
void OptionDialog::testRequired()
{
   status = OptionDialog::NEEDSTEST;
   changeColors();
}