mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
Merge 34447863e2 into d2fa7cf7f7
This commit is contained in:
commit
8094b0ebec
5 changed files with 79 additions and 5 deletions
|
|
@ -81,6 +81,9 @@ BaseInstance::BaseInstance(SettingsObject* globalSettings, std::unique_ptr<Setti
|
|||
m_settings->registerSetting("iconKey", "default");
|
||||
m_settings->registerSetting("notes", "");
|
||||
|
||||
m_settings->registerSetting("exportTemplate", "");
|
||||
m_settings->registerSetting("exportSettings", 0);
|
||||
|
||||
m_settings->registerSetting("lastLaunchTime", 0);
|
||||
m_settings->registerSetting("totalTimePlayed", 0);
|
||||
if (m_settings->get("totalTimePlayed").toLongLong() < 0)
|
||||
|
|
@ -398,6 +401,30 @@ void BaseInstance::setName(QString val)
|
|||
emit propertiesChanged(this);
|
||||
}
|
||||
|
||||
void BaseInstance::setExportTemplate(QString val)
|
||||
{
|
||||
// FIXME: if no change, do not set. setting involves saving a file.
|
||||
m_settings->set("exportTemplate", val);
|
||||
emit propertiesChanged(this);
|
||||
}
|
||||
|
||||
QString BaseInstance::exportTemplate() const
|
||||
{
|
||||
return m_settings->get("exportTemplate").toString();
|
||||
}
|
||||
|
||||
void BaseInstance::setExportSettings(int val)
|
||||
{
|
||||
// FIXME: if no change, do not set. setting involves saving a file.
|
||||
m_settings->set("exportSettings", val);
|
||||
emit propertiesChanged(this);
|
||||
}
|
||||
|
||||
int BaseInstance::exportSettings() const
|
||||
{
|
||||
return m_settings->get("exportSettings").toInt();
|
||||
}
|
||||
|
||||
bool BaseInstance::syncInstanceDirName(const QString& newRoot) const
|
||||
{
|
||||
auto oldRoot = instanceRoot();
|
||||
|
|
|
|||
|
|
@ -155,6 +155,12 @@ class BaseInstance : public QObject {
|
|||
QString notes() const;
|
||||
void setNotes(QString val);
|
||||
|
||||
QString exportTemplate() const;
|
||||
void setExportTemplate(QString val);
|
||||
|
||||
int exportSettings() const;
|
||||
void setExportSettings(int val);
|
||||
|
||||
QString getPreLaunchCommand();
|
||||
QString getPostExitCommand();
|
||||
QString getWrapperCommand();
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ const QHash<ExportToModList::Formats, QString> ExportToModListDialog::exampleLin
|
|||
{ ExportToModList::CSV, "{name},{url},{version},\"{authors}\"" },
|
||||
};
|
||||
|
||||
ExportToModListDialog::ExportToModListDialog(QString name, QList<Mod*> mods, QWidget* parent)
|
||||
: QDialog(parent), m_mods(mods), m_template_changed(false), m_name(name), ui(new Ui::ExportToModListDialog)
|
||||
ExportToModListDialog::ExportToModListDialog(QString name, QList<Mod*> mods, BaseInstance* inst, QWidget* parent)
|
||||
: QDialog(parent), m_mods(mods), m_template_changed(false), m_name(name), m_inst(inst), ui(new Ui::ExportToModListDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
enableCustom(false);
|
||||
|
|
@ -68,6 +68,27 @@ ExportToModListDialog::ExportToModListDialog(QString name, QList<Mod*> mods, QWi
|
|||
ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel"));
|
||||
ui->buttonBox->button(QDialogButtonBox::Save)->setText(tr("Save"));
|
||||
triggerImp();
|
||||
|
||||
// Grab the settings we saved
|
||||
int exportSettings = m_inst->exportSettings();
|
||||
|
||||
// Set the format
|
||||
ui->formatComboBox->setCurrentIndex(exportSettings / 10000 % 10);
|
||||
|
||||
// Check if the format is "Custom"
|
||||
if(m_format != 5)
|
||||
{
|
||||
qDebug() << exportSettings % 10 << ", " << exportSettings / 10 % 10 << ", " << exportSettings / 100 % 10 << ", " << exportSettings / 1000 % 10;
|
||||
ui->filenameCheckBox->setChecked(exportSettings % 10);
|
||||
ui->urlCheckBox->setChecked(exportSettings / 10 % 10);
|
||||
ui->versionCheckBox->setChecked(exportSettings / 100 % 10);
|
||||
ui->authorsCheckBox->setChecked(exportSettings / 1000 % 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto exportTemplate = m_inst->exportTemplate();
|
||||
ui->templateText->setPlainText(exportTemplate);
|
||||
}
|
||||
}
|
||||
|
||||
ExportToModListDialog::~ExportToModListDialog()
|
||||
|
|
@ -174,7 +195,7 @@ void ExportToModListDialog::done(int result)
|
|||
qCritical() << "Failed to save mod list file :" << e.cause();
|
||||
}
|
||||
}
|
||||
|
||||
ExportToModListDialog::saveExportSettings();
|
||||
QDialog::done(result);
|
||||
}
|
||||
|
||||
|
|
@ -232,3 +253,20 @@ void ExportToModListDialog::enableCustom(bool enabled)
|
|||
ui->filenameCheckBox->setHidden(enabled);
|
||||
ui->filenameButton->setHidden(!enabled);
|
||||
}
|
||||
|
||||
void ExportToModListDialog::saveExportSettings()
|
||||
{
|
||||
// Save the settings as an integer of form abcde
|
||||
// a = format, b = author checkbox, c = version checkbox, d = url checkbox, e = filename checkbox
|
||||
int exportSettings = m_format*10000 + ui->authorsCheckBox->isChecked()*1000 + ui->versionCheckBox->isChecked()*100
|
||||
+ ui->urlCheckBox->isChecked() * 10 + ui->filenameCheckBox->isChecked();
|
||||
|
||||
// If the format is "Custom", save the template as well
|
||||
if(m_format == ExportToModList::CUSTOM)
|
||||
{
|
||||
QString exportTemplate = ui->templateText->toPlainText();
|
||||
m_inst->setExportTemplate(exportTemplate);
|
||||
}
|
||||
// Save the settings
|
||||
m_inst->setExportSettings(exportSettings);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include <QList>
|
||||
#include "minecraft/mod/Mod.h"
|
||||
#include "modplatform/helpers/ExportToModList.h"
|
||||
#include "BaseInstance.h"
|
||||
|
||||
namespace Ui {
|
||||
class ExportToModListDialog;
|
||||
|
|
@ -31,7 +32,7 @@ class ExportToModListDialog : public QDialog {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ExportToModListDialog(QString name, QList<Mod*> mods, QWidget* parent = nullptr);
|
||||
explicit ExportToModListDialog(QString name, QList<Mod*> mods, BaseInstance* inst, QWidget* parent = nullptr);
|
||||
~ExportToModListDialog();
|
||||
|
||||
void done(int result) override;
|
||||
|
|
@ -45,10 +46,12 @@ class ExportToModListDialog : public QDialog {
|
|||
private:
|
||||
QString extension();
|
||||
void enableCustom(bool enabled);
|
||||
void saveExportSettings();
|
||||
|
||||
QList<Mod*> m_mods;
|
||||
bool m_template_changed;
|
||||
QString m_name;
|
||||
BaseInstance* m_inst;
|
||||
ExportToModList::Formats m_format = ExportToModList::Formats::HTML;
|
||||
Ui::ExportToModListDialog* ui;
|
||||
static const QHash<ExportToModList::Formats, QString> exampleLines;
|
||||
|
|
|
|||
|
|
@ -369,7 +369,7 @@ void ModFolderPage::exportModMetadata()
|
|||
}
|
||||
|
||||
std::ranges::sort(selectedMods, [](const Mod* a, const Mod* b) { return a->name() < b->name(); });
|
||||
ExportToModListDialog dlg(m_instance->name(), selectedMods, this);
|
||||
ExportToModListDialog dlg(m_instance->name(), selectedMods, m_instance, this);
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue