diff --git a/radiant/ui/modelexport/ExportAsModelDialog.cpp b/radiant/ui/modelexport/ExportAsModelDialog.cpp index e9c0b1dadf..6defdd87c5 100644 --- a/radiant/ui/modelexport/ExportAsModelDialog.cpp +++ b/radiant/ui/modelexport/ExportAsModelDialog.cpp @@ -145,6 +145,9 @@ void ExportAsModelDialog::populateWindow() keepOriginBox->Enable(false); } + // Check if options are available for the current format + handleFormatSelectionChange(); + Layout(); Fit(); CenterOnScreen(); @@ -191,7 +194,7 @@ void ExportAsModelDialog::onCancel(wxCommandEvent& ev) EndModal(wxID_CANCEL); } -void ExportAsModelDialog::onFormatSelection(wxCommandEvent& ev) +void ExportAsModelDialog::handleFormatSelectionChange() { std::string selectedFormat = wxutil::ChoiceHelper::GetSelectedStoredString( findNamedObject(this, "ExportDialogFormatChoice")); @@ -199,9 +202,33 @@ void ExportAsModelDialog::onFormatSelection(wxCommandEvent& ev) if (!selectedFormat.empty()) { findNamedObject(this, "ExportDialogFilePicker")->setDefaultExtension(selectedFormat); + + std::string extLower = boost::algorithm::to_lower_copy(selectedFormat); + + // Check if the replace current selection option is available + std::string extensions = GlobalGameManager().currentGame()->getKeyValue("modeltypes"); + std::set supportedExtensions; + boost::algorithm::split(supportedExtensions, extensions, boost::algorithm::is_any_of(" ")); + + wxCheckBox* replaceSelectionBox = findNamedObject(this, "ExportDialogReplaceWithModel"); + + // If the current game supports the format, make the option available + bool formatSupportedByCurrentGame = supportedExtensions.find(extLower) != supportedExtensions.end(); + + replaceSelectionBox->Enable(formatSupportedByCurrentGame); + + if (!formatSupportedByCurrentGame) + { + replaceSelectionBox->SetValue(false); + } } } +void ExportAsModelDialog::onFormatSelection(wxCommandEvent& ev) +{ + handleFormatSelectionChange(); +} + bool ExportAsModelDialog::_onDeleteEvent() { // Remember stuff even when X is pressed diff --git a/radiant/ui/modelexport/ExportAsModelDialog.h b/radiant/ui/modelexport/ExportAsModelDialog.h index e83ce9bb83..721006d460 100644 --- a/radiant/ui/modelexport/ExportAsModelDialog.h +++ b/radiant/ui/modelexport/ExportAsModelDialog.h @@ -29,6 +29,7 @@ class ExportAsModelDialog : void onFormatSelection(wxCommandEvent& ev); void saveOptionsToRegistry(); + void handleFormatSelectionChange(); }; }