aboutsummaryrefslogtreecommitdiff
path: root/launcher/InstanceCopyPrefs.cpp
blob: 7b93a5164ab73859d75cfbcebb2316e9a8f84307 (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
//
// Created by marcelohdez on 10/22/22.
//

#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
{
    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";

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

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