MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / initControlsFromEntity

Method initControlsFromEntity

plugins/dm.gui/ReadableEditorDialog.cpp:275–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

273// Private Methods:
274
275bool ReadableEditorDialog::initControlsFromEntity()
276{
277 // Inv_name
278 _nameEntry->SetValue(_entity->getKeyValue("inv_name"));
279
280 // Xdata contents
281 _xDataNameEntry->SetValue(_entity->getKeyValue("xdata_contents"));
282
283 // Construct the map-based Filename
284 _mapBasedFilename = GlobalMapModule().getMapName();
285 std::size_t nameStartPos = _mapBasedFilename.rfind("/") + 1;
286
287 if (nameStartPos != std::string::npos)
288 {
289 _mapBasedFilename = _mapBasedFilename.substr(nameStartPos, _mapBasedFilename.rfind(".") - nameStartPos);
290 }
291
292 std::string defaultXdName = "readables/" + _mapBasedFilename + "/" + _("<Name_Here>");
293 _mapBasedFilename += ".xd";
294
295 // Load xdata
296 if (!_entity->getKeyValue("xdata_contents").empty())
297 {
298 _xdNameSpecified = true;
299
300 try
301 {
302 int result = XdFileChooserDialog::Import(
303 _entity->getKeyValue("xdata_contents"), _xData, _xdFilename, _xdLoader, this
304 );
305
306 if (result == wxID_OK)
307 {
308 _useDefaultFilename = false;
309 refreshWindowTitle();
310 return true;
311 }
312
313 return false; // cancelled
314 }
315 catch (XdFileChooserDialog::ImportFailedException&)
316 {
317 std::string msg = fmt::format(_("Failed to import {0}."), _entity->getKeyValue("xdata_contents"));
318 msg += "\n";
319 msg += _("Creating a new XData definition...");
320 msg += "\n\n";
321 msg += _("Do you want to open the import summary?");
322
323 wxutil::Messagebox dialog(_("Import failed"),
324 msg, ui::IDialog::MESSAGE_ASK, this);
325
326 if (dialog.run() == ui::IDialog::RESULT_YES)
327 {
328 showXdImportSummary();
329 }
330
331 updateGuiView();
332 }

Callers

nothing calls this directly

Calls 10

setNumPagesMethod · 0.80
_Function · 0.50
formatFunction · 0.50
SetValueMethod · 0.45
getKeyValueMethod · 0.45
getMapNameMethod · 0.45
emptyMethod · 0.45
runMethod · 0.45
findMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected