|
|
|
@ -1,13 +1,53 @@
|
|
|
|
|
#include "plugin.hpp"
|
|
|
|
|
|
|
|
|
|
#include <MyGUI_LogManager.h>
|
|
|
|
|
#include <MyGUI_FactoryManager.h>
|
|
|
|
|
#include <MyGUI_ScrollBar.h>
|
|
|
|
|
#include <MyGUI_Gui.h>
|
|
|
|
|
|
|
|
|
|
#include <components/bsa/resources.hpp>
|
|
|
|
|
#include <components/files/configurationmanager.hpp>
|
|
|
|
|
#include <components/fontloader/fontloader.hpp>
|
|
|
|
|
|
|
|
|
|
namespace MyGUI
|
|
|
|
|
#include <OgreTextureManager.h>
|
|
|
|
|
#include <OgreHardwarePixelBuffer.h>
|
|
|
|
|
|
|
|
|
|
namespace MyGUIPlugin
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// Dummy - obsolete when using MyGUI git, because the ScrollBar there has autorepeat support added.
|
|
|
|
|
class MWScrollBar : public MyGUI::ScrollBar
|
|
|
|
|
{
|
|
|
|
|
MYGUI_RTTI_DERIVED(MWScrollBar)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Dummy - not properly supportable without bringing in the whole ESM store
|
|
|
|
|
class MWSkill : public MyGUI::Widget
|
|
|
|
|
{
|
|
|
|
|
MYGUI_RTTI_DERIVED( MWSkill )
|
|
|
|
|
};
|
|
|
|
|
class MWAttribute : public MyGUI::Widget
|
|
|
|
|
{
|
|
|
|
|
MYGUI_RTTI_DERIVED( MWAttribute )
|
|
|
|
|
};
|
|
|
|
|
class MWSpell : public MyGUI::Widget
|
|
|
|
|
{
|
|
|
|
|
MYGUI_RTTI_DERIVED( MWSpell )
|
|
|
|
|
};
|
|
|
|
|
class MWEffectList : public MyGUI::Widget
|
|
|
|
|
{
|
|
|
|
|
MYGUI_RTTI_DERIVED( MWEffectList )
|
|
|
|
|
};
|
|
|
|
|
class MWSpellEffect : public MyGUI::Widget
|
|
|
|
|
{
|
|
|
|
|
MYGUI_RTTI_DERIVED( MWSpellEffect )
|
|
|
|
|
};
|
|
|
|
|
class MWDynamicStat : public MyGUI::Widget
|
|
|
|
|
{
|
|
|
|
|
MYGUI_RTTI_DERIVED( MWDynamicStat )
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const std::string& ResourcePlugin::getName() const
|
|
|
|
|
{
|
|
|
|
|
static const std::string name = "OpenMW resource plugin";
|
|
|
|
@ -23,10 +63,8 @@ namespace MyGUI
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ResourcePlugin::initialize()
|
|
|
|
|
void ResourcePlugin::registerResources()
|
|
|
|
|
{
|
|
|
|
|
MYGUI_LOGGING("OpenMW_Resource_Plugin", Info, "initialize");
|
|
|
|
|
|
|
|
|
|
boost::program_options::variables_map variables;
|
|
|
|
|
|
|
|
|
|
boost::program_options::options_description desc("Allowed options");
|
|
|
|
@ -35,7 +73,8 @@ namespace MyGUI
|
|
|
|
|
("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());
|
|
|
|
|
default_value(std::vector<std::string>(), "fallback-archive")->multitoken())
|
|
|
|
|
("encoding", boost::program_options::value<std::string>()->default_value("win1252"));
|
|
|
|
|
|
|
|
|
|
boost::program_options::notify(variables);
|
|
|
|
|
|
|
|
|
@ -64,11 +103,51 @@ namespace MyGUI
|
|
|
|
|
Files::Collections collections (dataDirs, !fsStrict);
|
|
|
|
|
|
|
|
|
|
Bsa::registerResources(collections, archives, true, fsStrict);
|
|
|
|
|
|
|
|
|
|
std::string encoding(variables["encoding"].as<std::string>());
|
|
|
|
|
std::cout << ToUTF8::encodingUsingMessage(encoding) << std::endl;
|
|
|
|
|
|
|
|
|
|
Gui::FontLoader loader(ToUTF8::calculateEncoding(encoding));
|
|
|
|
|
loader.loadAllFonts(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ResourcePlugin::registerWidgets()
|
|
|
|
|
{
|
|
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<MWScrollBar>("Widget");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ResourcePlugin::createTransparentBGTexture()
|
|
|
|
|
{
|
|
|
|
|
// This texture is manually created in OpenMW to be able to change its opacity at runtime in the options menu
|
|
|
|
|
Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().createManual(
|
|
|
|
|
"transparent.png",
|
|
|
|
|
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
|
|
|
|
Ogre::TEX_TYPE_2D,
|
|
|
|
|
1, 1,
|
|
|
|
|
0,
|
|
|
|
|
Ogre::PF_A8R8G8B8,
|
|
|
|
|
Ogre::TU_WRITE_ONLY);
|
|
|
|
|
std::vector<Ogre::uint32> buffer;
|
|
|
|
|
buffer.resize(1);
|
|
|
|
|
const float val = 0.7;
|
|
|
|
|
buffer[0] = (int(255*val) << 24);
|
|
|
|
|
memcpy(tex->getBuffer()->lock(Ogre::HardwareBuffer::HBL_DISCARD), &buffer[0], 1*4);
|
|
|
|
|
tex->getBuffer()->unlock();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ResourcePlugin::initialize()
|
|
|
|
|
{
|
|
|
|
|
MYGUI_LOGGING("OpenMW_Resource_Plugin", Info, "initialize");
|
|
|
|
|
|
|
|
|
|
registerResources();
|
|
|
|
|
registerWidgets();
|
|
|
|
|
createTransparentBGTexture();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ResourcePlugin::shutdown()
|
|
|
|
|
{
|
|
|
|
|
/// \todo remove resource groups
|
|
|
|
|
/// \todo cleanup
|
|
|
|
|
|
|
|
|
|
MYGUI_LOGGING("OpenMW_Resource_Plugin", Info, "shutdown");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|