| 1 |
#include "FixupMapDialog.h" |
| 2 |
|
| 3 |
#include "i18n.h" |
| 4 |
#include "ui/imainframe.h" |
| 5 |
#include "wxutil/dialog/MessageBox.h" |
| 6 |
|
| 7 |
#include "string/string.h" |
| 8 |
#include "FixupMap.h" |
| 9 |
|
| 10 |
namespace ui |
| 11 |
{ |
| 12 |
|
| 13 |
namespace |
| 14 |
{ |
| 15 |
const char* const WINDOW_TITLE = N_("Fixup Map"); |
| 16 |
const char* const FIXUP_FILE_LABEL = N_("Fixup File"); |
| 17 |
} |
| 18 |
|
| 19 |
FixupMapDialog::FixupMapDialog() : |
| 20 |
Dialog(_(WINDOW_TITLE)) |
| 21 |
{ |
| 22 |
// Add the path entry |
| 23 |
_pathEntry = addPathEntry(FIXUP_FILE_LABEL, false); |
| 24 |
} |
| 25 |
|
| 26 |
std::string FixupMapDialog::getFixupFilePath() |
| 27 |
{ |
| 28 |
return getElementValue(_pathEntry); |
| 29 |
} |
| 30 |
|
| 31 |
void FixupMapDialog::RunDialog(const cmd::ArgumentList& args) |
| 32 |
{ |
| 33 |
FixupMapDialog dialog; |
| 34 |
|
| 35 |
if (dialog.run() == RESULT_OK) |
| 36 |
{ |
| 37 |
std::string filename = dialog.getFixupFilePath(); |
| 38 |
|
| 39 |
// Run fixup script |
| 40 |
FixupMap fixup(filename); |
| 41 |
|
| 42 |
FixupMap::Result result = fixup.perform(); |
| 43 |
|
| 44 |
// Show popup with results |
| 45 |
std::string msg; |
| 46 |
|
| 47 |
msg += fmt::format(_("{0} shaders replaced."), result.replacedShaders) + "\n"; |
| 48 |
msg += fmt::format(_("{0} entities replaced."), result.replacedEntities) + "\n"; |
| 49 |
msg += fmt::format(_("{0} models replaced."), result.replacedModels) + "\n"; |
| 50 |
msg += fmt::format(_("{0} spawnargs replaced."), result.replacedMisc) + "\n"; |
| 51 |
|
| 52 |
if (!result.errors.empty()) |
| 53 |
{ |
| 54 |
msg += "\n\n"; |
| 55 |
msg += _("Errors occurred:"); |
| 56 |
msg += "\n"; |
| 57 |
|
| 58 |
for (FixupMap::Result::ErrorMap::const_iterator i = result.errors.begin(); |
| 59 |
i != result.errors.end(); ++i) |
| 60 |
{ |
| 61 |
msg += fmt::format(_("(Line {0}): {1}"), i->first, i->second); |
| 62 |
msg += "\n"; |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
wxutil::Messagebox::Show(_("Fixup Results"), msg, IDialog::MESSAGE_CONFIRM); |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
} // namespace ui |