Exemple #1
0
void Board::checkCombos()
{
	mMatchesMade = false;
	vector<Point> comboMatches;
	for(int i = 0; i < mColumns; i++)
	{//if no matches were made in this column, ignore it
		if(mMatchingInfo.numberMatchesInColumn[i] == 0)
			continue;

		//checkmatches on the all the elements of this column above the lowest gem matched
		for(int j = 0; j <= mMatchingInfo.lowestGemPosition[i]; j++)
		{
			Point modifiedGemPoint = Point(i,j);
			Gem* g = mTiles[XYCoordinatesToIndex(modifiedGemPoint)];
			g->setVisible(true);

			mergeMatches(&comboMatches, checkForMatches(modifiedGemPoint ) );
		}
	}
	
	//clear matchingInfo
	clearNumberMatchesInColumns();
	
	//if we have matches, store and save info
	if(comboMatches.size() > 0)
		storeMatches(comboMatches);
	else
		if(mInitializing)	//if we are still initializing but haven't any more matches, finish initialization
			finishInitializing();
}
Exemple #2
0
void Board::switchGems(Point p1, Point p2, bool reverting, bool animate)
{
	mSwitching = true;
	//get vector index from coordinate in "matrix"
	int p1Index = XYCoordinatesToIndex(p1);
	int p2Index = XYCoordinatesToIndex(p2);
	//switch pointers
	Gem* tempGem = mTiles[p1Index];
	mTiles[p1Index] = mTiles[p2Index];
	mTiles[p2Index] = tempGem;
	
	//if we ante animations
	if(animate)
	{
		moveGem(mTiles[p1Index], mTiles[p2Index]->getPosition());
		moveGem(mTiles[p2Index], mTiles[p1Index]->getPosition());
	}

	//if we aren't reverting, check for matches
	if(!reverting)
	{
		vector<Point> matches = checkForMatches(p1);	
		vector<Point> matchesP2 = checkForMatches(p2);

		mergeMatches(&matches, matchesP2);

		//we weren't reverting and didn't find any match so need to undo the switch
		if(matches.size() == 0)
		{
			mUndoSwitch = true;
			mUndo.p1 = p1;
			mUndo.p2 = p2;
		}
		else
		{//we found matches so prepare things for animations
			storeMatches(matches);
		}
	}

	mSwitching = false;
}
void AlignmentDisplay::VLRcheck(vector<point> matches)//alternative to loadTexture
{
	/*int s = ui->scaleDial->value();
	s = max(4, (s / 4) * 4);//enforces scale is a multiple of 4
	ui->scaleDial->setValue(s);
	checkVariables();*/
	//return if changed?

	vector<color> alignment_colors;
	int end = max(1, (nucleotide_start + display_size) - 251);
	for(int i = nucleotide_start; i < end; i+=scale)
		alignment_colors.push_back( simpleAlignment(i) );

	mergeMatches( alignment_colors, matches );

	if(textureBuffer)
		delete textureBuffer;
	textureBuffer = new TextureCanvas( alignment_colors, width());

	upToDate = true;
}
SimilarCategoriesDialog::SimilarCategoriesDialog( ElementList &list, QWidget* parent )
   : QDialog( parent ),
     m_elementList(list)
{
   setObjectName( "SimilarCategoriesDialog" );
   setModal( true );

	SimilarCategoriesDialogLayout = new QVBoxLayout( this );
   SimilarCategoriesDialogLayout->setMargin( 11 );
   SimilarCategoriesDialogLayout->setSpacing( 6 );
   SimilarCategoriesDialogLayout->setObjectName( "SimilarCategoriesDialogLayout" );

	layout6 = new QHBoxLayout();
   layout6->setMargin( 0 );
   layout6->setSpacing( 6 );
   layout6->setObjectName( "layout6" );

	layout4 = new QGridLayout();
   layout4->cellRect( 1, 1 );
   layout4->setMargin( 0 );
   layout4->setSpacing( 6 );
   layout4->setObjectName( "layout4" );

	categoriesBox = new KLineEdit( this );

	layout4->addWidget( categoriesBox, 0, 1 );

	thresholdSlider = new QSlider( this );
   thresholdSlider->setObjectName( "thresholdSlider" );
	thresholdSlider->setValue( 40 );
	thresholdSlider->setOrientation( Qt::Horizontal );

	layout4->addWidget( thresholdSlider, 1, 1 );

	thresholdLabel = new QLabel( this );
   thresholdLabel->setObjectName( "thresholdLabel" );

	layout4->addWidget( thresholdLabel, 1, 0 );

	categoryLabel = new QLabel( this );
   categoryLabel->setObjectName( "categoryLabel" );

	layout4->addWidget( categoryLabel, 0, 0 );
	layout6->addLayout( layout4 );

	layout5 = new QVBoxLayout();
   layout5->setMargin( 0 );
   layout5->setSpacing( 6 );
   layout5->setObjectName( "layout5" );

	searchButton = new QPushButton( this );
   searchButton->setObjectName( "searchButton" );
	layout5->addWidget( searchButton );
	spacer4 = new QSpacerItem( 20, 51, QSizePolicy::Minimum, QSizePolicy::Expanding );
	layout5->addItem( spacer4 );
	layout6->addLayout( layout5 );
	SimilarCategoriesDialogLayout->addLayout( layout6 );

	layout9 = new QHBoxLayout();
   layout9->setMargin( 0 );
   layout9->setSpacing( 6 );
   layout9->setObjectName( "layout9" );

	layout8 = new QVBoxLayout();
   layout8->setMargin( 0 );
   layout8->setSpacing( 6 );
   layout8->setObjectName( "layout8" );

	allLabel = new QLabel( this );
   allLabel->setObjectName( "allLabel" );
	layout8->addWidget( allLabel );

	allListView = new K3ListView( this );
	allListView->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, 0, 1, allListView->sizePolicy().hasHeightForWidth() ) );
	layout8->addWidget( allListView );
	layout9->addLayout( layout8 );

	layout1 = new QVBoxLayout();
   layout1->setMargin( 0 );
   layout1->setSpacing( 6 );
   layout1->setObjectName( "layout1" );

	removeButton = new QPushButton( this );
   removeButton->setObjectName( "removeButton" );
	layout1->addWidget( removeButton );

	addButton = new QPushButton( this );
   addButton->setObjectName( "addButton" );
	layout1->addWidget( addButton );
	spacer1 = new QSpacerItem( 20, 61, QSizePolicy::Minimum, QSizePolicy::Expanding );
	layout1->addItem( spacer1 );
	layout9->addLayout( layout1 );

	layout7 = new QVBoxLayout();
   layout7->setMargin( 0 );
   layout7->setSpacing( 6 );
   layout7->setObjectName( "layout7" );

	toMergeLabel = new QLabel( this );
   toMergeLabel->setObjectName( "toMergeLabel" );
	layout7->addWidget( toMergeLabel );

	toMergeListView = new K3ListView( this );
	toMergeListView->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, 0, 1, toMergeListView->sizePolicy().hasHeightForWidth() ) );
	layout7->addWidget( toMergeListView );
	layout9->addLayout( layout7 );
	SimilarCategoriesDialogLayout->addLayout( layout9 );

	layout10 = new QHBoxLayout();
   layout10->setMargin( 0 );
   layout10->setSpacing( 6 );
   layout10->setObjectName( "layout10" );

	spacer2 = new QSpacerItem( 310, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
	layout10->addItem( spacer2 );

	mergeButton = new QPushButton( this );
   mergeButton->setObjectName( "mergeButton" );
	layout10->addWidget( mergeButton );

	cancelButton = new QPushButton( this );
   cancelButton->setObjectName( "cancelButton" );
	layout10->addWidget( cancelButton );
	SimilarCategoriesDialogLayout->addLayout( layout10 );
	languageChange();
	resize( QSize(573, 429).expandedTo(minimumSizeHint()) );
	//clearWState( WState_Polished );

	connect( searchButton, SIGNAL(clicked()), this, SLOT(findMatches()) );
	connect( mergeButton, SIGNAL(clicked()), this, SLOT(mergeMatches()) );
	connect( cancelButton, SIGNAL(clicked()), this, SLOT(reject()) );
	connect( addButton, SIGNAL(clicked()), this, SLOT(addCategory()) );
	connect( removeButton, SIGNAL(clicked()), this, SLOT(removeCategory()) );
}