Ejemplo n.º 1
0
void sub_shc_draw(SDL_Surface * screen)
{
    int td, animating = 0;
    shc_node *curr = NULL;

    if (shc_init_stage)
    {
        sub_shc_stages(screen);
    }

    if (shc_movereq && !shc_movedir)
    {
        if (shc_movereq < 0)
        {
            sfx_play(SFXMOVE);
            shc_movedir = -1;
            shc_movereq++;
        }
        else if (shc_movereq > 0)
        {
            sfx_play(SFXMOVE);
            shc_movedir = 1;
            shc_movereq--;
        }
        shc_assign_move(shc_movedir);
        shc_timer2 = SDL_GetTicks();
    }

    if (!shc_init_stage)
        gfx_draw_image(shc_arrow, 25, 113, screen);

    curr = shc_root;

    td = (SDL_GetTicks() - shc_timer2);

    shc_timer2 = SDL_GetTicks();

    if (!curr && !shc_init_stage)       /* Did not find anything */
    {
        gfx_draw_text(screen, font_normal, 50, 115, USESHADOW, NOGLOW,
                      "There are no applications.");
    }

    while (curr && !shc_init_stage)
    {
        char t_name[32];
        t_name[0] = '\0';
        strncat(t_name, curr->title, 31);
        if (shc_movedir)
        {
            int move_td_x =
                (int) rint((curr->move_x) / (float) XMBMOVEDELAY * td);
            int move_td_y =
                (int) rint((curr->move_y) / (float) XMBMOVEDELAY * td);

            curr->pos_x += move_td_x;
            curr->pos_y += move_td_y;

            if ((move_td_x > 0 && curr->pos_x > curr->move_tx) ||
                (move_td_x < 0 && curr->pos_x < curr->move_tx))
            {
                curr->pos_x = curr->move_tx;
                curr->move_x = 0;
                curr->move_tx = 0;

                if (curr->pos_x == 50)
                {
                    SDL_FreeSurface(curr->icon_curr);
                    curr->icon_curr =
                        gfx_scaleperc_surface(curr->icon_orig, 1.0, 1.0);
                }
                else
                {
                    SDL_FreeSurface(curr->icon_curr);
                    curr->icon_curr =
                        gfx_scaleperc_surface(curr->icon_orig, 0.5, 0.5);
                }

            }

            if ((move_td_y > 0 && curr->pos_y > curr->move_ty) ||
                (move_td_y < 0 && curr->pos_y < curr->move_ty))
            {
                curr->pos_y = curr->move_ty;
                curr->move_y = 0;
                curr->move_ty = 0;
            }

            if (curr->move_x)
            {
                float bval =
                    ((1.0 / (SHCICONX / 4)) *
                     (curr->pos_x + (curr->move_x - curr->move_tx)) / 2.0);

                if (bval < 0)
                    bval = 0.5 + fabs(bval);
                else if (bval > 0)
                    bval = 0.5 + (0.5 - fabs(bval));

                if (bval)
                {
                    SDL_FreeSurface(curr->icon_curr);
                    curr->icon_curr =
                        gfx_scaleperc_surface(curr->icon_orig, bval, bval);
                }
            }

            if (curr->move_x || curr->move_y)
                animating = 1;
        }
        else if (curr->pos_y == 83)     /* selected ... ugly but it works, for now */
        {
            gfx_draw_text(screen,
                          font_normal,
                          curr->pos_x + SHCICONX + 10,
                          curr->pos_y +
                          ((SHCICONY - SFont_TextHeight(font_normal)) / 2),
                          USESHADOW, NOGLOW, curr->title);
        }

        if ((curr->pos_y + curr->icon_curr->h) > 0 && curr->pos_y < 240)
            gfx_draw_image(curr->icon_curr, curr->pos_x, curr->pos_y,
                           screen);

        curr = curr->next;
    }
    if (!animating)
        shc_movedir = 0;

	if(shc_showpopup)
		POPUP_draw(screen);
}
Ejemplo n.º 2
0
void sub_music_draw(SDL_Surface * screen)
{
    if (music_stage == 1)       /* move left */
    {
        if (!music_xmb_offset_tx)
        {
            music_xmb_offset_ox = music_xmb_offset_x;
            music_xmb_offset_tx = -LIST_columnWidth();
        }
        music_xmb_offset_x -=
            rint(LIST_columnWidth() / ((float) (XMBMOVEDELAY)) *
                 (SDL_GetTicks() - music_animtimer));
    }
    else if (music_stage == 2)  /* move right */
    {
        if (!music_xmb_offset_tx)
        {
            music_xmb_offset_ox = music_xmb_offset_x;
            music_xmb_offset_tx = LIST_columnWidth();
        }
        music_xmb_offset_x +=
            rint(LIST_columnWidth() / ((float) (XMBMOVEDELAY)) *
                 (SDL_GetTicks() - music_animtimer));
    }
    else if (music_stage == 3)  /* move left (inital) */
    {
        if (!music_xmb_offset_tx)
        {
            music_xmb_offset_ox = music_xmb_offset_x;
            music_xmb_offset_tx = -LIST_columnWidth();
        }
        music_xmb_offset_x -=
            rint(LIST_columnWidth() / ((float) (XMBMOVEDELAY)) *
                 (SDL_GetTicks() - music_animtimer));
    }
    else if (music_stage == 4)  /* move right (final) */
    {
        if (!music_xmb_offset_tx)
        {
            music_xmb_offset_ox = music_xmb_offset_x;
            music_xmb_offset_tx = LIST_columnWidth();
        }
        music_xmb_offset_x +=
            rint(LIST_columnWidth() / ((float) (XMBMOVEDELAY)) *
                 (SDL_GetTicks() - music_animtimer));
    }
    else if (music_stage == 5)
    {
        music_stage++;
    }
    else if (music_stage == 6)
    {
        sub_music_browse();
        music_stage = 0;
    }

    if (SDL_GetTicks() - music_animtimer_b > XMBMOVEDELAY && music_stage)
    {
        if (music_stage == 1 || music_stage == 3)
        {
            LIST_setEmptyMsg("Please Wait...");
            music_stage = 5;
        }

        if (music_stage == 4 && music_levels == -1)
        {
            music_xmb_offset_x = 0;
            LIST_destroy();
            sub_music_destroy();
            submenu = NULL;
            sub_music_playing = 0;
            return;
        }

        if (music_stage <= 5)
        {
            music_xmb_offset_x = music_xmb_offset_ox + music_xmb_offset_tx;
            music_xmb_offset_tx = 0;
            music_xmb_offset_ox = 0;
        }

        if (music_stage > 0 && music_stage < 5)
            music_stage = 0;
    }
    music_animtimer = SDL_GetTicks();

    if (music_stage != MUS_FULLSCREEN)
    {
        if (music_stage != 3 && music_stage != 4)
        {
            LIST_draw(screen, (int) music_xmb_offset_x + ICONSCALE_X - 5,
                      0);
        }
    }
    else if (sub_music_playing)
    {
        tlistitem *sel;
        SDL_Rect wrect;
        char textstr[16];
        int minutes = 0, seconds = 0, tmin = 0, tsec = 0;
        textstr[0] = '\0';
        wrect.x = screen->w - 210;
        wrect.y = screen->h - 14;
        wrect.w = 200;
        wrect.h = 4;
        SDL_FillRect(screen, &wrect,
                     SDL_MapRGB(screen->format, 255, 255, 255));
        wrect.w *= mus_getpos() / (float) mus_getlength();
        wrect.w = ceil(wrect.w);
        SDL_FillRect(screen, &wrect,
                     SDL_MapRGB(screen->format, 0, 130, 180));

#ifdef TREMOR
        minutes = ((mus_getpos() / 1000) / 60);
        seconds = ((mus_getpos() / 1000) % 60);
        tmin = ((mus_getlength() / 1000) / 60);
        tsec = ((mus_getlength() / 1000) % 60);
#else
        minutes = ((mus_getpos()) / 60);
        seconds = ((mus_getpos()) % 60);
        tmin = ((mus_getlength()) / 60);
        tsec = ((mus_getlength()) % 60);
#endif

        sprintf(textstr, "%02i:%02i / %02i:%02i", minutes, seconds, tmin,
                tsec);
        gfx_draw_text(screen, font_monospace, 215, 210, USESHADOW, NOGLOW,
                      textstr);

        sel = LIST_getSelected();

        gfx_draw_image(sel->icon, 25, 102, screen);
        gfx_draw_text(screen, font_normal, 71, 100, USESHADOW, NOGLOW,
                      sel->title);
        gfx_draw_text(screen, font_small, 71, 126, USESHADOW, NOGLOW,
                      sel->subtitle);


        if (mus_eof())
        {
            if (LIST_down())
            {
                mus_stop();
                while (!mus_ready());
                sub_music_playsel();
            }
            else
            {
                sub_music_handle_input(GP2X_BUTTON_B);
            }
        }
    }
}
Ejemplo n.º 3
0
void sub_shc_stages(SDL_Surface * screen)
{
    if (!shc_arrow)
        shc_arrow = gfx_load_image("images/icons/arrow-left.png", 1);

    if (shc_init_stage == 1)
    {
        if (shc_timer && shc_xmb_offset_x > -80)
        {
            shc_xmb_offset_x -=
                (int) rint(((80) / (float) XMBMOVEDELAY) *
                           (SDL_GetTicks() - shc_timer));
        }
        else if (shc_xmb_offset_x == -80)
            shc_init_stage = 2;

        shc_timer = SDL_GetTicks();

        if (shc_xmb_offset_x < -80)
            shc_xmb_offset_x = -80;
    }
    else if (shc_init_stage == 2)
    {
        gfx_draw_text(screen, font_normal, 50, 115, USESHADOW, NOGLOW,
                      "Please Wait...");
        shc_init_stage++;
    }
    else if (shc_init_stage == 3)
    {
        /* Load everything */
        shc_load();

        shc_assign_initial_pos();
        shc_init_stage++;
    }
    else if (shc_init_stage == 4)
        shc_init_stage = 0;

    if (shc_init_stage == 10)
    {
        if (shc_timer && shc_xmb_offset_x < 0)
        {
            shc_xmb_offset_x +=
                (int) rint(((80) / (float) XMBMOVEDELAY) *
                           (SDL_GetTicks() - shc_timer));
        }
        else if (shc_xmb_offset_x == 0)
            shc_init_stage = 11;

        shc_timer = SDL_GetTicks();

        if (shc_xmb_offset_x > 0)
            shc_xmb_offset_x = 0;
    }
    else if (shc_init_stage == 11)
    {
        shc_xmb_offset_x = 0;
        shc_timer = 0;
        submenu = NULL;
        shc_init_stage = 1;
        shc_selection = 0;
        shc_delete_list();
    }
}