Skip to content

Commit

Permalink
ExportAsModelDialog disables the "replace selection" option if the se…
Browse files Browse the repository at this point in the history
…lected format is not supported by the current game type.
  • Loading branch information
codereader committed Aug 25, 2017
1 parent 1abec27 commit f8729dd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
29 changes: 28 additions & 1 deletion radiant/ui/modelexport/ExportAsModelDialog.cpp
Expand Up @@ -145,6 +145,9 @@ void ExportAsModelDialog::populateWindow()
keepOriginBox->Enable(false);
}

// Check if options are available for the current format
handleFormatSelectionChange();

Layout();
Fit();
CenterOnScreen();
Expand Down Expand Up @@ -191,17 +194,41 @@ void ExportAsModelDialog::onCancel(wxCommandEvent& ev)
EndModal(wxID_CANCEL);
}

void ExportAsModelDialog::onFormatSelection(wxCommandEvent& ev)
void ExportAsModelDialog::handleFormatSelectionChange()
{
std::string selectedFormat = wxutil::ChoiceHelper::GetSelectedStoredString(
findNamedObject<wxChoice>(this, "ExportDialogFormatChoice"));

if (!selectedFormat.empty())
{
findNamedObject<wxutil::PathEntry>(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<std::string> supportedExtensions;
boost::algorithm::split(supportedExtensions, extensions, boost::algorithm::is_any_of(" "));

wxCheckBox* replaceSelectionBox = findNamedObject<wxCheckBox>(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
Expand Down
1 change: 1 addition & 0 deletions radiant/ui/modelexport/ExportAsModelDialog.h
Expand Up @@ -29,6 +29,7 @@ class ExportAsModelDialog :
void onFormatSelection(wxCommandEvent& ev);

void saveOptionsToRegistry();
void handleFormatSelectionChange();
};

}

0 comments on commit f8729dd

Please sign in to comment.