summaryrefslogtreecommitdiffstats
path: root/api/logic/minecraft/ProfilePatch.cpp
blob: e001479894e7f6b80fb17bf5052410c0f8aad4da (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
#include "ProfilePatch.h"

#include "meta/Version.h"
#include "VersionFile.h"

ProfilePatch::ProfilePatch(std::shared_ptr<Meta::Version> version)
	:m_metaVersion(version)
{
}

ProfilePatch::ProfilePatch(std::shared_ptr<VersionFile> file, const QString& filename)
	:m_file(file), m_filename(filename)
{
}

void ProfilePatch::applyTo(MinecraftProfile* profile)
{
	auto vfile = getVersionFile();
	if(vfile)
	{
		vfile->applyTo(profile);
	}
}

std::shared_ptr<class VersionFile> ProfilePatch::getVersionFile()
{
	if(m_metaVersion)
	{
		if(!m_metaVersion->isLoaded())
		{
			m_metaVersion->load();
		}
		return m_metaVersion->data();
	}
	return m_file;
}

int ProfilePatch::getOrder()
{
	if(m_orderOverride)
		return m_order;

	auto vfile = getVersionFile();
	if(vfile)
	{
		return vfile->order;
	}
	return 0;
}
void ProfilePatch::setOrder(int order)
{
	m_orderOverride = true;
	m_order = order;
}
QString ProfilePatch::getID()
{
	if(m_metaVersion)
		return m_metaVersion->uid();
	return getVersionFile()->uid;
}
QString ProfilePatch::getName()
{
	if(m_metaVersion)
		return m_metaVersion->name();
	return getVersionFile()->name;
}
QString ProfilePatch::getVersion()
{
	if(m_metaVersion)
		return m_metaVersion->version();
	return getVersionFile()->version;
}
QString ProfilePatch::getFilename()
{
	return m_filename;
}
QDateTime ProfilePatch::getReleaseDateTime()
{
	if(m_metaVersion)
	{
		return m_metaVersion->time();
	}
	return getVersionFile()->releaseTime;
}

bool ProfilePatch::isCustom()
{
	return !m_isVanilla;
};

bool ProfilePatch::isCustomizable()
{
	if(m_metaVersion)
	{
		if(getVersionFile())
		{
			return true;
		}
	}
	return false;
}
bool ProfilePatch::isRemovable()
{
	return m_isRemovable;
}
bool ProfilePatch::isRevertible()
{
	return m_isRevertible;
}
bool ProfilePatch::isMoveable()
{
	return m_isMovable;
}
bool ProfilePatch::isVersionChangeable()
{
	return false;
}

void ProfilePatch::setVanilla (bool state)
{
	m_isVanilla = state;
}
void ProfilePatch::setRemovable (bool state)
{
	m_isRemovable = state;
}
void ProfilePatch::setRevertible (bool state)
{
	m_isRevertible = state;
}
void ProfilePatch::setMovable (bool state)
{
	m_isMovable = state;
}