mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2025-03-25 01:43:36 +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());
|
||||
|
||||
for (const QString &filePath: filesToResolve) {
|
||||
|
@ -21,6 +21,7 @@ struct ModrinthExportSettings {
|
||||
bool includeModConfigs;
|
||||
bool includeResourcePacks;
|
||||
bool includeShaderPacks;
|
||||
QString datapacksPath;
|
||||
|
||||
QString gameVersion;
|
||||
QString forgeVersion;
|
||||
|
@ -32,7 +32,11 @@ void ModrinthExportDialog::updateDialogState()
|
||||
ui->buttonBox->button(QDialogButtonBox::StandardButton::Ok)->setEnabled(
|
||||
!ui->name->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));
|
||||
dialog.setDefaultSuffix("mrpack");
|
||||
dialog.setNameFilter("Modrinth modpacks (*.mrpack)");
|
||||
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||
dialog.setFileMode(QFileDialog::AnyFile);
|
||||
dialog.selectFile(ui->name->text() + ".mrpack");
|
||||
@ -51,6 +56,19 @@ void ModrinthExportDialog::on_fileBrowseButton_clicked()
|
||||
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()
|
||||
{
|
||||
ModrinthExportSettings settings;
|
||||
@ -64,6 +82,10 @@ void ModrinthExportDialog::accept()
|
||||
settings.includeResourcePacks = ui->includeResourcePacks->isChecked();
|
||||
settings.includeShaderPacks = ui->includeShaderPacks->isChecked();
|
||||
|
||||
if (ui->includeDatapacks->isChecked()) {
|
||||
settings.datapacksPath = ui->datapacksPath->text();
|
||||
}
|
||||
|
||||
MinecraftInstancePtr minecraftInstance = std::dynamic_pointer_cast<MinecraftInstance>(m_instance);
|
||||
minecraftInstance->getPackProfile()->reload(Net::Mode::Offline);
|
||||
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
|
||||
private slots:
|
||||
void on_fileBrowseButton_clicked();
|
||||
void on_datapackPathBrowse_clicked();
|
||||
void accept() override;
|
||||
void updateDialogState();
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>679</width>
|
||||
<width>835</width>
|
||||
<height>559</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -24,7 +24,7 @@
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>661</width>
|
||||
<width>821</width>
|
||||
<height>541</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -58,7 +58,7 @@
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>641</width>
|
||||
<width>801</width>
|
||||
<height>151</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -111,7 +111,7 @@
|
||||
<rect>
|
||||
<x>9</x>
|
||||
<y>29</y>
|
||||
<width>641</width>
|
||||
<width>801</width>
|
||||
<height>221</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -174,6 +174,30 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -270,6 +294,38 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</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>
|
||||
<slots>
|
||||
<slot>updateDialogState()</slot>
|
||||
|
Loading…
x
Reference in New Issue
Block a user