add more options to copy instance dialog

- Copy game options, copy resource packs, copy shaders,
copy servers, and copy mods
- Also made a new InstanceCopyPrefs struct to store those
options rather than passing 7 different booleans into
InstanceCopyTask's constructor

Signed-off-by: Marcelo Hernandez <marcelohdez.inq@gmail.com>
This commit is contained in:
Marcelo Hernandez
2022-10-22 14:50:32 -04:00
parent 8b28ed67ae
commit e7e56eb1e3
8 changed files with 254 additions and 22 deletions

View File

@ -80,6 +80,11 @@ CopyInstanceDialog::CopyInstanceDialog(InstancePtr original, QWidget *parent)
ui->groupBox->lineEdit()->setPlaceholderText(tr("No group"));
ui->copySavesCheckbox->setChecked(m_copySaves);
ui->keepPlaytimeCheckbox->setChecked(m_keepPlaytime);
ui->copyGameOptionsCheckbox->setChecked(m_copyGameOptions);
ui->copyResPacksCheckbox->setChecked(m_copyResourcePacks);
ui->copyShaderPacksCheckbox->setChecked(m_copyShaderPacks);
ui->copyServersCheckbox->setChecked(m_copyServers);
ui->copyModsCheckbox->setChecked(m_copyMods);
}
CopyInstanceDialog::~CopyInstanceDialog()
@ -168,3 +173,88 @@ void CopyInstanceDialog::on_keepPlaytimeCheckbox_stateChanged(int state)
m_keepPlaytime = true;
}
}
bool CopyInstanceDialog::shouldCopyGameOptions() const
{
return m_copyGameOptions;
}
void CopyInstanceDialog::on_copyGameOptionsCheckbox_stateChanged(int state)
{
if(state == Qt::Unchecked)
{
m_copyGameOptions = false;
}
else if(state == Qt::Checked)
{
m_copyGameOptions = true;
}
}
bool CopyInstanceDialog::shouldCopyResourcePacks() const
{
return m_copyResourcePacks;
}
void CopyInstanceDialog::on_copyResPacksCheckbox_stateChanged(int state)
{
if(state == Qt::Unchecked)
{
m_copyResourcePacks = false;
}
else if(state == Qt::Checked)
{
m_copyResourcePacks = true;
}
}
bool CopyInstanceDialog::shouldCopyShaderPacks() const
{
return m_copyShaderPacks;
}
void CopyInstanceDialog::on_copyShaderPacksCheckbox_stateChanged(int state)
{
if(state == Qt::Unchecked)
{
m_copyShaderPacks = false;
}
else if(state == Qt::Checked)
{
m_copyShaderPacks = true;
}
}
bool CopyInstanceDialog::shouldCopyServers() const
{
return m_copyServers;
}
void CopyInstanceDialog::on_copyServersCheckbox_stateChanged(int state)
{
if(state == Qt::Unchecked)
{
m_copyServers = false;
}
else if(state == Qt::Checked)
{
m_copyServers = true;
}
}
bool CopyInstanceDialog::shouldCopyMods() const
{
return m_copyMods;
}
void CopyInstanceDialog::on_copyModsCheckbox_stateChanged(int state)
{
if(state == Qt::Unchecked)
{
m_copyMods = false;
}
else if(state == Qt::Checked)
{
m_copyMods = true;
}
}

View File

@ -41,6 +41,11 @@ public:
QString iconKey() const;
bool shouldCopySaves() const;
bool shouldKeepPlaytime() const;
bool shouldCopyGameOptions() const;
bool shouldCopyResourcePacks() const;
bool shouldCopyShaderPacks() const;
bool shouldCopyServers() const;
bool shouldCopyMods() const;
private
slots:
@ -48,6 +53,11 @@ slots:
void on_instNameTextBox_textChanged(const QString &arg1);
void on_copySavesCheckbox_stateChanged(int state);
void on_keepPlaytimeCheckbox_stateChanged(int state);
void on_copyGameOptionsCheckbox_stateChanged(int state);
void on_copyResPacksCheckbox_stateChanged(int state);
void on_copyShaderPacksCheckbox_stateChanged(int state);
void on_copyServersCheckbox_stateChanged(int state);
void on_copyModsCheckbox_stateChanged(int state);
private:
Ui::CopyInstanceDialog *ui;
@ -55,4 +65,9 @@ private:
InstancePtr m_original;
bool m_copySaves = true;
bool m_keepPlaytime = true;
bool m_copyGameOptions = true;
bool m_copyResourcePacks = true;
bool m_copyShaderPacks = true;
bool m_copyServers = true;
bool m_copyMods = true;
};

View File

@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>345</width>
<height>323</height>
<width>265</width>
<height>425</height>
</rect>
</property>
<property name="windowTitle">
@ -33,7 +33,7 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<width>60</width>
<height>20</height>
</size>
</property>
@ -123,6 +123,50 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="copyGameOptionsCheckbox">
<property name="toolTip">
<string>Copy the in-game options like FOV, max framerate, etc.</string>
</property>
<property name="text">
<string>Copy game options</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="copyResPacksCheckbox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Copy resource packs</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="copyShaderPacksCheckbox">
<property name="text">
<string>Copy shader packs</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="copyServersCheckbox">
<property name="text">
<string>Copy servers</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="copyModsCheckbox">
<property name="toolTip">
<string>Disabling this will still keep the mod loader (ex: Fabric, Quilt, etc.) but erase the mods folder and their configs.</string>
</property>
<property name="text">
<string>Copy mods</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
@ -153,8 +197,8 @@
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
<x>254</x>
<y>316</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
@ -169,8 +213,8 @@
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
<x>322</x>
<y>316</y>
</hint>
<hint type="destinationlabel">
<x>286</x>