From 977b4075254ca79e68bbdec2e689eccb291fe701 Mon Sep 17 00:00:00 2001 From: Tannin Date: Tue, 13 May 2014 21:20:44 +0200 Subject: - mod list context menu split into two menus (one for whole list, one for selected mods) - added option to combine category filters using "or" - added context menu option for deselecting category filters - slightly changed ui on the category filters - added a sample plugin for cpp that can be built without building the rest of MO - simple installer can now be configured to run without any user interaction - extended interface for python plugins - iorganizer implementation moved out of the main window - nexus requests from plugins will now be identified in the user agent - bugfix: shortcuts created from MO used the wrong working directory - bugfix: deactivation of bsas didn't stick - bugfix: file hiding mechanism wasn't active - bugfix: executables linked on the toolbar couldn't be removed if the executable was removed first - bugfix: the endorsement-filter couldn't be combined with other filters - bugfix: python interface to repository bridge was broken --- src/organizerproxy.cpp | 185 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 src/organizerproxy.cpp (limited to 'src/organizerproxy.cpp') diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp new file mode 100644 index 00000000..f17d7cd9 --- /dev/null +++ b/src/organizerproxy.cpp @@ -0,0 +1,185 @@ +#include "organizerproxy.h" +#include +#include + + +using namespace MOBase; +using namespace MOShared; + + +OrganizerProxy::OrganizerProxy(MainWindow *window, const QString &pluginName) + : m_Proxied(window) + , m_PluginName(pluginName) +{ +} + +IGameInfo &OrganizerProxy::gameInfo() const +{ + return *m_Proxied->m_GameInfo; +} + + +IModRepositoryBridge *OrganizerProxy::createNexusBridge() const +{ + return new NexusBridge(m_PluginName); +} + + +QString OrganizerProxy::profileName() const +{ + if (m_Proxied->m_CurrentProfile != NULL) { + return m_Proxied->m_CurrentProfile->getName(); + } else { + return ""; + } +} + +QString OrganizerProxy::profilePath() const +{ + if (m_Proxied->m_CurrentProfile != NULL) { + return m_Proxied->m_CurrentProfile->getPath(); + } else { + return ""; + } +} + +QString OrganizerProxy::downloadsPath() const +{ + return QDir::fromNativeSeparators(m_Proxied->m_Settings.getDownloadDirectory()); +} + +VersionInfo OrganizerProxy::appVersion() const +{ + return m_Proxied->m_Updater.getVersion(); +} + +IModInterface *OrganizerProxy::getMod(const QString &name) +{ + return m_Proxied->getMod(name); +} + +IModInterface *OrganizerProxy::createMod(MOBase::GuessedValue &name) +{ + return m_Proxied->createMod(name); +} + +bool OrganizerProxy::removeMod(IModInterface *mod) +{ + return m_Proxied->removeMod(mod); +} + +void OrganizerProxy::modDataChanged(IModInterface*) +{ + m_Proxied->refreshModList(); +} + +QVariant OrganizerProxy::pluginSetting(const QString &pluginName, const QString &key) const +{ + return m_Proxied->m_Settings.pluginSetting(pluginName, key); +} + +void OrganizerProxy::setPluginSetting(const QString &pluginName, const QString &key, const QVariant &value) +{ + m_Proxied->m_Settings.setPluginSetting(pluginName, key, value); +} + +QVariant OrganizerProxy::persistent(const QString &pluginName, const QString &key, const QVariant &def) const +{ + return m_Proxied->m_Settings.pluginPersistent(pluginName, key, def); +} + +void OrganizerProxy::setPersistent(const QString &pluginName, const QString &key, const QVariant &value, bool sync) +{ + m_Proxied->m_Settings.setPluginPersistent(pluginName, key, value, sync); +} + +QString OrganizerProxy::pluginDataPath() const +{ + QString pluginPath = QDir::fromNativeSeparators(ToQString(GameInfo::instance().getOrganizerDirectory())) + "/" + ToQString(AppConfig::pluginPath()); + return pluginPath + "/data"; +} + +HANDLE OrganizerProxy::startApplication(const QString &executable, const QStringList &args, const QString &cwd, const QString &profile) +{ + return m_Proxied->startApplication(executable, args, cwd, profile); +} + +bool OrganizerProxy::onAboutToRun(const std::function &func) +{ + auto conn = m_Proxied->m_AboutToRun.connect(func); + return conn.connected(); +} + +void OrganizerProxy::refreshModList(bool saveChanges) +{ + m_Proxied->refreshModList(saveChanges); +} + +IModInterface *OrganizerProxy::installMod(const QString &fileName) +{ + return m_Proxied->installMod(fileName); +} + +QString OrganizerProxy::resolvePath(const QString &fileName) const +{ + if (m_Proxied->m_DirectoryStructure == NULL) { + return QString(); + } + const FileEntry::Ptr file = m_Proxied->m_DirectoryStructure->searchFile(ToWString(fileName), NULL); + if (file.get() != NULL) { + return ToQString(file->getFullPath()); + } else { + return QString(); + } +} + +QStringList OrganizerProxy::listDirectories(const QString &directoryName) const +{ + QStringList result; + DirectoryEntry *dir = m_Proxied->m_DirectoryStructure->findSubDirectoryRecursive(ToWString(directoryName)); + if (dir != NULL) { + std::vector::iterator current, end; + dir->getSubDirectories(current, end); + for (; current != end; ++current) { + result.append(ToQString((*current)->getName())); + } + } + return result; +} + +QStringList OrganizerProxy::findFiles(const QString &path, const std::function &filter) const +{ + QStringList result; + DirectoryEntry *dir = m_Proxied->m_DirectoryStructure->findSubDirectoryRecursive(ToWString(path)); + if (dir != NULL) { + std::vector files = dir->getFiles(); + foreach (FileEntry::Ptr file, files) { + if (filter(ToQString(file->getFullPath()))) { + result.append(ToQString(file->getFullPath())); + } + } + } else { + qWarning("directory %s not found", qPrintable(path)); + } + return result; +} + +QList OrganizerProxy::findFileInfos(const QString &path, const std::function &filter) const +{ + return m_Proxied->findFileInfos(path, filter); +} + +MOBase::IDownloadManager *OrganizerProxy::downloadManager() +{ + return &m_Proxied->m_DownloadManager; +} + +MOBase::IPluginList *OrganizerProxy::pluginList() +{ + return &m_Proxied->m_PluginList; +} + +MOBase::IModList *OrganizerProxy::modList() +{ + return &m_Proxied->m_ModList; +} -- cgit v1.3.1