2022-10-23 08:34:36 +05:30
|
|
|
//
|
|
|
|
// Created by marcelohdez on 10/22/22.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "InstanceCopyPrefs.h"
|
|
|
|
|
2022-10-23 09:55:38 +05:30
|
|
|
bool InstanceCopyPrefs::allTrue() const
|
|
|
|
{
|
|
|
|
return copySaves &&
|
|
|
|
keepPlaytime &&
|
|
|
|
copyGameOptions &&
|
|
|
|
copyResourcePacks &&
|
|
|
|
copyShaderPacks &&
|
|
|
|
copyServers &&
|
2022-10-30 07:57:31 +05:30
|
|
|
copyMods &&
|
|
|
|
copyScreenshots;
|
2022-10-23 09:55:38 +05:30
|
|
|
}
|
2022-10-26 09:50:36 +05:30
|
|
|
|
2023-02-10 08:18:40 +05:30
|
|
|
|
2022-10-26 09:50:36 +05:30
|
|
|
// Returns a single RegEx string of the selected folders/files to filter out (ex: ".minecraft/saves|.minecraft/server.dat")
|
|
|
|
QString InstanceCopyPrefs::getSelectedFiltersAsRegex() const
|
2023-02-10 08:18:40 +05:30
|
|
|
{
|
|
|
|
return getSelectedFiltersAsRegex({});
|
|
|
|
}
|
|
|
|
QString InstanceCopyPrefs::getSelectedFiltersAsRegex(const QStringList& additionalFilters) const
|
2022-10-26 09:50:36 +05:30
|
|
|
{
|
|
|
|
QStringList filters;
|
|
|
|
|
|
|
|
if(!copySaves)
|
|
|
|
filters << "saves";
|
|
|
|
|
|
|
|
if(!copyGameOptions)
|
|
|
|
filters << "options.txt";
|
|
|
|
|
|
|
|
if(!copyResourcePacks)
|
|
|
|
filters << "resourcepacks" << "texturepacks";
|
|
|
|
|
|
|
|
if(!copyShaderPacks)
|
|
|
|
filters << "shaderpacks";
|
|
|
|
|
|
|
|
if(!copyServers)
|
|
|
|
filters << "servers.dat" << "servers.dat_old" << "server-resource-packs";
|
|
|
|
|
|
|
|
if(!copyMods)
|
|
|
|
filters << "coremods" << "mods" << "config";
|
|
|
|
|
2022-10-30 07:57:31 +05:30
|
|
|
if(!copyScreenshots)
|
|
|
|
filters << "screenshots";
|
|
|
|
|
2023-02-10 08:18:40 +05:30
|
|
|
for (auto filter : additionalFilters) {
|
|
|
|
filters << filter;
|
|
|
|
}
|
|
|
|
|
2022-10-26 09:50:36 +05:30
|
|
|
// If we have any filters to add, join them as a single regex string to return:
|
|
|
|
if (!filters.isEmpty()) {
|
|
|
|
const QString MC_ROOT = "[.]?minecraft/";
|
|
|
|
// Ensure first filter starts with root, then join other filters with OR regex before root (ex: ".minecraft/saves|.minecraft/mods"):
|
|
|
|
return MC_ROOT + filters.join("|" + MC_ROOT);
|
|
|
|
}
|
|
|
|
|
|
|
|
return {};
|
|
|
|
}
|
2022-10-29 10:25:33 +05:30
|
|
|
|
|
|
|
// ======= Getters =======
|
|
|
|
bool InstanceCopyPrefs::isCopySavesEnabled() const
|
|
|
|
{
|
|
|
|
return copySaves;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool InstanceCopyPrefs::isKeepPlaytimeEnabled() const
|
|
|
|
{
|
|
|
|
return keepPlaytime;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool InstanceCopyPrefs::isCopyGameOptionsEnabled() const
|
|
|
|
{
|
|
|
|
return copyGameOptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool InstanceCopyPrefs::isCopyResourcePacksEnabled() const
|
|
|
|
{
|
|
|
|
return copyResourcePacks;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool InstanceCopyPrefs::isCopyShaderPacksEnabled() const
|
|
|
|
{
|
|
|
|
return copyShaderPacks;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool InstanceCopyPrefs::isCopyServersEnabled() const
|
|
|
|
{
|
|
|
|
return copyServers;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool InstanceCopyPrefs::isCopyModsEnabled() const
|
|
|
|
{
|
|
|
|
return copyMods;
|
|
|
|
}
|
|
|
|
|
2022-10-30 07:57:31 +05:30
|
|
|
bool InstanceCopyPrefs::isCopyScreenshotsEnabled() const
|
|
|
|
{
|
|
|
|
return copyScreenshots;
|
|
|
|
}
|
|
|
|
|
2023-02-10 04:49:38 +05:30
|
|
|
bool InstanceCopyPrefs::isUseSymLinksEnabled() const
|
2023-02-07 12:35:06 +05:30
|
|
|
{
|
2023-02-10 04:49:38 +05:30
|
|
|
return useSymLinks;
|
2023-02-07 12:35:06 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
bool InstanceCopyPrefs::isUseHardLinksEnabled() const
|
|
|
|
{
|
|
|
|
return useHardLinks;
|
|
|
|
}
|
|
|
|
|
2023-02-09 07:09:17 +05:30
|
|
|
bool InstanceCopyPrefs::isLinkRecursivelyEnabled() const
|
|
|
|
{
|
|
|
|
return linkRecursively;
|
|
|
|
}
|
|
|
|
|
2023-02-09 04:00:45 +05:30
|
|
|
bool InstanceCopyPrefs::isDontLinkSavesEnabled() const
|
2023-02-07 12:35:06 +05:30
|
|
|
{
|
2023-02-09 04:00:45 +05:30
|
|
|
return dontLinkSaves;
|
2023-02-07 12:35:06 +05:30
|
|
|
}
|
|
|
|
|
2023-02-09 14:32:40 +05:30
|
|
|
bool InstanceCopyPrefs::isUseCloneEnabled() const
|
|
|
|
{
|
|
|
|
return useClone;
|
|
|
|
}
|
|
|
|
|
2022-10-29 10:25:33 +05:30
|
|
|
// ======= Setters =======
|
|
|
|
void InstanceCopyPrefs::enableCopySaves(bool b)
|
|
|
|
{
|
|
|
|
copySaves = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceCopyPrefs::enableKeepPlaytime(bool b)
|
|
|
|
{
|
|
|
|
keepPlaytime = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceCopyPrefs::enableCopyGameOptions(bool b)
|
|
|
|
{
|
|
|
|
copyGameOptions = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceCopyPrefs::enableCopyResourcePacks(bool b)
|
|
|
|
{
|
|
|
|
copyResourcePacks = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceCopyPrefs::enableCopyShaderPacks(bool b)
|
|
|
|
{
|
|
|
|
copyShaderPacks = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceCopyPrefs::enableCopyServers(bool b)
|
|
|
|
{
|
|
|
|
copyServers = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InstanceCopyPrefs::enableCopyMods(bool b)
|
|
|
|
{
|
|
|
|
copyMods = b;
|
|
|
|
}
|
2022-10-30 07:57:31 +05:30
|
|
|
|
|
|
|
void InstanceCopyPrefs::enableCopyScreenshots(bool b)
|
|
|
|
{
|
|
|
|
copyScreenshots = b;
|
|
|
|
}
|
2023-02-07 12:35:06 +05:30
|
|
|
|
2023-02-10 04:49:38 +05:30
|
|
|
void InstanceCopyPrefs::enableUseSymLinks(bool b)
|
2023-02-07 12:35:06 +05:30
|
|
|
{
|
2023-02-10 04:49:38 +05:30
|
|
|
useSymLinks = b;
|
2023-02-07 12:35:06 +05:30
|
|
|
}
|
|
|
|
|
2023-02-09 07:09:17 +05:30
|
|
|
void InstanceCopyPrefs::enableLinkRecursively(bool b)
|
|
|
|
{
|
|
|
|
linkRecursively = b;
|
|
|
|
}
|
|
|
|
|
2023-02-07 12:35:06 +05:30
|
|
|
void InstanceCopyPrefs::enableUseHardLinks(bool b)
|
|
|
|
{
|
|
|
|
useHardLinks = b;
|
|
|
|
}
|
|
|
|
|
2023-02-09 04:00:45 +05:30
|
|
|
void InstanceCopyPrefs::enableDontLinkSaves(bool b)
|
2023-02-07 12:35:06 +05:30
|
|
|
{
|
2023-02-09 04:00:45 +05:30
|
|
|
dontLinkSaves = b;
|
2023-02-07 12:35:06 +05:30
|
|
|
}
|
2023-02-09 14:32:40 +05:30
|
|
|
|
|
|
|
void InstanceCopyPrefs::enableUseClone(bool b)
|
|
|
|
{
|
|
|
|
useClone = b;
|
|
|
|
}
|