MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / LoadDirectory

Method LoadDirectory

engine/Poseidon/UI/OptionsUIImpl.cpp:148–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148void DisplaySingleMission::LoadDirectory()
149{
150 ProgressStart(LocalizeString(IDS_LOAD_WORLD));
151 C3DListBox* lbox = dynamic_cast<C3DListBox*>(GetCtrl(IDC_SINGLE_MISSION));
152 if (!lbox)
153 {
154 return;
155 }
156
157 lbox->ClearStrings();
158
159 if (_directory.GetLength() > 0)
160 {
161 // Parent directory
162 int index = lbox->AddString("..");
163 lbox->SetValue(index, -2); // subdirectory
164 }
165
166 RString dir = RString("Missions\\") + _directory;
167
168 const char* searchStr = "briefingName";
169 int searchLen = strlen(searchStr);
170
171 _finddata_t info;
172
173 // first search for .pbo files
174 intptr_t h = _findfirst(dir + RString("*.pbo"), &info);
175 if (h != -1)
176 {
177 do
178 {
179 if ((info.attrib & _A_SUBDIR) == 0)
180 {
181 // remove extension (.pbo)
182 RString name = info.name;
183 int n = name.GetLength() - 4;
184 PoseidonAssert(stricmp(name + n, ".pbo") == 0);
185 RString nameNoExt = name.Substring(0, n);
186
187 // create bank (temporary)
188 QFBank bank;
189 bank.open(dir + nameNoExt);
190
191 ProgressRefresh();
192
193 ParamFile f;
194 if (f.ParseBin(bank, "mission.sqm"))
195 {
196 const ParamEntry& entry = f >> "Mission" >> "Intel";
197 if (entry.FindEntry("briefingName"))
198 {
199 name = entry >> "briefingName";
200 }
201 }
202 else
203 {
204 // fast search for mission name without parsing
205 // suppose "briefingName" is found in first 4KB of mission file

Callers

nothing calls this directly

Calls 15

ProgressStartFunction · 0.85
LocalizeStringFunction · 0.85
GetCtrlFunction · 0.85
_findfirstFunction · 0.85
ProgressRefreshFunction · 0.85
saturateMinFunction · 0.85
LocalizeFunction · 0.85
_findnextFunction · 0.85
_findcloseFunction · 0.85
LookupStringtableCsvFunction · 0.85
ProgressFinishFunction · 0.85
ClearStringsMethod · 0.80

Tested by

no test coverage detected