Esempio n. 1
0
msg_t* initMsg(const char* strTitle, const char* strName,SDL_Surface* screen)
{
  msg_t* t = malloc(sizeof(msg_t));

  //Create surface
  t->surfTitle = SDL_CreateRGBSurface(SDL_SWSURFACE, (getCharSize(FONTSMALL)[0]*strlen(strTitle)),(getCharSize(FONTSMALL)[1]), (setting()->bpp*8), screen->format->Rmask,screen->format->Gmask,screen->format->Bmask,0xff000000);
  t->nameWaving.img = SDL_CreateRGBSurface(SDL_SWSURFACE, (getCharSize(FONTMEDIUM)[0]*strlen(strName)),(getCharSize(FONTMEDIUM)[1]),(setting()->bpp*8), screen->format->Rmask,screen->format->Gmask,screen->format->Bmask,0xff000000);
  t->nameWaving.screen=screen;
  SDL_FillRect(t->surfTitle, 0, SDL_MapRGB(t->surfTitle->format, 0,255,255));
  SDL_FillRect(t->nameWaving.img, 0, SDL_MapRGB(t->nameWaving.img->format, 0,255,255));

  //Render text to surface
  txtWrite(t->surfTitle, FONTSMALL, strTitle, 0,0);
  txtWrite(t->nameWaving.img, FONTMEDIUM, strName, 0,0);

  SDL_Surface* tempSurf;


  SDL_SetColorKey( t->surfTitle, SDL_SRCCOLORKEY, SDL_MapRGB( t->surfTitle->format, 0, 0xFF, 0xFF ) );
  tempSurf=SDL_DisplayFormat(t->surfTitle);
  SDL_FreeSurface(t->surfTitle);
  t->surfTitle=tempSurf;

  SDL_SetColorKey( t->nameWaving.img, SDL_SRCCOLORKEY, SDL_MapRGB( t->nameWaving.img->format, 0, 0xFF, 0xFF ) );
  tempSurf=SDL_DisplayFormat(t->nameWaving.img);
  SDL_FreeSurface(t->nameWaving.img);
  t->nameWaving.img=tempSurf;

  return(t);
}
Esempio n. 2
0
void drawFPS(SDL_Surface* scr)
{
  fps++;
  fpsSecondCounter+=getTicks();
  if(fpsSecondCounter > 999)
  {
    sprintf(fpsStr, "%i Fps", fps);
    fps=0;
    fpsSecondCounter=0;
  }

  txtWrite(scr,FONTSMALL, fpsStr, HSCREENW-160,HSCREENH-120);
}
Esempio n. 3
0
//Return number of lines of text
int aboutScreen(SDL_Surface* screen, int* menuPosY,  int menuChangeY)
{
  int i;
  for(i=*menuPosY; i < 23+*menuPosY && i < numLines; i++)
    txtWrite(screen, FONTSMALL, lines[i], HSCREENW-160+28, HSCREENH-120+40+(i-*menuPosY)*8);

  i=scrollBar(screen, HSCREENW-160+6,HSCREENH-120+40, numLines-15, *menuPosY,menuChangeY);
  if( i != -1 )
  {
    *menuPosY=i;
  }

  return(numLines-15);
}
Esempio n. 4
0
void drawPackBox(SDL_Surface* screen,int posx, int posy,int packNum)
{
  char buf[128];
  SDL_Rect r;
  r.x=posx+5;
  r.y=posy+5;

  //We do this so the menu can unload the images when not used.
  if(!ps.packBoxImg)
  {
    //Load graphics
    ps.packBoxImg = loadImg( "data/pack-box-small.png" );
    ps.packBoxSpr[PCKLISTIMG_SELECTED] = cutSprite(ps.packBoxImg, 0,0,260,42);
    ps.packBoxSpr[PCKLISTIMG_DEFAULT] = cutSprite(ps.packBoxImg, 0,42,260,42);
    ps.packBoxSpr[PCKLISTIMG_IS_DLC] = cutSprite(ps.packBoxImg, 0,42+42,260,42);
    ps.packBoxSpr[PCKLISTIMG_DLC_ENTER] = cutSprite(ps.packBoxImg, 0,42+42+42,260,42);
    ps.packBoxSpr[PCKLISTIMG_DLC_OFFLINE] = cutSprite(ps.packBoxImg, 0,42+42+42+42,260,42);
  }
  
  SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "==== 10");

  //PackInfo is now in pi.
  packInfoType* pi;

  if( packNum == ps.numPacks )
  {
    pi = ps.dlc;
  } else {
    pi = (packInfoType*)( listGetItemAt(ps.packs,packNum) )->data;
  }

  //Blit the box
  if(pi == ps.dlc )
  {

#if defined( PLATFORM_SUPPORTS_STATSUPLOAD )
    if( setting()->online && dlcGetState()==DLC_READY )
    {
      drawSprite(screen, ps.packBoxSpr[PCKLISTIMG_DLC_ENTER], posx, posy);
      txtWrite(screen, FONTSMALL, STR_MENU_PACKLIST_DLC_ENTER, posx+40, posy+4);
    } else {
      drawSprite(screen, ps.packBoxSpr[PCKLISTIMG_DLC_OFFLINE], posx, posy);
      txtWrite(screen, FONTSMALL, STR_MENU_PACKLIST_DLC_OFFLINE, posx+12, posy+4);
    }
#else
    drawSprite(screen, ps.packBoxSpr[PCKLISTIMG_DLC_OFFLINE], posx, posy);
    txtWrite(screen, FONTSMALL, STR_MENU_PACKLIST_DLC_OFFLINE, posx+12, posy+4);
#endif
    return; //We don't want to write any info on that special box.
  } else if(ps.selected==packNum)
  {
    drawSprite(screen, ps.packBoxSpr[PCKLISTIMG_SELECTED], posx, posy);
  } else {
    if(pi->isDLC == PACK_IS_DLC)
    {
      drawSprite(screen, ps.packBoxSpr[PCKLISTIMG_IS_DLC], posx, posy);
    } else {
      drawSprite(screen, ps.packBoxSpr[PCKLISTIMG_DEFAULT], posx, posy);
    }
  }
  
  SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "==== 20");

  //Blit the icon image
  SDL_BlitSurface(pi->icon,0,screen, &r);

  //PackName
  txtWrite(screen, FONTSMALL, pi->name, posx+40, posy+4);

  //Author
  txtWrite(screen, FONTSMALL, pi->author, posx+258-9*(strlen(pi->author)), posy+4);

  //Comment
  txtWrite(screen, FONTSMALL, pi->comment, posx+40, posy+4+12);

  //Number of levels
  sprintf(buf, "%i levels", pi->numLevels);
  txtWrite(screen, FONTSMALL, buf, posx+258-9*(strlen(buf)), posy+4+24);

  //Number of lives
  if( pi->lives > 0 )
  {
    sprintf(buf, "%i lives", pi->lives);
  } else {
    sprintf(buf, "Infinite lives!");
  }
  txtWrite(screen, FONTSMALL, buf, posx+40, posy+4+24);
  SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "==== 200");
}
Esempio n. 5
0
//Return 0 until a string is present in state->str.
int inpStrGet(inpStrState* state, int menuPosX, int menuPosY, int blink)
{
  int cy,cx;
  char hack[2]={ ' ',0x00 };
  int hsKeyboardWasClicked=0;

  txtWriteCenter(state->dstSurface, FONTSMALL, STR_STRINPUT_CONTROLS, HSCREENW,HSCREENH+108);

  if( getChar() )
  {
    if( getChar() == SDLK_RETURN )
    {
      //Save
      menuPosY=4;
      hsKeyboardWasClicked=1;
    }

    if( getChar() == SDLK_BACKSPACE && strlen( state->str ) > 0 )
    {
      state->str[ strlen(state->str)-1 ]=0;
    } else if( getChar() > 31 && getChar() < 123 && strlen( state->str ) < state->maxLen+1 )
    {
      state->str[ strlen(state->str) ] = getChar();
      state->str[ strlen(state->str)+1 ] = 0x0;
    }
  }

  sprintf(state->_buf, "%s %s", state->prompt, state->str);

  txtWrite(state->dstSurface, FONTSMALL, state->_buf, HSCREENW-110, HSCREENH-45);


  for(cy=0; cy < kbRows; cy++)
  {
    for(cx=0; cx < kbCols; cx++)
    {

      if( (menuPosX==cx && menuPosY==cy) && !blink && !( getInpPointerState()->timeSinceMoved < POINTER_SHOW_TIMEOUT  ) )
      {
        txtWrite(state->dstSurface, FONTSMALL, "[_]", (HSCREENW-70)+(cx)*16-8, (HSCREENH-9)+cy*15);
      }

      hack[0]=(*(state->kb))[cy][cx];
      txtWrite(state->dstSurface, FONTSMALL, hack, (HSCREENW-70)+cx*16, (HSCREENH-10)+cy*15);
      hack[0]=0;
      if( isBoxClicked( getTxtBox() ) )
      {
        menuPosX=cx;
        menuPosY=cy;
        hsKeyboardWasClicked=1;
      }
    }
  }
  //Blink "Save" underline if selected
  if( menuPosY==4 && blink)
  {
    if(menuPosX > 9) menuPosX=0;
    txtWriteCenter(state->dstSurface, FONTSMALL, " _____ ", HSCREENW, HSCREENH+50);
  }
  txtWriteCenter(state->dstSurface, FONTSMALL, "[ENTER]", HSCREENW, HSCREENH+50);
  if( isBoxClicked( getTxtBox() ) )
  {
    menuPosY=4;
    hsKeyboardWasClicked=1;
  }

  //Blink "Caps" underline if selected
  if( menuPosX==10 && blink)
  {
    if(menuPosY >3) menuPosY =1;
    txtWrite( state->dstSurface, FONTSMALL, " ____", HSCREENW-130, HSCREENH+10 );
  }
  txtWrite( state->dstSurface, FONTSMALL, "[Caps]", HSCREENW-130, HSCREENH+10 );
  if( isBoxClicked( getTxtBox() ))
  {
    menuPosX=10;
    hsKeyboardWasClicked=1;
  }

  //If the cursor is being used, show "delete" button, this is only usable with pointer.
  if(  getInpPointerState()->timeSinceMoved < POINTER_SHOW_TIMEOUT  )
  {
    txtWrite(state->dstSurface, FONTSMALL, "[DEL]", (HSCREENW+38), (HSCREENH-25) );
    if( isBoxClicked( getTxtBox() ))
    {
      menuPosY=5;
      hsKeyboardWasClicked=1;
    }
  }

  //Switch layouts if we're at posX 10
  if( menuPosX == 10 && (getButton( C_BTNB ) || hsKeyboardWasClicked) )
  {

    resetBtn( C_BTNB );
    if(state->kb==&kbl)
    {
      state->kb=&kbh;
    } else if(state->kb==&kbh) {
      state->kb=&kbl;
    }

  } else if( menuPosY==4 && ( getButton( C_BTNB ) || hsKeyboardWasClicked ) ) //Return true
  {
    resetBtn( C_BTNB );
    if(strlen( state->str ) >= state->minLen)
    {
      return(1);
    }
  } else if( getButton( C_BTNB ) || (hsKeyboardWasClicked && menuPosY < 5) )
  {
    resetBtn( C_BTNB );
    resetMouseBtn();
    if( strlen( state->str ) < state->maxLen+1)
    {
      state->str[ strlen(state->str) ] = (*(state->kb))[menuPosY][menuPosX];
      state->str[ strlen(state->str)+1 ] = 0;
    }
  } else if( getButton( C_BTNA ) || (hsKeyboardWasClicked && menuPosY == 5) )
  {
    resetBtn( C_BTNA);
    if(strlen(state->str) > 0)
    {
      state->str[ strlen(state->str)-1 ]=0;
    }
  }
  return(0);
}