2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
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
9 // CampaignFilelistBox.cpp : implementation file
14 #include "freespace.h"
15 #include "campaignfilelistbox.h"
16 #include "campaigntreewnd.h"
17 #include "missioncampaign.h"
18 #include "missionparse.h"
23 static char THIS_FILE[] = __FILE__;
26 /////////////////////////////////////////////////////////////////////////////
27 // campaign_filelist_box
29 campaign_filelist_box::campaign_filelist_box()
33 campaign_filelist_box::~campaign_filelist_box()
38 BEGIN_MESSAGE_MAP(campaign_filelist_box, CListBox)
39 //{{AFX_MSG_MAP(campaign_filelist_box)
43 /////////////////////////////////////////////////////////////////////////////
44 // campaign_filelist_box message handlers
46 void campaign_filelist_box::initialize()
50 WIN32_FIND_DATA file_data;
55 memset(wild_card, 0, 256);
56 strcpy(wild_card, NOX("*"));
57 strcat(wild_card, FS_MISSION_FILE_EXT);
58 h = FindFirstFile(wild_card, &file_data);
59 if (h != INVALID_HANDLE_VALUE) {
62 // make a call to get the mission info for this mission. Passing a misison as the second
63 // parameter will prevent The_mission from getting overwritten.
64 get_mission_info( file_data.cFileName, &a_mission );
66 // only add missions of the appropriate type to the file listbox
67 if ( (Campaign.type == CAMPAIGN_TYPE_SINGLE) && (a_mission.game_type & (MISSION_TYPE_SINGLE|MISSION_TYPE_TRAINING)) )
68 AddString(file_data.cFileName);
69 else if ( (Campaign.type == CAMPAIGN_TYPE_MULTI_COOP) && (a_mission.game_type & MISSION_TYPE_MULTI_COOP) )
70 AddString(file_data.cFileName);
71 else if ( (Campaign.type == CAMPAIGN_TYPE_MULTI_TEAMS) && (a_mission.game_type & MISSION_TYPE_MULTI_TEAMS) )
72 AddString(file_data.cFileName);
74 } while (FindNextFile(h, &file_data));
79 for (i=0; i<Campaign.num_missions; i++) {
80 z = FindString(-1, Campaign.missions[i].name);
82 DeleteString(z); // take out all missions already in the campaign
83 i--; // recheck for name just in case there are two (should be impossible but can't be sure)