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

Method updateGuiView

plugins/dm.gui/ReadableEditorDialog.cpp:625–750  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

623}
624
625void ReadableEditorDialog::updateGuiView(wxWindow* parent,
626 const std::string& guiPath,
627 const std::string& xDataName,
628 const std::string& xDataPath)
629{
630 // If the name of an xData object is passed it will be rendered instead of the current
631 // xData object, to enable previewing of XData definitions induced by the XDataSelector.
632 if (!xDataName.empty())
633 {
634 XData::XDataPtr xd;
635 XData::XDataMap xdMap;
636
637 if (_xdLoader->importDef(xDataName, xdMap, xDataPath))
638 {
639 xd = xdMap.begin()->second;
640 _guiView->setGui(GlobalGuiManager().getGui(xd->getGuiPage(0)));
641 }
642 else
643 {
644 std::string msg = fmt::format(_("Failed to import {0}."), xDataName);
645 msg += "\n\n";
646 msg += _("Do you want to open the import summary?");
647
648 wxutil::Messagebox dialog(_("Import failed"),
649 msg, ui::IDialog::MESSAGE_ASK, parent ? parent : this
650 );
651
652 if (dialog.run() == ui::IDialog::RESULT_YES)
653 {
654 showXdImportSummary();
655 }
656 return;
657 }
658
659 const gui::IGuiPtr& gui = _guiView->getGui();
660
661 if (gui == NULL)
662 {
663 std::string msg = fmt::format(_("Failed to load gui definition {0}."), xd->getGuiPage(0));
664 msg += "\n\n";
665 msg += _("Do you want to open the import summary?");
666
667 wxutil::Messagebox dialog(_("Import failed"),
668 msg, ui::IDialog::MESSAGE_ASK, parent ? parent : this
669 );
670
671 if (dialog.run() == ui::IDialog::RESULT_YES)
672 {
673 showGuiImportSummary();
674 }
675 return;
676 }
677
678 // Load data from xdata into the GUI's state variables
679 if (xd->getPageLayout() == XData::OneSided)
680 {
681 // One-sided has title and body
682 gui->setStateString("title", xd->getPageContent(XData::Title, 0, XData::Left));

Callers 3

onSelectionChangedMethod · 0.80
onSelectionChangedMethod · 0.80
onSelectionChangedMethod · 0.80

Calls 12

importDefMethod · 0.80
getGuiMethod · 0.80
setStateStringMethod · 0.80
redrawMethod · 0.80
formatFunction · 0.50
_Function · 0.50
emptyMethod · 0.45
beginMethod · 0.45
setGuiMethod · 0.45
runMethod · 0.45
getPageLayoutMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected