forked from teamnwah/openmw-tes3coop
Add a MyGUI plugin to register OpenMW resources, to use with MyGUI's standalone tools
parent
f3d4b63aaf
commit
ecfc2ff5d0
@ -0,0 +1,24 @@
|
||||
set (MYGUI_RESOURCE_PLUGIN_SOURCES
|
||||
plugin.hpp
|
||||
plugin.cpp
|
||||
plugin_export.cpp
|
||||
)
|
||||
|
||||
set (MYGUI_RESOURCE_PLUGIN_LIBRARY
|
||||
Plugin_MyGUI_OpenMW_Resources
|
||||
)
|
||||
|
||||
add_definitions("-D_USRDLL -DMYGUI_BUILD_DLL")
|
||||
|
||||
add_library(${MYGUI_RESOURCE_PLUGIN_LIBRARY}
|
||||
SHARED
|
||||
${MYGUI_RESOURCE_PLUGIN_SOURCES}
|
||||
)
|
||||
|
||||
set_target_properties(${MYGUI_RESOURCE_PLUGIN_LIBRARY} PROPERTIES PREFIX "")
|
||||
|
||||
target_link_libraries(${MYGUI_RESOURCE_PLUGIN_LIBRARY}
|
||||
${OGRE_LIBRARIES}
|
||||
${MYGUI_LIBRARIES}
|
||||
components
|
||||
)
|
@ -0,0 +1,75 @@
|
||||
#include "plugin.hpp"
|
||||
|
||||
#include <MyGUI_LogManager.h>
|
||||
|
||||
#include <components/bsa/resources.hpp>
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
|
||||
namespace MyGUI
|
||||
{
|
||||
|
||||
const std::string& ResourcePlugin::getName() const
|
||||
{
|
||||
static const std::string name = "OpenMW resource plugin";
|
||||
return name;
|
||||
}
|
||||
|
||||
void ResourcePlugin::install()
|
||||
{
|
||||
|
||||
}
|
||||
void ResourcePlugin::uninstall()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ResourcePlugin::initialize()
|
||||
{
|
||||
MYGUI_LOGGING("OpenMW_Resource_Plugin", Info, "initialize");
|
||||
|
||||
boost::program_options::variables_map variables;
|
||||
|
||||
boost::program_options::options_description desc("Allowed options");
|
||||
desc.add_options()
|
||||
("data", boost::program_options::value<Files::PathContainer>()->default_value(Files::PathContainer(), "data")->multitoken())
|
||||
("data-local", boost::program_options::value<std::string>()->default_value(""))
|
||||
("fs-strict", boost::program_options::value<bool>()->implicit_value(true)->default_value(false))
|
||||
("fallback-archive", boost::program_options::value<std::vector<std::string> >()->
|
||||
default_value(std::vector<std::string>(), "fallback-archive")->multitoken());
|
||||
|
||||
boost::program_options::notify(variables);
|
||||
|
||||
Files::ConfigurationManager cfgManager;
|
||||
cfgManager.readConfiguration(variables, desc);
|
||||
|
||||
std::vector<std::string> archives = variables["fallback-archive"].as<std::vector<std::string> >();
|
||||
bool fsStrict = variables["fs-strict"].as<bool>();
|
||||
|
||||
Files::PathContainer dataDirs, dataLocal;
|
||||
if (!variables["data"].empty()) {
|
||||
dataDirs = Files::PathContainer(variables["data"].as<Files::PathContainer>());
|
||||
}
|
||||
|
||||
std::string local = variables["data-local"].as<std::string>();
|
||||
if (!local.empty()) {
|
||||
dataLocal.push_back(Files::PathContainer::value_type(local));
|
||||
}
|
||||
|
||||
cfgManager.processPaths (dataDirs);
|
||||
cfgManager.processPaths (dataLocal, true);
|
||||
|
||||
if (!dataLocal.empty())
|
||||
dataDirs.insert (dataDirs.end(), dataLocal.begin(), dataLocal.end());
|
||||
|
||||
Files::Collections collections (dataDirs, !fsStrict);
|
||||
|
||||
Bsa::registerResources(collections, archives, true, fsStrict);
|
||||
}
|
||||
|
||||
void ResourcePlugin::shutdown()
|
||||
{
|
||||
/// \todo remove resource groups
|
||||
MYGUI_LOGGING("OpenMW_Resource_Plugin", Info, "shutdown");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
#ifndef OPENMW_MYGUI_RESOURCE_PLUGIN_H
|
||||
#define OPENMW_MYGUI_RESOURCE_PLUGIN_H
|
||||
|
||||
#include <MyGUI_Plugin.h>
|
||||
|
||||
namespace MyGUI
|
||||
{
|
||||
|
||||
class ResourcePlugin : public MyGUI::IPlugin
|
||||
{
|
||||
/*! Get the name of the plugin.
|
||||
@remarks An implementation must be supplied for this method to uniquely
|
||||
identify the plugin
|
||||
*/
|
||||
virtual const std::string& getName() const;
|
||||
|
||||
/*! Perform the plugin initial installation sequence
|
||||
*/
|
||||
virtual void install();
|
||||
|
||||
/*! Perform any tasks the plugin needs to perform on full system
|
||||
initialisation.
|
||||
*/
|
||||
virtual void initialize();
|
||||
|
||||
/*! Perform any tasks the plugin needs to perform when the system is shut down
|
||||
*/
|
||||
virtual void shutdown();
|
||||
|
||||
/*! Perform the final plugin uninstallation sequence
|
||||
*/
|
||||
virtual void uninstall();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,17 @@
|
||||
#include "plugin.hpp"
|
||||
#include "MyGUI_PluginManager.h"
|
||||
|
||||
MyGUI::ResourcePlugin* plugin_item = nullptr;
|
||||
|
||||
extern "C" MYGUI_EXPORT_DLL void dllStartPlugin(void)
|
||||
{
|
||||
plugin_item = new MyGUI::ResourcePlugin();
|
||||
MyGUI::PluginManager::getInstance().installPlugin(plugin_item);
|
||||
}
|
||||
|
||||
extern "C" MYGUI_EXPORT_DLL void dllStopPlugin(void)
|
||||
{
|
||||
MyGUI::PluginManager::getInstance().uninstallPlugin(plugin_item);
|
||||
delete plugin_item;
|
||||
plugin_item = nullptr;
|
||||
}
|
Loading…
Reference in New Issue