CExportGameDialog: Mark strings as translatable where applicable

This commit is contained in:
Lioncash 2020-06-28 03:17:40 -04:00
parent c4b29106f1
commit 69f8ff1200

View File

@ -34,7 +34,7 @@ CExportGameDialog::CExportGameDialog(const QString& rkIsoPath, const QString& rk
InitUI(rkExportDir); InitUI(rkExportDir);
TString IsoName = TO_TSTRING(rkIsoPath).GetFileName(); TString IsoName = TO_TSTRING(rkIsoPath).GetFileName();
setWindowTitle(QString("Export Settings - %1").arg( TO_QSTRING(IsoName) )); setWindowTitle(tr("Export Settings - %1").arg(TO_QSTRING(IsoName)));
} }
else else
{ {
@ -69,14 +69,14 @@ void CExportGameDialog::InitUI(QString ExportDir)
// Info boxes // Info boxes
mpUI->GameTitleLineEdit->setText( TO_QSTRING(mGameTitle) ); mpUI->GameTitleLineEdit->setText( TO_QSTRING(mGameTitle) );
mpUI->GameIdLineEdit->setText( TO_QSTRING(mGameID) ); mpUI->GameIdLineEdit->setText( TO_QSTRING(mGameID) );
mpUI->BuildVersionLineEdit->setText( QString("%1 (%2)").arg(mBuildVer).arg( TO_QSTRING(GameInfo.GetBuildName(mBuildVer, mRegion)) )); mpUI->BuildVersionLineEdit->setText(tr("%1 (%2)").arg(mBuildVer).arg(TO_QSTRING(GameInfo.GetBuildName(mBuildVer, mRegion))));
mpUI->RegionLineEdit->setText(TEnumReflection<ERegion>::ConvertValueToString(mRegion)); mpUI->RegionLineEdit->setText(TEnumReflection<ERegion>::ConvertValueToString(mRegion));
// Disc tree widget // Disc tree widget
nod::IPartition *pPartition = mpDisc->getDataPartition(); nod::IPartition *pPartition = mpDisc->getDataPartition();
ASSERT(pPartition); ASSERT(pPartition);
QTreeWidgetItem *pTreeRoot = new QTreeWidgetItem((QTreeWidgetItem*) nullptr, QStringList(QString("Disc"))); auto* pTreeRoot = new QTreeWidgetItem((QTreeWidgetItem*)nullptr, QStringList(tr("Disc")));
mpUI->DiscFstTreeWidget->addTopLevelItem(pTreeRoot); mpUI->DiscFstTreeWidget->addTopLevelItem(pTreeRoot);
const nod::Node *pkDiscRoot = &pPartition->getFSTRoot(); const nod::Node *pkDiscRoot = &pPartition->getFSTRoot();
@ -214,7 +214,7 @@ bool CExportGameDialog::ValidateGame()
if (mGame == EGame::PrimeDemo || mGame == EGame::EchoesDemo || mGame == EGame::CorruptionProto) if (mGame == EGame::PrimeDemo || mGame == EGame::EchoesDemo || mGame == EGame::CorruptionProto)
{ {
// we cannot parent the error message box to ourselves because this window hasn't been shown // we cannot parent the error message box to ourselves because this window hasn't been shown
UICommon::ErrorMsg(parentWidget(), "The demo builds are currently not supported."); UICommon::ErrorMsg(parentWidget(), tr("The demo builds are currently not supported."));
return false; return false;
} }
@ -224,22 +224,22 @@ bool CExportGameDialog::ValidateGame()
bool CExportGameDialog::RequestWiiPortGame() bool CExportGameDialog::RequestWiiPortGame()
{ {
QDialog Dialog; QDialog Dialog;
Dialog.setWindowTitle("Select Game"); Dialog.setWindowTitle(tr("Select Game"));
bool IsTrilogy = (mGame == EGame::Invalid); const bool IsTrilogy = (mGame == EGame::Invalid);
bool HasMP1 = (IsTrilogy || mGame == EGame::Prime); const bool HasMP1 = (IsTrilogy || mGame == EGame::Prime);
bool HasMP2 = (IsTrilogy || mGame == EGame::Echoes); const bool HasMP2 = (IsTrilogy || mGame == EGame::Echoes);
bool HasMP3 = IsTrilogy; const bool HasMP3 = IsTrilogy;
QString GameName = (IsTrilogy ? "Metroid Prime: Trilogy" : "Wii de Asobu"); const QString GameName = (IsTrilogy ? tr("Metroid Prime: Trilogy") : tr("Wii de Asobu"));
QString LabelText = QString("You have selected a %1 ISO. Please pick a game to export:").arg(GameName); const QString LabelText = tr("You have selected a %1 ISO. Please pick a game to export:").arg(GameName);
QLabel Label(LabelText, &Dialog); QLabel Label(LabelText, &Dialog);
QComboBox ComboBox(&Dialog); QComboBox ComboBox(&Dialog);
ComboBox.addItem("Front End"); ComboBox.addItem(tr("Front End"));
if (HasMP1) ComboBox.addItem("Metroid Prime"); if (HasMP1) ComboBox.addItem(tr("Metroid Prime"));
if (HasMP2) ComboBox.addItem("Metroid Prime 2: Echoes"); if (HasMP2) ComboBox.addItem(tr("Metroid Prime 2: Echoes"));
if (HasMP3) ComboBox.addItem("Metroid Prime 3: Corruption"); if (HasMP3) ComboBox.addItem(tr("Metroid Prime 3: Corruption"));
QDialogButtonBox ButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, &Dialog); QDialogButtonBox ButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, &Dialog);
connect(&ButtonBox, SIGNAL(accepted()), &Dialog, SLOT(accept())); connect(&ButtonBox, SIGNAL(accepted()), &Dialog, SLOT(accept()));
connect(&ButtonBox, SIGNAL(rejected()), &Dialog, SLOT(reject())); connect(&ButtonBox, SIGNAL(rejected()), &Dialog, SLOT(reject()));
@ -250,7 +250,7 @@ bool CExportGameDialog::RequestWiiPortGame()
Layout.addWidget(&ButtonBox); Layout.addWidget(&ButtonBox);
Dialog.setLayout(&Layout); Dialog.setLayout(&Layout);
int Result = Dialog.exec(); const int Result = Dialog.exec();
if (Result == QDialog::Accepted) if (Result == QDialog::Accepted)
{ {
@ -276,7 +276,8 @@ bool CExportGameDialog::RequestWiiPortGame()
return true; return true;
} }
else return false;
return false;
} }
float CExportGameDialog::FindBuildVersion() float CExportGameDialog::FindBuildVersion()
@ -332,8 +333,8 @@ void CExportGameDialog::RecursiveAddToTree(const nod::Node *pkNode, QTreeWidgetI
}); });
// Add nodes to tree // Add nodes to tree
static const QIcon skFileIcon = QIcon(":/icons/New_16px.svg"); static const QIcon skFileIcon{QStringLiteral(":/icons/New_16px.svg")};
static const QIcon skDirIcon = QIcon(":/icons/Open_16px.svg"); static const QIcon skDirIcon{QStringLiteral(":/icons/Open_16px.svg")};
for (auto Iter = NodeList.begin(); Iter != NodeList.end(); Iter++) for (auto Iter = NodeList.begin(); Iter != NodeList.end(); Iter++)
{ {
@ -342,9 +343,9 @@ void CExportGameDialog::RecursiveAddToTree(const nod::Node *pkNode, QTreeWidgetI
if (!mpExporter->ShouldExportDiscNode(pkNode, pParent->parent() == nullptr)) if (!mpExporter->ShouldExportDiscNode(pkNode, pParent->parent() == nullptr))
continue; continue;
bool IsDir = pkNode->getKind() == nod::Node::Kind::Directory; const bool IsDir = pkNode->getKind() == nod::Node::Kind::Directory;
QTreeWidgetItem *pItem = new QTreeWidgetItem(pParent, QStringList(QString::fromStdString(pkNode->getName().data())) ); auto* pItem = new QTreeWidgetItem(pParent, QStringList(QString::fromStdString(pkNode->getName().data())));
pItem->setIcon(0, QIcon(IsDir ? skDirIcon : skFileIcon)); pItem->setIcon(0, QIcon(IsDir ? skDirIcon : skFileIcon));
if (IsDir) if (IsDir)
@ -354,47 +355,50 @@ void CExportGameDialog::RecursiveAddToTree(const nod::Node *pkNode, QTreeWidgetI
void CExportGameDialog::BrowseOutputDirectory() void CExportGameDialog::BrowseOutputDirectory()
{ {
QString NewOutputDir = UICommon::OpenDirDialog(this, "Choose export directory"); const QString NewOutputDir = UICommon::OpenDirDialog(this, tr("Choose export directory"));
if (!NewOutputDir.isEmpty()) mpUI->OutputDirectoryLineEdit->setText(NewOutputDir); if (!NewOutputDir.isEmpty())
mpUI->OutputDirectoryLineEdit->setText(NewOutputDir);
} }
void CExportGameDialog::BrowseAssetNameMap() void CExportGameDialog::BrowseAssetNameMap()
{ {
QString Filter = "*." + TO_QSTRING(CAssetNameMap::GetExtension()); const QString Filter = "*." + TO_QSTRING(CAssetNameMap::GetExtension());
QString NewNameMap = UICommon::OpenFileDialog(this, "Choose Asset Name Map", Filter); const QString NewNameMap = UICommon::OpenFileDialog(this, tr("Choose Asset Name Map"), Filter);
if (!NewNameMap.isEmpty()) mpUI->AssetNameMapLineEdit->setText(NewNameMap); if (!NewNameMap.isEmpty())
mpUI->AssetNameMapLineEdit->setText(NewNameMap);
} }
void CExportGameDialog::BrowseGameEditorInfo() void CExportGameDialog::BrowseGameEditorInfo()
{ {
QString Filter = "*." + TO_QSTRING(CGameInfo::GetExtension()); const QString Filter = "*." + TO_QSTRING(CGameInfo::GetExtension());
QString NewGameInfo = UICommon::OpenFileDialog(this, "Choose Game Editor Info", Filter); const QString NewGameInfo = UICommon::OpenFileDialog(this, tr("Choose Game Editor Info"), Filter);
if (!NewGameInfo.isEmpty()) mpUI->GameEditorInfoLineEdit->setText(NewGameInfo); if (!NewGameInfo.isEmpty())
mpUI->GameEditorInfoLineEdit->setText(NewGameInfo);
} }
void CExportGameDialog::Export() void CExportGameDialog::Export()
{ {
QString ExportDir = mpUI->OutputDirectoryLineEdit->text(); const QString ExportDir = mpUI->OutputDirectoryLineEdit->text();
QString NameMapPath = mpUI->AssetNameMapLineEdit->text(); const QString NameMapPath = mpUI->AssetNameMapLineEdit->text();
QString GameInfoPath = mpUI->GameEditorInfoLineEdit->text(); const QString GameInfoPath = mpUI->GameEditorInfoLineEdit->text();
// Validate export dir // Validate export dir
if (ExportDir.isEmpty()) if (ExportDir.isEmpty())
{ {
UICommon::ErrorMsg(this, "Please specify an empty output directory!"); UICommon::ErrorMsg(this, tr("Please specify an empty output directory!"));
return; return;
} }
else if (!FileUtil::IsEmpty( TO_TSTRING(ExportDir) )) if (!FileUtil::IsEmpty(TO_TSTRING(ExportDir)))
{ {
UICommon::ErrorMsg(this, "The output directory is not empty!"); UICommon::ErrorMsg(this, tr("The output directory is not empty!"));
return; return;
} }
// Verify name map is valid // Verify name map is valid
if (!NameMapPath.isEmpty() && !FileUtil::Exists(TO_TSTRING(NameMapPath))) if (!NameMapPath.isEmpty() && !FileUtil::Exists(TO_TSTRING(NameMapPath)))
{ {
UICommon::ErrorMsg(this, "The Asset Name Map path is invalid!"); UICommon::ErrorMsg(this, tr("The Asset Name Map path is invalid!"));
return; return;
} }
@ -402,17 +406,17 @@ void CExportGameDialog::Export()
if (!NameMapPath.isEmpty()) if (!NameMapPath.isEmpty())
{ {
bool LoadSuccess = NameMap.LoadAssetNames( TO_TSTRING(NameMapPath) ); const bool LoadSuccess = NameMap.LoadAssetNames( TO_TSTRING(NameMapPath) );
if (!LoadSuccess) if (!LoadSuccess)
{ {
UICommon::ErrorMsg(this, "Failed to load the asset name map!"); UICommon::ErrorMsg(this, tr("Failed to load the asset name map!"));
return; return;
} }
else if (!NameMap.IsValid()) if (!NameMap.IsValid())
{ {
UICommon::ErrorMsg(this, "The Asset Name Map is invalid and cannot be used! See the log for more information."); UICommon::ErrorMsg(this, tr("The Asset Name Map is invalid and cannot be used! See the log for more information."));
return; return;
} }
} }
@ -420,18 +424,18 @@ void CExportGameDialog::Export()
// Verify game info is valid // Verify game info is valid
if (!GameInfoPath.isEmpty() && !FileUtil::Exists(TO_TSTRING(GameInfoPath))) if (!GameInfoPath.isEmpty() && !FileUtil::Exists(TO_TSTRING(GameInfoPath)))
{ {
UICommon::ErrorMsg(this, "The Game Editor Info path is invalid!"); UICommon::ErrorMsg(this, tr("The Game Editor Info path is invalid!"));
return; return;
} }
CGameInfo GameInfo; CGameInfo GameInfo;
if (!GameInfoPath.isEmpty()) if (!GameInfoPath.isEmpty())
{ {
bool LoadSuccess = GameInfo.LoadGameInfo( TO_TSTRING(GameInfoPath) ); const bool LoadSuccess = GameInfo.LoadGameInfo(TO_TSTRING(GameInfoPath));
if (!LoadSuccess) if (!LoadSuccess)
{ {
UICommon::ErrorMsg(this, "Failed to load game info!"); UICommon::ErrorMsg(this, tr("Failed to load game info!"));
return; return;
} }
} }
@ -442,14 +446,14 @@ void CExportGameDialog::Export()
TString StrExportDir = TO_TSTRING(ExportDir); TString StrExportDir = TO_TSTRING(ExportDir);
StrExportDir.EnsureEndsWith('/'); StrExportDir.EnsureEndsWith('/');
CProgressDialog Dialog("Creating new game project", false, true, parentWidget()); CProgressDialog Dialog(tr("Creating new game project"), false, true, parentWidget());
QFuture<bool> Future = QtConcurrent::run(mpExporter.get(), &CGameExporter::Export, mpDisc.get(), StrExportDir, &NameMap, &GameInfo, &Dialog); QFuture<bool> Future = QtConcurrent::run(mpExporter.get(), &CGameExporter::Export, mpDisc.get(), StrExportDir, &NameMap, &GameInfo, &Dialog);
mExportSuccess = Dialog.WaitForResults(Future); mExportSuccess = Dialog.WaitForResults(Future);
if (!mExportSuccess) if (!mExportSuccess)
{ {
if (!Dialog.ShouldCancel()) if (!Dialog.ShouldCancel())
UICommon::ErrorMsg(this, "Export failed!"); UICommon::ErrorMsg(this, tr("Export failed!"));
} }
else else
{ {