level-editor is completly impleted for the current level-format now!
authorTobias Gläßer <tobi.web@gmx.de>
Sat, 6 Mar 2004 19:08:27 +0000 (19:08 +0000)
committerTobias Gläßer <tobi.web@gmx.de>
Sat, 6 Mar 2004 19:08:27 +0000 (19:08 +0000)
SVN-Revision: 176

src/button.c
src/button.h
src/leveleditor.c
src/setup.c
src/setup.h
src/type.c
src/type.h

index 4efc96c..158f77c 100644 (file)
@@ -49,8 +49,10 @@ void button_load(button_type* pbutton,char* icon_file, char* info, SDLKey shortc
   pbutton->y = y;
   pbutton->w = pbutton->icon.w;
   pbutton->h = pbutton->icon.h;
+  pbutton->tag = -1;
   pbutton->state = -1;
   pbutton->show_info = NO;
+  pbutton->bkgd = NULL;
 }
 
 button_type* button_create(char* icon_file, char* info, SDLKey shortcut, int x, int y)
@@ -64,14 +66,18 @@ void button_draw(button_type* pbutton)
 {
   fillrect(pbutton->x,pbutton->y,pbutton->w,pbutton->h,75,75,75,200);
   fillrect(pbutton->x+1,pbutton->y+1,pbutton->w-2,pbutton->h-2,175,175,175,200);
+  if(pbutton->bkgd != NULL)
+  {
+  texture_draw(pbutton->bkgd,pbutton->x,pbutton->y,NO_UPDATE);
+  }
   texture_draw(&pbutton->icon,pbutton->x,pbutton->y,NO_UPDATE);
   if(pbutton->show_info == YES)
     {
       char str[80];
       int i = -32;
-      
+
       if(0 > pbutton->x - (int)strlen(pbutton->info) * white_small_text.w)
-          i = pbutton->w + strlen(pbutton->info) * white_small_text.w;
+        i = pbutton->w + strlen(pbutton->info) * white_small_text.w;
 
       if(pbutton->info)
         text_draw(&white_small_text, pbutton->info, i + pbutton->x - strlen(pbutton->info) * white_small_text.w, pbutton->y, 1, NO_UPDATE);
@@ -164,7 +170,9 @@ int button_get_state(button_type* pbutton)
       return state;
     }
   else
-    return pbutton->state;
+    {
+      return pbutton->state;
+    }
 }
 
 void button_panel_init(button_panel_type* pbutton_panel, int x, int y, int w, int h)
@@ -175,6 +183,26 @@ void button_panel_init(button_panel_type* pbutton_panel, int x, int y, int w, in
   pbutton_panel->y = y;
   pbutton_panel->w = w;
   pbutton_panel->h = h;
+  pbutton_panel->hidden = NO;
+}
+
+button_type* button_panel_event(button_panel_type* pbutton_panel, SDL_Event* event)
+{
+  if(pbutton_panel->hidden == NO)
+    {
+      int i;
+      for(i = 0; i < pbutton_panel->num_items; ++i)
+        {
+          button_event(&pbutton_panel->item[i],event);
+          if(pbutton_panel->item[i].state != -1)
+            return &pbutton_panel->item[i];
+        }
+      return NULL;
+    }
+  else
+    {
+      return NULL;
+    }
 }
 
 void button_panel_free(button_panel_type* pbutton_panel)
@@ -190,15 +218,18 @@ void button_panel_free(button_panel_type* pbutton_panel)
 
 void button_panel_draw(button_panel_type* pbutton_panel)
 {
-  int i;
-  fillrect(pbutton_panel->x,pbutton_panel->y,pbutton_panel->w,pbutton_panel->h,100,100,100,200);
-  for(i = 0; i < pbutton_panel->num_items; ++i)
+  if(pbutton_panel->hidden == NO)
     {
-      button_draw(&pbutton_panel->item[i]);
+      int i;
+      fillrect(pbutton_panel->x,pbutton_panel->y,pbutton_panel->w,pbutton_panel->h,100,100,100,200);
+      for(i = 0; i < pbutton_panel->num_items; ++i)
+        {
+          button_draw(&pbutton_panel->item[i]);
+        }
     }
 }
 
-void button_panel_additem(button_panel_type* pbutton_panel, button_type* pbutton)
+void button_panel_additem(button_panel_type* pbutton_panel, button_type* pbutton, int tag)
 {
   int max_cols, row, col;
 
@@ -211,11 +242,14 @@ void button_panel_additem(button_panel_type* pbutton_panel, button_type* pbutton
 
   max_cols = pbutton_panel->w / 32;
 
-  row = pbutton_panel->num_items / max_cols;
-  col = pbutton_panel->num_items % max_cols;
+  row = (pbutton_panel->num_items-1) / max_cols;
+  col = (pbutton_panel->num_items-1) % max_cols;
+
+  printf("R %d C %d\n",row,col);
 
   pbutton_panel->item[pbutton_panel->num_items-1].x = pbutton_panel->x + col * 32;
   pbutton_panel->item[pbutton_panel->num_items-1].y = pbutton_panel->y + row * 32;
+  pbutton_panel->item[pbutton_panel->num_items-1].tag = tag;
 
 }
 
index 1e1a274..bcadd86 100644 (file)
@@ -24,6 +24,7 @@ enum {
 typedef struct button_type
   {
     texture_type icon;
+    texture_type* bkgd;
     char *info;
     SDLKey shortcut;
     int x;
@@ -32,6 +33,7 @@ typedef struct button_type
     int h;
     int show_info;
     int state;
+    int tag;
   }
 button_type;
 
@@ -45,6 +47,7 @@ int button_get_state(button_type* pbutton);
 typedef struct button_panel_type
   {
     int num_items;
+    int hidden;
     int x,y;
     int w,h;
     button_type* item;
@@ -54,6 +57,7 @@ button_panel_type;
 void button_panel_init(button_panel_type* pbutton_panel, int x, int y, int w, int h);
 void button_panel_free(button_panel_type* pbutton_panel);
 void button_panel_draw(button_panel_type* pbutton_panel);
-void button_panel_additem(button_panel_type* pbutton_panel, button_type* pbutton);
+void button_panel_additem(button_panel_type* pbutton_panel, button_type* pbutton, int tag);
+button_type* button_panel_event(button_panel_type* pbutton_panel, SDL_Event* event);
 
 #endif /*SUPERTUX_BUTTON_H*/
index c617e62..453b1c1 100644 (file)
@@ -102,7 +102,12 @@ static button_type le_select_mode_one_bt;
 static button_type le_select_mode_two_bt;
 static button_type le_bad_bsod_bt;
 static button_type le_settings_bt;
-static button_panel_type le_bt_panel;
+static button_type le_bad_bt;
+static button_type le_bkgd_bt;
+static button_type le_fgd_bt;
+static button_panel_type le_bkgd_panel;
+static button_panel_type le_fgd_panel;
+static button_panel_type le_bad_panel;
 static menu_type leveleditor_menu;
 static menu_type subset_load_menu;
 static menu_type subset_new_menu;
@@ -139,14 +144,6 @@ void le_set_defaults()
     }
 }
 
-/* FIXME: Needs to be implemented. It should ask the user for the level(file)name and then let him create a new level based on this. */
-void newlevel()
-{}
-
-/* FIXME: It should let select the user a level, which is in the leveldirectory and then load it. */
-void selectlevel()
-{}
-
 int leveleditor(int levelnb)
 {
   int last_time, now_time, i;
@@ -359,7 +356,7 @@ void le_new_subset(char *subset_name)
 
 int le_init()
 {
-  int i;
+  int i,j;
   char str[80];
   level_subsets = dsubdirs("/levels", "info");
 
@@ -391,7 +388,104 @@ int le_init()
   button_load(&le_settings_bt,"/images/icons/settings.png","Level settings",SDLK_F5,screen->w-32,screen->h - 64);
   button_load(&le_move_left_bt,"/images/icons/left.png","Move left",SDLK_LEFT,0,0);
   button_load(&le_move_right_bt,"/images/icons/right.png","Move right",SDLK_RIGHT,screen->w-80,0);
-  button_panel_init(&le_bt_panel, screen->w - 64,82, 64, 334);
+  button_load(&le_fgd_bt,"/images/icons/fgd.png","Foreground tiles", SDLK_F7,screen->w-64,82);
+  button_load(&le_bkgd_bt,"/images/icons/bgd.png","Background tiles", SDLK_F8,screen->w-43,82);
+  button_load(&le_bad_bt,"/images/icons/bad.png","Bad guys", SDLK_F9,screen->w-22,82);
+
+  string_list_type bkgd_files =  dfiles("images/themes/antarctica","bkgd-", NULL);
+  string_list_sort(&bkgd_files);
+
+  button_panel_init(&le_bkgd_panel, screen->w - 64,98, 64, 318);
+  le_bkgd_panel.hidden = YES;
+  for(i = 0; i < bkgd_files.num_items; ++i)
+    {
+      char filename[1024];
+      sprintf(filename,"images/themes/antarctica/%s",bkgd_files.item[i]);
+      button_panel_additem(&le_bkgd_panel,button_create(filename, "My dear",SDLK_a,0,0),i);
+    }
+
+  string_list_free(&bkgd_files);
+  bkgd_files = dfiles("images/shared","cloud-", NULL);
+  string_list_sort(&bkgd_files);
+
+  for(i = 0; i < bkgd_files.num_items; ++i)
+    {
+      char filename[1024];
+      sprintf(filename,"images/shared/%s",bkgd_files.item[i]);
+      button_panel_additem(&le_bkgd_panel,button_create(filename, "My Doooooo",SDLK_a,0,0),i+8);
+    }
+
+  string_list_type fgd_files =  dfiles("images/themes/antarctica","solid", NULL);
+  string_list_sort(&fgd_files);
+
+  button_panel_init(&le_fgd_panel, screen->w - 64,98, 64, 318);
+  for(i = 0; i < fgd_files.num_items; ++i)
+    {
+      char filename[1024];
+      sprintf(filename,"images/themes/antarctica/%s",fgd_files.item[i]);
+      printf("%s",filename);
+      button_panel_additem(&le_fgd_panel,button_create(filename, "My dear",SDLK_a,0,0),i);
+    }
+
+  string_list_free(&fgd_files);
+  string_list_add_item(&fgd_files,"waves-0.png");
+  string_list_add_item(&fgd_files,"water.png");
+  string_list_add_item(&fgd_files,"pole.png");
+  string_list_add_item(&fgd_files,"poletop.png");
+  string_list_add_item(&fgd_files,"flag-0.png");
+  string_list_add_item(&fgd_files,"box-empty.png");
+  string_list_add_item(&fgd_files,"mints.png");
+  string_list_add_item(&fgd_files,"distro-0.png");
+  string_list_add_item(&fgd_files,"golden-herring.png");
+  string_list_add_item(&fgd_files,"distro-0.png");
+
+  for(i = 0; i < fgd_files.num_items; ++i)
+    {
+      char filename[1024];
+      sprintf(filename,"images/shared/%s",fgd_files.item[i]);
+      button_panel_additem(&le_fgd_panel,button_create(filename, "My dear",SDLK_a,0,0),i+4);
+    }
+
+  string_list_free(&fgd_files);
+  fgd_files =  dfiles("images/themes/antarctica","brick", NULL);
+  string_list_sort(&fgd_files);
+  
+  for(i = 0; i < fgd_files.num_items; ++i)
+    {
+      char filename[1024];
+      sprintf(filename,"images/themes/antarctica/%s",fgd_files.item[i]);
+      button_panel_additem(&le_fgd_panel,button_create(filename, "My dear",SDLK_a,0,0),i+14);
+    }
+    
+  string_list_free(&fgd_files);
+  string_list_add_item(&fgd_files,"distro-0.png");
+  string_list_add_item(&fgd_files,"distro-0.png");
+  for(i = 0; i < fgd_files.num_items; ++i)
+    {
+      char filename[1024];
+      sprintf(filename,"images/shared/%s",fgd_files.item[i]);
+      button_panel_additem(&le_fgd_panel,button_create(filename, "My dear",SDLK_a,0,0),i+16);
+    }
+  
+  le_fgd_panel.item[10].bkgd = &le_fgd_panel.item[9].icon;
+  le_fgd_panel.item[11].bkgd = &le_fgd_panel.item[9].icon;
+  le_fgd_panel.item[12].bkgd = &le_fgd_panel.item[9].icon;
+  le_fgd_panel.item[16].bkgd = &le_fgd_panel.item[14].icon;
+  le_fgd_panel.item[17].bkgd = &le_fgd_panel.item[15].icon;
+
+  string_list_type bad_files;
+  string_list_init(&bad_files);
+  string_list_add_item(&bad_files,"bsod-left-0.png");
+  string_list_add_item(&bad_files,"laptop-left-0.png");
+  string_list_add_item(&bad_files,"bag-left-0.png");
+  button_panel_init(&le_bad_panel, screen->w - 64,98, 64, 318);
+  le_bad_panel.hidden = YES;
+  for(i = 0; i < bad_files.num_items; ++i)
+    {
+      char filename[1024];
+      sprintf(filename,"images/shared/%s",bad_files.item[i]);
+      button_panel_additem(&le_bad_panel,button_create(filename, "My Doooooo",SDLK_a,0,0),i);
+    }
 
   menu_init(&leveleditor_menu);
   menu_additem(&leveleditor_menu,menu_item_create(MN_LABEL,"Level Editor Menu",0,0));
@@ -439,16 +533,16 @@ int le_init()
   level_settings_menu.arrange_left = YES;
   menu_additem(&level_settings_menu,menu_item_create(MN_LABEL,"Level Settings",0,0));
   menu_additem(&level_settings_menu,menu_item_create(MN_HL,"",0,0));
-  menu_additem(&level_settings_menu,menu_item_create(MN_TEXTFIELD,"Name:",0,0));
-  menu_additem(&level_settings_menu,menu_item_create(MN_STRINGSELECT,"Theme:",0,0));
-  menu_additem(&level_settings_menu,menu_item_create(MN_STRINGSELECT,"Song:",0,0));
-  menu_additem(&level_settings_menu,menu_item_create(MN_STRINGSELECT,"Background:",0,0));
-  menu_additem(&level_settings_menu,menu_item_create(MN_NUMFIELD,"Length: ",0,0));
-  menu_additem(&level_settings_menu,menu_item_create(MN_NUMFIELD,"Time:   ",0,0));
-  menu_additem(&level_settings_menu,menu_item_create(MN_NUMFIELD,"Gravity:",0,0));
-  menu_additem(&level_settings_menu,menu_item_create(MN_NUMFIELD,"Red:    ",0,0));
-  menu_additem(&level_settings_menu,menu_item_create(MN_NUMFIELD,"Green:  ",0,0));
-  menu_additem(&level_settings_menu,menu_item_create(MN_NUMFIELD,"Blue:   ",0,0));
+  menu_additem(&level_settings_menu,menu_item_create(MN_TEXTFIELD,"Name    ",0,0));
+  menu_additem(&level_settings_menu,menu_item_create(MN_STRINGSELECT,"Theme   ",0,0));
+  menu_additem(&level_settings_menu,menu_item_create(MN_STRINGSELECT,"Song    ",0,0));
+  menu_additem(&level_settings_menu,menu_item_create(MN_STRINGSELECT,"Bg-Image",0,0));
+  menu_additem(&level_settings_menu,menu_item_create(MN_NUMFIELD,"Length ",0,0));
+  menu_additem(&level_settings_menu,menu_item_create(MN_NUMFIELD,"Time   ",0,0));
+  menu_additem(&level_settings_menu,menu_item_create(MN_NUMFIELD,"Gravity",0,0));
+  menu_additem(&level_settings_menu,menu_item_create(MN_NUMFIELD,"Red    ",0,0));
+  menu_additem(&level_settings_menu,menu_item_create(MN_NUMFIELD,"Green  ",0,0));
+  menu_additem(&level_settings_menu,menu_item_create(MN_NUMFIELD,"Blue   ",0,0));
   menu_additem(&level_settings_menu,menu_item_create(MN_HL,"",0,0));
   menu_additem(&level_settings_menu,menu_item_create(MN_ACTION,"Apply Changes",0,0));
 
@@ -466,8 +560,8 @@ void update_level_settings_menu()
   sprintf(str,"%d",le_current_level->width);
 
   string_list_copy(level_settings_menu.item[3].list, dsubdirs("images/themes", "solid0.png"));
-  string_list_copy(level_settings_menu.item[4].list, dfiles("music/", "-fast"));
-  string_list_copy(level_settings_menu.item[5].list, dfiles("images/background", NULL));
+  string_list_copy(level_settings_menu.item[4].list, dfiles("music/",NULL, "-fast"));
+  string_list_copy(level_settings_menu.item[5].list, dfiles("images/background",NULL, NULL));
   if((i = string_list_find(level_settings_menu.item[3].list,le_current_level->theme)) != -1)
     level_settings_menu.item[3].list->active_item = i;
   if((i = string_list_find(level_settings_menu.item[4].list,le_current_level->song_title)) != -1)
@@ -641,6 +735,31 @@ void le_drawinterface()
   /* draw button bar */
   fillrect(screen->w - 64, 0, 64, screen->h, 50, 50, 50,255);
   drawshape(19 * 32, 14 * 32, le_current_tile);
+  switch(le_current_tile)
+    {
+    case 'B':
+      texture_draw(&img_mints, 19 * 32, 14 * 32, NO_UPDATE);
+      break;
+    case '!':
+      texture_draw(&img_golden_herring,19 * 32, 14 * 32, NO_UPDATE);
+      break;
+    case 'x':
+    case 'y':
+    case 'A':
+      texture_draw(&img_distro[(le_frame / 5) % 4], 19 * 32, 14 * 32, NO_UPDATE);
+      break;
+    case '0':
+      texture_draw(&img_bsod_left[(le_frame / 5) % 4],19 * 32, 14 * 32, NO_UPDATE);
+      break;
+    case '1':
+      texture_draw(&img_laptop_left[(le_frame / 5) % 3],19 * 32, 14 * 32, NO_UPDATE);
+      break;
+    case '2':
+      texture_draw(&img_money_left[0],19 * 32, 14 * 32, NO_UPDATE);
+      break;
+    default:
+      break;
+    }
 
   if(le_current_level != NULL)
     {
@@ -655,7 +774,12 @@ void le_drawinterface()
       button_draw(&le_settings_bt);
       button_draw(&le_move_right_bt);
       button_draw(&le_move_left_bt);
-      button_panel_draw(&le_bt_panel);
+      button_draw(&le_bad_bt);
+      button_draw(&le_bkgd_bt);
+      button_draw(&le_fgd_bt);
+      button_panel_draw(&le_bkgd_panel);
+      button_panel_draw(&le_fgd_panel);
+      button_panel_draw(&le_bad_panel);
 
       sprintf(str, "%d/%d", le_level,le_level_subset.levels);
       text_drawf(&white_text, str, -8, 16, A_RIGHT, A_NONE, 1, NO_UPDATE);
@@ -740,6 +864,7 @@ void le_checkevents()
 {
   SDLKey key;
   SDLMod keymod;
+  button_type* pbutton;
   int x,y;
 
   keymod = SDL_GetModState();
@@ -1093,9 +1218,29 @@ void le_checkevents()
                   button_event(&le_select_mode_two_bt,&event);
                   if(button_get_state(&le_select_mode_two_bt) == BN_CLICKED)
                     le_selection_mode = SQUARE;
-                  button_event(&le_bad_bsod_bt,&event);
-                  if(button_get_state(&le_bad_bsod_bt) == BN_CLICKED)
-                    le_current_tile = '0';
+
+                  button_event(&le_bad_bt,&event);
+                  if(button_get_state(&le_bad_bt) == BN_CLICKED)
+                    {
+                      le_bad_panel.hidden = NO;
+                      le_fgd_panel.hidden = YES;
+                      le_bkgd_panel.hidden = YES;
+                    }
+
+                  button_event(&le_fgd_bt,&event);
+                  if(button_get_state(&le_fgd_bt) == BN_CLICKED)
+                    {
+                      le_bad_panel.hidden = YES;
+                      le_fgd_panel.hidden = NO;
+                      le_bkgd_panel.hidden = YES;
+                    }
+                  button_event(&le_bkgd_bt,&event);
+                  if(button_get_state(&le_bkgd_bt) == BN_CLICKED)
+                    {
+                      le_bad_panel.hidden = YES;
+                      le_fgd_panel.hidden = YES;
+                      le_bkgd_panel.hidden = NO;
+                    }
                   button_event(&le_settings_bt,&event);
                   if(button_get_state(&le_settings_bt) == BN_CLICKED)
                     {
@@ -1111,6 +1256,79 @@ void le_checkevents()
                           show_menu = NO;
                         }
                     }
+                  if((pbutton = button_panel_event(&le_bkgd_panel,&event)) != NULL)
+                    {
+                      if(button_get_state(pbutton) == BN_CLICKED)
+                        {
+                          char c = '\0';
+                          if(pbutton->tag >= 0 && pbutton->tag <= 3)
+                            c = 'G' + pbutton->tag;
+                          else if(pbutton->tag >= 4 && pbutton->tag <= 7)
+                            c = 'g' + pbutton->tag - 4;
+                          else if(pbutton->tag >= 8 && pbutton->tag <= 11)
+                            c = 'C' + pbutton->tag - 8;
+                          else if(pbutton->tag >= 12 && pbutton->tag <= 15)
+                            c = 'c' + pbutton->tag - 12;
+                          if(c != '\0')
+                            le_current_tile = c;
+                        }
+                    }
+                  if((pbutton = button_panel_event(&le_fgd_panel,&event)) != NULL)
+                    {
+                      if(button_get_state(pbutton) == BN_CLICKED)
+                        {
+                          char c = '\0';
+                          if(pbutton->tag == 0)
+                            c = '#' ;
+                          else if(pbutton->tag == 1)
+                            c = '[';
+                          else if(pbutton->tag == 2)
+                            c = '=';
+                          else if(pbutton->tag == 3)
+                            c = ']';
+                          else if(pbutton->tag == 4)
+                            c = '^';
+                          else if(pbutton->tag == 5)
+                            c = '&';
+                          else if(pbutton->tag == 6)
+                            c = '|';
+                          else if(pbutton->tag == 7)
+                            c = '*';
+                          else if(pbutton->tag == 8)
+                            c = '\\';
+                          else if(pbutton->tag == 9)
+                            c = 'a';
+                          else if(pbutton->tag == 10)
+                            c = 'B';
+                          else if(pbutton->tag == 11)
+                            c = 'A';
+                          else if(pbutton->tag == 12)
+                            c = '!';
+                          else if(pbutton->tag == 13)
+                            c = '$';
+                          else if(pbutton->tag == 14)
+                            c = 'X';
+                          else if(pbutton->tag == 15)
+                            c = 'Y';
+                          else if(pbutton->tag == 16)
+                            c = 'x';
+                          else if(pbutton->tag == 17)
+                            c = 'y';                       
+                          if(c != '\0')
+                            le_current_tile = c;
+                        }
+                    }
+                  if((pbutton = button_panel_event(&le_bad_panel,&event)) != NULL)
+                    {
+                      if(button_get_state(pbutton) == BN_CLICKED)
+                        {
+                          char c = '\0';
+                          if(pbutton->tag >= 0 && pbutton->tag <= 2)
+                            c = '0' + pbutton->tag;
+                          if(c != '\0')
+                            le_current_tile = c;
+                        }
+                    }
                 }
               else
                 {
index 1a1583a..2695cbf 100644 (file)
@@ -119,7 +119,7 @@ string_list_type dsubdirs(char *rel_path, char* expected_file)
                     continue;
                 }
 
-               string_list_add_item(&sdirs,direntp->d_name);
+              string_list_add_item(&sdirs,direntp->d_name);
             }
         }
       closedir(dirStructP);
@@ -152,7 +152,7 @@ string_list_type dsubdirs(char *rel_path, char* expected_file)
                     }
                 }
 
-               string_list_add_item(&sdirs,direntp->d_name);
+              string_list_add_item(&sdirs,direntp->d_name);
             }
         }
       closedir(dirStructP);
@@ -161,7 +161,7 @@ string_list_type dsubdirs(char *rel_path, char* expected_file)
   return sdirs;
 }
 
-string_list_type dfiles(char *rel_path, char* exception_str)
+string_list_type dfiles(char *rel_path, char* glob, char* exception_str)
 {
   DIR *dirStructP;
   struct dirent *direntp;
@@ -188,8 +188,11 @@ string_list_type dfiles(char *rel_path, char* exception_str)
                   if(strstr(direntp->d_name,exception_str) != NULL)
                     continue;
                 }
+              if(glob != NULL)
+                if(strstr(direntp->d_name,glob) == NULL)
+                  continue;
 
-               string_list_add_item(&sdirs,direntp->d_name);
+              string_list_add_item(&sdirs,direntp->d_name);
             }
         }
       closedir(dirStructP);
@@ -212,8 +215,11 @@ string_list_type dfiles(char *rel_path, char* exception_str)
                   if(strstr(direntp->d_name,exception_str) != NULL)
                     continue;
                 }
+              if(glob != NULL)
+                if(strstr(direntp->d_name,glob) == NULL)
+                  continue;
 
-               string_list_add_item(&sdirs,direntp->d_name);
+              string_list_add_item(&sdirs,direntp->d_name);
             }
         }
       closedir(dirStructP);
index 7bfebc4..60154cb 100644 (file)
@@ -21,7 +21,7 @@ int faccessible(char *filename);
 int fcreatedir(char* relative_dir);
 int fwriteable(char *filename);
 string_list_type dsubdirs(char *rel_path, char* expected_file);
-string_list_type dfiles(char *rel_path, char* exception_str);
+string_list_type dfiles(char *rel_path, char* glob, char* exception_str);
 void free_strings(char **strings, int num);
 void st_directory_setup(void);
 void st_general_setup(void);
index 2a77ee9..3b0e1a4 100644 (file)
@@ -71,6 +71,37 @@ int string_list_find(string_list_type* pstring_list, char* str)
   return -1;
 }
 
+void string_list_sort(string_list_type* pstring_list)
+{
+  int i,j,y;
+  short int sorter[pstring_list->num_items];
+
+  for(j = 0; j < pstring_list->num_items; ++j)
+    for(i = 0; i < pstring_list->num_items-1; ++i)
+      {
+
+        y = strcmp(pstring_list->item[i],pstring_list->item[i+1]);
+        if(y == 0)
+          {
+            continue;
+          }
+        else if(y < 0)
+          {
+            continue;
+          }
+        else if(y > 0)
+          {
+            char* char_pointer;
+            char_pointer = pstring_list->item[i];
+            pstring_list->item[i] = pstring_list->item[i+1];
+            pstring_list->item[i+1] = char_pointer;
+            continue;
+          }
+
+      }
+
+}
+
 void string_list_free(string_list_type* pstring_list)
 {
   if(pstring_list != NULL)
index c039486..8d02c50 100644 (file)
@@ -42,6 +42,7 @@ void string_list_init(string_list_type* pstring_list);
 char* string_list_active(string_list_type* pstring_list);
 void string_list_copy(string_list_type* pstring_list, string_list_type pstring_list_orig);
 int string_list_find(string_list_type* pstring_list, char* str);
+void string_list_sort(string_list_type* pstring_list);
 void string_list_add_item(string_list_type* pstring_list, char* str);
 void string_list_free(string_list_type* pstring_list);