diff --git a/extras/Introjucer/Source/Application/jucer_CommonHeaders.h b/extras/Introjucer/Source/Application/jucer_CommonHeaders.h index e86abc3b31..ceb0751a74 100644 --- a/extras/Introjucer/Source/Application/jucer_CommonHeaders.h +++ b/extras/Introjucer/Source/Application/jucer_CommonHeaders.h @@ -25,7 +25,34 @@ #ifndef JUCER_COMMONHEADERS_H_INCLUDED #define JUCER_COMMONHEADERS_H_INCLUDED +//============================================================================== +struct TargetOS +{ + enum OS + { + windows = 0, + osx, + linux, + unknown + }; + + static OS getThisOS() noexcept + { + #if JUCE_WINDOWS + return windows; + #elif JUCE_MAC + return osx; + #elif JUCE_LINUX + return linux; + #else + return unknown; + #endif + } +}; + +typedef TargetOS::OS DependencyPathOS; +//============================================================================== #include "../Utility/jucer_StoredSettings.h" #include "../Utility/jucer_Icons.h" #include "../Utility/jucer_MiscUtilities.h" diff --git a/extras/Introjucer/Source/Application/jucer_GlobalPreferences.cpp b/extras/Introjucer/Source/Application/jucer_GlobalPreferences.cpp index 5948b27434..e767a1c690 100644 --- a/extras/Introjucer/Source/Application/jucer_GlobalPreferences.cpp +++ b/extras/Introjucer/Source/Application/jucer_GlobalPreferences.cpp @@ -29,28 +29,22 @@ public: }; //============================================================================== -namespace PathSettingsHelpers -{ - bool checkSdkPathContainsFile (const String& path, const String& fileToCheckFor) - { - return File::getCurrentWorkingDirectory().getChildFile( path + "/" + fileToCheckFor).existsAsFile(); - } -} - PathSettingsTab::PathSettingsTab (DependencyPathOS os) { const int maxChars = 1024; - vst2PathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (DependencyPath::vst2KeyName, os), "VST SDK", maxChars, false)); - vst3PathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (DependencyPath::vst3KeyName, os), "VST3 SDK", maxChars, false)); + StoredSettings& settings = getAppSettings(); + + vst2PathComponent = pathComponents.add (new TextPropertyComponent (settings.getGlobalPath (Ids::vst2Path, os), "VST SDK", maxChars, false)); + vst3PathComponent = pathComponents.add (new TextPropertyComponent (settings.getGlobalPath (Ids::vst3Path, os), "VST3 SDK", maxChars, false)); #if ! JUCE_LINUX - rtasPathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (DependencyPath::rtasKeyName, os), "RTAS SDK", maxChars, false)); - aaxPathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (DependencyPath::aaxKeyName, os), "AAX SDK", maxChars, false)); + rtasPathComponent = pathComponents.add (new TextPropertyComponent (settings.getGlobalPath (Ids::rtasPath, os), "RTAS SDK", maxChars, false)); + aaxPathComponent = pathComponents.add (new TextPropertyComponent (settings.getGlobalPath (Ids::aaxPath, os), "AAX SDK", maxChars, false)); #endif - androidSdkPathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (DependencyPath::androidSdkKeyName, os), "Android SDK", maxChars, false)); - androidNdkPathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (DependencyPath::androidNdkKeyName, os), "Android NDK", maxChars, false)); + androidSdkPathComponent = pathComponents.add (new TextPropertyComponent (settings.getGlobalPath (Ids::androidSDKPath, os), "Android SDK", maxChars, false)); + androidNdkPathComponent = pathComponents.add (new TextPropertyComponent (settings.getGlobalPath (Ids::androidNDKPath, os), "Android NDK", maxChars, false)); for (TextPropertyComponent** component = pathComponents.begin(); component != pathComponents.end(); ++component) { @@ -66,20 +60,23 @@ PathSettingsTab::~PathSettingsTab() void PathSettingsTab::textPropertyComponentChanged (TextPropertyComponent* textPropertyComponent) { - String keyName = getKeyForPropertyComponent (textPropertyComponent); + Identifier keyName = getKeyForPropertyComponent (textPropertyComponent); + + Colour textColour = getAppSettings().isGlobalPathValid (keyName, textPropertyComponent->getText()) + ? Colours::black + : Colours::red; - Colour textColour = checkPathByKey (keyName, textPropertyComponent->getText()) ? Colours::black : Colours::red; textPropertyComponent->setColour (TextPropertyComponent::textColourId, textColour); } -String PathSettingsTab::getKeyForPropertyComponent (TextPropertyComponent* component) const +Identifier PathSettingsTab::getKeyForPropertyComponent (TextPropertyComponent* component) const { - if (component == vst2PathComponent) return DependencyPath::vst2KeyName; - if (component == vst3PathComponent) return DependencyPath::vst3KeyName; - if (component == rtasPathComponent) return DependencyPath::rtasKeyName; - if (component == aaxPathComponent) return DependencyPath::aaxKeyName; - if (component == androidSdkPathComponent) return DependencyPath::androidSdkKeyName; - if (component == androidNdkPathComponent) return DependencyPath::androidNdkKeyName; + if (component == vst2PathComponent) return Ids::vst2Path; + if (component == vst3PathComponent) return Ids::vst3Path; + if (component == rtasPathComponent) return Ids::rtasPath; + if (component == aaxPathComponent) return Ids::aaxPath; + if (component == androidSdkPathComponent) return Ids::androidSDKPath; + if (component == androidNdkPathComponent) return Ids::androidNDKPath; // this property component does not have a key associated to it! jassertfalse; @@ -107,104 +104,6 @@ void PathSettingsTab::resized() } } -//============================================================================== -Value& PathSettingsTab::getPathByKey (const String& key, DependencyPathOS os) -{ - getAppSettings().pathValues[key].referTo (getAppSettings().projectDefaults.getPropertyAsValue (key, nullptr)); - Value& value = getAppSettings().pathValues[key]; - - if (value.toString().isEmpty()) - value = getFallbackPathByKey (key, os); - - return value; -} - -//============================================================================== -String PathSettingsTab::getFallbackPathByKey (const String& key, DependencyPathOS os) -{ - if (key == DependencyPath::vst2KeyName || key == DependencyPath::vst3KeyName) - return os == DependencyPath::windows ? "c:\\SDKs\\VST3 SDK" - : "~/SDKs/VST3 SDK"; - - if (key == DependencyPath::rtasKeyName) - { - if (os == DependencyPath::windows) return "c:\\SDKs\\PT_80_SDK"; - if (os == DependencyPath::osx) return "~/SDKs/PT_80_SDK"; - - // no RTAS on this OS! - jassertfalse; - return String(); - } - - if (key == DependencyPath::aaxKeyName) - { - if (os == DependencyPath::windows) return "c:\\SDKs\\AAX"; - if (os == DependencyPath::osx) return "~/SDKs/AAX" ; - - // no RTAS on this OS! - jassertfalse; - return String(); - } - - if (key == DependencyPath::androidSdkKeyName) - return os == DependencyPath::windows ? "c:\\SDKs\\android-sdk" - : "~/Library/Android/sdk"; - - if (key == DependencyPath::androidNdkKeyName) - return os == DependencyPath::windows ? "c:\\SDKs\\android-ndk" - : "~/Library/Android/ndk"; - - // didn't recognise the key provided! - jassertfalse; - return String(); -} - -//============================================================================== -bool PathSettingsTab::checkPathByKey (const String& key, const String& path) -{ - String fileToCheckFor; - - if (key == DependencyPath::vst2KeyName) - { - fileToCheckFor = "public.sdk/source/vst2.x/audioeffectx.h"; - } - else if (key == DependencyPath::vst3KeyName) - { - fileToCheckFor = "base/source/baseiids.cpp"; - } - else if (key == DependencyPath::rtasKeyName) - { - fileToCheckFor = "AlturaPorts/TDMPlugIns/PlugInLibrary/EffectClasses/CEffectProcessMIDI.cpp"; - } - else if (key == DependencyPath::aaxKeyName) - { - fileToCheckFor = "Interfaces/AAX_Exports.cpp"; - } - else if (key == DependencyPath::androidSdkKeyName) - { - #if JUCE_WINDOWS - fileToCheckFor = "platform-tools/adb.exe"; - #else - fileToCheckFor = "platform-tools/adb"; - #endif - } - else if (key == DependencyPath::androidNdkKeyName) - { - #if JUCE_WINDOWS - fileToCheckFor = "ndk-depends.exe"; - #else - fileToCheckFor = "ndk-depends"; - #endif - } - else - { - // didn't recognise the key provided! - jassertfalse; - return false; - } - - return PathSettingsHelpers::checkSdkPathContainsFile (path, fileToCheckFor); -} //============================================================================== struct AppearanceEditor @@ -469,7 +368,7 @@ String AppearanceSettingsTab::getName() const noexcept GlobalPreferencesComponent::GlobalPreferencesComponent() : TabbedComponent (TabbedButtonBar::TabsAtTop) { - preferenceTabs.add (new PathSettingsTab (DependencyPath::getThisOS())); + preferenceTabs.add (new PathSettingsTab (TargetOS::getThisOS())); preferenceTabs.add (new AppearanceSettingsTab); for (GlobalPreferencesTab** tab = preferenceTabs.begin(); tab != preferenceTabs.end(); ++tab) diff --git a/extras/Introjucer/Source/Application/jucer_GlobalPreferences.h b/extras/Introjucer/Source/Application/jucer_GlobalPreferences.h index 9e9f66714f..21637c8392 100644 --- a/extras/Introjucer/Source/Application/jucer_GlobalPreferences.h +++ b/extras/Introjucer/Source/Application/jucer_GlobalPreferences.h @@ -43,14 +43,10 @@ public: void resized() override; - static Value& getPathByKey (const String& key, DependencyPathOS); - static String getFallbackPathByKey (const String& key, DependencyPathOS); - static bool checkPathByKey (const String& key, const String& path); - private: void textPropertyComponentChanged (TextPropertyComponent*) override; - String getKeyForPropertyComponent (TextPropertyComponent*) const; + Identifier getKeyForPropertyComponent (TextPropertyComponent*) const; OwnedArray pathComponents; diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h index 324db7175a..6b6361e76e 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h @@ -753,17 +753,13 @@ private: void initialiseDependencyPathValues() { - sdkPath.referTo (Value (new DependencyPathValueSource ( - getSetting (Ids::androidSDKPath), - DependencyPath::androidSdkKeyName, - DependencyPath::getThisOS() - ))); - - ndkPath.referTo (Value (new DependencyPathValueSource ( - getSetting (Ids::androidNDKPath), - DependencyPath::androidNdkKeyName, - DependencyPath::getThisOS() - ))); + sdkPath.referTo (Value (new DependencyPathValueSource (getSetting (Ids::androidSDKPath), + Ids::androidSDKPath, + TargetOS::getThisOS()))); + + ndkPath.referTo (Value (new DependencyPathValueSource (getSetting (Ids::androidNDKPath), + Ids::androidNDKPath, + TargetOS::getThisOS()))); } //============================================================================== diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_CodeBlocks.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_CodeBlocks.h index 40b9265bb3..5482278265 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_CodeBlocks.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_CodeBlocks.h @@ -405,33 +405,16 @@ private: void initialiseDependencyPathValues() { - DependencyPathOS pathOS = isLinux() ? DependencyPath::linux : DependencyPath::windows; + DependencyPathOS pathOS = isLinux() ? TargetOS::linux + : TargetOS::windows; - vst2Path.referTo (Value (new DependencyPathValueSource ( - getSetting (Ids::vstFolder), - DependencyPath::vst2KeyName, - pathOS - ))); - - vst3Path.referTo (Value (new DependencyPathValueSource ( - getSetting (Ids::vst3Folder), - DependencyPath::vst3KeyName, - pathOS - ))); + vst2Path.referTo (Value (new DependencyPathValueSource (getSetting (Ids::vstFolder), Ids::vst2Path, pathOS))); + vst3Path.referTo (Value (new DependencyPathValueSource (getSetting (Ids::vst3Folder), Ids::vst3Path, pathOS))); if (! isLinux()) { - aaxPath.referTo (Value (new DependencyPathValueSource ( - getSetting (Ids::aaxFolder), - DependencyPath::aaxKeyName, - pathOS - ))); - - rtasPath.referTo (Value (new DependencyPathValueSource ( - getSetting (Ids::rtasFolder), - DependencyPath::rtasKeyName, - pathOS - ))); + aaxPath.referTo (Value (new DependencyPathValueSource (getSetting (Ids::aaxFolder), Ids::aaxPath, pathOS))); + rtasPath.referTo (Value (new DependencyPathValueSource (getSetting (Ids::rtasFolder), Ids::rtasPath, pathOS))); } } diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h index 3c1a9eccd1..a374bbd989 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h @@ -559,29 +559,21 @@ protected: void initialiseDependencyPathValues() { - vst2Path.referTo (Value (new DependencyPathValueSource ( - getSetting (Ids::vstFolder), - DependencyPath::vst2KeyName, - DependencyPath::windows - ))); - - vst3Path.referTo (Value (new DependencyPathValueSource ( - getSetting (Ids::vst3Folder), - DependencyPath::vst3KeyName, - DependencyPath::windows - ))); - - aaxPath.referTo (Value (new DependencyPathValueSource ( - getSetting (Ids::aaxFolder), - DependencyPath::aaxKeyName, - DependencyPath::windows - ))); - - rtasPath.referTo (Value (new DependencyPathValueSource ( - getSetting (Ids::rtasFolder), - DependencyPath::rtasKeyName, - DependencyPath::windows - ))); + vst2Path.referTo (Value (new DependencyPathValueSource (getSetting (Ids::vstFolder), + Ids::vst2Path, + TargetOS::windows))); + + vst3Path.referTo (Value (new DependencyPathValueSource (getSetting (Ids::vst3Folder), + Ids::vst3Path, + TargetOS::windows))); + + aaxPath.referTo (Value (new DependencyPathValueSource (getSetting (Ids::aaxFolder), + Ids::aaxPath, + TargetOS::windows))); + + rtasPath.referTo (Value (new DependencyPathValueSource (getSetting (Ids::rtasFolder), + Ids::rtasPath, + TargetOS::windows))); } JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterBase) diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h index 16a463dd74..15eff85a8c 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h @@ -350,17 +350,13 @@ private: void initialiseDependencyPathValues() { - vst2Path.referTo (Value (new DependencyPathValueSource ( - getSetting (Ids::vstFolder), - DependencyPath::vst2KeyName, - DependencyPath::linux - ))); - - vst3Path.referTo (Value (new DependencyPathValueSource ( - getSetting (Ids::vst3Folder), - DependencyPath::vst3KeyName, - DependencyPath::linux - ))); + vst2Path.referTo (Value (new DependencyPathValueSource (getSetting (Ids::vstFolder), + Ids::vst2Path, + TargetOS::linux))); + + vst3Path.referTo (Value (new DependencyPathValueSource (getSetting (Ids::vst3Folder), + Ids::vst3Path, + TargetOS::linux))); } JUCE_DECLARE_NON_COPYABLE (MakefileProjectExporter) diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h index 060b831a33..26b20064bc 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h @@ -1504,28 +1504,16 @@ private: void initialiseDependencyPathValues() { - vst2Path.referTo (Value (new DependencyPathValueSource ( - getSetting (Ids::vstFolder), - DependencyPath::vst2KeyName, - DependencyPath::osx - ))); - - vst3Path.referTo (Value (new DependencyPathValueSource ( - getSetting (Ids::vst3Folder), - DependencyPath::vst3KeyName, - DependencyPath::osx - ))); - - aaxPath.referTo (Value (new DependencyPathValueSource ( - getSetting (Ids::aaxFolder), - DependencyPath::aaxKeyName, - DependencyPath::osx - ))); - - rtasPath.referTo (Value (new DependencyPathValueSource ( - getSetting (Ids::rtasFolder), - DependencyPath::rtasKeyName, - DependencyPath::osx - ))); + vst2Path.referTo (Value (new DependencyPathValueSource (getSetting (Ids::vstFolder), + Ids::vst2Path, TargetOS::osx))); + + vst3Path.referTo (Value (new DependencyPathValueSource (getSetting (Ids::vst3Folder), + Ids::vst3Path, TargetOS::osx))); + + aaxPath.referTo (Value (new DependencyPathValueSource (getSetting (Ids::aaxFolder), + Ids::aaxPath, TargetOS::osx))); + + rtasPath.referTo (Value (new DependencyPathValueSource (getSetting (Ids::rtasFolder), + Ids::rtasPath, TargetOS::osx))); } }; diff --git a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp index 4c7504b784..55c187ffc2 100644 --- a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp +++ b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp @@ -12,24 +12,16 @@ #include "jucer_DependencyPathPropertyComponent.h" #include "../Application/jucer_GlobalPreferences.h" -//============================================================================== -const String DependencyPath::vst2KeyName = "vst2Path"; -const String DependencyPath::vst3KeyName = "vst3Path"; -const String DependencyPath::rtasKeyName = "rtasPath"; -const String DependencyPath::aaxKeyName = "aaxPath"; -const String DependencyPath::androidSdkKeyName = "androidSdkPath"; -const String DependencyPath::androidNdkKeyName = "androidNdkPath"; //============================================================================== - DependencyPathValueSource::DependencyPathValueSource (const Value& projectSettingsPath, - String globalSettingsKey, + Identifier globalSettingsKey, DependencyPathOS osThisSettingAppliesTo) : projectSettingsValue (projectSettingsPath), globalKey (globalSettingsKey), os (osThisSettingAppliesTo), - globalSettingsValue (PathSettingsTab::getPathByKey (globalKey, os)), - fallbackValue (PathSettingsTab::getFallbackPathByKey (globalKey, os)) + globalSettingsValue (getAppSettings().getGlobalPath (globalKey, os)), + fallbackValue (getAppSettings().getFallbackPath (globalKey, os)) { globalSettingsValue.addListener (this); } @@ -41,7 +33,7 @@ bool DependencyPathValueSource::isValidPath() const if (! appliesToThisOS()) return true; - return PathSettingsTab::checkPathByKey (globalKey, getValue().toString()); + return getAppSettings().isGlobalPathValid (globalKey, getValue().toString()); } //============================================================================== diff --git a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h index 70b5ecd390..346a8f01eb 100644 --- a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h +++ b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h @@ -11,36 +11,6 @@ #ifndef JUCER_DEPENDENCYPATHPROPERTYCOMPONENT_H_INCLUDED #define JUCER_DEPENDENCYPATHPROPERTYCOMPONENT_H_INCLUDED -//============================================================================== -class DependencyPath -{ -public: - enum OS - { - windows = 0, - osx, - linux, - unknown - }; - - static OS getThisOS() - { - #if JUCE_WINDOWS - return DependencyPath::windows; - #elif JUCE_MAC - return DependencyPath::osx; - #elif JUCE_LINUX - return DependencyPath::linux; - #else - return DependencyPath::unknown; - #endif - } - - const static String vst2KeyName, vst3KeyName, rtasKeyName, aaxKeyName, - androidSdkKeyName, androidNdkKeyName; -}; - -typedef DependencyPath::OS DependencyPathOS; //============================================================================== /** This ValueSource type implements the fallback logic required for dependency @@ -54,7 +24,7 @@ class DependencyPathValueSource : public Value::ValueSource, { public: DependencyPathValueSource (const Value& projectSettingsPath, - String globalSettingsKey, + Identifier globalSettingsKey, DependencyPathOS osThisSettingAppliesTo); /** This gets the currently used value, which may be either @@ -95,7 +65,7 @@ public: bool appliesToThisOS() const { - return os == DependencyPath::getThisOS(); + return os == TargetOS::getThisOS(); } bool isValidPath() const; @@ -124,9 +94,9 @@ private: { // only use the global settings if they are set on the same OS // that this setting is for! - DependencyPathOS thisOS = DependencyPath::getThisOS(); + DependencyPathOS thisOS = TargetOS::getThisOS(); - return thisOS == DependencyPath::unknown ? false : os == thisOS; + return thisOS == TargetOS::unknown ? false : os == thisOS; } /** the dependency path setting as set in this Introjucer project. */ @@ -134,7 +104,7 @@ private: /** the global key used in the application settings for the global setting value. needed for checking whether the path is valid. */ - String globalKey; + Identifier globalKey; /** on what operating system should this dependency path be used? note that this is *not* the os that is targeted by the project, diff --git a/extras/Introjucer/Source/Utility/jucer_PresetIDs.h b/extras/Introjucer/Source/Utility/jucer_PresetIDs.h index c4f29e7452..add7a9962a 100644 --- a/extras/Introjucer/Source/Utility/jucer_PresetIDs.h +++ b/extras/Introjucer/Source/Utility/jucer_PresetIDs.h @@ -55,6 +55,10 @@ namespace Ids DECLARE_ID (vst3Folder); DECLARE_ID (rtasFolder); DECLARE_ID (auFolder); + DECLARE_ID (vst2Path); + DECLARE_ID (vst3Path); + DECLARE_ID (rtasPath); + DECLARE_ID (aaxPath); DECLARE_ID (flags); DECLARE_ID (line); DECLARE_ID (index); diff --git a/extras/Introjucer/Source/Utility/jucer_StoredSettings.cpp b/extras/Introjucer/Source/Utility/jucer_StoredSettings.cpp index d5d58d5697..3a3a894d6a 100644 --- a/extras/Introjucer/Source/Utility/jucer_StoredSettings.cpp +++ b/extras/Introjucer/Source/Utility/jucer_StoredSettings.cpp @@ -216,3 +216,104 @@ void StoredSettings::ColourSelectorWithSwatches::setSwatchColour (int index, con { getAppSettings().swatchColours.set (index, newColour); } + +//============================================================================== +static bool doesSDKPathContainFile (const String& path, const String& fileToCheckFor) +{ + return File::getCurrentWorkingDirectory().getChildFile( path + "/" + fileToCheckFor).existsAsFile(); +} + +Value StoredSettings::getGlobalPath (const Identifier& key, DependencyPathOS os) +{ + Value v (projectDefaults.getPropertyAsValue (key, nullptr)); + + if (v.toString().isEmpty()) + v = getFallbackPath (key, os); + + return v; +} + +String StoredSettings::getFallbackPath (const Identifier& key, DependencyPathOS os) +{ + if (key == Ids::vst2Path || key == Ids::vst3Path) + return os == TargetOS::windows ? "c:\\SDKs\\VST3 SDK" + : "~/SDKs/VST3 SDK"; + + if (key == Ids::rtasPath) + { + if (os == TargetOS::windows) return "c:\\SDKs\\PT_80_SDK"; + if (os == TargetOS::osx) return "~/SDKs/PT_80_SDK"; + + // no RTAS on this OS! + jassertfalse; + return String(); + } + + if (key == Ids::aaxPath) + { + if (os == TargetOS::windows) return "c:\\SDKs\\AAX"; + if (os == TargetOS::osx) return "~/SDKs/AAX" ; + + // no AAX on this OS! + jassertfalse; + return String(); + } + + if (key == Ids::androidSDKPath) + return os == TargetOS::windows ? "c:\\SDKs\\android-sdk" + : "~/Library/Android/sdk"; + + if (key == Ids::androidNDKPath) + return os == TargetOS::windows ? "c:\\SDKs\\android-ndk" + : "~/Library/Android/ndk"; + + // didn't recognise the key provided! + jassertfalse; + return String(); +} + +bool StoredSettings::isGlobalPathValid (const Identifier& key, const String& path) +{ + String fileToCheckFor; + + if (key == Ids::vst2Path) + { + fileToCheckFor = "public.sdk/source/vst2.x/audioeffectx.h"; + } + else if (key == Ids::vst3Path) + { + fileToCheckFor = "base/source/baseiids.cpp"; + } + else if (key == Ids::rtasPath) + { + fileToCheckFor = "AlturaPorts/TDMPlugIns/PlugInLibrary/EffectClasses/CEffectProcessMIDI.cpp"; + } + else if (key == Ids::aaxPath) + { + fileToCheckFor = "Interfaces/AAX_Exports.cpp"; + } + else if (key == Ids::androidSDKPath) + { + #if JUCE_WINDOWS + fileToCheckFor = "platform-tools/adb.exe"; + #else + fileToCheckFor = "platform-tools/adb"; + #endif + } + else if (key == Ids::androidNDKPath) + { + #if JUCE_WINDOWS + fileToCheckFor = "ndk-depends.exe"; + #else + fileToCheckFor = "ndk-depends"; + #endif + } + else + { + // didn't recognise the key provided! + jassertfalse; + return false; + } + + return doesSDKPathContainFile (path, fileToCheckFor); +} \ No newline at end of file diff --git a/extras/Introjucer/Source/Utility/jucer_StoredSettings.h b/extras/Introjucer/Source/Utility/jucer_StoredSettings.h index fefa0a6ce9..136450a685 100644 --- a/extras/Introjucer/Source/Utility/jucer_StoredSettings.h +++ b/extras/Introjucer/Source/Utility/jucer_StoredSettings.h @@ -41,13 +41,6 @@ public: void flush(); void reload(); - //============================================================================== - void valueTreePropertyChanged (ValueTree&, const Identifier&) override { changed(); } - void valueTreeChildAdded (ValueTree&, ValueTree&) override { changed(); } - void valueTreeChildRemoved (ValueTree&, ValueTree&, int) override { changed(); } - void valueTreeChildOrderChanged (ValueTree&, int, int) override { changed(); } - void valueTreeParentChanged (ValueTree&) override { changed(); } - //============================================================================== RecentlyOpenedFilesList recentFiles; @@ -71,11 +64,14 @@ public: StringArray monospacedFontNames; - ValueTree projectDefaults; - std::map pathValues; + //============================================================================== + Value getGlobalPath (const Identifier& key, DependencyPathOS); + String getFallbackPath (const Identifier& key, DependencyPathOS); + bool isGlobalPathValid (const Identifier& key, const String& path); private: OwnedArray propertyFiles; + ValueTree projectDefaults; void changed() { @@ -91,6 +87,13 @@ private: void loadSwatchColours(); void saveSwatchColours(); + //============================================================================== + void valueTreePropertyChanged (ValueTree&, const Identifier&) override { changed(); } + void valueTreeChildAdded (ValueTree&, ValueTree&) override { changed(); } + void valueTreeChildRemoved (ValueTree&, ValueTree&, int) override { changed(); } + void valueTreeChildOrderChanged (ValueTree&, int, int) override { changed(); } + void valueTreeParentChanged (ValueTree&) override { changed(); } + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StoredSettings) };