]> icculus.org git repositories - taylor/freespace2.git/blob - src/fred2/campaignfilelistbox.cpp
fix issue with looping audio streams
[taylor/freespace2.git] / src / fred2 / campaignfilelistbox.cpp
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
6  * the source.
7  */
8
9 // CampaignFilelistBox.cpp : implementation file
10 //
11
12 #include "stdafx.h"
13 #include "fred.h"
14 #include "freespace.h"
15 #include "campaignfilelistbox.h"
16 #include "campaigntreewnd.h"
17 #include "missioncampaign.h"
18 #include "missionparse.h"
19
20 #ifdef _DEBUG
21 #define new DEBUG_NEW
22 #undef THIS_FILE
23 static char THIS_FILE[] = __FILE__;
24 #endif
25
26 /////////////////////////////////////////////////////////////////////////////
27 // campaign_filelist_box
28
29 campaign_filelist_box::campaign_filelist_box()
30 {
31 }
32
33 campaign_filelist_box::~campaign_filelist_box()
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
43 /////////////////////////////////////////////////////////////////////////////
44 // campaign_filelist_box message handlers
45
46 void campaign_filelist_box::initialize()
47 {
48         int i, z;
49         char wild_card[256];
50         WIN32_FIND_DATA file_data;
51         HANDLE h;
52         mission a_mission;
53
54         ResetContent();
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) {
60                 do {
61
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 );
65
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);
73
74                 } while (FindNextFile(h, &file_data));
75
76                 FindClose(h);
77         }
78
79         for (i=0; i<Campaign.num_missions; i++) {
80                 z = FindString(-1, Campaign.missions[i].name);
81                 if (z != LB_ERR) {
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)
84                 }
85         }
86 }
87