mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Install from file; add translation strings; fix button size
This commit is contained in:
parent
6901825b62
commit
19f606e84b
@ -379,7 +379,7 @@ void FirstLaunchView::copyHeroesData(const QString & path, bool move)
|
||||
|
||||
if(dirData.empty())
|
||||
{
|
||||
QMessageBox::critical(this, "Heroes III data not found!", "Failed to detect valid Heroes III data in chosen directory.\nPlease select directory with installed Heroes III data.");
|
||||
QMessageBox::critical(this, tr("Heroes III data not found!"), tr("Failed to detect valid Heroes III data in chosen directory.\nPlease select directory with installed Heroes III data."));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -393,19 +393,19 @@ void FirstLaunchView::copyHeroesData(const QString & path, bool move)
|
||||
if (roeFiles.empty())
|
||||
{
|
||||
// Directory structure is correct (Data/Maps/Mp3) but no .lod archives that should be present in any install
|
||||
QMessageBox::critical(this, "Heroes III data not found!", "Failed to detect valid Heroes III data in chosen directory.\nPlease select directory with installed Heroes III data.");
|
||||
QMessageBox::critical(this, tr("Heroes III data not found!"), tr("Failed to detect valid Heroes III data in chosen directory.\nPlease select directory with installed Heroes III data."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hdFiles.empty())
|
||||
{
|
||||
// HD Edition contains only RoE data so we can't use even unmodified files from it
|
||||
QMessageBox::critical(this, "Heroes III data not found!", "Heroes III: HD Edition files are not supported by VCMI.\nPlease select directory with Heroes III: Complete Edition or Heroes III: Shadow of Death.");
|
||||
QMessageBox::critical(this, tr("Heroes III data not found!"), tr("Heroes III: HD Edition files are not supported by VCMI.\nPlease select directory with Heroes III: Complete Edition or Heroes III: Shadow of Death."));
|
||||
return;
|
||||
}
|
||||
|
||||
// RoE or some other unsupported edition. Demo version?
|
||||
QMessageBox::critical(this, "Heroes III data not found!", "Unknown or unsupported Heroes III version found.\nPlease select directory with Heroes III: Complete Edition or Heroes III: Shadow of Death.");
|
||||
QMessageBox::critical(this, tr("Heroes III data not found!"), tr("Unknown or unsupported Heroes III version found.\nPlease select directory with Heroes III: Complete Edition or Heroes III: Shadow of Death."));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -617,6 +617,29 @@ void CModListView::on_installButton_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void CModListView::on_installFromFileButton_clicked()
|
||||
{
|
||||
QString filter = tr("Maps") + " (*.h3m *.vmap);;" + tr("Campaigns") + " (*.h3c *.vcmp);;" + tr("Mods") + " (*.zip)";
|
||||
QStringList files = QFileDialog::getOpenFileNames(this, tr("Select files (mods, maps, campaigns) to install..."), QDir::homePath(), filter);
|
||||
|
||||
for (const auto & file : files)
|
||||
{
|
||||
QUrl url = QUrl::fromLocalFile(file);
|
||||
QString fileUrl = url.toString();
|
||||
QString fileName = url.fileName();
|
||||
|
||||
if(fileUrl.endsWith(".zip", Qt::CaseInsensitive))
|
||||
downloadFile(fileName.toLower()
|
||||
// mod name currently comes from zip file -> remove suffixes from github zip download
|
||||
.replace(QRegularExpression("-[0-9a-f]{40}"), "")
|
||||
.replace(QRegularExpression("-vcmi-.+\\.zip"), ".zip")
|
||||
.replace("-main.zip", ".zip")
|
||||
, fileUrl, "mods", 0);
|
||||
else
|
||||
downloadFile(fileName, fileUrl, "mods", 0);
|
||||
}
|
||||
}
|
||||
|
||||
void CModListView::downloadFile(QString file, QString url, QString description, qint64 size)
|
||||
{
|
||||
if(!dlManager)
|
||||
|
@ -120,6 +120,8 @@ private slots:
|
||||
|
||||
void on_installButton_clicked();
|
||||
|
||||
void on_installFromFileButton_clicked();
|
||||
|
||||
void on_pushButton_clicked();
|
||||
|
||||
void on_refreshButton_clicked();
|
||||
|
@ -349,6 +349,41 @@ hr { height: 1px; border-width: 0; }
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="installFromFileButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>51</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Install from file</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>icons:mod-download.png</normaloff>icons:mod-download.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="modButtonSpacer">
|
||||
<property name="orientation">
|
||||
@ -521,7 +556,7 @@ hr { height: 1px; border-width: 0; }
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<width>120</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
|
@ -274,15 +274,15 @@ bool CModManager::doInstallMod(QString modname, QString archivePath)
|
||||
const auto destDir = CLauncherDirs::modsPath() + QChar{'/'};
|
||||
|
||||
if(!QFile(archivePath).exists())
|
||||
return addError(modname, "Mod archive is missing");
|
||||
return addError(modname, tr("Mod archive is missing"));
|
||||
|
||||
if(localMods.contains(modname))
|
||||
return addError(modname, "Mod with such name is already installed");
|
||||
return addError(modname, tr("Mod with such name is already installed"));
|
||||
|
||||
std::vector<std::string> filesToExtract;
|
||||
QString modDirName = ::detectModArchive(archivePath, modname, filesToExtract);
|
||||
if(!modDirName.size())
|
||||
return addError(modname, "Mod archive is invalid or corrupted");
|
||||
return addError(modname, tr("Mod archive is invalid or corrupted"));
|
||||
|
||||
std::atomic<int> filesCounter = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user