Added the option to specify the custom path for loading plugins

svn-id: r31960
This commit is contained in:
Jordi Vilalta Prat 2008-05-09 01:58:12 +00:00
parent c7c8bb99ee
commit 420d376a90
6 changed files with 60 additions and 1 deletions

View File

@ -26,6 +26,10 @@
#include "base/plugins.h"
#include "common/util.h"
#ifdef DYNAMIC_MODULES
#include "common/config-manager.h"
#endif
int pluginTypeVersions[PLUGIN_TYPE_MAX] = {
PLUGIN_TYPE_ENGINE_VERSION,
};
@ -168,13 +172,21 @@ PluginList FilePluginProvider::getPlugins() {
// Prepare the list of directories to search
Common::StringList pluginDirs;
// TODO: Add the user specified directory (via config file)
// Add the default directories
pluginDirs.push_back(".");
pluginDirs.push_back("plugins");
// Add the provider's custom directories
addCustomDirectories(pluginDirs);
// Add the user specified directory
Common::String pluginsPath(ConfMan.get("pluginspath"));
if (!pluginsPath.empty()) {
FilesystemNode dir(pluginsPath);
pluginDirs.push_back(dir.getPath());
}
Common::StringList::const_iterator d;
for (d = pluginDirs.begin(); d != pluginDirs.end(); d++) {
// Load all plugins.

View File

@ -55,6 +55,7 @@ enum {
kChooseSaveDirCmd = 'chos',
kChooseThemeDirCmd = 'chth',
kChooseExtraDirCmd = 'chex',
kChoosePluginsDirCmd = 'chpl',
kChooseThemeCmd = 'chtf'
};
@ -706,6 +707,11 @@ GlobalOptionsDialog::GlobalOptionsDialog()
new ButtonWidget(tab, "globaloptions_extrabutton", "Extra Path:", kChooseExtraDirCmd, 0);
_extraPath = new StaticTextWidget(tab, "globaloptions_extrapath", "None");
#ifdef DYNAMIC_MODULES
new ButtonWidget(tab, "globaloptions_pluginsbutton", "Plugins Path:", kChoosePluginsDirCmd, 0);
_pluginsPath = new StaticTextWidget(tab, "globaloptions_pluginspath", "None");
#endif
#endif
#ifdef SMALL_SCREEN_DEVICE
@ -772,6 +778,15 @@ void GlobalOptionsDialog::open() {
} else {
_extraPath->setLabel(extraPath);
}
#ifdef DYNAMIC_MODULES
Common::String pluginsPath(ConfMan.get("pluginspath", _domain));
if (pluginsPath.empty() || !ConfMan.hasKey("pluginspath", _domain)) {
_pluginsPath->setLabel("None");
} else {
_pluginsPath->setLabel(pluginsPath);
}
#endif
#endif
// Misc Tab
@ -801,6 +816,14 @@ void GlobalOptionsDialog::close() {
else
ConfMan.removeKey("extrapath", _domain);
#ifdef DYNAMIC_MODULES
String pluginsPath(_pluginsPath->getLabel());
if (!pluginsPath.empty() && (pluginsPath != "None"))
ConfMan.set("pluginspath", pluginsPath, _domain);
else
ConfMan.removeKey("pluginspath", _domain);
#endif
ConfMan.setInt("autosave_period", _autosavePeriodPopUp->getSelectedTag(), _domain);
}
OptionsDialog::close();
@ -844,6 +867,18 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
}
break;
}
#ifdef DYNAMIC_MODULES
case kChoosePluginsDirCmd: {
BrowserDialog browser("Select directory for plugins", true);
if (browser.runModal() > 0) {
// User made his choice...
FilesystemNode dir(browser.getResult());
_pluginsPath->setLabel(dir.getPath());
draw();
}
break;
}
#endif
case kChooseSoundFontCmd: {
BrowserDialog browser("Select SoundFont", false);
if (browser.runModal() > 0) {

View File

@ -158,6 +158,9 @@ protected:
StaticTextWidget *_savePath;
StaticTextWidget *_themePath;
StaticTextWidget *_extraPath;
#ifdef DYNAMIC_MODULES
StaticTextWidget *_pluginsPath;
#endif
//
// Misc controls

View File

@ -215,6 +215,9 @@ const char *Theme::_defaultConfigINI =
"globaloptions_themebutton=10 yoffset (buttonWidth + 5) buttonHeight\n"
"globaloptions_themepath=(prev.x2 + 20) (yoffset + glOff) (parent.w - (prev.w + 20) - 15) kLineHeight\n"
"yoffset=(yoffset + buttonHeight + 4)\n"
"globaloptions_pluginsbutton=10 yoffset (buttonWidth + 5) buttonHeight\n"
"globaloptions_pluginspath=(prev.x2 + 20) (yoffset + glOff) (parent.w - (prev.w + 20) - 15) kLineHeight\n"
"yoffset=(yoffset + buttonHeight + 4)\n"
"globaloptions_keysbutton=10 yoffset (buttonWidth + 5) buttonHeight\n"
"\n"
"# Misc options\n"

View File

@ -134,6 +134,9 @@ yoffset=(yoffset + buttonHeight + 4)
globaloptions_themebutton=10 yoffset (buttonWidth + 5) buttonHeight
globaloptions_themepath=(prev.x2 + 20) (yoffset + glOff) (parent.w - (prev.w + 20) - 15) kLineHeight
yoffset=(yoffset + buttonHeight + 4)
globaloptions_pluginsbutton=10 yoffset (buttonWidth + 5) buttonHeight
globaloptions_pluginspath=(prev.x2 + 20) (yoffset + glOff) (parent.w - (prev.w + 20) - 15) kLineHeight
yoffset=(yoffset + buttonHeight + 4)
globaloptions_keysbutton=10 yoffset (buttonWidth + 5) buttonHeight
# Misc options

View File

@ -295,6 +295,9 @@ yoffset=(yoffset + buttonHeight + ySeparation)
globaloptions_themebutton=xBorder yoffset buttonWidth buttonHeight
globaloptions_themepath=(prev.x2 + xSeparation) (yoffset + glOff) (parent.w - self.x - xBorder) kLineHeight
yoffset=(yoffset + buttonHeight + ySeparation)
globaloptions_pluginsbutton=xBorder yoffset buttonWidth buttonHeight
globaloptions_pluginspath=(prev.x2 + xSeparation) (yoffset + glOff) (parent.w - self.x - xBorder) kLineHeight
yoffset=(yoffset + buttonHeight + ySeparation)
globaloptions_keysbutton=xBorder yoffset buttonWidth buttonHeight
# Misc options