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 GuiIconCarousel::OnDPADClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) { if(trigger == &buttonATrigger){ //! do not auto launch when wiimote is pointing to screen and presses A if((controller->chan & (GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5)) && controller->data.validPointer) { return; } OnLaunchClick(button,controller,trigger); } else if(trigger == &buttonLTrigger){ OnLeftSkipClick(button,controller,trigger); } else if(trigger == &buttonRTrigger){ OnRightSkipClick(button,controller,trigger); } else if(trigger == &buttonLeftTrigger){ OnLeftClick(button,controller,trigger); } else if(trigger == &buttonRightTrigger){ OnRightClick(button,controller,trigger); } }