| @@ -60,7 +60,7 @@ void PathSettingsTab::textPropertyComponentChanged (TextPropertyComponent* textP | |||||
| { | { | ||||
| Identifier keyName = getKeyForPropertyComponent (textPropertyComponent); | Identifier keyName = getKeyForPropertyComponent (textPropertyComponent); | ||||
| Colour textColour = getAppSettings().isGlobalPathValid (keyName, textPropertyComponent->getText()) | |||||
| Colour textColour = getAppSettings().isGlobalPathValid (File::getCurrentWorkingDirectory(), keyName, textPropertyComponent->getText()) | |||||
| ? Colours::black | ? Colours::black | ||||
| : Colours::red; | : Colours::red; | ||||
| @@ -129,10 +129,10 @@ public: | |||||
| props.add (new TextWithDefaultPropertyComponent<String> (androidVersionCode, "Android Version Code", 32), | props.add (new TextWithDefaultPropertyComponent<String> (androidVersionCode, "Android Version Code", 32), | ||||
| "An integer value that represents the version of the application code, relative to other versions."); | "An integer value that represents the version of the application code, relative to other versions."); | ||||
| props.add (new DependencyPathPropertyComponent (sdkPath, "Android SDK Path"), | |||||
| props.add (new DependencyPathPropertyComponent (project.getFile().getParentDirectory(), sdkPath, "Android SDK Path"), | |||||
| "The path to the Android SDK folder on the target build machine"); | "The path to the Android SDK folder on the target build machine"); | ||||
| props.add (new DependencyPathPropertyComponent (ndkPath, "Android NDK Path"), | |||||
| props.add (new DependencyPathPropertyComponent (project.getFile().getParentDirectory(), ndkPath, "Android NDK Path"), | |||||
| "The path to the Android NDK folder on the target build machine"); | "The path to the Android NDK folder on the target build machine"); | ||||
| props.add (new TextWithDefaultPropertyComponent<String> (androidMinimumSDK, "Minimum SDK version", 32), | props.add (new TextWithDefaultPropertyComponent<String> (androidMinimumSDK, "Minimum SDK version", 32), | ||||
| @@ -244,19 +244,19 @@ void ProjectExporter::createDependencyPathProperties (PropertyListBuilder& props | |||||
| { | { | ||||
| if (supportsVST3() && (project.shouldBuildVST3().getValue() || project.isVST3PluginHost())) | if (supportsVST3() && (project.shouldBuildVST3().getValue() || project.isVST3PluginHost())) | ||||
| { | { | ||||
| props.add (new DependencyPathPropertyComponent (getVST3PathValue(), "VST3 SDK Folder"), | |||||
| props.add (new DependencyPathPropertyComponent (project.getFile().getParentDirectory(), getVST3PathValue(), "VST3 SDK Folder"), | |||||
| "If you're building a VST3 plugin or host, this must be the folder containing the VST3 SDK. This can be an absolute path, or a path relative to the Projucer project file."); | "If you're building a VST3 plugin or host, this must be the folder containing the VST3 SDK. This can be an absolute path, or a path relative to the Projucer project file."); | ||||
| } | } | ||||
| if (supportsAAX() && project.shouldBuildAAX().getValue()) | if (supportsAAX() && project.shouldBuildAAX().getValue()) | ||||
| { | { | ||||
| props.add (new DependencyPathPropertyComponent (getAAXPathValue(), "AAX SDK Folder"), | |||||
| props.add (new DependencyPathPropertyComponent (project.getFile().getParentDirectory(), getAAXPathValue(), "AAX SDK Folder"), | |||||
| "If you're building an AAX plugin, this must be the folder containing the AAX SDK. This can be an absolute path, or a path relative to the Projucer project file."); | "If you're building an AAX plugin, this must be the folder containing the AAX SDK. This can be an absolute path, or a path relative to the Projucer project file."); | ||||
| } | } | ||||
| if (supportsRTAS() && project.shouldBuildRTAS().getValue()) | if (supportsRTAS() && project.shouldBuildRTAS().getValue()) | ||||
| { | { | ||||
| props.add (new DependencyPathPropertyComponent (getRTASPathValue(), "RTAS SDK Folder"), | |||||
| props.add (new DependencyPathPropertyComponent (project.getFile().getParentDirectory(), getRTASPathValue(), "RTAS SDK Folder"), | |||||
| "If you're building an RTAS, this must be the folder containing the RTAS SDK. This can be an absolute path, or a path relative to the Projucer project file."); | "If you're building an RTAS, this must be the folder containing the RTAS SDK. This can be an absolute path, or a path relative to the Projucer project file."); | ||||
| } | } | ||||
| } | } | ||||
| @@ -40,20 +40,27 @@ DependencyPathValueSource::DependencyPathValueSource (const Value& projectSettin | |||||
| globalSettingsValue.addListener (this); | globalSettingsValue.addListener (this); | ||||
| } | } | ||||
| bool DependencyPathValueSource::isValidPath() const | |||||
| bool DependencyPathValueSource::isValidPath (const File& relativeTo) const | |||||
| { | { | ||||
| // if we are on another OS than the one which this path setting is for, | // if we are on another OS than the one which this path setting is for, | ||||
| // we have no way of knowing whether the path is valid - so just assume it is: | // we have no way of knowing whether the path is valid - so just assume it is: | ||||
| if (! appliesToThisOS()) | if (! appliesToThisOS()) | ||||
| return true; | return true; | ||||
| return getAppSettings().isGlobalPathValid (globalKey, getValue().toString()); | |||||
| return getAppSettings().isGlobalPathValid (relativeTo, globalKey, getValue().toString()); | |||||
| } | |||||
| bool DependencyPathValueSource::isValidPath() const | |||||
| { | |||||
| return isValidPath (File::getCurrentWorkingDirectory()); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| DependencyPathPropertyComponent::DependencyPathPropertyComponent (const Value& value, | |||||
| DependencyPathPropertyComponent::DependencyPathPropertyComponent (const File& pathRelativeToUse, | |||||
| const Value& value, | |||||
| const String& propertyName) | const String& propertyName) | ||||
| try : TextPropertyComponent (propertyName, 1024, false), | try : TextPropertyComponent (propertyName, 1024, false), | ||||
| pathRelativeTo (pathRelativeToUse), | |||||
| pathValue (value), | pathValue (value), | ||||
| pathValueSource (dynamic_cast<DependencyPathValueSource&> (pathValue.getValueSource())) | pathValueSource (dynamic_cast<DependencyPathValueSource&> (pathValue.getValueSource())) | ||||
| { | { | ||||
| @@ -100,11 +107,11 @@ void DependencyPathPropertyComponent::textWasEdited() | |||||
| Colour DependencyPathPropertyComponent::getTextColourToDisplay() const | Colour DependencyPathPropertyComponent::getTextColourToDisplay() const | ||||
| { | { | ||||
| if (! pathValueSource.isUsingProjectSettings()) | if (! pathValueSource.isUsingProjectSettings()) | ||||
| return pathValueSource.isValidPath() ? Colours::grey | |||||
| : Colours::lightpink; | |||||
| return pathValueSource.isValidPath (pathRelativeTo) ? Colours::grey | |||||
| : Colours::lightpink; | |||||
| return pathValueSource.isValidPath() ? Colours::black | |||||
| : Colours::red; | |||||
| return pathValueSource.isValidPath (pathRelativeTo) ? Colours::black | |||||
| : Colours::red; | |||||
| } | } | ||||
| void DependencyPathPropertyComponent::labelTextChanged (Label*) | void DependencyPathPropertyComponent::labelTextChanged (Label*) | ||||
| @@ -82,6 +82,8 @@ public: | |||||
| return os == TargetOS::getThisOS(); | return os == TargetOS::getThisOS(); | ||||
| } | } | ||||
| bool isValidPath (const File& relativeTo) const; | |||||
| bool isValidPath() const; | bool isValidPath() const; | ||||
| private: | private: | ||||
| @@ -143,7 +145,8 @@ class DependencyPathPropertyComponent : public TextPropertyComponent, | |||||
| private Label::Listener | private Label::Listener | ||||
| { | { | ||||
| public: | public: | ||||
| DependencyPathPropertyComponent (const Value& value, | |||||
| DependencyPathPropertyComponent (const File& pathRelativeToUse, | |||||
| const Value& value, | |||||
| const String& propertyName); | const String& propertyName); | ||||
| @@ -158,6 +161,10 @@ private: | |||||
| /** This function handles path changes because the global path changed. */ | /** This function handles path changes because the global path changed. */ | ||||
| void valueChanged (Value& value) override; | void valueChanged (Value& value) override; | ||||
| /** If the dependency path is relative, relative to which directory should | |||||
| we check if an object is available. */ | |||||
| File pathRelativeTo; | |||||
| /** the value that represents this dependency path setting. */ | /** the value that represents this dependency path setting. */ | ||||
| Value pathValue; | Value pathValue; | ||||
| @@ -218,10 +218,10 @@ void StoredSettings::ColourSelectorWithSwatches::setSwatchColour (int index, con | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| static bool doesSDKPathContainFile (const String& path, const String& fileToCheckFor) | |||||
| static bool doesSDKPathContainFile (const File& relativeTo, const String& path, const String& fileToCheckFor) | |||||
| { | { | ||||
| String actualPath = path.replace ("${user.home}", File::getSpecialLocation (File::userHomeDirectory).getFullPathName()); | String actualPath = path.replace ("${user.home}", File::getSpecialLocation (File::userHomeDirectory).getFullPathName()); | ||||
| return File::getCurrentWorkingDirectory().getChildFile (actualPath + "/" + fileToCheckFor).existsAsFile(); | |||||
| return relativeTo.getChildFile (actualPath + "/" + fileToCheckFor).existsAsFile(); | |||||
| } | } | ||||
| Value StoredSettings::getGlobalPath (const Identifier& key, DependencyPathOS os) | Value StoredSettings::getGlobalPath (const Identifier& key, DependencyPathOS os) | ||||
| @@ -271,7 +271,7 @@ String StoredSettings::getFallbackPath (const Identifier& key, DependencyPathOS | |||||
| return String(); | return String(); | ||||
| } | } | ||||
| bool StoredSettings::isGlobalPathValid (const Identifier& key, const String& path) | |||||
| bool StoredSettings::isGlobalPathValid (const File& relativeTo, const Identifier& key, const String& path) | |||||
| { | { | ||||
| String fileToCheckFor; | String fileToCheckFor; | ||||
| @@ -310,5 +310,5 @@ bool StoredSettings::isGlobalPathValid (const Identifier& key, const String& pat | |||||
| return false; | return false; | ||||
| } | } | ||||
| return doesSDKPathContainFile (path, fileToCheckFor); | |||||
| return doesSDKPathContainFile (relativeTo, path, fileToCheckFor); | |||||
| } | } | ||||
| @@ -67,7 +67,8 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| Value getGlobalPath (const Identifier& key, DependencyPathOS); | Value getGlobalPath (const Identifier& key, DependencyPathOS); | ||||
| String getFallbackPath (const Identifier& key, DependencyPathOS); | String getFallbackPath (const Identifier& key, DependencyPathOS); | ||||
| bool isGlobalPathValid (const Identifier& key, const String& path); | |||||
| bool isGlobalPathValid (const File& relativeTo, const Identifier& key, const String& path); | |||||
| private: | private: | ||||
| OwnedArray<PropertiesFile> propertyFiles; | OwnedArray<PropertiesFile> propertyFiles; | ||||