Esempio n. 1
0
void setCurrent()
{
  cm=(msg_t*)listGetItemAt(msgList,currentMsgIndex)->data;

  cm->stateTicks=0;
  cm->state=MSGSTATE_TITLE_SLIDING_IN;
  cm->rTitle.w=0;
  cm->rTitle.h=0;
  cm->rTitle.x=SCREENW+1;
  cm->rTitle.y=HSCREENH+15;
  cm->nameWaving.x=-(cm->nameWaving.img->w);
  cm->nameWaving.y=HSCREENH+35;
  cm->nameWaving.rotations=2+(cm->nameWaving.img->w/100);
  cm->nameWaving.amount=35;
  cm->nameWaving.speed=50;
  cm->nameWaving.privRotAmount=0;
  cm->nameWaving.useOverlay=0;

  //Setup particle system
  ps.layer=PSYS_LAYER_TOP;
  ps.vel=100;
  ps.life=200;
  ps.lifeVar=100;
  ps.numParticles=0;
  ps.fade=0;
  ps.gravity=0;
  ps.bounce=0;
  ps.srcRect.x=0;
  ps.srcRect.y=0;

}
Esempio n. 2
0
//Select packNum (or default if out of range
void packSet(int packNum)
{
  if(packNum < ps.numPacks)
    ps.selected=packNum;
  else
  {
    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "packSet(); Error: packNum '%i' out of range (%i)\n",packNum, ps.numPacks);
    ps.selected=0;
  }

  SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "packSet(); Selecting pack %i...\n", ps.selected);
  ps.cp = (packInfoType*)listGetItemAt(ps.packs, ps.selected)->data;

  //Set finishedImg 0 when we select a pack, to make sure the correct image is loaded.
  ps.finishedImg=0;

  SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,"packSet(); Selected pack '%s' Loading stats..\n", ps.cp->path);
  //Load stats for this pack
  statsLoad();
  SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,"packSet(); Stats loaded.\n");

}
Esempio n. 3
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. 4
0
levelInfo_t* levelInfo(int num)
{
  levelInfo_t* li = (levelInfo_t*)(listGetItemAt(ps.cp->levels,num)->data);
  return( li );
}
Esempio n. 5
0
int main()
{
  int i;
  printf("Test: New list.\n");
  list_t* list = listInit(freeItem);
  listDebugShow(list,LIST_DEBUG_SHOW_BACKWARD|LIST_DEBUG_SHOW_FORWARD);
  listItem* it;

  printf("\nTest: Appending 4 items to list.\n");
  listAppendData(list, mkItem(1, "Fisk") );
  listAppendData(list, mkItem(2, "Hund") );
  it=listAppendData(list, mkItem(3, "Hest") );
  listAppendData(list, mkItem(4, "Rose") );
  listDebugShow(list,LIST_DEBUG_SHOW_SHORT);
  showItems(list);


  printf("\nTest: Prepending 4 items.\n");
  listPrependData(list, mkItem(5, "Laks") );
  listPrependData(list, mkItem(6, "Ko") );
  listPrependData(list, mkItem(7, "Tiger") );
  listPrependData(list, mkItem(8, "Zebra") );
  listDebugShow(list,LIST_DEBUG_SHOW_SHORT);
  showItems(list);


  printf("\nTest: Removing item (Hest) from list.\n");
  listRemoveItem(list,it, LIST_PREV);
  listDebugShow(list,LIST_DEBUG_SHOW_SHORT);
  showItems(list);


  printf("\nTest: Inserting 4 items\n");
  listInsertAtIdx(list, mkItem(1, "New Pos 0"), 0 );
  it=listInsertAtIdx(list, mkItem(1, "New Pos 2"), 2 );
  listInsertAtIdx(list, mkItem(1, "New Pos 8"), 8 );
  listInsertAtIdx(list, mkItem(list->count, "New Last Pos"), list->count );
  listDebugShow(list,LIST_DEBUG_SHOW_SHORT);
  showItems(list);


  printf("\nTest: Insert after item %p (New Pos 2)\n");
  listInsertAfterItem(list, it, mkItem(2, "New Pos 3") );
  listDebugShow(list,LIST_DEBUG_SHOW_SHORT);
  showItems(list);



  printf("\nTest: Getting data.\n");
  for(i=0; i < list->count; i++)
  {
    printf("  Idx %i Got data: %p\n", i, listGetItemAt(list, i )->data );
  }

  printf("\nTest: Filling list into array.\n");
  item** arr = (item**)listAddToArray( malloc(sizeof(void*)*list->count), list );

  int idx;
  for(idx=0; idx < list->count; idx++)
  {
    printf("  Arr[%i] = %p\n",idx,arr[idx] );
    showItem(arr[idx]);
  }

  printf("\nTest: Appending array to list2.\n");
  list_t* list2 = listAddFromArray(listInit(NULL), (void*)arr, list->count);
  listDebugShow(list2,LIST_DEBUG_SHOW_SHORT);
  showItems(list2);

  list_t* list3 = listAddFromArray(listInit(NULL), (void*)arr, list->count);

  free(arr);

  printf("\nRemoving all list2 elements individually in a forward loop.");
  it=&list2->begin;
  while( LISTFWD(list2,it) )
  {
    it=listRemoveItem(list2,it, LIST_PREV);
  }
  listDebugShow(list2, LIST_DEBUG_SHOW_BACKWARD|LIST_DEBUG_SHOW_FORWARD);

  printf("\nRemoving all list3 elements individually in a reverse loop.");
  it=&list3->end;
  while( LISTBCK(list3, it) )
  {
    it=listRemoveItem(list3,it,LIST_NEXT);
  }
  listDebugShow(list3, LIST_DEBUG_SHOW_BACKWARD|LIST_DEBUG_SHOW_FORWARD);



  printf("\nTest: Freeing lists.\n");
  listFree(list);
  listFree(list2);

  printf("\nTests done, it's up to you to figure out if they passed, <nelson>hahaaa!</nelson>\n");

  return(0);
}