File: FixupMapDialog.cpp

package info (click to toggle)
darkradiant 3.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 41,080 kB
  • sloc: cpp: 264,743; ansic: 10,659; python: 1,852; xml: 1,650; sh: 92; makefile: 21
file content (70 lines) | stat: -rw-r--r-- 1,596 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "FixupMapDialog.h"

#include "i18n.h"
#include "ui/imainframe.h"
#include "wxutil/dialog/MessageBox.h"

#include "string/string.h"
#include "FixupMap.h"

namespace ui
{

namespace
{
	const char* const WINDOW_TITLE = N_("Fixup Map");
	const char* const FIXUP_FILE_LABEL = N_("Fixup File");
}

FixupMapDialog::FixupMapDialog() :
	Dialog(_(WINDOW_TITLE))
{
	// Add the path entry
	_pathEntry = addPathEntry(FIXUP_FILE_LABEL, false);
}

std::string FixupMapDialog::getFixupFilePath()
{
	return getElementValue(_pathEntry);
}

void FixupMapDialog::RunDialog(const cmd::ArgumentList& args)
{
	FixupMapDialog dialog;

	if (dialog.run() == RESULT_OK)
	{
		std::string filename = dialog.getFixupFilePath();

		// Run fixup script
		FixupMap fixup(filename);

		FixupMap::Result result = fixup.perform();

		// Show popup with results
		std::string msg;

		msg += fmt::format(_("{0} shaders replaced."), result.replacedShaders) + "\n";
		msg += fmt::format(_("{0} entities replaced."), result.replacedEntities) + "\n";
		msg += fmt::format(_("{0} models replaced."), result.replacedModels) + "\n";
		msg += fmt::format(_("{0} spawnargs replaced."), result.replacedMisc) + "\n";

		if (!result.errors.empty())
		{
			msg += "\n\n";
			msg += _("Errors occurred:");
			msg += "\n";

			for (FixupMap::Result::ErrorMap::const_iterator i = result.errors.begin();
				 i != result.errors.end(); ++i)
			{
				msg += fmt::format(_("(Line {0}): {1}"), i->first, i->second);
				msg += "\n";
			}
		}

		wxutil::Messagebox::Show(_("Fixup Results"), msg, IDialog::MESSAGE_CONFIRM);
	}
}

} // namespace ui