コード例 #1
0
ファイル: box_viewer.cpp プロジェクト: Razorzeto/PHBank
// --------------------------------------------------
/// Compute the slot and the inslot of the cursor
void computeSlot(CursorBox_s* cursorBox)
// --------------------------------------------------
{
	currentBox(cursorBox);
	cursorBox->inslot = cursorBox->row == BOX_HEADER_SELECTED ? SLOT_NO_SELECTION : cursorBox->row * BOX_COL_PKM_COUNT + cursorBox->col;
	cursorBox->slot   = cursorBox->row == BOX_HEADER_SELECTED ? SLOT_NO_SELECTION : *cursorBox->box * BOX_PKM_COUNT + cursorBox->inslot;
}
コード例 #2
0
ファイル: IMGUI.cpp プロジェクト: DezerteR/Po-Male-Ka
IMGUI& IMGUI::offset(float x, float y){
	float u(x),v(y);
	auto &parentBox = currentBox().m_box;
	if(x>-1 && x<1){
		u += parentBox.z*x;
	}
	if(y>-1 && y<1){
		v += parentBox.w*y;
	}
	if(x<0){
		u += parentBox.z;
	}
	if(y<0){
		v += parentBox.w;
	}

	this->m_box.x += floor(u);
	this->m_box.y += floor(v);

	this->m_hover = hasHover(this->m_box);
	this->m_lClicked = this->m_hover && this->ks.lClick;
	this->m_rClicked = this->m_hover && this->ks.rClick;

	return *this;
}
コード例 #3
0
ファイル: IMGUI.cpp プロジェクト: DezerteR/Po-Male-Ka
IMGUI& IMGUI::rect(int w, int h){

	this->m_box = currentBox().getSpawnPoint(Box(0,0,w,h));
	this->m_hover = hasHover(this->m_box);
	this->m_lClicked = this->m_hover && this->ks.lClick;
	this->m_rClicked = this->m_hover && this->ks.rClick;
	return *this;
}
コード例 #4
0
ファイル: IMGUI.cpp プロジェクト: DezerteR/Po-Male-Ka
IMGUI& IMGUI::image(const std::string &name){
	this->m_image = m_imageSet->set[name];
	this->m_box = currentBox().getSpawnPoint(this->m_image.rect);
	this->m_image.rect = this->m_box;
	this->m_hover = hasHover(this->m_box) && !captureMouse;
	this->m_lClicked = this->m_hover && this->ks.lClick;
	this->m_rClicked = this->m_hover && this->ks.rClick;
	this->m_imageEnbl = true;
	return *this;
}
コード例 #5
0
ファイル: IMGUI.cpp プロジェクト: DezerteR/Po-Male-Ka
IMGUI& IMGUI::rect(HexColor color){
	this->m_box = currentBox().getSpawnPoint(Box(0,0,20,20));
	this->m_hover = hasHover(this->m_box);
	this->m_lClicked = this->m_hover && this->ks.lClick;
	this->m_rClicked = this->m_hover && this->ks.rClick;

	m_UIContainer->push(Label, color, this->m_box, currentLayer);

	this->m_forceNoDraw = true;

	return *this;
}
コード例 #6
0
ファイル: IMGUI.cpp プロジェクト: DezerteR/Po-Male-Ka
IMGUI& IMGUI::size(float x, float y){
	auto &parentBox = currentBox().m_box;
	if(x>-1 && x<1){
		x = floor(abs(parentBox.z * x));
	}
	if(y>-1 && y<1){
		y = floor(abs(parentBox.w * y));
	}
	this->m_box.z = x;
	this->m_box.w = y;

	return *this;
}
コード例 #7
0
void ADonkeyKongCharacter::Landed(const FHitResult& Hit)
{
	Super::Landed(Hit);
	//make box at last location
	//in case of falling, in location where pawn last standed.
	//in case of jumping it will be at about jump apex.
	FBox lastBox(LastLocation-100, LastLocation+100);
	//and box at location where pawn landed.
	FBox currentBox(GetActorLocation() - 100, GetActorLocation() + 100);

	if (currentBox.Intersect(lastBox))
	{

	}
	else
	{
		CharacterDied();
	}
}
コード例 #8
0
ファイル: IMGUI.cpp プロジェクト: DezerteR/Po-Male-Ka
IMGUI& IMGUI::operator () (int flags){
	if(this->m_lClicked || this->m_rClicked)
		this->m_box += Box(-1,-1,2,2);

	// if((flags & UI::Hover) && this->m_hover)
	// 	 m_UIContainer->push(UI::Hover, m_styles[m_style].hover, this->m_box, currentLayer);
	// else if(flags & UI::Editable)
	// 	 m_UIContainer->push(UI::Editable, m_styles[m_style].editBox, this->m_box, currentLayer);
	// else if(flags & UI::Label)
	// 	 m_UIContainer->push(UI::Label, m_styles[m_style].button, this->m_box, currentLayer);
	if (!(m_buttonFlags & NoInsertion))
		 currentBox().insertRect(this->m_box);

	// m_UIContainer->push(flags, m_styles[m_style], this->m_color, this->m_box, currentLayer);
	m_UIContainer->push(flags, m_styles[0], this->m_color, this->m_box, currentLayer);

	if(this->m_imageEnbl){
		// this->m_image.color = this->m_color;
		// this->m_image.color = this->m_forceColor ? m_color : m_styles[m_style].imageColor;
		this->m_image.color = this->m_color ? this->m_color : m_styles[m_style].imageColor;
		m_UIContainer->push(UI::Image, this->m_image);
	}
	if (flags & UI::CaptureMouse){
		if(this->m_lClicked || this->m_rClicked){
			this->ks.lClick = false;
			this->ks.rClick = false;
			this->ks.mousePosition = glm::vec2(-500, -500);
			this->captureMouse = true;
		}
		if(this->m_lClicked&& this->m_hover){
			this->captureMouse = true;
		}
	}
	restoreDefaults();
	return *this;
}
コード例 #9
0
ファイル: box_viewer.cpp プロジェクト: Razorzeto/PHBank
// --------------------------------------------------
Result BoxViewer::updateControls(const u32& kDown, const u32& kHeld, const u32& kUp, const touchPosition* touch)
// --------------------------------------------------
{
	if (hasRegularChild() || hasOverlayChild()) { if (this->child->updateControls(kDown, kHeld, kUp, touch) == PARENT_STEP); else return CHILD_STEP; }

	// TODO: Detect if mediatype and the cartridge has been removed!
	// Result FSUSER_CardSlotIsInserted(bool* inserted)

	if (kDown & KEY_START)
	{
		// Open the Savexit popup
		new SavexitViewer(ViewType::Overlay, this);
		child->initialize();
		return CHILD_STEP;
	}

	bool bboxMod = false;

	{
		bool boolMod = false;
		s16 boxMod = 0;
		s16 rowMod = 0;
		s16 colMod = 0;

		if (kDown & KEY_L) boxMod--;
		else if (kDown & KEY_R) boxMod++;

		if (kDown & KEY_UP) rowMod--;
		else if (kDown & KEY_DOWN) rowMod++;

		if (kDown & KEY_LEFT) { if (cursorBox.row == BOX_HEADER_SELECTED) boxMod--; else colMod--; }
		else if (kDown & KEY_RIGHT) { if (cursorBox.row == BOX_HEADER_SELECTED) boxMod++; else colMod++; }

		if (kDown & KEY_ZL) { cursorBox.inBank = false; boolMod = true; }
		else if (kDown & KEY_ZR) { cursorBox.inBank = true; boolMod = true; }

		if (kDown & KEY_TOUCH)
		{
			s16 boxShift = cursorBox.inBank ? BK_BOX_SHIFT_USED : PC_BOX_SHIFT_USED;

			// If the box arrows are touched down
			if (touchWithin(touch->px, touch->py, boxShift + 4, 18, 16, 24)) boxMod--;
			else if (touchWithin(touch->px, touch->py, boxShift + 200, 18, 16, 24)) boxMod++;

			boxShift = cursorBox.inBank ? PC_BOX_SHIFT_UNUSED : BK_BOX_SHIFT_UNUSED;

			// If the other box (PC|BK) is touched down
			if (touchWithin(touch->px, touch->py, boxShift, 0, BACKGROUND_WIDTH, BACKGROUND_HEIGHT)) { cursorBox.inBank = !cursorBox.inBank; boolMod = bboxMod = true; }
		}
		else if (kHeld & KEY_TOUCH)
		{
			if (sPkm || isPkmChecking)
			{
				s16 boxShift = cursorBox.inBank ? BK_BOX_SHIFT_USED : PC_BOX_SHIFT_USED;

				// If the box arrows are touched held once
				if (touchWithin(touch->px, touch->py, boxShift + 4, 18, 16, 24) && !touchWithin(this->touch.px, this->touch.py, boxShift + 4, 18, 16, 24)) boxMod--;
				else if (touchWithin(touch->px, touch->py, boxShift + 200, 18, 16, 24) && !touchWithin(this->touch.px, this->touch.py, boxShift + 200, 18, 16, 24)) boxMod++;

				boxShift = cursorBox.inBank ? PC_BOX_SHIFT_UNUSED : BK_BOX_SHIFT_UNUSED;

				// If the other box (PC|BK) is touched held
				if (touchWithin(touch->px, touch->py, boxShift, 0, BACKGROUND_WIDTH, BACKGROUND_HEIGHT)) { cursorBox.inBank = !cursorBox.inBank; boolMod = bboxMod = true; }
			}
		}

		if (boxMod || rowMod || colMod)
		{
			currentBox(&cursorBox);
			*cursorBox.box += boxMod;
			cursorBox.row += rowMod;
			cursorBox.col += colMod;

			if (save->bankdata.bk.wboxUnlocked)
			{
				if (*cursorBox.box < 0) *cursorBox.box = (cursorBox.inBank ? save->bankdata.bk.boxUnlocked+1 : save->savedata.pc.boxUnlocked)-1;
				else if (*cursorBox.box > (cursorBox.inBank ? save->bankdata.bk.boxUnlocked+1 : save->savedata.pc.boxUnlocked)-1) *cursorBox.box = 0;
			}
			else
			{
				if (*cursorBox.box < 0) *cursorBox.box = (cursorBox.inBank ? save->bankdata.bk.boxUnlocked : save->savedata.pc.boxUnlocked)-1;
				else if (*cursorBox.box > (cursorBox.inBank ? save->bankdata.bk.boxUnlocked : save->savedata.pc.boxUnlocked)-1) *cursorBox.box = 0;
			}
			
			if (cursorBox.row < BOX_HEADER_SELECTED) cursorBox.row = BOX_ROW_PKM_COUNT-1;
			else if (cursorBox.row > BOX_ROW_PKM_COUNT-1) cursorBox.row = BOX_HEADER_SELECTED;

			if (cursorBox.col < 0) { cursorBox.col = BOX_COL_PKM_COUNT-1; cursorBox.inBank = !cursorBox.inBank; }
			else if (cursorBox.col > BOX_COL_PKM_COUNT-1) { cursorBox.col = 0; cursorBox.inBank = !cursorBox.inBank; }

			boolMod = true;
		}

		if (boolMod)
		{
			// Update the current Box/Pokémon displayed
			currentBox(&cursorBox);
			selectViewBox();
			selectViewPokemon();
		}
	}

	if (kDown & KEY_SELECT)
	{
		switchCursorType();
	}

	if (cursorType == CursorType::SingleSelect)
	{
		if (kDown & KEY_A && !isPkmDragged)
		{
			// Move a Pokémon (grab and drop)
			selectMovePokemon();
		}

		if (kDown & KEY_B && !isPkmDragged)
		{
			// Drop a Pokémon
			cancelMovePokemon();
		}
	}
	else if (cursorType == CursorType::QuickSelect)
	{
		if (kDown & KEY_A && !isPkmDragged)
		{
			// Move a Pokémon (grab and drop)
			selectMovePokemon();
		}

		if (kDown & KEY_B && !isPkmDragged)
		{
			// Drop a Pokémon
			cancelMovePokemon();
		}

		if (kDown & KEY_Y && !sPkm)
		{
			// Swap the two boxes (PC|BK)
			save->moveBox(cursorBox.boxPC, false, cursorBox.boxBK, true);
		}
	}
	else if (cursorType == CursorType::MultiSelect)
	{
		if (kDown & KEY_A)
		{
			// Toggle a Pokémon (check & move)
			selectMultiMovePokemon(true);

			if (vPkm.pkm)
			{
				checkToggle = vPkm.pkm->checked;
				isPkmChecking = true;
			}
		}
		else if (kHeld & KEY_A)
		{
			if (vPkm.pkm && vPkm.pkm->checked != checkToggle)
			{
				// Toggle a Pokémon (check & move)
				selectMultiMovePokemon(true);
			}
		}

		if (kDown & KEY_B)
		{
			// Cancel the checked
			cancelMovePokemon();
		}

		if (kDown & KEY_X)
		{
			// Move the checked Pokémon to the current box
			selectMultiMovePokemon(false);
		}

		if (kDown & KEY_Y)
		{
			// Open the UltraBox viewer
			UltraBoxViewer* ultraBoxViewer = new UltraBoxViewer(ViewType::Regular, this);
			ultraBoxViewer->selectViewBox(*cursorBox.box, cursorBox.inBank);
			child->initialize();
			return CHILD_STEP;
		}
	}

	{
		if (bboxMod); // Cancel selection if the (PC|BK) changed
		else if (kDown & KEY_TOUCH)
		{
			s16 boxShift = cursorBox.inBank ? BK_BOX_SHIFT_USED : PC_BOX_SHIFT_USED;
			s16 middleBoxShift = (cursorBox.inBank ? PC_BOX_SHIFT_UNUSED : PC_BOX_SHIFT_USED) + BACKGROUND_WIDTH;
			u16 px = touch->px;
			u16 py = touch->py;
			this->touch = *touch;

			if (!sPkm && sPkmCount == 0)
			{
				// If the TouchArea is within the SingleSelect CursorType button area
				if (touchWithin(px, py, boxShift + 22, 0, 59, 16))
				{
					selectCursorType(CursorType::SingleSelect);
				}
				// If the TouchArea is within the QuickSelect CursorType button area
				else if (touchWithin(px, py, boxShift + 86, 0, 59, 16))
				{
					selectCursorType(CursorType::QuickSelect);
				}
				// If the TouchArea is within the MultiSelect CursorType button area
				else if (touchWithin(px, py, boxShift + 150, 0, 59, 16))
				{
					selectCursorType(CursorType::MultiSelect);
				}
				// If the TouchArea is within the SwapBox button area
				else if (touchWithin(px, py, middleBoxShift + 10, 215, 20, 20))
				{
					// Swap the two boxes (PC|BK)
					save->moveBox(cursorBox.boxPC, false, cursorBox.boxBK, true);
				}
			}
			else
			{
				if (cursorType == CursorType::MultiSelect)
				{
					// If the TouchArea is within the MultiSelect CursorType button area
					if (touchWithin(px, py, boxShift + 150, 0, 59, 16))
					{
						cancelMovePokemon();
					}
					// If the TouchArea is within the MiddleArea
					else if (touchWithin(px, py, middleBoxShift, 0, BACKGROUND_SHIFT, BACKGROUND_HEIGHT))
					{
						// Trigger the end of the selection
						selectMultiMovePokemon(false);
					}
				}
			}

			// If the TouchArea is within the Pokémon icons area of the box
			if (touchWithin(px, py, boxShift, PKM_BOX_MARGIN_TOP, BACKGROUND_WIDTH - PKM_BOX_MARGIN_RIGHT, BACKGROUND_HEIGHT - PKM_BOX_MARGIN_TOP))
			{
				// If no Pokémon is currently selected or dragged
				if (!sPkm && !isPkmDragged)
				{
					// Move the cursor to the new slot
					cursorBox.row = (py - PKM_BOX_MARGIN_TOP) / PKM_HEIGHT;
					cursorBox.col = (px - boxShift) / PKM_WIDTH;

					// Update the current Pokémon
					selectViewPokemon();

					if (cursorType == CursorType::MultiSelect)
					{
						// Select the current Pokémon (check)
						selectMultiMovePokemon(true);

						if (vPkm.pkm)
						{
							checkToggle = vPkm.pkm->checked;
							isPkmChecking = true;
						}
					}
					else
					{
						// Move the current Pokémon (grab)
						selectMovePokemon();

						if (!vPkm.emptySlot)
						{
							isPkmDragged = true;
						}
					}
				}
				// If a Pokémon is currently selected and dragged
				else
				{
					u16 oldRow = cursorBox.row;
					u16 oldCol = cursorBox.col;

					// Move the cursor to the new slot
					cursorBox.row = (py - PKM_BOX_MARGIN_TOP) / PKM_HEIGHT;
					cursorBox.col = (px - boxShift) / PKM_WIDTH;

					// Update the current Pokémon
					selectViewPokemon();

					// And drop the Pokémon if one is held and it is the same current slot (mean double tap to move a held Pokémon)
					if (isPkmHeld && oldRow == cursorBox.row && oldCol == cursorBox.col)
					{
						selectMovePokemon();
					}
				}
			}
		}
		else if (kHeld & KEY_TOUCH)
		{
			if (cursorType == CursorType::MultiSelect)
			{
				s16 boxShift = cursorBox.inBank ? BK_BOX_SHIFT_USED : PC_BOX_SHIFT_USED;
				u16 px = touch->px;
				u16 py = touch->py;

				// If the TouchArea is within the Pokémon icons area of the box
				if (touchWithin(px, py, boxShift, PKM_BOX_MARGIN_TOP, BACKGROUND_WIDTH - PKM_BOX_MARGIN_RIGHT, BACKGROUND_HEIGHT - PKM_BOX_MARGIN_TOP))
				{
					s16 row = (py - PKM_BOX_MARGIN_TOP) / PKM_HEIGHT;
					s16 col = (px - boxShift) / PKM_WIDTH;

					// If the touch position is not the same slot as before.
					if (cursorBox.row != row || cursorBox.col != col)
					{
						// Move the cursor to the new slot
						cursorBox.row = row;
						cursorBox.col = col;

						// Update the current Pokémon
						selectViewPokemon();

						// If it has to be toggled.
						if (vPkm.pkm->checked != checkToggle)
						{
							// Select the current Pokémon (check)
							selectMultiMovePokemon(true);
						}
					}
				}
			}

			// Keep the last touched position
			this->touch = *touch;	
		}
		else if (kUp & KEY_TOUCH)
		{
			touch = &(this->touch);

			s16 boxShift = cursorBox.inBank ? BK_BOX_SHIFT_USED : PC_BOX_SHIFT_USED;
			u16 px = touch->px;
			u16 py = touch->py;

			// If a Pokémon is currently dragged
			if (sPkm && isPkmDragged)
			{
				// If the TouchArea is within the Pokémon icons area of the box
				if (touchWithin(px, py, boxShift, PKM_BOX_MARGIN_TOP, BACKGROUND_WIDTH - PKM_BOX_MARGIN_RIGHT, BACKGROUND_HEIGHT - PKM_BOX_MARGIN_TOP))
				{
					// Move the cursor to the new slot
					cursorBox.row = (py - PKM_BOX_MARGIN_TOP) / PKM_HEIGHT;
					cursorBox.col = (px - boxShift) / PKM_WIDTH;

					// Update the current Pokémon
					selectViewPokemon();

					// Move the dragged Pokémon (drop)
					selectMovePokemon();
				}
				else
				{
					// Cancel the Pokémon dragging
					cancelMovePokemon();

					// Return to the old dragged Pokémon slot?
					// injectBoxSlot(&sSlot, &cursorBox);
					// selectViewBox();

					// Update the current Pokémon
					selectViewPokemon();
				}

				isPkmDragged = false;
			}

			isPkmChecking = false;
		}
	}

	cursorPositionOffY += cursorPositionShiftY;
	if (cursorPositionOffY < 0 || cursorPositionOffY > cursorPositionMaxY)
		cursorPositionShiftY *= -1;

	return SUCCESS_STEP;
}