FS2_Open
Open source remastering of the Freespace 2 engine
campaignfilelistbox.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 // CampaignFilelistBox.cpp : implementation file
11 //
12 
13 #include "stdafx.h"
14 #include "FRED.h"
15 #include "freespace2/freespace.h"
16 #include "CampaignFilelistBox.h"
17 #include "CampaignTreeWnd.h"
19 #include "mission/missionparse.h"
20 
21 #ifdef _DEBUG
22 #undef THIS_FILE
23 static char THIS_FILE[] = __FILE__;
24 #endif
25 
27 // campaign_filelist_box
28 
30 {
31 }
32 
34 {
35 }
36 
37 
38 BEGIN_MESSAGE_MAP(campaign_filelist_box, CListBox)
39  //{{AFX_MSG_MAP(campaign_filelist_box)
40  //}}AFX_MSG_MAP
41 END_MESSAGE_MAP()
42 
44 // campaign_filelist_box message handlers
45 
46 void campaign_filelist_box::initialize()
47 {
48  int i, z, num_files;
49  char *mission_filenames[2000];
50  char mission_filenames_arr[2000][MAX_FILENAME_LEN];
51  mission a_mission;
52 
53  ResetContent();
54 
55  extern int Skip_packfile_search;
56  Skip_packfile_search = 1;
57  num_files = cf_get_file_list_preallocated(2000, mission_filenames_arr, mission_filenames, CF_TYPE_MISSIONS, "*.fs2");
58  Skip_packfile_search = 0;
59 
60  i=0;
61 
62  while (i < num_files)
63  {
64  // make a call to get the mission info for this mission. Passing a misison as the second
65  // parameter will prevent The_mission from getting overwritten.
66  get_mission_info( mission_filenames[i] , &a_mission );
67  strcat(mission_filenames[i],".fs2");
68 
69  // only add missions of the appropriate type to the file listbox
71  AddString(mission_filenames[i]);
73  AddString(mission_filenames[i]);
75  AddString(mission_filenames[i]);
76 
77  i++;
78  }
79 
80 
81  for (i=0; i<Campaign.num_missions; i++) {
82  z = FindString(-1, Campaign.missions[i].name);
83  if (z != LB_ERR) {
84  DeleteString(z); // take out all missions already in the campaign
85  i--; // recheck for name just in case there are two (should be impossible but can't be sure)
86  }
87  }
88 
89 }
#define MAX_FILENAME_LEN
Definition: pstypes.h:324
int i
Definition: multi_pxo.cpp:466
#define CAMPAIGN_TYPE_SINGLE
int game_type
Definition: missionparse.h:138
char * name
#define MISSION_TYPE_MULTI_COOP
Definition: missionparse.h:64
int cf_get_file_list_preallocated(int max, char arr[][MAX_FILENAME_LEN], char **list, int type, const char *filter, int sort=CF_SORT_NONE, file_list_info *info=NULL)
#define MISSION_TYPE_SINGLE
Definition: missionparse.h:61
GLdouble GLdouble z
Definition: Glext.h:5451
int get_mission_info(const char *filename, mission *mission_p, bool basic)
#define MISSION_TYPE_TRAINING
Definition: missionparse.h:63
campaign Campaign
#define CF_TYPE_MISSIONS
Definition: cfile.h:74
#define CAMPAIGN_TYPE_MULTI_TEAMS
#define CAMPAIGN_TYPE_MULTI_COOP
int Skip_packfile_search
cmission missions[MAX_CAMPAIGN_MISSIONS]
#define MISSION_TYPE_MULTI_TEAMS
Definition: missionparse.h:65