mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2025-04-09 18:45:44 +00:00
GH-4699 Add global datapacks support to Modrinth exporter
This commit is contained in:
parent
a6dff61ff7
commit
a1f256a745
@ -56,6 +56,19 @@ void ModrinthInstanceExportTask::executeTask()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!m_settings.datapacksPath.isEmpty()) {
|
||||||
|
QDir datapacksDir(m_instance->gameRoot() + "/" + m_settings.datapacksPath);
|
||||||
|
datapacksDir.setFilter(QDir::Files);
|
||||||
|
datapacksDir.setNameFilters(QStringList() << "*.zip");
|
||||||
|
|
||||||
|
if (datapacksDir.exists()) {
|
||||||
|
QDirIterator datapacksIterator(datapacksDir);
|
||||||
|
while (datapacksIterator.hasNext()) {
|
||||||
|
filesToResolve << datapacksIterator.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_netJob = new NetJob(tr("Modrinth pack export"), APPLICATION->network());
|
m_netJob = new NetJob(tr("Modrinth pack export"), APPLICATION->network());
|
||||||
|
|
||||||
for (const QString &filePath: filesToResolve) {
|
for (const QString &filePath: filesToResolve) {
|
||||||
|
@ -21,6 +21,7 @@ struct ModrinthExportSettings {
|
|||||||
bool includeModConfigs;
|
bool includeModConfigs;
|
||||||
bool includeResourcePacks;
|
bool includeResourcePacks;
|
||||||
bool includeShaderPacks;
|
bool includeShaderPacks;
|
||||||
|
QString datapacksPath;
|
||||||
|
|
||||||
QString gameVersion;
|
QString gameVersion;
|
||||||
QString forgeVersion;
|
QString forgeVersion;
|
||||||
|
@ -32,7 +32,11 @@ void ModrinthExportDialog::updateDialogState()
|
|||||||
ui->buttonBox->button(QDialogButtonBox::StandardButton::Ok)->setEnabled(
|
ui->buttonBox->button(QDialogButtonBox::StandardButton::Ok)->setEnabled(
|
||||||
!ui->name->text().isEmpty()
|
!ui->name->text().isEmpty()
|
||||||
&& !ui->version->text().isEmpty()
|
&& !ui->version->text().isEmpty()
|
||||||
&& !ui->file->text().isEmpty()
|
&& ui->file->text().endsWith(".mrpack")
|
||||||
|
&& (
|
||||||
|
!ui->includeDatapacks->isChecked()
|
||||||
|
|| (!ui->datapacksPath->text().isEmpty() && QDir(m_instance->gameRoot() + "/" + ui->datapacksPath->text()).exists())
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,6 +44,7 @@ void ModrinthExportDialog::on_fileBrowseButton_clicked()
|
|||||||
{
|
{
|
||||||
QFileDialog dialog(this, tr("Select modpack file"), QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
|
QFileDialog dialog(this, tr("Select modpack file"), QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
|
||||||
dialog.setDefaultSuffix("mrpack");
|
dialog.setDefaultSuffix("mrpack");
|
||||||
|
dialog.setNameFilter("Modrinth modpacks (*.mrpack)");
|
||||||
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||||
dialog.setFileMode(QFileDialog::AnyFile);
|
dialog.setFileMode(QFileDialog::AnyFile);
|
||||||
dialog.selectFile(ui->name->text() + ".mrpack");
|
dialog.selectFile(ui->name->text() + ".mrpack");
|
||||||
@ -51,6 +56,19 @@ void ModrinthExportDialog::on_fileBrowseButton_clicked()
|
|||||||
updateDialogState();
|
updateDialogState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModrinthExportDialog::on_datapackPathBrowse_clicked()
|
||||||
|
{
|
||||||
|
QFileDialog dialog(this, tr("Select global datapacks folder"), m_instance->gameRoot());
|
||||||
|
dialog.setAcceptMode(QFileDialog::AcceptOpen);
|
||||||
|
dialog.setFileMode(QFileDialog::DirectoryOnly);
|
||||||
|
|
||||||
|
if (dialog.exec()) {
|
||||||
|
ui->datapacksPath->setText(QDir(m_instance->gameRoot()).relativeFilePath(dialog.selectedFiles().at(0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
updateDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
void ModrinthExportDialog::accept()
|
void ModrinthExportDialog::accept()
|
||||||
{
|
{
|
||||||
ModrinthExportSettings settings;
|
ModrinthExportSettings settings;
|
||||||
@ -64,6 +82,10 @@ void ModrinthExportDialog::accept()
|
|||||||
settings.includeResourcePacks = ui->includeResourcePacks->isChecked();
|
settings.includeResourcePacks = ui->includeResourcePacks->isChecked();
|
||||||
settings.includeShaderPacks = ui->includeShaderPacks->isChecked();
|
settings.includeShaderPacks = ui->includeShaderPacks->isChecked();
|
||||||
|
|
||||||
|
if (ui->includeDatapacks->isChecked()) {
|
||||||
|
settings.datapacksPath = ui->datapacksPath->text();
|
||||||
|
}
|
||||||
|
|
||||||
MinecraftInstancePtr minecraftInstance = std::dynamic_pointer_cast<MinecraftInstance>(m_instance);
|
MinecraftInstancePtr minecraftInstance = std::dynamic_pointer_cast<MinecraftInstance>(m_instance);
|
||||||
minecraftInstance->getPackProfile()->reload(Net::Mode::Offline);
|
minecraftInstance->getPackProfile()->reload(Net::Mode::Offline);
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_fileBrowseButton_clicked();
|
void on_fileBrowseButton_clicked();
|
||||||
|
void on_datapackPathBrowse_clicked();
|
||||||
void accept() override;
|
void accept() override;
|
||||||
void updateDialogState();
|
void updateDialogState();
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>679</width>
|
<width>835</width>
|
||||||
<height>559</height>
|
<height>559</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -24,7 +24,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>10</y>
|
<y>10</y>
|
||||||
<width>661</width>
|
<width>821</width>
|
||||||
<height>541</height>
|
<height>541</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -58,7 +58,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>30</y>
|
<y>30</y>
|
||||||
<width>641</width>
|
<width>801</width>
|
||||||
<height>151</height>
|
<height>151</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -111,7 +111,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>9</x>
|
<x>9</x>
|
||||||
<y>29</y>
|
<y>29</y>
|
||||||
<width>641</width>
|
<width>801</width>
|
||||||
<height>221</height>
|
<height>221</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -174,6 +174,30 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="includeDatapacks">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Use this if your modpack contains a mod which adds global datapacks.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Include global datapacks folder:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="datapacksPath"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="datapackPathBrowse">
|
||||||
|
<property name="text">
|
||||||
|
<string>Browse...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
@ -270,6 +294,38 @@
|
|||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>datapacksPath</sender>
|
||||||
|
<signal>textChanged(QString)</signal>
|
||||||
|
<receiver>ModrinthExportDialog</receiver>
|
||||||
|
<slot>updateDialogState()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>532</x>
|
||||||
|
<y>472</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>417</x>
|
||||||
|
<y>279</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>includeDatapacks</sender>
|
||||||
|
<signal>stateChanged(int)</signal>
|
||||||
|
<receiver>ModrinthExportDialog</receiver>
|
||||||
|
<slot>updateDialogState()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>183</x>
|
||||||
|
<y>472</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>417</x>
|
||||||
|
<y>279</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
<slots>
|
<slots>
|
||||||
<slot>updateDialogState()</slot>
|
<slot>updateDialogState()</slot>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user