summaryrefslogtreecommitdiffstats
path: root/api/logic/minecraft/Component.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-12-03 15:48:25 +0100
committerPetr Mrázek <peterix@gmail.com>2017-12-03 15:48:25 +0100
commit6a462d0778e27379c3b22b3a1a0339093819d3cf (patch)
tree6c5f57959a2588a62f76eef33931511a6cb40788 /api/logic/minecraft/Component.cpp
parent0a56b562864ce56d14a9657681f221e91dfba129 (diff)
downloadMultiMC-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.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;