forked from mirror/openmw-tes3mp
Add a MyGUI plugin to register OpenMW resources, to use with MyGUI's standalone tools
This commit is contained in:
parent
f3d4b63aaf
commit
ecfc2ff5d0
6 changed files with 192 additions and 19 deletions
|
@ -78,6 +78,7 @@ option(BUILD_OPENCS "build OpenMW Construction Set" ON)
|
||||||
option(BUILD_WITH_CODE_COVERAGE "Enable code coverage with gconv" OFF)
|
option(BUILD_WITH_CODE_COVERAGE "Enable code coverage with gconv" OFF)
|
||||||
option(BUILD_UNITTESTS "Enable Unittests with Google C++ Unittest ang GMock frameworks" OFF)
|
option(BUILD_UNITTESTS "Enable Unittests with Google C++ Unittest ang GMock frameworks" OFF)
|
||||||
option(BUILD_NIFTEST "build nif file tester" OFF)
|
option(BUILD_NIFTEST "build nif file tester" OFF)
|
||||||
|
option(BUILD_MYGUI_PLUGIN "build MyGUI plugin for OpenMW resources, to use with MyGUI tools" ON)
|
||||||
|
|
||||||
# OS X deployment
|
# OS X deployment
|
||||||
option(OPENMW_OSX_DEPLOYMENT OFF)
|
option(OPENMW_OSX_DEPLOYMENT OFF)
|
||||||
|
@ -103,32 +104,32 @@ cmake_minimum_required(VERSION 2.6)
|
||||||
|
|
||||||
# source directory: libs
|
# source directory: libs
|
||||||
|
|
||||||
set(LIBDIR ${CMAKE_SOURCE_DIR}/libs)
|
set(LIBS_DIR ${CMAKE_SOURCE_DIR}/libs)
|
||||||
|
|
||||||
set(OENGINE_OGRE
|
set(OENGINE_OGRE
|
||||||
${LIBDIR}/openengine/ogre/renderer.cpp
|
${LIBS_DIR}/openengine/ogre/renderer.cpp
|
||||||
${LIBDIR}/openengine/ogre/lights.cpp
|
${LIBS_DIR}/openengine/ogre/lights.cpp
|
||||||
${LIBDIR}/openengine/ogre/selectionbuffer.cpp
|
${LIBS_DIR}/openengine/ogre/selectionbuffer.cpp
|
||||||
${LIBDIR}/openengine/ogre/imagerotate.cpp
|
${LIBS_DIR}/openengine/ogre/imagerotate.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(OENGINE_GUI
|
set(OENGINE_GUI
|
||||||
${LIBDIR}/openengine/gui/loglistener.cpp
|
${LIBS_DIR}/openengine/gui/loglistener.cpp
|
||||||
${LIBDIR}/openengine/gui/manager.cpp
|
${LIBS_DIR}/openengine/gui/manager.cpp
|
||||||
${LIBDIR}/openengine/gui/layout.hpp
|
${LIBS_DIR}/openengine/gui/layout.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(OENGINE_BULLET
|
set(OENGINE_BULLET
|
||||||
${LIBDIR}/openengine/bullet/BtOgre.cpp
|
${LIBS_DIR}/openengine/bullet/BtOgre.cpp
|
||||||
${LIBDIR}/openengine/bullet/BtOgreExtras.h
|
${LIBS_DIR}/openengine/bullet/BtOgreExtras.h
|
||||||
${LIBDIR}/openengine/bullet/BtOgreGP.h
|
${LIBS_DIR}/openengine/bullet/BtOgreGP.h
|
||||||
${LIBDIR}/openengine/bullet/BtOgrePG.h
|
${LIBS_DIR}/openengine/bullet/BtOgrePG.h
|
||||||
${LIBDIR}/openengine/bullet/physic.cpp
|
${LIBS_DIR}/openengine/bullet/physic.cpp
|
||||||
${LIBDIR}/openengine/bullet/physic.hpp
|
${LIBS_DIR}/openengine/bullet/physic.hpp
|
||||||
${LIBDIR}/openengine/bullet/BulletShapeLoader.cpp
|
${LIBS_DIR}/openengine/bullet/BulletShapeLoader.cpp
|
||||||
${LIBDIR}/openengine/bullet/BulletShapeLoader.h
|
${LIBS_DIR}/openengine/bullet/BulletShapeLoader.h
|
||||||
${LIBDIR}/openengine/bullet/trace.cpp
|
${LIBS_DIR}/openengine/bullet/trace.cpp
|
||||||
${LIBDIR}/openengine/bullet/trace.h
|
${LIBS_DIR}/openengine/bullet/trace.h
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -261,7 +262,7 @@ include_directories("."
|
||||||
${MYGUI_INCLUDE_DIRS}
|
${MYGUI_INCLUDE_DIRS}
|
||||||
${MYGUI_PLATFORM_INCLUDE_DIRS}
|
${MYGUI_PLATFORM_INCLUDE_DIRS}
|
||||||
${OPENAL_INCLUDE_DIR}
|
${OPENAL_INCLUDE_DIR}
|
||||||
${LIBDIR}
|
${LIBS_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
link_directories(${SDL2_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ${OGRE_LIB_DIR} ${MYGUI_LIB_DIR})
|
link_directories(${SDL2_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ${OGRE_LIB_DIR} ${MYGUI_LIB_DIR})
|
||||||
|
@ -333,8 +334,10 @@ add_subdirectory(files/mygui)
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${APP_BUNDLE_DIR}/Contents/MacOS")
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${APP_BUNDLE_DIR}/Contents/MacOS")
|
||||||
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${APP_BUNDLE_DIR}/Contents/MacOS")
|
||||||
else (APPLE)
|
else (APPLE)
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${OpenMW_BINARY_DIR}")
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${OpenMW_BINARY_DIR}")
|
||||||
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${OpenMW_BINARY_DIR}")
|
||||||
endif (APPLE)
|
endif (APPLE)
|
||||||
|
|
||||||
# Other files
|
# Other files
|
||||||
|
@ -379,6 +382,7 @@ IF(NOT WIN32 AND NOT APPLE)
|
||||||
# Linux building
|
# Linux building
|
||||||
# Paths
|
# Paths
|
||||||
SET(BINDIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Where to install binaries")
|
SET(BINDIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Where to install binaries")
|
||||||
|
SET(LIBDIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Where to install libraries")
|
||||||
SET(DATAROOTDIR "${CMAKE_INSTALL_PREFIX}/share" CACHE PATH "Sets the root of data directories to a non-default location")
|
SET(DATAROOTDIR "${CMAKE_INSTALL_PREFIX}/share" CACHE PATH "Sets the root of data directories to a non-default location")
|
||||||
SET(DATADIR "${DATAROOTDIR}/games/openmw" CACHE PATH "Sets the openmw data directories to a non-default location")
|
SET(DATADIR "${DATAROOTDIR}/games/openmw" CACHE PATH "Sets the openmw data directories to a non-default location")
|
||||||
SET(ICONDIR "${DATAROOTDIR}/pixmaps" CACHE PATH "Set icon dir")
|
SET(ICONDIR "${DATAROOTDIR}/pixmaps" CACHE PATH "Set icon dir")
|
||||||
|
@ -405,6 +409,9 @@ IF(NOT WIN32 AND NOT APPLE)
|
||||||
IF(BUILD_NIFTEST)
|
IF(BUILD_NIFTEST)
|
||||||
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/niftest" DESTINATION "${BINDIR}" )
|
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/niftest" DESTINATION "${BINDIR}" )
|
||||||
ENDIF(BUILD_NIFTEST)
|
ENDIF(BUILD_NIFTEST)
|
||||||
|
if(BUILD_MYGUI_PLUGIN)
|
||||||
|
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/Plugin_MyGUI_OpenMW_Resources.so" DESTINATION "${LIBDIR}" )
|
||||||
|
ENDIF(BUILD_MYGUI_PLUGIN)
|
||||||
|
|
||||||
# Install licenses
|
# Install licenses
|
||||||
INSTALL(FILES "docs/license/DejaVu Font License.txt" DESTINATION "${LICDIR}" )
|
INSTALL(FILES "docs/license/DejaVu Font License.txt" DESTINATION "${LICDIR}" )
|
||||||
|
@ -454,6 +461,9 @@ if(WIN32)
|
||||||
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/Release/opencs.exe" DESTINATION ".")
|
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/Release/opencs.exe" DESTINATION ".")
|
||||||
INSTALL(FILES "${OpenMW_BINARY_DIR}/opencs.ini" DESTINATION ".")
|
INSTALL(FILES "${OpenMW_BINARY_DIR}/opencs.ini" DESTINATION ".")
|
||||||
ENDIF(BUILD_OPENCS)
|
ENDIF(BUILD_OPENCS)
|
||||||
|
if(BUILD_MYGUI_PLUGIN)
|
||||||
|
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/Release/Plugin_MyGUI_OpenMW_Resources.dll" DESTINATION ".")
|
||||||
|
ENDIF(BUILD_MYGUI_PLUGIN)
|
||||||
|
|
||||||
INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION ".")
|
INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION ".")
|
||||||
|
|
||||||
|
@ -521,6 +531,10 @@ add_subdirectory (extern/sdl4ogre)
|
||||||
# Components
|
# Components
|
||||||
add_subdirectory (components)
|
add_subdirectory (components)
|
||||||
|
|
||||||
|
if (BUILD_MYGUI_PLUGIN)
|
||||||
|
add_subdirectory(libs/mygui_resource_plugin)
|
||||||
|
endif()
|
||||||
|
|
||||||
#Testing
|
#Testing
|
||||||
if (BUILD_NIFTEST)
|
if (BUILD_NIFTEST)
|
||||||
add_subdirectory(components/nif/tests/)
|
add_subdirectory(components/nif/tests/)
|
||||||
|
|
|
@ -112,6 +112,12 @@ if(QT_QTGUI_LIBRARY AND QT_QTCORE_LIBRARY)
|
||||||
QT4_WRAP_CPP(MOC_SRCS ${COMPONENT_MOC_FILES})
|
QT4_WRAP_CPP(MOC_SRCS ${COMPONENT_MOC_FILES})
|
||||||
endif(QT_QTGUI_LIBRARY AND QT_QTCORE_LIBRARY)
|
endif(QT_QTGUI_LIBRARY AND QT_QTCORE_LIBRARY)
|
||||||
|
|
||||||
|
if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" AND NOT APPLE)
|
||||||
|
add_definitions(-fPIC)
|
||||||
|
endif()
|
||||||
|
endif ()
|
||||||
|
|
||||||
include_directories(${BULLET_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR})
|
include_directories(${BULLET_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
add_library(components STATIC ${COMPONENT_FILES} ${MOC_SRCS} ${ESM_UI_HDR})
|
add_library(components STATIC ${COMPONENT_FILES} ${MOC_SRCS} ${ESM_UI_HDR})
|
||||||
|
|
24
libs/mygui_resource_plugin/CMakeLists.txt
Normal file
24
libs/mygui_resource_plugin/CMakeLists.txt
Normal file
|
@ -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
|
||||||
|
)
|
75
libs/mygui_resource_plugin/plugin.cpp
Normal file
75
libs/mygui_resource_plugin/plugin.cpp
Normal file
|
@ -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");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
37
libs/mygui_resource_plugin/plugin.hpp
Normal file
37
libs/mygui_resource_plugin/plugin.hpp
Normal file
|
@ -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
|
17
libs/mygui_resource_plugin/plugin_export.cpp
Normal file
17
libs/mygui_resource_plugin/plugin_export.cpp
Normal file
|
@ -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 a new issue