GH-1314 add UI for custom minecraft jar addition
Also changes the text of the jar mod addition button. It should be clearer what it does and hopefully will not confuse as many people.
This commit is contained in:
@ -56,8 +56,7 @@ void GuiUtil::setClipboardText(const QString &text)
|
||||
QApplication::clipboard()->setText(text);
|
||||
}
|
||||
|
||||
|
||||
QStringList GuiUtil::BrowseForFiles(QString context, QString caption, QString filter, QString defaultPath, QWidget *parentWidget)
|
||||
static QStringList BrowseForFileInternal(QString context, QString caption, QString filter, QString defaultPath, QWidget *parentWidget, bool single)
|
||||
{
|
||||
static QMap<QString, QString> savedPaths;
|
||||
|
||||
@ -82,7 +81,7 @@ QStringList GuiUtil::BrowseForFiles(QString context, QString caption, QString fi
|
||||
}
|
||||
urls.append(QUrl::fromLocalFile(defaultPath));
|
||||
|
||||
w.setFileMode(QFileDialog::ExistingFiles);
|
||||
w.setFileMode(single ? QFileDialog::ExistingFile : QFileDialog::ExistingFiles);
|
||||
w.setAcceptMode(QFileDialog::AcceptOpen);
|
||||
w.setNameFilter(filter);
|
||||
|
||||
@ -114,3 +113,19 @@ QStringList GuiUtil::BrowseForFiles(QString context, QString caption, QString fi
|
||||
savedPaths[context] = w.directory().absolutePath();
|
||||
return {};
|
||||
}
|
||||
|
||||
QString GuiUtil::BrowseForFile(QString context, QString caption, QString filter, QString defaultPath, QWidget *parentWidget)
|
||||
{
|
||||
auto resultList = BrowseForFileInternal(context, caption, filter, defaultPath, parentWidget, true);
|
||||
if(resultList.size())
|
||||
{
|
||||
return resultList[0];
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
QStringList GuiUtil::BrowseForFiles(QString context, QString caption, QString filter, QString defaultPath, QWidget *parentWidget)
|
||||
{
|
||||
return BrowseForFileInternal(context, caption, filter, defaultPath, parentWidget, false);
|
||||
}
|
||||
|
@ -7,4 +7,5 @@ namespace GuiUtil
|
||||
QString uploadPaste(const QString &text, QWidget *parentWidget);
|
||||
void setClipboardText(const QString &text);
|
||||
QStringList BrowseForFiles(QString context, QString caption, QString filter, QString defaultPath, QWidget *parentWidget);
|
||||
QString BrowseForFile(QString context, QString caption, QString filter, QString defaultPath, QWidget *parentWidget);
|
||||
}
|
||||
|
@ -501,9 +501,6 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
|
||||
|
||||
m_settings->registerSetting("UpdateDialogGeometry", "");
|
||||
|
||||
// Jar mod nag dialog in version page
|
||||
m_settings->registerSetting("JarModNagSeen", false);
|
||||
|
||||
// paste.ee API key
|
||||
m_settings->registerSetting("PasteEEAPIKey", "multimc");
|
||||
|
||||
|
@ -250,34 +250,20 @@ void VersionPage::on_modBtn_clicked()
|
||||
|
||||
void VersionPage::on_jarmodBtn_clicked()
|
||||
{
|
||||
bool nagShown = false;
|
||||
if (!m_profile->hasTrait("legacyLaunch") && !m_profile->hasTrait("alphaLaunch"))
|
||||
{
|
||||
// not legacy launch... nag
|
||||
auto seenNag = MMC->settings()->get("JarModNagSeen").toBool();
|
||||
if(!seenNag)
|
||||
{
|
||||
auto result = QMessageBox::question(this,
|
||||
tr("Are you sure?"),
|
||||
tr("This will add mods directly to the Minecraft jar.\n"
|
||||
"Unless you KNOW that this is what NEEDS to be done, you should just use the mods folder (Loader mods).\n"
|
||||
"\n"
|
||||
"Do you want to continue?"),
|
||||
tr("I understand, continue."), tr("Cancel"), QString(), 1, 1
|
||||
);
|
||||
if(result != 0)
|
||||
return;
|
||||
nagShown = true;
|
||||
}
|
||||
}
|
||||
auto list = GuiUtil::BrowseForFiles("jarmod", tr("Select jar mods"), tr("Minecraft.jar mods (*.zip *.jar)"), MMC->settings()->get("CentralModsDir").toString(), this->parentWidget());
|
||||
if(!list.empty())
|
||||
{
|
||||
m_profile->installJarMods(list);
|
||||
if(nagShown)
|
||||
{
|
||||
MMC->settings()->set("JarModNagSeen", QVariant(true));
|
||||
}
|
||||
}
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
void VersionPage::on_jarBtn_clicked()
|
||||
{
|
||||
auto jarPath = GuiUtil::BrowseForFile("jar", tr("Select jar"), tr("Minecraft.jar replacement (*.jar)"), MMC->settings()->get("CentralModsDir").toString(), this->parentWidget());
|
||||
if(!jarPath.isEmpty())
|
||||
{
|
||||
m_profile->installCustomJar(jarPath);
|
||||
}
|
||||
updateButtons();
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ private slots:
|
||||
void on_moveUpBtn_clicked();
|
||||
void on_moveDownBtn_clicked();
|
||||
void on_jarmodBtn_clicked();
|
||||
void on_jarBtn_clicked();
|
||||
void on_revertBtn_clicked();
|
||||
void on_editBtn_clicked();
|
||||
void on_modBtn_clicked();
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>693</width>
|
||||
<height>750</height>
|
||||
<height>788</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
@ -206,7 +206,14 @@
|
||||
<string>Add a mod into the Minecraft jar file.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add jar mod</string>
|
||||
<string>Add to Minecraft.jar</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="jarBtn">
|
||||
<property name="text">
|
||||
<string>Replace Minecraft.jar</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -281,7 +288,6 @@
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
<tabstop>packageView</tabstop>
|
||||
<tabstop>changeVersionBtn</tabstop>
|
||||
<tabstop>moveUpBtn</tabstop>
|
||||
|
Reference in New Issue
Block a user