void GuiIconCarousel::OnTouchRelease(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) { if(!controller->lastData.validPointer) return; for(size_t i = 0; i < gameIcons.size(); ++i) { if(gameIcons[i]->isStateSet(STATE_CLICKED)) { gameIcons[i]->setEffect(EFFECT_SCALE, -4, 100); gameIcons[i]->clearState(STATE_CLICKED); } } f32 degreeAdd = lastTouchDifference * 0.128f; if(touchClickDelay || fabsf(degreeAdd) < 2.0f) { updateDrawMap(); if(bWasDragging && selectedGameOnDragStart != selectedGame) { setSelectedGame(selectedGame); gameSelectionChanged(this, selectedGame); } return; } circlePosition = ((int)(circlePosition + 0.5f)) % 360; if(circlePosition < 0.0f) circlePosition += 360.0f; f32 partDegree = 360.0f / (radiusScale * gameIcons.size()); circleTargetPosition = circlePosition - 0.5f * degreeAdd * partDegree; //! round to nearest game position at the target position circleTargetPosition = ((int)(circleTargetPosition / partDegree + 0.5f)) * partDegree; circleSpeedLimit = 10.0f; int iItem = 0; f32 zMax = -9999.9f; for(u32 i = 0; i < gameIcons.size(); i++) { float currDegree = DegToRad(360.0f / (radiusScale * gameIcons.size()) * i + circleTargetPosition + 90.0f); float posZ = radiusScale * circleRadius * sinf(currDegree) + RADIUS - gameIcons.size() * (RADIUS / 12.0f); if(zMax < posZ) { iItem = i; zMax = posZ; } } selectedGame = iItem; gameSelectionChanged(this, selectedGame); }
void GuiGameCarousel::OnTouchRelease(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) { f32 degreeAdd = lastTouchDifference * 0.04f; if(touchClickDelay || fabsf(degreeAdd) < 2.0f) { updateDrawMap(); if(bWasDragging && selectedGameOnDragStart != selectedGame) { setSelectedGame(selectedGame); gameSelectionChanged(this, selectedGame); } return; } currDegree = ((int)(currDegree + 0.5f)) % 360; if(currDegree < 0.0f) currDegree += 360.0f; f32 partDegree = DEG_OFFSET; destDegree = currDegree - degreeAdd * partDegree; //! round to nearest game position at the target position destDegree = ((int)(destDegree / partDegree + 0.5f)) * partDegree; circleSpeedLimit = 10.0f; int iMin = 0; int iDegreeMin = destDegree; for(int i = 0; i < pagesize; i++) { f32 setDegree = (destDegree - DEG_OFFSET * i); int degree = labs(((int)setDegree - 90) % 360); if(degree < iDegreeMin) { iDegreeMin = degree; iMin = i; } } selectedGame = iMin; gameSelectionChanged(this, selectedGame); loadBgImage(selectedGame); refreshDrawMap = true; }
void GuiGameCarousel::OnRightClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) { int sel = getSelectedGame() + 1; if(sel >= (int)GameList::instance()->size()) sel = 0; setSelectedGame(sel); gameSelectionChanged(this, sel); }
void GuiGameCarousel::OnLeftClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) { int sel = getSelectedGame() - 1; if(sel < 0 && (GameList::instance()->size() > 1)) sel = GameList::instance()->size() - 1; setSelectedGame(sel); gameSelectionChanged(this, sel); }
void GuiIconCarousel::OnRightSkipClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) { if((int)GameList::instance()->size() > 5){ int sel = getSelectedGame() - 5; if(sel < 0 && (GameList::instance()->size() > 5)) sel += GameList::instance()->size(); setSelectedGame(sel); gameSelectionChanged(this, sel); } }
void GuiIconCarousel::OnTouchClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) { if(!controller->data.validPointer) return; bWasDragging = false; selectedGameOnDragStart = getSelectedGame(); lastPosition.x = controller->data.x; lastPosition.y = controller->data.y; //! calculate ray origin and direction glm::vec3 rayOrigin; glm::vec3 rayDir; CVideo *video = Application::instance()->getVideo(); video->screenPosToWorldRay(controller->data.x, controller->data.y, rayOrigin, rayDir); glm::vec3 rayDirFrac((rayDir.x != 0.0f) ? (1.0f / rayDir.x) : 0.0f, (rayDir.y != 0.0f) ? (1.0f / rayDir.y) : 0.0f, (rayDir.z != 0.0f) ? (1.0f / rayDir.z) : 0.0f); for(u32 i = 0; i < drawOrder.size(); ++i) { int idx = drawOrder[i]; if(gameIcons[idx]->checkRayIntersection(rayOrigin, rayDirFrac)) { if(buttonClickSound) buttonClickSound->Play(); setSelectedGame(idx); gameSelectionChanged(this, idx); //! TODO: change this to a button assigned image gameIcons[idx]->setState(STATE_CLICKED); gameIcons[idx]->setEffect(EFFECT_SCALE, 4, 125); if(selectedGame == idx) { if(gameLaunchTimer < 30) OnLaunchClick(button, controller, trigger); gameLaunchTimer = 0; } } } }
void GuiGameCarousel::OnGameButtonClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) { for(u32 i = 0; i < game.size(); i++) { if(button == game[i]) { if(selectedGame == (int)i) { if(gameLaunchTimer < 30) OnLaunchClick(button, controller, trigger); gameLaunchTimer = 0; } setSelectedGame(i); gameSelectionChanged(this, selectedGame); break; } } }
void GameDialog::OnGameSelectionChanged(GameSelectionCommand& command) { if (IsBeingDeleted()) return; gameSelectionChanged(command.gameName()); }