summaryrefslogtreecommitdiff
path: root/archived/projt-launcher/launcher/InstanceCopyPrefs.cpp
blob: 48f3c465d3d1df0ba8d68fb5bd6b30397b22be66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
// SPDX-License-Identifier: GPL-3.0-only
// SPDX-FileCopyrightText: 2026 Project Tick
// SPDX-FileContributor: Project Tick Team
/*
 *  ProjT Launcher - Minecraft Launcher
 *  Copyright (C) 2026 Project Tick
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, version 3.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, write to the Free Software Foundation,
 *  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
#include "InstanceCopyPrefs.h"

bool InstanceCopyPrefs::allTrue() const
{
	return copySaves && keepPlaytime && copyGameOptions && copyResourcePacks && copyShaderPacks && copyServers
		&& copyMods && copyScreenshots;
}

// Returns a single RegEx string of the selected folders/files to filter out (ex:
// ".minecraft/saves|.minecraft/server.dat")
QString InstanceCopyPrefs::getSelectedFiltersAsRegex() const
{
	return getSelectedFiltersAsRegex({});
}
QString InstanceCopyPrefs::getSelectedFiltersAsRegex(const QStringList& additionalFilters) const
{
	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";

	if (!copyScreenshots)
		filters << "screenshots";

	for (auto filter : additionalFilters)
	{
		filters << filter;
	}

	// 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 {};
}

// ======= 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;
}

bool InstanceCopyPrefs::isCopyScreenshotsEnabled() const
{
	return copyScreenshots;
}

bool InstanceCopyPrefs::isUseSymLinksEnabled() const
{
	return useSymLinks;
}

bool InstanceCopyPrefs::isUseHardLinksEnabled() const
{
	return useHardLinks;
}

bool InstanceCopyPrefs::isLinkRecursivelyEnabled() const
{
	return linkRecursively;
}

bool InstanceCopyPrefs::isDontLinkSavesEnabled() const
{
	return dontLinkSaves;
}

bool InstanceCopyPrefs::isUseCloneEnabled() const
{
	return useClone;
}

// ======= 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;
}

void InstanceCopyPrefs::enableCopyScreenshots(bool b)
{
	copyScreenshots = b;
}

void InstanceCopyPrefs::enableUseSymLinks(bool b)
{
	useSymLinks = b;
}

void InstanceCopyPrefs::enableLinkRecursively(bool b)
{
	linkRecursively = b;
}

void InstanceCopyPrefs::enableUseHardLinks(bool b)
{
	useHardLinks = b;
}

void InstanceCopyPrefs::enableDontLinkSaves(bool b)
{
	dontLinkSaves = b;
}

void InstanceCopyPrefs::enableUseClone(bool b)
{
	useClone = b;
}