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);
}
示例#3
0
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);
}
示例#4
0
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 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;
}
示例#6
0
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;
        }
    }
}
示例#8
0
bool PhoenixGlobals::validGame( QString game_path ) {
    qDebug() << "game loaded ?: " << game_path;

    if( game_path == "" ) {
        return false;
    }

    QFile in_file( game_path );
    bool result = in_file.open( QIODevice::ReadOnly );

    in_file.close();

    if( result ) {
        setSelectedGame( QString( game_path ) );
    } else {
        userNotifications.setGameNotification( game_path + " could not be loaded" );
    }

    qDebug() << "game loaded ?: " << result;
    return result;
}
示例#9
0
GuiIconCarousel::GuiIconCarousel(int w, int h, int GameIndex)
    : GuiGameBrowser(w, h, GameIndex)
    , buttonClickSound(Resources::GetSound("button_click.mp3"))
    , bgGridData(Resources::GetFile("bgGridTile.png"), Resources::GetFileSize("bgGridTile.png"), GX2_TEX_CLAMP_WRAP)
    , bgGrid(&bgGridData)
    , noIcon(Resources::GetFile("noGameIcon.png"), Resources::GetFileSize("noGameIcon.png"), GX2_TEX_CLAMP_MIRROR)
    , bgUsedImageDataAsync(NULL)
    , bgNewImageDataAsync(NULL)
    , bgFadingImageDataAsync(NULL)
    , gameTitle((char*)NULL, 52, glm::vec4(1.0f))
    , touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH)
    , wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A)
    , buttonATrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_A, true)
    , buttonLTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_L, true)
    , buttonRTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_R, true)
    , buttonLeftTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_LEFT | GuiTrigger::STICK_L_LEFT, true)
    , buttonRightTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_RIGHT | GuiTrigger::STICK_L_RIGHT, true)
    , touchButton(w, h)
    , DPADButtons(w, h)
{
    m_modelView = glm::mat4(1.0f);
    circlePosition = 0.0f;
    bUpdateMap = true;
    gameLaunchTimer = 60;
    touchClickDelay = 0;
    selectedGame = GameIndex;
    selectedGameOnDragStart = 0;
    bWasDragging = false;
    circleRadius = RADIUS * GameList::instance()->size() / 12.0f;

    circlePosition = 0.0f;
    circleTargetPosition = 0.0f;
    circleRotationSpeed = 0.0f;
    lastTouchDifference = 0.0f;
    startRotationDistance = 0.0f;
    circleSpeedLimit = 1.8f;

    bgGrid.setScale(0.25f);
    append(&bgGrid);

    touchButton.setClickable(true);
    touchButton.setHoldable(true);
    touchButton.setTrigger(&touchTrigger);
    touchButton.setTrigger(&wpadTouchTrigger);
    touchButton.clicked.connect(this, &GuiIconCarousel::OnTouchClick);
    touchButton.held.connect(this, &GuiIconCarousel::OnTouchHold);
    touchButton.released.connect(this, &GuiIconCarousel::OnTouchRelease);
    append(&touchButton);

    DPADButtons.setTrigger(&buttonATrigger);
    DPADButtons.setTrigger(&buttonLTrigger);
    DPADButtons.setTrigger(&buttonRTrigger);
    DPADButtons.setTrigger(&buttonLeftTrigger);
    DPADButtons.setTrigger(&buttonRightTrigger);
    DPADButtons.clicked.connect(this, &GuiIconCarousel::OnDPADClick);
    append(&DPADButtons);

    for(int i = 0; i < GameList::instance()->size(); i++)
    {
		std::string filepath = GameList::instance()->at(i)->gamepath + META_PATH + "/iconTex.tga";

        GameIcon *icon = new GameIcon(filepath, &noIcon);
        icon->setParent(this);

        gameIcons.push_back(icon);
        drawOrder.push_back(i);
        append(icon);
    }

    gameTitle.setPosition(0, -320);
    gameTitle.setBlurGlowColor(16.0f, glm::vec4(0.109804, 0.6549, 1.0f, 1.0f));
    gameTitle.setMaxWidth(900, GuiText::DOTTED);
    append(&gameTitle);
    
    circleTargetPosition = 360.0f - GameIndex * 360.0f / (radiusScale * gameIcons.size());
    circlePosition = circleTargetPosition;
    setSelectedGame(selectedGame);
}