forked from HaloMods/SparkEdit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ImportScenarioTagDlg.cpp
174 lines (145 loc) · 4.53 KB
/
ImportScenarioTagDlg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// ImportScenarioTagDlg.cpp : implementation file
//
#include "stdafx.h"
#include "sparkedit.h"
#include "ImportScenarioTagDlg.h"
#include "HaloStructDefs.h"
#include "HaloTagManager.h"
#include "Scenario.h"
#include "ToolView.h"
extern CHaloTagManager gTagManager;
extern CScenario gScenario;
extern CToolView *g_pTools;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CImportScenarioTagDlg dialog
CImportScenarioTagDlg::CImportScenarioTagDlg(CWnd* pParent /*=NULL*/)
: CDialog(CImportScenarioTagDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CImportScenarioTagDlg)
m_AvailableTagIndex = 0;
m_PalletteType = 0;
//}}AFX_DATA_INIT
//ZeroMemory(m_UnregSceneryPallette, sizeof(m_UnregSceneryPallette));
//ZeroMemory(m_UnregVehiclePallette, sizeof(m_UnregVehiclePallette));
m_VehicleItemCount = 0;
m_SceneryItemCount = 0;
}
void CImportScenarioTagDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CImportScenarioTagDlg)
DDX_CBIndex(pDX, IDC_AVAILABLE_TAGS, m_AvailableTagIndex);
DDX_CBIndex(pDX, IDC_PALLETTE_TYPE, m_PalletteType);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CImportScenarioTagDlg, CDialog)
//{{AFX_MSG_MAP(CImportScenarioTagDlg)
ON_CBN_SELCHANGE(IDC_PALLETTE_TYPE, OnSelchangePalletteType)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CImportScenarioTagDlg message handlers
void CImportScenarioTagDlg::SearchForMatchingTags()
{
int i;
int item_coll_count;
int scenery_count;
int vehicle_count;
CString str;
UINT tag_id, raw_name_offset;
//call on tag manager to build a list of vehi,scenery, mp_equip tags
item_coll_count = gTagManager.GetHighLevelTagCount(TAG_ITEM_COLLECTION);
scenery_count = gTagManager.GetHighLevelTagCount(TAG_SCENERY);
vehicle_count = gTagManager.GetHighLevelTagCount(TAG_VEHICLE);
for(i=0; i<vehicle_count; i++)
{
gTagManager.GetHighLevelTagInfo(TAG_VEHICLE, i, &tag_id, &raw_name_offset, &str);
if(!gScenario.CheckPalletteForTagExistence(TAG_VEHICLE, tag_id))
{
m_UnregVehiclePallette[m_VehicleItemCount].GuiName = str;
m_UnregVehiclePallette[m_VehicleItemCount].TagId = tag_id;
m_UnregVehiclePallette[m_VehicleItemCount].RawName = raw_name_offset;
m_VehicleItemCount++;
}
}
for(i=0; i<scenery_count; i++)
{
gTagManager.GetHighLevelTagInfo(TAG_SCENERY, i, &tag_id, &raw_name_offset, &str);
if(!gScenario.CheckPalletteForTagExistence(TAG_SCENERY, tag_id))
{
m_UnregSceneryPallette[m_SceneryItemCount].GuiName = str;
m_UnregSceneryPallette[m_SceneryItemCount].TagId = tag_id;
m_UnregSceneryPallette[m_SceneryItemCount].RawName = raw_name_offset;
m_SceneryItemCount++;
}
}
}
BOOL CImportScenarioTagDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SearchForMatchingTags();
OnSelchangePalletteType();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CImportScenarioTagDlg::OnSelchangePalletteType()
{
UpdateData(TRUE);
CComboBox *pCtrl = NULL;
int i;
pCtrl = (CComboBox*)GetDlgItem(IDC_AVAILABLE_TAGS);
pCtrl->ResetContent();
switch(m_PalletteType)
{
case 0:
if(m_VehicleItemCount > 0)
pCtrl->EnableWindow(TRUE);
else
pCtrl->EnableWindow(FALSE);
for(i=0; i<m_VehicleItemCount; i++)
{
pCtrl->AddString(m_UnregVehiclePallette[i].GuiName);
}
pCtrl->SetCurSel(0);
break;
case 1:
if(m_SceneryItemCount > 0)
pCtrl->EnableWindow(TRUE);
else
pCtrl->EnableWindow(FALSE);
for(i=0; i<m_SceneryItemCount; i++)
{
pCtrl->AddString(m_UnregSceneryPallette[i].GuiName);
}
pCtrl->SetCurSel(0);
break;
}
}
void CImportScenarioTagDlg::OnOK()
{
UpdateData(TRUE);
switch(m_PalletteType)
{
case 0:
if((m_VehicleItemCount > 0)&&(m_AvailableTagIndex < m_VehicleItemCount))
{
gScenario.AddVehicleType(m_UnregVehiclePallette[m_AvailableTagIndex].TagId,
m_UnregVehiclePallette[m_AvailableTagIndex].RawName);
}
break;
case 1:
if((m_SceneryItemCount > 0)&&(m_AvailableTagIndex < m_SceneryItemCount))
{
gScenario.AddSceneryType(m_UnregSceneryPallette[m_AvailableTagIndex].TagId,
m_UnregSceneryPallette[m_AvailableTagIndex].RawName);
}
break;
}
g_pTools->m_pToolSheet->m_EditTab.ResetTypePallette();
CDialog::OnOK();
}