diff options
author | Petr Mrázek <peterix@gmail.com> | 2017-12-03 15:48:25 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2017-12-03 15:48:25 +0100 |
commit | 6a462d0778e27379c3b22b3a1a0339093819d3cf (patch) | |
tree | 6c5f57959a2588a62f76eef33931511a6cb40788 /api/logic/minecraft/Component.cpp | |
parent | 0a56b562864ce56d14a9657681f221e91dfba129 (diff) | |
download | MultiMC-6a462d0778e27379c3b22b3a1a0339093819d3cf.tar MultiMC-6a462d0778e27379c3b22b3a1a0339093819d3cf.tar.gz MultiMC-6a462d0778e27379c3b22b3a1a0339093819d3cf.tar.lz MultiMC-6a462d0778e27379c3b22b3a1a0339093819d3cf.tar.xz MultiMC-6a462d0778e27379c3b22b3a1a0339093819d3cf.zip |
GH-1082 allow disabling components
Currently only ones that are removable and aren't dep-only
Diffstat (limited to 'api/logic/minecraft/Component.cpp')
-rw-r--r-- | api/logic/minecraft/Component.cpp | 31 |
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; |