summaryrefslogtreecommitdiffstats
path: root/api/logic/minecraft/Component.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'api/logic/minecraft/Component.cpp')
-rw-r--r--api/logic/minecraft/Component.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/api/logic/minecraft/Component.cpp b/api/logic/minecraft/Component.cpp
index db523142..50a2ae16 100644
--- a/api/logic/minecraft/Component.cpp
+++ b/api/logic/minecraft/Component.cpp
@@ -50,6 +50,11 @@ std::shared_ptr<Meta::Version> Component::getMeta()
void Component::applyTo(LaunchProfile* profile)
{
+ // do not apply disabled components
+ if(!isEnabled())
+ {
+ return;
+ }
auto vfile = getVersionFile();
if(vfile)
{
@@ -137,6 +142,32 @@ QDateTime Component::getReleaseDateTime()
return QDateTime::currentDateTime();
}
+bool Component::isEnabled()
+{
+ return !canBeDisabled() || !m_disabled;
+};
+
+bool Component::canBeDisabled()
+{
+ return isRemovable() && !m_dependencyOnly;
+}
+
+bool Component::setEnabled(bool state)
+{
+ bool intendedDisabled = !state;
+ if (!canBeDisabled())
+ {
+ intendedDisabled = false;
+ }
+ if(intendedDisabled != m_disabled)
+ {
+ m_disabled = intendedDisabled;
+ emit dataChanged();
+ return true;
+ }
+ return false;
+}
+
bool Component::isCustom()
{
return m_file != nullptr;