Exemple #1
0
void
checkMouse (data_t * gfx, mouse_t * mouse, int *sel, int nops, int off)
{
  int rx = 0, ry = 0;
  int no = MIN (gfx->mMaxOps, nops);

  mouse->clicked = SDL_GetMouseState (&(mouse->x), &(mouse->y));

  if (mouse->x >= gfx->menuX
      && mouse->x < gfx->menuX + gfx->menuW
      && mouse->y >= gfx->menuY
      && mouse->y < gfx->menuY + SFont_TextHeight (gfx->menufont) * no)
    {

      if (((mouse->clicked = SDL_GetRelativeMouseState (&rx, &ry)) || rx != 0
	   || ry != 0))
	*sel =
	  (mouse->y - gfx->menuY) / SFont_TextHeight (gfx->menufont) + off;

      if (!mouse->clicked)
	setMouseState (mouse, M_OVER);
      else
	setMouseState (mouse, M_DOWN);
    }
  else
    {
      if (!mouse->clicked)
	setMouseState (mouse, M_IDLE);
      else
	setMouseState (mouse, M_DOWN);
    }
}
Exemple #2
0
byte *Render_text_SFont(const char *str, int font_number, int *width, int *height)
{
  SFont_Font *font;
  SDL_Surface * TexteColore;
  SDL_Surface * Texte8Bit;
  SDL_Surface *Surface_fonte;
  byte * new_brush;

  // Chargement de la fonte
  Surface_fonte=IMG_Load(Font_name(font_number));
  if (!Surface_fonte)
  {
    DEBUG("Font loading failed",0);
    return NULL;
  }
  font=SFont_InitFont(Surface_fonte);
  if (!font)
  {
    DEBUG("Font init failed",1);
    return NULL;
  }
  
  // Calcul des dimensions
  *height=SFont_TextHeight(font);
  *width=SFont_TextWidth(font, str);
  // Allocation d'une surface SDL
  TexteColore=SDL_CreateRGBSurface(SDL_SWSURFACE, *width, *height, 24, 0, 0, 0, 0);
  // Rendu du texte
  SFont_Write(TexteColore, font, 0, 0, str);
  if (!TexteColore)
  {
    DEBUG("Rendering failed",2);
    SFont_FreeFont(font);
    return NULL;
  }
  
  Texte8Bit=SDL_DisplayFormat(TexteColore);
  SDL_FreeSurface(TexteColore);
    
  new_brush=Surface_to_bytefield(Texte8Bit, NULL);
  if (!new_brush)
  {
    DEBUG("Converting failed",3);
    SDL_FreeSurface(TexteColore);
    SDL_FreeSurface(Texte8Bit);
    SFont_FreeFont(font);
    return NULL;
  }
  SDL_FreeSurface(Texte8Bit);
  SFont_FreeFont(font);

  return new_brush;
}
Exemple #3
0
	int FontTool::getFontHeight() { 
		return SFont_TextHeight(FontTool::sfont);
	}
Exemple #4
0
void
drawCredits (data_t * gfx)
{
  int x, y, w, h;

  x = gfx->gameX + 2 * BLOCKSIZE;
  w = GRIDWIDTH * BLOCKSIZE - 4 * BLOCKSIZE;
  h = BLOCKSIZE + 10 * SFont_TextHeight (gfx->textfont);
  y = gfx->gameY + (GRIDHEIGHT * BLOCKSIZE - h) / 2;

  drawAnimatedSquare (gfx, gfx->gcolor, gfx->galpha, x, y, w, h, MSGTIME);

  y += SFont_TextHeight (gfx->textfont);
  x += BLOCKSIZE;

  SFont_WriteAligned (gfx->textfont, x, y, w - 2 * BLOCKSIZE,
		      0, ACENTER, _("SOURCE CODE AUTHOR"));
  y += SFont_AlignedHeight (gfx->textfont, w - 2 * BLOCKSIZE,
			    0, _("SOURCE CODE AUTHOR"));

  SFont_WriteAligned (gfx->textfont, x, y, w - 2 * BLOCKSIZE,
		      0, ACENTER, AUTHOR);
  y += SFont_AlignedHeight (gfx->textfont, w - 2 * BLOCKSIZE,
			    0, AUTHOR) + SFont_TextHeight (gfx->textfont);

  SFont_WriteAligned (gfx->textfont, x, y, w - 2 * BLOCKSIZE,
		      0, ACENTER, _("THIS GRAPHICS THEME AUTHOR"));
  y += SFont_AlignedHeight (gfx->textfont, w - 2 * BLOCKSIZE,
			    0, _("THIS GRAPHICS THEME AUTHOR"));

  SFont_WriteAligned (gfx->textfont, x, y, w - 2 * BLOCKSIZE,
		      0, ACENTER, gfx->gfxauth);
  y += SFont_AlignedHeight (gfx->textfont, w - 2 * BLOCKSIZE,
			    0,
			    gfx->gfxauth) + SFont_TextHeight (gfx->textfont);

  SFont_WriteAligned (gfx->textfont, x, y, w - 2 * BLOCKSIZE,
		      0, ACENTER, _("THIS SOUND THEME AUTHOR"));
  y += SFont_AlignedHeight (gfx->textfont, w - 2 * BLOCKSIZE,
			    0, _("THIS SOUND THEME AUTHOR"));

  SFont_WriteAligned (gfx->textfont, x, y, w - 2 * BLOCKSIZE,
		      0, ACENTER, gfx->sndauth);
  y += SFont_AlignedHeight (gfx->textfont, w - 2 * BLOCKSIZE,
			    0,
			    gfx->sndauth) + SFont_TextHeight (gfx->textfont);

  /* No idea how to get the translation author with gettext */
  /*
     SFont_WriteAligned(gfx->textfont, x, y, w-2*BLOCKSIZE,
     0, ACENTER, _("THIS TRANSLATION AUTHOR"));
     y += SFont_AlignedHeight(gfx->textfont, w-2*BLOCKSIZE,
     0, _("THIS TRANSLATION AUTHOR"));

     SFont_WriteAligned(gfx->textfont, x, y, w-2*BLOCKSIZE,
     0, ACENTER, gfx->langauth);
     y += SFont_AlignedHeight(gfx->textfont, w-2*BLOCKSIZE,
     0, gfx->langauth) + SFont_TextHeight(gfx->textfont);
   */
  FlipScreen ();
}
Exemple #5
0
int gfx_text_height(SFont_Font * font)
{
    return SFont_TextHeight(font);
}
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);
}