Esempio n. 1
0
void ofxGuiGrid::draw() {
	selectedColor();

	glPushMatrix();
		glTranslatef( mObjX, mObjY, 0.0f );

		if ( bDblClickMode ) {
			this->dblClickImage->draw();
		} else {
			if ( mParamName != "" ) {
				drawParamString( 0.0, 0.0, mParamName, false );
			}

			ofFill();

			//! Background
			//glColor4f( mGlobals->mCoverColor.r, mGlobals->mCoverColor.g, mGlobals->mCoverColor.b, mGlobals->mCoverColor.a );

			ofNoFill();

			//! Grids
			for ( int j = 0; j < mYGrid; j++ ) {
				for ( int i = 0; i < mXGrid; i++ ) {
					int index = i + j * mXGrid;
					ofNoFill();

					if ( mSelectedId == index ) {
						drawSelectedRect( getGridX(i), getGridY(j), getGridWidth(), getGridHeight() );
					} else {
						glColor4f( mGlobals->mFrameColor.r, mGlobals->mFrameColor.g, mGlobals->mFrameColor.b, mGlobals->mFrameColor.a );
						//ofRect( mCtrX + mBorder + i * mSpacing + i * mGridWidth,
						//	mCtrY + mBorder + j * mSpacing + j * mGridHeight,
						//	mGridWidth, mGridHeight );
						ofRect( getGridX(i), getGridY(j), getGridWidth(), getGridHeight() );
					}

					if ( gridImages[index] != NULL ) {
						gridImages[index]->draw();
					}
				}
			}
		}

		ofNoFill();

		//! Frame
		glColor4f( mGlobals->mFrameColor.r, mGlobals->mFrameColor.g, mGlobals->mFrameColor.b, mGlobals->mFrameColor.a );

		ofRect( mCtrX, mCtrY, mCtrWidth, mCtrHeight );

	glPopMatrix();

	if ( !bDblClickMode ) {
		for ( int i = 0; i < mObjects.size(); ++i ) {
			mObjects[i]->draw();
		}
	}
}
Esempio n. 2
0
void EditLayer::onMessage( unsigned int type, unsigned long param1, unsigned long param2 )
{
	switch (type)
	{
	case MSG_DELETESELECTED:
		deleteSelected();
		break;

	case MSG_CHANGEITEMTYPE:
		changeEnemyType(param1, param2);
		break;

	case MSG_CHANGEITEMRINGTYPE:
		changeEnemyRingType(param1, param2);
		break;

	case MSG_CHANGEBOXTYPE:
		changeBlockBoxType(param1, param2);
		break;

	case MSG_CHANGESELECTED:
		{
			hidePropertyLayer();
			hideBlockBoxPropertyLayer();

			int old_sel = param1;
			int new_sel = param2;

			Node* pNode = this->getChildByTag(old_sel);
			if (pNode)
				pNode->removeChildByTag(TAG_SELECTED_RECT);

			Sprite* pSelected = dynamic_cast<Sprite*>(this->getChildByTag(new_sel));
			if (pSelected)
				drawSelectedRect(pSelected);
		}
		break;

	case MSG_ADDBLOCK:
		{
			switch (param1)
			{
			case kBlockBox:
				addBlock(Vec2(200, 200));
				break;

			case kBlockWheel:
				addWheel(Vec2(300, 300));
				break;

			case kBlockVortex:
				addVortex(Vec2(400, 400));
				break;

			case kBlockBomb:
				addBomb(Vec2(500, 500));
				break;
			default:
				break;
			}
		}
		break;

	case MSG_ADDENEMYITEM:
		addEnemy(BallBase::kTypeNormal1, Vec2(100, 100), BallBase::kTypeBulletUnknown);
		break;

	case MSG_SAVESTAGE:
		{
			_sectionId = param1;
			_stageId = param2;
			save();
		}
		break;

	case MSG_SETBULLETCOUNT:
		{
			_bulletCounter[param1] = param2;
			updateBulletCount();
		}
		break;

	default:
		break;
	}
}