mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-07-06 21:25:59 +00:00
CResourceBrowser: Mark strings as translatable where applicable
This commit is contained in:
parent
071bdf4d2f
commit
11690ab6b5
@ -33,10 +33,10 @@ CResourceBrowser::CResourceBrowser(QWidget *pParent)
|
|||||||
mpUI->SortComboBox->hide();
|
mpUI->SortComboBox->hide();
|
||||||
|
|
||||||
// Create undo/redo actions
|
// Create undo/redo actions
|
||||||
mpUndoAction = new QAction("Undo", this);
|
mpUndoAction = new QAction(tr("Undo"), this);
|
||||||
mpRedoAction = new QAction("Redo", this);
|
mpRedoAction = new QAction(tr("Redo"), this);
|
||||||
mpUndoAction->setShortcut( QKeySequence::Undo );
|
mpUndoAction->setShortcut(QKeySequence::Undo);
|
||||||
mpRedoAction->setShortcut( QKeySequence::Redo );
|
mpRedoAction->setShortcut(QKeySequence::Redo);
|
||||||
|
|
||||||
// todo - undo/redo commands are deactivated because they conflict with the World Editor undo/redo commands. fix this
|
// todo - undo/redo commands are deactivated because they conflict with the World Editor undo/redo commands. fix this
|
||||||
#if 0
|
#if 0
|
||||||
@ -103,29 +103,29 @@ CResourceBrowser::CResourceBrowser(QWidget *pParent)
|
|||||||
|
|
||||||
// Set up the options menu
|
// Set up the options menu
|
||||||
QMenu *pOptionsMenu = new QMenu(this);
|
QMenu *pOptionsMenu = new QMenu(this);
|
||||||
QMenu *pImportMenu = pOptionsMenu->addMenu("Import Names");
|
QMenu *pImportMenu = pOptionsMenu->addMenu(tr("Import Names"));
|
||||||
pOptionsMenu->addAction("Export Names", this, SLOT(ExportAssetNames()));
|
pOptionsMenu->addAction(tr("Export Names"), this, SLOT(ExportAssetNames()));
|
||||||
pOptionsMenu->addSeparator();
|
pOptionsMenu->addSeparator();
|
||||||
|
|
||||||
pImportMenu->addAction("Asset Name Map", this, SLOT(ImportAssetNameMap()));
|
pImportMenu->addAction(tr("Asset Name Map"), this, SLOT(ImportAssetNameMap()));
|
||||||
pImportMenu->addAction("Package Contents List", this, SLOT(ImportPackageContentsList()));
|
pImportMenu->addAction(tr("Package Contents List"), this, SLOT(ImportPackageContentsList()));
|
||||||
pImportMenu->addAction("Generate Asset Names", this, SLOT(GenerateAssetNames()));
|
pImportMenu->addAction(tr("Generate Asset Names"), this, SLOT(GenerateAssetNames()));
|
||||||
|
|
||||||
QAction *pDisplayAssetIDsAction = new QAction("Display Asset IDs", this);
|
QAction *pDisplayAssetIDsAction = new QAction(tr("Display Asset IDs"), this);
|
||||||
pDisplayAssetIDsAction->setCheckable(true);
|
pDisplayAssetIDsAction->setCheckable(true);
|
||||||
connect(pDisplayAssetIDsAction, SIGNAL(toggled(bool)), this, SLOT(SetAssetIDDisplayEnabled(bool)));
|
connect(pDisplayAssetIDsAction, SIGNAL(toggled(bool)), this, SLOT(SetAssetIDDisplayEnabled(bool)));
|
||||||
pOptionsMenu->addAction(pDisplayAssetIDsAction);
|
pOptionsMenu->addAction(pDisplayAssetIDsAction);
|
||||||
|
|
||||||
pOptionsMenu->addAction("Find Asset by ID", this, SLOT(FindAssetByID()));
|
pOptionsMenu->addAction(tr("Find Asset by ID"), this, SLOT(FindAssetByID()));
|
||||||
pOptionsMenu->addAction("Rebuild Database", this, SLOT(RebuildResourceDB()));
|
pOptionsMenu->addAction(tr("Rebuild Database"), this, SLOT(RebuildResourceDB()));
|
||||||
mpUI->OptionsToolButton->setMenu(pOptionsMenu);
|
mpUI->OptionsToolButton->setMenu(pOptionsMenu);
|
||||||
|
|
||||||
#if !PUBLIC_RELEASE
|
#if !PUBLIC_RELEASE
|
||||||
// Only add the store menu in debug builds. We don't want end users editing the editor store.
|
// Only add the store menu in debug builds. We don't want end users editing the editor store.
|
||||||
pOptionsMenu->addSeparator();
|
pOptionsMenu->addSeparator();
|
||||||
QMenu *pStoreMenu = pOptionsMenu->addMenu("Set Store");
|
QMenu *pStoreMenu = pOptionsMenu->addMenu(tr("Set Store"));
|
||||||
QAction *pProjStoreAction = pStoreMenu->addAction("Project Store", this, SLOT(SetProjectStore()));
|
QAction *pProjStoreAction = pStoreMenu->addAction(tr("Project Store"), this, SLOT(SetProjectStore()));
|
||||||
QAction *pEdStoreAction = pStoreMenu->addAction("Editor Store", this, SLOT(SetEditorStore()));
|
QAction *pEdStoreAction = pStoreMenu->addAction(tr("Editor Store"), this, SLOT(SetEditorStore()));
|
||||||
|
|
||||||
pProjStoreAction->setCheckable(true);
|
pProjStoreAction->setCheckable(true);
|
||||||
pProjStoreAction->setChecked(true);
|
pProjStoreAction->setChecked(true);
|
||||||
@ -287,10 +287,10 @@ void CResourceBrowser::CreateAddMenu()
|
|||||||
if (mpStore)
|
if (mpStore)
|
||||||
{
|
{
|
||||||
mpAddMenu = new QMenu(this);
|
mpAddMenu = new QMenu(this);
|
||||||
mpAddMenu->addAction("New Folder", this, SLOT(CreateDirectory()));
|
mpAddMenu->addAction(tr("New Folder"), this, SLOT(CreateDirectory()));
|
||||||
mpAddMenu->addSeparator();
|
mpAddMenu->addSeparator();
|
||||||
|
|
||||||
QMenu* pCreateMenu = new QMenu("Create...", mpAddMenu);
|
QMenu* pCreateMenu = new QMenu(tr("Create..."), mpAddMenu);
|
||||||
mpAddMenu->addMenu(pCreateMenu);
|
mpAddMenu->addMenu(pCreateMenu);
|
||||||
AddCreateAssetMenuActions(pCreateMenu);
|
AddCreateAssetMenuActions(pCreateMenu);
|
||||||
|
|
||||||
@ -328,21 +328,21 @@ bool CResourceBrowser::RenameResource(CResourceEntry *pEntry, const TString& rkN
|
|||||||
{
|
{
|
||||||
if (pEntry->Directory()->FindChildResource(rkNewName, pEntry->ResourceType()) != nullptr)
|
if (pEntry->Directory()->FindChildResource(rkNewName, pEntry->ResourceType()) != nullptr)
|
||||||
{
|
{
|
||||||
UICommon::ErrorMsg(this, "Failed to rename; the destination directory has conflicting files!");
|
UICommon::ErrorMsg(this, tr("Failed to rename; the destination directory has conflicting files!"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UICommon::ErrorMsg(this, "Failed to rename; filename is invalid!");
|
UICommon::ErrorMsg(this, tr("Failed to rename; filename is invalid!"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Everything seems to be valid; proceed with the rename
|
// Everything seems to be valid; proceed with the rename
|
||||||
mUndoStack.beginMacro("Rename Resource");
|
mUndoStack.beginMacro(tr("Rename Resource"));
|
||||||
mUndoStack.push( new CSaveStoreCommand(mpStore) );
|
mUndoStack.push(new CSaveStoreCommand(mpStore));
|
||||||
mUndoStack.push( new CRenameResourceCommand(pEntry, rkNewName) );
|
mUndoStack.push(new CRenameResourceCommand(pEntry, rkNewName));
|
||||||
mUndoStack.push( new CSaveStoreCommand(mpStore) );
|
mUndoStack.push(new CSaveStoreCommand(mpStore));
|
||||||
mUndoStack.endMacro();
|
mUndoStack.endMacro();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -354,22 +354,22 @@ bool CResourceBrowser::RenameDirectory(CVirtualDirectory *pDir, const TString& r
|
|||||||
|
|
||||||
if (!CVirtualDirectory::IsValidDirectoryName(rkNewName))
|
if (!CVirtualDirectory::IsValidDirectoryName(rkNewName))
|
||||||
{
|
{
|
||||||
UICommon::ErrorMsg(this, "Failed to rename; directory name is invalid!");
|
UICommon::ErrorMsg(this, tr("Failed to rename; directory name is invalid!"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for conflicts
|
// Check for conflicts
|
||||||
if (pDir->Parent()->FindChildDirectory(rkNewName, false) != nullptr)
|
if (pDir->Parent()->FindChildDirectory(rkNewName, false) != nullptr)
|
||||||
{
|
{
|
||||||
UICommon::ErrorMsg(this, "Failed to rename; the destination directory has a conflicting directory!");
|
UICommon::ErrorMsg(this, tr("Failed to rename; the destination directory has a conflicting directory!"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No conflicts, proceed with the rename
|
// No conflicts, proceed with the rename
|
||||||
mUndoStack.beginMacro("Rename Directory");
|
mUndoStack.beginMacro(tr("Rename Directory"));
|
||||||
mUndoStack.push( new CSaveStoreCommand(mpStore) );
|
mUndoStack.push(new CSaveStoreCommand(mpStore));
|
||||||
mUndoStack.push( new CRenameDirectoryCommand(pDir, rkNewName) );
|
mUndoStack.push(new CRenameDirectoryCommand(pDir, rkNewName));
|
||||||
mUndoStack.push( new CSaveStoreCommand(mpStore) );
|
mUndoStack.push(new CSaveStoreCommand(mpStore));
|
||||||
mUndoStack.endMacro();
|
mUndoStack.endMacro();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -412,16 +412,16 @@ bool CResourceBrowser::MoveResources(const QList<CResourceEntry*>& rkResources,
|
|||||||
// If there were conflicts, notify the user of them
|
// If there were conflicts, notify the user of them
|
||||||
if (!ConflictingResources.isEmpty() || !ConflictingDirs.isEmpty())
|
if (!ConflictingResources.isEmpty() || !ConflictingDirs.isEmpty())
|
||||||
{
|
{
|
||||||
QString ErrorMsg = "Failed to move; the destination directory has conflicting files.\n\n";
|
QString ErrorMsg = tr("Failed to move; the destination directory has conflicting files.\n\n");
|
||||||
|
|
||||||
foreach (CVirtualDirectory *pDir, ConflictingDirs)
|
foreach (CVirtualDirectory *pDir, ConflictingDirs)
|
||||||
{
|
{
|
||||||
ErrorMsg += QString("* %1").arg( TO_QSTRING(pDir->Name()) );
|
ErrorMsg += tr("* %1").arg(TO_QSTRING(pDir->Name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (CResourceEntry *pEntry, ConflictingResources)
|
foreach (CResourceEntry *pEntry, ConflictingResources)
|
||||||
{
|
{
|
||||||
ErrorMsg += QString("* %1.%2\n").arg( TO_QSTRING(pEntry->Name()) ).arg( TO_QSTRING(pEntry->CookedExtension().ToString()) );
|
ErrorMsg += tr("* %1.%2\n").arg(TO_QSTRING(pEntry->Name())).arg(TO_QSTRING(pEntry->CookedExtension().ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
UICommon::ErrorMsg(this, ErrorMsg);
|
UICommon::ErrorMsg(this, ErrorMsg);
|
||||||
@ -431,16 +431,16 @@ bool CResourceBrowser::MoveResources(const QList<CResourceEntry*>& rkResources,
|
|||||||
// Create undo actions to actually perform the moves
|
// Create undo actions to actually perform the moves
|
||||||
if (!ValidResources.isEmpty() || !ValidDirs.isEmpty())
|
if (!ValidResources.isEmpty() || !ValidDirs.isEmpty())
|
||||||
{
|
{
|
||||||
mUndoStack.beginMacro("Move Resources");
|
mUndoStack.beginMacro(tr("Move Resources"));
|
||||||
mUndoStack.push( new CSaveStoreCommand(mpStore) );
|
mUndoStack.push(new CSaveStoreCommand(mpStore));
|
||||||
|
|
||||||
foreach (CVirtualDirectory *pDir, ValidDirs)
|
foreach (CVirtualDirectory* pDir, ValidDirs)
|
||||||
mUndoStack.push( new CMoveDirectoryCommand(mpStore, pDir, pNewDir) );
|
mUndoStack.push(new CMoveDirectoryCommand(mpStore, pDir, pNewDir));
|
||||||
|
|
||||||
foreach (CResourceEntry *pEntry, ValidResources)
|
foreach (CResourceEntry* pEntry, ValidResources)
|
||||||
mUndoStack.push( new CMoveResourceCommand(pEntry, pNewDir) );
|
mUndoStack.push(new CMoveResourceCommand(pEntry, pNewDir));
|
||||||
|
|
||||||
mUndoStack.push( new CSaveStoreCommand(mpStore) );
|
mUndoStack.push(new CSaveStoreCommand(mpStore));
|
||||||
mUndoStack.endMacro();
|
mUndoStack.endMacro();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,10 +486,10 @@ CResourceEntry* CResourceBrowser::CreateNewResource(EResourceType Type,
|
|||||||
CResourceEntry* pEntry = mpStore->CreateNewResource(ID, Type, pDir->FullPath(), Name);
|
CResourceEntry* pEntry = mpStore->CreateNewResource(ID, Type, pDir->FullPath(), Name);
|
||||||
|
|
||||||
// Push undo command
|
// Push undo command
|
||||||
mUndoStack.beginMacro("Create Resource");
|
mUndoStack.beginMacro(tr("Create Resource"));
|
||||||
mUndoStack.push( new CSaveStoreCommand(mpStore) );
|
mUndoStack.push(new CSaveStoreCommand(mpStore));
|
||||||
mUndoStack.push( new CCreateResourceCommand(pEntry) );
|
mUndoStack.push(new CCreateResourceCommand(pEntry));
|
||||||
mUndoStack.push( new CSaveStoreCommand(mpStore) );
|
mUndoStack.push(new CSaveStoreCommand(mpStore));
|
||||||
mUndoStack.endMacro();
|
mUndoStack.endMacro();
|
||||||
|
|
||||||
pEntry->Save();
|
pEntry->Save();
|
||||||
@ -541,24 +541,26 @@ void CResourceBrowser::UpdateDescriptionLabel()
|
|||||||
|
|
||||||
if (mpStore)
|
if (mpStore)
|
||||||
{
|
{
|
||||||
QString ModelDesc = mpModel->ModelDescription();
|
const QString ModelDesc = mpModel->ModelDescription();
|
||||||
|
|
||||||
if (mSearching)
|
if (mSearching)
|
||||||
{
|
{
|
||||||
QString SearchText = mpUI->SearchBar->text();
|
const QString SearchText = mpUI->SearchBar->text();
|
||||||
Desc = QString("Searching \"%1\" in: %2").arg(SearchText).arg(ModelDesc);
|
Desc = tr("Searching \"%1\" in: %2").arg(SearchText).arg(ModelDesc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Desc = QString("Displaying: %1").arg(ModelDesc);
|
{
|
||||||
|
Desc = tr("Displaying: %1").arg(ModelDesc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mpUI->TableDescriptionLabel->setText(Desc);
|
mpUI->TableDescriptionLabel->setText(Desc);
|
||||||
|
|
||||||
// Update clear button status
|
// Update clear button status
|
||||||
bool CanGoUp = (mpSelectedDir && !mpSelectedDir->IsRoot());
|
const bool CanGoUp = (mpSelectedDir && !mpSelectedDir->IsRoot());
|
||||||
bool CanClear = (!mpUI->SearchBar->text().isEmpty() || mpModel->IsDisplayingUserEntryList());
|
const bool CanClear = (!mpUI->SearchBar->text().isEmpty() || mpModel->IsDisplayingUserEntryList());
|
||||||
mpUI->ClearButton->setEnabled(CanGoUp || CanClear);
|
mpUI->ClearButton->setEnabled(CanGoUp || CanClear);
|
||||||
mpUI->ClearButton->setIcon( CanClear ? QIcon(":/icons/X_16px.svg") : QIcon(":/icons/ToParentFolder_16px.svg") );
|
mpUI->ClearButton->setIcon(CanClear ? QIcon(QStringLiteral(":/icons/X_16px.svg")) : QIcon(QStringLiteral(":/icons/ToParentFolder_16px.svg")));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CResourceBrowser::SetResourceTreeView()
|
void CResourceBrowser::SetResourceTreeView()
|
||||||
@ -635,11 +637,11 @@ bool CResourceBrowser::CreateDirectory()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Push create command to actually create the directory
|
// Push create command to actually create the directory
|
||||||
mUndoStack.beginMacro("Create Directory");
|
mUndoStack.beginMacro(tr("Create Directory"));
|
||||||
mUndoStack.push( new CSaveStoreCommand(mpStore) );
|
mUndoStack.push(new CSaveStoreCommand(mpStore));
|
||||||
CCreateDirectoryCommand *pCmd = new CCreateDirectoryCommand(mpStore, mpSelectedDir->FullPath(), DirName);
|
CCreateDirectoryCommand *pCmd = new CCreateDirectoryCommand(mpStore, mpSelectedDir->FullPath(), DirName);
|
||||||
mUndoStack.push(pCmd);
|
mUndoStack.push(pCmd);
|
||||||
mUndoStack.push( new CSaveStoreCommand(mpStore) );
|
mUndoStack.push(new CSaveStoreCommand(mpStore));
|
||||||
mUndoStack.endMacro();
|
mUndoStack.endMacro();
|
||||||
|
|
||||||
// Now fetch the new directory and start editing it so the user can enter a name
|
// Now fetch the new directory and start editing it so the user can enter a name
|
||||||
@ -673,7 +675,7 @@ bool CResourceBrowser::Delete(QVector<CResourceEntry*> Resources, QVector<CVirtu
|
|||||||
{
|
{
|
||||||
if (!Directories[DirIdx]->IsSafeToDelete())
|
if (!Directories[DirIdx]->IsSafeToDelete())
|
||||||
{
|
{
|
||||||
ErrorPaths += TO_QSTRING( Directories[DirIdx]->FullPath() ) + '\n';
|
ErrorPaths += TO_QSTRING(Directories[DirIdx]->FullPath()) + '\n';
|
||||||
Directories.removeAt(DirIdx);
|
Directories.removeAt(DirIdx);
|
||||||
DirIdx--;
|
DirIdx--;
|
||||||
}
|
}
|
||||||
@ -683,7 +685,7 @@ bool CResourceBrowser::Delete(QVector<CResourceEntry*> Resources, QVector<CVirtu
|
|||||||
{
|
{
|
||||||
if (Resources[ResIdx]->IsLoaded() && Resources[ResIdx]->Resource()->IsReferenced())
|
if (Resources[ResIdx]->IsLoaded() && Resources[ResIdx]->Resource()->IsReferenced())
|
||||||
{
|
{
|
||||||
ErrorPaths += TO_QSTRING( Resources[ResIdx]->CookedAssetPath(true) ) + '\n';
|
ErrorPaths += TO_QSTRING(Resources[ResIdx]->CookedAssetPath(true)) + '\n';
|
||||||
Resources.removeAt(ResIdx);
|
Resources.removeAt(ResIdx);
|
||||||
ResIdx--;
|
ResIdx--;
|
||||||
}
|
}
|
||||||
@ -693,8 +695,8 @@ bool CResourceBrowser::Delete(QVector<CResourceEntry*> Resources, QVector<CVirtu
|
|||||||
{
|
{
|
||||||
// Remove trailing newline
|
// Remove trailing newline
|
||||||
ErrorPaths.chop(1);
|
ErrorPaths.chop(1);
|
||||||
UICommon::ErrorMsg(this, QString("The following resources/directories are still referenced and cannot be deleted:\n\n%1")
|
UICommon::ErrorMsg(this, tr("The following resources/directories are still referenced and cannot be deleted:\n\n%1")
|
||||||
.arg(ErrorPaths));
|
.arg(ErrorPaths));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gather a complete list of resources in subdirectories
|
// Gather a complete list of resources in subdirectories
|
||||||
@ -716,48 +718,48 @@ bool CResourceBrowser::Delete(QVector<CResourceEntry*> Resources, QVector<CVirtu
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Allow the user to confirm before proceeding.
|
// Allow the user to confirm before proceeding.
|
||||||
QString ConfirmMsg = QString("Are you sure you want to permanently delete ");
|
QString ConfirmMsg = tr("Are you sure you want to permanently delete ");
|
||||||
|
|
||||||
if (Resources.size() > 0)
|
if (Resources.size() > 0)
|
||||||
{
|
{
|
||||||
ConfirmMsg += QString("%1 resource%2").arg(Resources.size()).arg(Resources.size() == 1 ? "" : "s");
|
ConfirmMsg += tr("%1 resource%2").arg(Resources.size()).arg(Resources.size() == 1 ? "" : "s");
|
||||||
|
|
||||||
if (Directories.size() > 0)
|
if (Directories.size() > 0)
|
||||||
{
|
{
|
||||||
ConfirmMsg += " and ";
|
ConfirmMsg += tr(" and ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Directories.size() > 0)
|
if (Directories.size() > 0)
|
||||||
{
|
{
|
||||||
ConfirmMsg += QString("%1 %2").arg(Directories.size()).arg(Directories.size() == 1 ? "directory" : "directories");
|
ConfirmMsg += tr("%1 %2").arg(Directories.size()).arg(Directories.size() == 1 ? tr("directory") : tr("directories"));
|
||||||
}
|
}
|
||||||
ConfirmMsg += "?";
|
ConfirmMsg += tr("?");
|
||||||
|
|
||||||
if (UICommon::YesNoQuestion(this, "Warning", ConfirmMsg))
|
if (UICommon::YesNoQuestion(this, tr("Warning"), ConfirmMsg))
|
||||||
{
|
{
|
||||||
// Note that the undo stack will undo actions in the reverse order they are pushed
|
// Note that the undo stack will undo actions in the reverse order they are pushed
|
||||||
// So we need to push commands last that we want to be undone first
|
// So we need to push commands last that we want to be undone first
|
||||||
// We want to delete subdirectories first, then parent directories, then resources
|
// We want to delete subdirectories first, then parent directories, then resources
|
||||||
mUndoStack.beginMacro("Delete");
|
mUndoStack.beginMacro(tr("Delete"));
|
||||||
mUndoStack.push( new CSaveStoreCommand(mpStore) );
|
mUndoStack.push(new CSaveStoreCommand(mpStore));
|
||||||
|
|
||||||
// Delete resources first.
|
// Delete resources first.
|
||||||
foreach (CResourceEntry* pEntry, Resources)
|
foreach (CResourceEntry* pEntry, Resources)
|
||||||
mUndoStack.push( new CDeleteResourceCommand(pEntry) );
|
mUndoStack.push(new CDeleteResourceCommand(pEntry));
|
||||||
|
|
||||||
// Now delete directories in reverse order (so subdirectories delete first)
|
// Now delete directories in reverse order (so subdirectories delete first)
|
||||||
for (int DirIdx = Directories.size()-1; DirIdx >= 0; DirIdx--)
|
for (int DirIdx = Directories.size()-1; DirIdx >= 0; DirIdx--)
|
||||||
{
|
{
|
||||||
CVirtualDirectory* pDir = Directories[DirIdx];
|
CVirtualDirectory* pDir = Directories[DirIdx];
|
||||||
mUndoStack.push( new CDeleteDirectoryCommand(mpStore, pDir->Parent()->FullPath(), pDir->Name()) );
|
mUndoStack.push(new CDeleteDirectoryCommand(mpStore, pDir->Parent()->FullPath(), pDir->Name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
mUndoStack.push( new CSaveStoreCommand(mpStore) );
|
mUndoStack.push(new CSaveStoreCommand(mpStore));
|
||||||
mUndoStack.endMacro();
|
mUndoStack.endMacro();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CResourceBrowser::OnSearchStringChanged(QString SearchString)
|
void CResourceBrowser::OnSearchStringChanged(QString SearchString)
|
||||||
@ -822,7 +824,7 @@ void CResourceBrowser::FindAssetByID()
|
|||||||
if (!mpStore)
|
if (!mpStore)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QString QStringAssetID = QInputDialog::getText(this, "Enter Asset ID", "Enter asset ID:");
|
const QString QStringAssetID = QInputDialog::getText(this, tr("Enter Asset ID"), tr("Enter asset ID:"));
|
||||||
TString StringAssetID = TO_TSTRING(QStringAssetID);
|
TString StringAssetID = TO_TSTRING(QStringAssetID);
|
||||||
StringAssetID.RemoveWhitespace();
|
StringAssetID.RemoveWhitespace();
|
||||||
|
|
||||||
@ -846,18 +848,20 @@ void CResourceBrowser::FindAssetByID()
|
|||||||
WasValid = true;
|
WasValid = true;
|
||||||
|
|
||||||
if (pEntry)
|
if (pEntry)
|
||||||
|
{
|
||||||
SelectResource(pEntry, true);
|
SelectResource(pEntry, true);
|
||||||
|
}
|
||||||
// User entered valid but unrecognized ID
|
else // User entered valid but unrecognized ID
|
||||||
else
|
{
|
||||||
UICommon::ErrorMsg(this, QString("Couldn't find any asset with ID %1").arg(QStringAssetID));
|
UICommon::ErrorMsg(this, tr("Couldn't find any asset with ID %1").arg(QStringAssetID));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// User entered invalid string
|
// User entered invalid string
|
||||||
if (!WasValid)
|
if (!WasValid)
|
||||||
{
|
{
|
||||||
UICommon::ErrorMsg(this, "The entered string is not a valid asset ID!");
|
UICommon::ErrorMsg(this, tr("The entered string is not a valid asset ID!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -912,8 +916,10 @@ void CResourceBrowser::SetEditorStore()
|
|||||||
|
|
||||||
void CResourceBrowser::ImportPackageContentsList()
|
void CResourceBrowser::ImportPackageContentsList()
|
||||||
{
|
{
|
||||||
QStringList PathList = UICommon::OpenFilesDialog(this, "Open package contents list", "*.pak.contents.txt");
|
const QStringList PathList = UICommon::OpenFilesDialog(this, tr("Open package contents list"), QStringLiteral("*.pak.contents.txt"));
|
||||||
if (PathList.isEmpty()) return;
|
if (PathList.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
SetActiveDirectory(nullptr);
|
SetActiveDirectory(nullptr);
|
||||||
|
|
||||||
foreach(const QString& rkPath, PathList)
|
foreach(const QString& rkPath, PathList)
|
||||||
@ -927,7 +933,7 @@ void CResourceBrowser::GenerateAssetNames()
|
|||||||
{
|
{
|
||||||
SetActiveDirectory(nullptr);
|
SetActiveDirectory(nullptr);
|
||||||
|
|
||||||
CProgressDialog Dialog("Generating asset names", true, true, this);
|
CProgressDialog Dialog(tr("Generating asset names"), true, true, this);
|
||||||
Dialog.DisallowCanceling();
|
Dialog.DisallowCanceling();
|
||||||
Dialog.SetOneShotTask("Generating asset names");
|
Dialog.SetOneShotTask("Generating asset names");
|
||||||
|
|
||||||
@ -940,22 +946,23 @@ void CResourceBrowser::GenerateAssetNames()
|
|||||||
RefreshResources();
|
RefreshResources();
|
||||||
RefreshDirectories();
|
RefreshDirectories();
|
||||||
|
|
||||||
UICommon::InfoMsg(this, "Complete", "Asset name generation complete!");
|
UICommon::InfoMsg(this, tr("Complete"), tr("Asset name generation complete!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CResourceBrowser::ImportAssetNameMap()
|
void CResourceBrowser::ImportAssetNameMap()
|
||||||
{
|
{
|
||||||
CAssetNameMap Map( mpStore->Game() );
|
CAssetNameMap Map(mpStore->Game());
|
||||||
bool LoadSuccess = Map.LoadAssetNames();
|
const bool LoadSuccess = Map.LoadAssetNames();
|
||||||
|
|
||||||
if (!LoadSuccess)
|
if (!LoadSuccess)
|
||||||
{
|
{
|
||||||
UICommon::ErrorMsg(this, "Import failed; couldn't load asset name map!");
|
UICommon::ErrorMsg(this, tr("Import failed; couldn't load asset name map!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (!Map.IsValid())
|
|
||||||
|
if (!Map.IsValid())
|
||||||
{
|
{
|
||||||
UICommon::ErrorMsg(this, "Import failed; the input asset name map is invalid! See the log for details.");
|
UICommon::ErrorMsg(this, tr("Import failed; the input asset name map is invalid! See the log for details."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -973,16 +980,17 @@ void CResourceBrowser::ImportAssetNameMap()
|
|||||||
mpStore->ConditionalSaveStore();
|
mpStore->ConditionalSaveStore();
|
||||||
RefreshResources();
|
RefreshResources();
|
||||||
RefreshDirectories();
|
RefreshDirectories();
|
||||||
UICommon::InfoMsg(this, "Success", "New asset names imported successfully!");
|
UICommon::InfoMsg(this, tr("Success"), tr("New asset names imported successfully!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CResourceBrowser::ExportAssetNames()
|
void CResourceBrowser::ExportAssetNames()
|
||||||
{
|
{
|
||||||
QString OutFile = UICommon::SaveFileDialog(this, "Export asset name map", "*.xml",
|
const QString OutFile = UICommon::SaveFileDialog(this, tr("Export asset name map"), QStringLiteral("*.xml"),
|
||||||
gResourcesWritable ? *(gDataDir + "resources/gameinfo/") : "");
|
gResourcesWritable ? *(gDataDir + "resources/gameinfo/") : "");
|
||||||
if (OutFile.isEmpty()) return;
|
if (OutFile.isEmpty())
|
||||||
TString OutFileStr = TO_TSTRING(OutFile);
|
return;
|
||||||
|
|
||||||
|
TString OutFileStr = TO_TSTRING(OutFile);
|
||||||
CAssetNameMap NameMap(mpStore->Game());
|
CAssetNameMap NameMap(mpStore->Game());
|
||||||
|
|
||||||
if (FileUtil::Exists(OutFileStr))
|
if (FileUtil::Exists(OutFileStr))
|
||||||
@ -991,7 +999,7 @@ void CResourceBrowser::ExportAssetNames()
|
|||||||
|
|
||||||
if (!LoadSuccess || !NameMap.IsValid())
|
if (!LoadSuccess || !NameMap.IsValid())
|
||||||
{
|
{
|
||||||
UICommon::ErrorMsg(this, "Unable to export; failed to load existing names from the original asset name map file! See the log for details.");
|
UICommon::ErrorMsg(this, tr("Unable to export; failed to load existing names from the original asset name map file! See the log for details."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1000,14 +1008,14 @@ void CResourceBrowser::ExportAssetNames()
|
|||||||
bool SaveSuccess = NameMap.SaveAssetNames(OutFileStr);
|
bool SaveSuccess = NameMap.SaveAssetNames(OutFileStr);
|
||||||
|
|
||||||
if (!SaveSuccess)
|
if (!SaveSuccess)
|
||||||
UICommon::ErrorMsg(this, "Failed to export asset names!");
|
UICommon::ErrorMsg(this, tr("Failed to export asset names!"));
|
||||||
else
|
else
|
||||||
UICommon::InfoMsg(this, "Success", "Asset names exported successfully!");
|
UICommon::InfoMsg(this, tr("Success"), tr("Asset names exported successfully!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CResourceBrowser::RebuildResourceDB()
|
void CResourceBrowser::RebuildResourceDB()
|
||||||
{
|
{
|
||||||
if (UICommon::YesNoQuestion(this, "Rebuild resource database", "Are you sure you want to rebuild the resource database? This will take a while."))
|
if (UICommon::YesNoQuestion(this, tr("Rebuild resource database"), tr("Are you sure you want to rebuild the resource database? This will take a while.")))
|
||||||
{
|
{
|
||||||
gpEdApp->RebuildResourceDatabase();
|
gpEdApp->RebuildResourceDatabase();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user