Skip to content

Commit

Permalink
Merge pull request #6 from rolandoislas/develop
Browse files Browse the repository at this point in the history
Multiple instances and profiles
  • Loading branch information
rolandoislas authored Sep 23, 2016
2 parents e0232ea + cb69f21 commit 03cb4d0
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 28 deletions.
30 changes: 15 additions & 15 deletions LightHost.jucer
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
pluginSilenceInIsSilenceOut="0" pluginTailLength="0" pluginEditorRequiresKeys="0"
pluginAUExportPrefix="JuceProjectAU" pluginAUViewClass="JuceProjectAU_V1"
pluginRTASCategory="" bundleIdentifier="com.rolandoislas.lighthost"
jucerVersion="4.2.1" companyName="Rolando Islas" includeBinaryInAppConfig="1"
jucerVersion="4.2.4" companyName="Rolando Islas" includeBinaryInAppConfig="1"
companyWebsite="https://www.rolandoislas.com" companyEmail="[email protected]">
<EXPORTFORMATS>
<XCODE_MAC targetFolder="Builds/MacOSX" vstFolder="" rtasFolder="~/SDKs/PT_80_SDK"
Expand Down Expand Up @@ -137,20 +137,20 @@
JUCE_PLUGINHOST_VST="enabled" JUCE_PLUGINHOST_AU="enabled" JUCE_WEB_BROWSER="disabled"
JUCE_PLUGINHOST_VST3="enabled" JUCE_ASIO="enabled"/>
<MODULES>
<MODULE id="juce_audio_basics" showAllCode="1"/>
<MODULE id="juce_audio_devices" showAllCode="1"/>
<MODULE id="juce_audio_formats" showAllCode="1"/>
<MODULE id="juce_audio_processors" showAllCode="1"/>
<MODULE id="juce_audio_utils" showAllCode="1"/>
<MODULE id="juce_core" showAllCode="1"/>
<MODULE id="juce_cryptography" showAllCode="1"/>
<MODULE id="juce_data_structures" showAllCode="1"/>
<MODULE id="juce_events" showAllCode="1"/>
<MODULE id="juce_graphics" showAllCode="1"/>
<MODULE id="juce_gui_basics" showAllCode="1"/>
<MODULE id="juce_gui_extra" showAllCode="1"/>
<MODULE id="juce_opengl" showAllCode="1"/>
<MODULE id="juce_video" showAllCode="1"/>
<MODULE id="juce_audio_basics" showAllCode="1" useLocalCopy="1"/>
<MODULE id="juce_audio_devices" showAllCode="1" useLocalCopy="1"/>
<MODULE id="juce_audio_formats" showAllCode="1" useLocalCopy="1"/>
<MODULE id="juce_audio_processors" showAllCode="1" useLocalCopy="1"/>
<MODULE id="juce_audio_utils" showAllCode="1" useLocalCopy="1"/>
<MODULE id="juce_core" showAllCode="1" useLocalCopy="1"/>
<MODULE id="juce_cryptography" showAllCode="1" useLocalCopy="1"/>
<MODULE id="juce_data_structures" showAllCode="1" useLocalCopy="1"/>
<MODULE id="juce_events" showAllCode="1" useLocalCopy="1"/>
<MODULE id="juce_graphics" showAllCode="1" useLocalCopy="1"/>
<MODULE id="juce_gui_basics" showAllCode="1" useLocalCopy="1"/>
<MODULE id="juce_gui_extra" showAllCode="1" useLocalCopy="1"/>
<MODULE id="juce_opengl" showAllCode="1" useLocalCopy="1"/>
<MODULE id="juce_video" showAllCode="1" useLocalCopy="1"/>
</MODULES>
<LIVE_SETTINGS>
<OSX headerPath=""/>
Expand Down
46 changes: 33 additions & 13 deletions Source/HostStartup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

class PluginHostApp : public JUCEApplication
{

public:
PluginHostApp() {}

Expand All @@ -17,6 +18,8 @@ class PluginHostApp : public JUCEApplication
options.filenameSuffix = "settings";
options.osxLibrarySubFolder = "Preferences";

checkArguments(&options);

appProperties = new ApplicationProperties();
appProperties->setStorageParameters (options);

Expand All @@ -26,16 +29,6 @@ class PluginHostApp : public JUCEApplication
#if JUCE_MAC
Process::setDockIconVisible(false);
#endif

File fileToOpen;

for (int i = 0; i < getCommandLineParameterArray().size(); ++i)
{
fileToOpen = File::getCurrentWorkingDirectory().getChildFile (getCommandLineParameterArray()[i]);

if (fileToOpen.existsAsFile())
break;
}
}

void shutdown() override
Expand All @@ -52,15 +45,42 @@ class PluginHostApp : public JUCEApplication

const String getApplicationName() override { return "Light Host"; }
const String getApplicationVersion() override { return ProjectInfo::versionString; }
bool moreThanOneInstanceAllowed() override { return false; }
bool moreThanOneInstanceAllowed() override {
StringArray multiInstance = getParameter("-multi-instance");
return multiInstance.size() == 2;
}

ApplicationCommandManager commandManager;
ScopedPointer<ApplicationProperties> appProperties;
LookAndFeel_V3 lookAndFeel;

private:
ScopedPointer<IconMenu> mainWindow;
};
ScopedPointer<IconMenu> mainWindow;

StringArray getParameter(String lookFor) {
StringArray parameters = getCommandLineParameterArray();
StringArray found;
for (int i = 0; i < parameters.size(); ++i)
{
String param = parameters[i];
if (param.contains(lookFor))
{
found.add(lookFor);
int delimiter = param.indexOf(0, "=") + 1;
String val = param.substring(delimiter);
found.add(val);
return found;
}
}
return found;
}

void checkArguments(PropertiesFile::Options *options) {
StringArray multiInstance = getParameter("-multi-instance");
if (multiInstance.size() == 2)
options->filenameSuffix = multiInstance[1] + "." + options->filenameSuffix;
}
};

static PluginHostApp& getApp() { return *dynamic_cast<PluginHostApp*>(JUCEApplication::getInstance()); }
ApplicationCommandManager& getCommandManager() { return getApp().commandManager; }
Expand Down
1 change: 1 addition & 0 deletions Source/IconMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "IconMenu.hpp"
#include "PluginWindow.h"
#include <ctime>
#include <limits.h>
#if JUCE_WINDOWS
#include "Windows.h"
#endif
Expand Down

0 comments on commit 03cb4d0

Please sign in to comment.