Changeset 538


Ignore:
Timestamp:
Apr 23, 2011, 12:48:48 AM (6 years ago)
Author:
sam
Message:

game: add enough code to handle 15 save slots instead of 5. The artwork
is still missing, though.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/loadgame.cpp

    r523 r538  
    3434extern JCFont *console_font;
    3535
    36 #define MAX_SAVE_GAMES 5
     36#define MAX_SAVE_GAMES 15
     37#define MAX_SAVE_LINES 5
    3738int last_save_game_number=0;
    3839
    39 int save_buts[MAX_SAVE_GAMES*3];
     40int save_buts[MAX_SAVE_GAMES * 3];
    4041
    4142
    4243void load_number_icons()
    4344{
    44   char name[100];
    45   int i;
    46   for (i=0; i<MAX_SAVE_GAMES*3; i++)
    47   {
    48     sprintf(name,"nums%04d.pcx",i+1);
    49     save_buts[i]=cache.reg("art/icons.spe",name,SPEC_IMAGE,1);
    50   }
     45    for (int i = 0; i < MAX_SAVE_GAMES * 3; i++)
     46    {
     47        char name[100];
     48        sprintf(name, "nums%04d.pcx", i % (5 * 3) + 1); // FIXME
     49        save_buts[i] = cache.reg("art/icons.spe", name, SPEC_IMAGE, 1);
     50    }
    5151}
    5252
     
    5858}
    5959
    60 Jwindow *create_num_window(int mx, int total_saved, image **thumb_nails)
     60Jwindow *create_num_window(int mx, int total_saved, int lines, image **thumb_nails)
    6161{
    6262  ico_button *buts[MAX_SAVE_GAMES];
    63   int y = 0, i;
     63  int y = 0, x = 0, i;
     64  int iw=cache.img(save_buts[0])->Size().x;
    6465  int ih=cache.img(save_buts[0])->Size().y;
    65   int x=0;
     66  int maxih = ih, maxiw = iw;
     67  int n=0;
    6668  for (i=0; i<total_saved; i++,y+=ih)
    6769  {
    68     if (thumb_nails) { while (!thumb_nails[x]) x++; }
    69     buts[i]=new ico_button(0, y, ID_LOAD_GAME_NUMBER + x,
    70                save_buts[x*3+0],save_buts[x*3+0],save_buts[x*3+1],save_buts[x*3+2],NULL);
    71     buts[i]->set_act_id(ID_LOAD_GAME_PREVIEW+x);
    72     x++;
     70    maxih = Max(ih, maxih);
     71    maxiw = Max(iw, maxiw);
     72    if (y >= lines * ih)
     73    {
     74        y = 0;
     75        x += iw;
     76    }
     77    if (thumb_nails) { while (!thumb_nails[n]) n++; }
     78    buts[i]=new ico_button(x, y, ID_LOAD_GAME_NUMBER + n,
     79               save_buts[n*3+0],save_buts[n*3+0],save_buts[n*3+1],save_buts[n*3+2],NULL);
     80    buts[i]->set_act_id(ID_LOAD_GAME_PREVIEW+n);
     81    n++;
    7382  }
    7483
     
    7685    buts[i]->next=buts[i+1];
    7786
    78   return wm->new_window(mx,yres/2-(Jwindow::top_border()+ih*5)/2,-1,-1,buts[0]);
     87  return wm->new_window(mx,yres/2-(Jwindow::top_border()+maxih*5)/2,-1,-1,buts[0]);
    7988}
    8089
     
    100109  if(mx < 0) mx = 0;
    101110
    102   Jwindow *l_win=create_num_window(mx,MAX_SAVE_GAMES,NULL);
     111  Jwindow *l_win=create_num_window(mx,MAX_SAVE_GAMES,MAX_SAVE_LINES,NULL);
    103112  event ev;
    104113  int got_level=0;
     
    222231
    223232
    224     Jwindow *l_win=create_num_window(0,total_saved,thumb_nails);
     233    Jwindow *l_win=create_num_window(0,total_saved,MAX_SAVE_LINES,thumb_nails);
    225234    Jwindow *preview=wm->new_window(l_win->x+l_win->l+5,l_win->y,max_w,max_h,NULL,title);
    226235
Note: See TracChangeset for help on using the changeset viewer.