Exemple #1
0
	bool Label::onMouseDown(april::Key keyCode)
	{
		if (Object::onMouseDown(keyCode))
		{
			return true;
		}
		if (isCursorInside())
		{
			this->triggerEvent("MouseDown", keyCode);
			return true;
		}
		return false;
	}
Exemple #2
0
void CSVRenderer::drawElement(CSVElement *csvElement) {
	int type = csvElement->getType();
	CSVSRC *currentSRC = csvElement->src[csvElement->srcNum];

	if (type == CSVReader::CSVTYPE_IMAGE || 
		type == CSVReader::CSVTYPE_JUDGELINE) {
		// in case of IMG
		drawImage(csvElement);
	} else if (type == CSVReader::CSVTYPE_BUTTON) {
		// similar to IMG, but considers click
		CSVSRC csrc;
		CSVDST cdst;
		int idx = csvElement->getSRCIndex();
		if (csvElement->getCurrentSRC()->getClick() == 1) {
			idx += CSVButton::GetClick(csvElement->getCurrentSRC()->getButtonType());
		}
		csvElement->getSRCFromIdx(&csrc, idx);
		
		// INFO: we won't check SRC OP
		if (csvElement->getDST(&cdst)) {
			// convert negative height/width
			// cause CSV won't support this
			if (cdst.getWidth() < 0) {
				cdst.dst[2] = cdst.getX() + cdst.getWidth();
				cdst.dst[4] = -cdst.getWidth();
			}
			if (cdst.getHeight() < 0) {
				cdst.dst[3] = cdst.getY() + cdst.getHeight();
				cdst.dst[5] = -cdst.getHeight();
			}

			// draw image
			drawFunc(csvElement->getCurrentSRC()->getImgNum(), 0, &csrc, &cdst);
		
			// TODO: check ONMOUSE
			// (draw onmouse first)
			// route had moved to drawAll
			/*
			CSVElement *onmouse = csvElement->getRelatedElement();
			if (onmouse && isCursorInside(&cdst)) {
				drawImage(onmouse);
			}*/
		}
	} else if (type == CSVReader::CSVTYPE_ONMOUSE) {
		// check isCursorInside
		CSVDST *dst = csvElement->getCurrentLastDST();

		if (dst) {
			CSVSRC *src = csvElement->getCurrentSRC();
			CSVDST ndst;
			ndst.setDSTWidth( src->getONX2() );
			ndst.setDSTHeight( src->getONY2() );
			ndst.setDSTX( dst->getX()+src->getONX() );
			ndst.setDSTY( dst->getY()+src->getONY() );
			if (isCursorInside(&ndst))
				drawImage(csvElement);
		}
	} else if (type == CSVReader::CSVTYPE_TEXT) {
		// draw text
		drawText(csvElement);
	} else if (type == CSVReader::CSVTYPE_NUMBER) {
		// draw Number
		drawNumber(csvElement);
	} else if (type == CSVReader::CSVTYPE_BARGRAPH) {
		CSVSRC csrc;
		CSVDST cdst;

		csvElement->getSRC(&csrc);
		if (csvElement->getDST(&cdst)) {
			if (currentSRC->getMuki() == 0) {
				// change width
				cdst.setDSTWidth(cdst.getWidth() * CSVBargraph::getVal(currentSRC->getNum()));
			} else {
				// change height
				cdst.setDSTHeight(cdst.getHeight() * CSVBargraph::getVal(currentSRC->getNum()));
			}
			
			// convert negative height/width
			// cause CSV won't support this
			if (cdst.getWidth() < 0) {
				cdst.dst[2] = cdst.getX() + cdst.getWidth();
				cdst.dst[4] = -cdst.getWidth();
			}
			if (cdst.getHeight() < 0) {
				cdst.dst[3] = cdst.getY() + cdst.getHeight();
				cdst.dst[5] = -cdst.getHeight();
			}

			drawFunc(currentSRC->getImgNum(), 0, &csrc, &cdst);
		}
	} else if (type == CSVReader::CSVTYPE_GROOVEGUAGE) {
		// TODO: change algorithm for graph (blinking effect)
		// get guage
		int guage = CSVNumber::getNumber(CSVNumConst::PLAYER_1P_GUAGE);
		int addx = currentSRC->getOP1();
		int addy = currentSRC->getOP2();

		// draw 50
		CSVSRC csrc;
		CSVDST cdst;

		// TODO: if guage has no Alphablend ...? -> change it with preload...?
		// TODO: if 2P plays...?
		if (csvElement->getDST(&cdst)) {
			int orgX = cdst.getX();
			int orgY = cdst.getY();

			bool blink;

			for (int i=0; i<guage; i+=2) {
				// blinking effect - display faint when true
				blink = false;
				if (i != 0 && i != guage-2) {
					if (i == guage - 4) {
						if (rand() % 100 < 70)
							blink = true;
					} else if (i == guage - 6) {
						if (rand() % 100 < 50)
							blink = true;
					}
				}

				if (CSVOption::getOption(CSVOptionConst::PLAYER1_NORMAL_GUAGE)) {
					if (i >= 80) {
						if (!blink)
							csvElement->getSRCFromIdx(&csrc, 0);	// survival guage color
						else
							csvElement->getSRCFromIdx(&csrc, 2);
					} else {
						if (!blink)
							csvElement->getSRCFromIdx(&csrc, 1);
						else
							csvElement->getSRCFromIdx(&csrc, 3);
					}
				} else if (CSVOption::getOption(CSVOptionConst::PLAYER1_HARD_GUAGE)) {
					if (!blink)
						csvElement->getSRCFromIdx(&csrc, 0);
					else
						csvElement->getSRCFromIdx(&csrc, 2);
				}
				
				cdst.setDSTX(orgX);
				cdst.setDSTY(orgY);

				drawFunc(currentSRC->getImgNum(), 0, &csrc, &cdst);
				orgY += addy;
				orgX += addx;
			}
			for (int i=guage; i<100; i+=2) {
				if (CSVOption::getOption(CSVOptionConst::PLAYER1_NORMAL_GUAGE)) {
					if (i >= 80)
						csvElement->getSRCFromIdx(&csrc, 2);	// survival guage color
					else
						csvElement->getSRCFromIdx(&csrc, 3);
				} else if (CSVOption::getOption(CSVOptionConst::PLAYER1_HARD_GUAGE)) {
					csvElement->getSRCFromIdx(&csrc, 2);
				}
				
				cdst.setDSTX(orgX);
				cdst.setDSTY(orgY);

				drawFunc(currentSRC->getImgNum(), 0, &csrc, &cdst);

				orgY += addy;
				orgX += addx;
			}
		}
	} else if (type == CSVReader::CSVTYPE_NOWJUDGE_1P) {
		// TODO: support 2P
		// nowcombo is drawed with NOWJUDGE, so we won't make case for that.
		CSVSRC src_nowjudge;
		CSVDST dst_nowjudge, dst_nowcombo;

		// set judge case
		int judge = 0;
		if (CSVOption::getOption(CSVOptionConst::PLAY_1P_JUDGE_PGREAT))
			judge = 5;
		else if (CSVOption::getOption(CSVOptionConst::PLAY_1P_JUDGE_GREAT))
			judge = 4;
		else if (CSVOption::getOption(CSVOptionConst::PLAY_1P_JUDGE_GOOD))
			judge = 3;
		else if (CSVOption::getOption(CSVOptionConst::PLAY_1P_JUDGE_BAD))
			judge = 2;
		else if (CSVOption::getOption(CSVOptionConst::PLAY_1P_JUDGE_POOR))
			judge = 1;
		else if (CSVOption::getOption(CSVOptionConst::PLAY_1P_JUDGE_EMPTYPOOR))
			judge = 0;
		csvElement->srcNum = csvElement->dstNum = judge;

		csvElement->getSRC(&src_nowjudge);
		if (csvElement->getDST(&dst_nowjudge)) {
			// get nowcombo
			CSVElement *csvCombo = csvElement->parent->csvNowCombo1P;
			// TODO: set judge case
			csvCombo->srcNum = csvCombo->dstNum = judge;

			int width = 0;
			bool comboDrawable = false;

			// set combo
			int combo = CSVNumber::getNumber(CSVNumConst::PLAYER_COMBO);

			if (csvCombo->getDST(&dst_nowcombo)) {
				comboDrawable = true;
				// src op1 is noshift (dstOffset is 0)
				if (csvCombo->getCurrentSRC()->getOP1() == 0) {
					// get total number size
					width = dst_nowcombo.getWidth() * getNumberLength(combo);
				}
			}

			// draw image
			csvElement->dstOffsetX = -width/2;
			drawImage(csvElement);
			if (comboDrawable) {
				csvCombo->dstOffsetX = dst_nowjudge.getX()-width/2;
				csvCombo->dstOffsetY = dst_nowjudge.getY();
				drawNumber(csvCombo, combo);
				// it effects to next getDST, so init them
				csvCombo->dstOffsetX = 0;
				csvCombo->dstOffsetY = 0;
			}
			csvElement->dstOffsetX = 0;
		}
	} else if (type == CSVReader::CSVTYPE_SLIDER) {
		// muki - 0: top, 1:right, 2:bottom, 3:left
		CSVSRC *src = csvElement->getCurrentSRC();
		int muki = src->getSliderMuki();
		int offsetX, offsetY;
		offsetX = offsetY = CSVSlider::getSliderValue(src->getSliderType())
			* src->getSliderRange();
		switch (muki) {
		case 0:
			offsetX = 0;
			offsetY = src->getSliderRange() - offsetY;
			break;
		case 1:
			offsetY = 0;
			break;
		case 2:
			offsetX = 0;
			break;
		case 3:
			offsetX = src->getSliderRange() - offsetX;
			offsetY = 0;
			break;
		}
		csvElement->dstOffsetX = offsetX;
		csvElement->dstOffsetY = offsetY;
		drawImage(csvElement);
	} else if (type == CSVReader::CSVTYPE_BAR_BODY) {
		// calculate moving first
		CSVSelectList::CalculateMoving();

		// call drawbar with current argument
		for (int i=0; i<30; i++) {
			drawBar(csvElement, i);
		}

		// draw BAR_FLASH
		CSVSRC csrc;
		CSVDST cdst;
		csvElement->parent->csvFlash->getSRC(&csrc);
		if (csvElement->getDSTBar(&cdst, csvElement->parent->barCenter)) {
			csvElement->parent->csvFlash->dstOffsetX = cdst.getX();
			csvElement->parent->csvFlash->dstOffsetY = cdst.getY();
			drawImage(csvElement->parent->csvFlash);
		}
	} else if (type == CSVReader::CSVTYPE_NOTE) {
		// draw note/lnnote/mine/line
		if (notedrawFunc) {
			notedrawFunc();
		}
	}
}