Merge remote-tracking branch 'scrawl/myguiplugin'
commit
9b7f61b4ba
@ -0,0 +1,407 @@
|
||||
#include "box.hpp"
|
||||
|
||||
namespace Gui
|
||||
{
|
||||
|
||||
void AutoSizedWidget::notifySizeChange (MyGUI::Widget* w)
|
||||
{
|
||||
MyGUI::Widget * parent = w->getParent();
|
||||
if (parent != 0)
|
||||
{
|
||||
if (mExpandDirection == MyGUI::Align::Left)
|
||||
{
|
||||
int hdiff = getRequestedSize ().width - w->getSize().width;
|
||||
w->setPosition(w->getPosition() - MyGUI::IntPoint(hdiff, 0));
|
||||
}
|
||||
w->setSize(getRequestedSize ());
|
||||
|
||||
while (parent != 0)
|
||||
{
|
||||
Box * b = dynamic_cast<Box*>(parent);
|
||||
if (b)
|
||||
b->notifyChildrenSizeChanged();
|
||||
else
|
||||
break;
|
||||
parent = parent->getParent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MyGUI::IntSize AutoSizedTextBox::getRequestedSize()
|
||||
{
|
||||
return getTextSize();
|
||||
}
|
||||
|
||||
void AutoSizedTextBox::setCaption(const MyGUI::UString& _value)
|
||||
{
|
||||
TextBox::setCaption(_value);
|
||||
|
||||
notifySizeChange (this);
|
||||
}
|
||||
|
||||
void AutoSizedTextBox::setPropertyOverride(const std::string& _key, const std::string& _value)
|
||||
{
|
||||
if (_key == "ExpandDirection")
|
||||
{
|
||||
mExpandDirection = MyGUI::Align::parse (_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
TextBox::setPropertyOverride (_key, _value);
|
||||
}
|
||||
}
|
||||
|
||||
MyGUI::IntSize AutoSizedEditBox::getRequestedSize()
|
||||
{
|
||||
if (getAlign().isHStretch())
|
||||
throw std::runtime_error("AutoSizedEditBox can't have HStretch align (" + getName() + ")");
|
||||
return MyGUI::IntSize(getSize().width, getTextSize().height);
|
||||
}
|
||||
|
||||
void AutoSizedEditBox::setCaption(const MyGUI::UString& _value)
|
||||
{
|
||||
EditBox::setCaption(_value);
|
||||
|
||||
notifySizeChange (this);
|
||||
}
|
||||
|
||||
void AutoSizedEditBox::setPropertyOverride(const std::string& _key, const std::string& _value)
|
||||
{
|
||||
if (_key == "ExpandDirection")
|
||||
{
|
||||
mExpandDirection = MyGUI::Align::parse (_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditBox::setPropertyOverride (_key, _value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MyGUI::IntSize AutoSizedButton::getRequestedSize()
|
||||
{
|
||||
MyGUI::IntSize padding(24, 8);
|
||||
if (isUserString("TextPadding"))
|
||||
padding = MyGUI::IntSize::parse(getUserString("TextPadding"));
|
||||
|
||||
MyGUI::IntSize size = getTextSize() + MyGUI::IntSize(padding.width,padding.height);
|
||||
return size;
|
||||
}
|
||||
|
||||
void AutoSizedButton::setCaption(const MyGUI::UString& _value)
|
||||
{
|
||||
Button::setCaption(_value);
|
||||
|
||||
notifySizeChange (this);
|
||||
}
|
||||
|
||||
void AutoSizedButton::setPropertyOverride(const std::string& _key, const std::string& _value)
|
||||
{
|
||||
if (_key == "ExpandDirection")
|
||||
{
|
||||
mExpandDirection = MyGUI::Align::parse (_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
Button::setPropertyOverride (_key, _value);
|
||||
}
|
||||
}
|
||||
|
||||
Box::Box()
|
||||
: mSpacing(4)
|
||||
, mPadding(0)
|
||||
, mAutoResize(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Box::notifyChildrenSizeChanged ()
|
||||
{
|
||||
align();
|
||||
}
|
||||
|
||||
bool Box::_setPropertyImpl(const std::string& _key, const std::string& _value)
|
||||
{
|
||||
if (_key == "Spacing")
|
||||
mSpacing = MyGUI::utility::parseValue<int>(_value);
|
||||
else if (_key == "Padding")
|
||||
mPadding = MyGUI::utility::parseValue<int>(_value);
|
||||
else if (_key == "AutoResize")
|
||||
mAutoResize = MyGUI::utility::parseValue<bool>(_value);
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void HBox::align ()
|
||||
{
|
||||
unsigned int count = getChildCount ();
|
||||
size_t h_stretched_count = 0;
|
||||
int total_width = 0;
|
||||
int total_height = 0;
|
||||
std::vector< std::pair<MyGUI::IntSize, bool> > sizes;
|
||||
sizes.resize(count);
|
||||
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
{
|
||||
MyGUI::Widget* w = getChildAt(i);
|
||||
bool hstretch = w->getUserString ("HStretch") == "true";
|
||||
bool hidden = w->getUserString("Hidden") == "true";
|
||||
if (hidden)
|
||||
continue;
|
||||
h_stretched_count += hstretch;
|
||||
AutoSizedWidget* aw = dynamic_cast<AutoSizedWidget*>(w);
|
||||
if (aw)
|
||||
{
|
||||
sizes[i] = std::make_pair(aw->getRequestedSize (), hstretch);
|
||||
total_width += aw->getRequestedSize ().width;
|
||||
total_height = std::max(total_height, aw->getRequestedSize ().height);
|
||||
}
|
||||
else
|
||||
{
|
||||
sizes[i] = std::make_pair(w->getSize(), hstretch);
|
||||
total_width += w->getSize().width;
|
||||
if (!(w->getUserString("VStretch") == "true"))
|
||||
total_height = std::max(total_height, w->getSize().height);
|
||||
}
|
||||
|
||||
if (i != count-1)
|
||||
total_width += mSpacing;
|
||||
}
|
||||
|
||||
if (mAutoResize && (total_width+mPadding*2 != getSize().width || total_height+mPadding*2 != getSize().height))
|
||||
{
|
||||
setSize(MyGUI::IntSize(total_width+mPadding*2, total_height+mPadding*2));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int curX = 0;
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
{
|
||||
if (i == 0)
|
||||
curX += mPadding;
|
||||
|
||||
MyGUI::Widget* w = getChildAt(i);
|
||||
|
||||
bool hidden = w->getUserString("Hidden") == "true";
|
||||
if (hidden)
|
||||
continue;
|
||||
|
||||
bool vstretch = w->getUserString ("VStretch") == "true";
|
||||
int max_height = getSize().height - mPadding*2;
|
||||
int height = vstretch ? max_height : sizes[i].first.height;
|
||||
|
||||
MyGUI::IntCoord widgetCoord;
|
||||
widgetCoord.left = curX;
|
||||
widgetCoord.top = mPadding + (getSize().height-mPadding*2 - height) / 2;
|
||||
int width = sizes[i].second ? sizes[i].first.width + (getSize().width-mPadding*2 - total_width)/h_stretched_count
|
||||
: sizes[i].first.width;
|
||||
widgetCoord.width = width;
|
||||
widgetCoord.height = height;
|
||||
w->setCoord(widgetCoord);
|
||||
curX += width;
|
||||
|
||||
if (i != count-1)
|
||||
curX += mSpacing;
|
||||
}
|
||||
}
|
||||
|
||||
void HBox::setPropertyOverride(const std::string& _key, const std::string& _value)
|
||||
{
|
||||
if (!Box::_setPropertyImpl (_key, _value))
|
||||
MyGUI::Widget::setPropertyOverride(_key, _value);
|
||||
}
|
||||
|
||||
void HBox::setSize (const MyGUI::IntSize& _value)
|
||||
{
|
||||
MyGUI::Widget::setSize (_value);
|
||||
align();
|
||||
}
|
||||
|
||||
void HBox::setCoord (const MyGUI::IntCoord& _value)
|
||||
{
|
||||
MyGUI::Widget::setCoord (_value);
|
||||
align();
|
||||
}
|
||||
|
||||
void HBox::onWidgetCreated(MyGUI::Widget* _widget)
|
||||
{
|
||||
align();
|
||||
}
|
||||
|
||||
MyGUI::IntSize HBox::getRequestedSize ()
|
||||
{
|
||||
MyGUI::IntSize size(0,0);
|
||||
for (unsigned int i = 0; i < getChildCount (); ++i)
|
||||
{
|
||||
bool hidden = getChildAt(i)->getUserString("Hidden") == "true";
|
||||
if (hidden)
|
||||
continue;
|
||||
|
||||
AutoSizedWidget* w = dynamic_cast<AutoSizedWidget*>(getChildAt(i));
|
||||
if (w)
|
||||
{
|
||||
MyGUI::IntSize requested = w->getRequestedSize ();
|
||||
size.height = std::max(size.height, requested.height);
|
||||
size.width = size.width + requested.width;
|
||||
if (i != getChildCount()-1)
|
||||
size.width += mSpacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
MyGUI::IntSize requested = getChildAt(i)->getSize ();
|
||||
size.height = std::max(size.height, requested.height);
|
||||
|
||||
if (getChildAt(i)->getUserString("HStretch") != "true")
|
||||
size.width = size.width + requested.width;
|
||||
|
||||
if (i != getChildCount()-1)
|
||||
size.width += mSpacing;
|
||||
}
|
||||
size.height += mPadding*2;
|
||||
size.width += mPadding*2;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void VBox::align ()
|
||||
{
|
||||
unsigned int count = getChildCount ();
|
||||
size_t v_stretched_count = 0;
|
||||
int total_height = 0;
|
||||
int total_width = 0;
|
||||
std::vector< std::pair<MyGUI::IntSize, bool> > sizes;
|
||||
sizes.resize(count);
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
{
|
||||
MyGUI::Widget* w = getChildAt(i);
|
||||
|
||||
bool hidden = w->getUserString("Hidden") == "true";
|
||||
if (hidden)
|
||||
continue;
|
||||
|
||||
bool vstretch = w->getUserString ("VStretch") == "true";
|
||||
v_stretched_count += vstretch;
|
||||
AutoSizedWidget* aw = dynamic_cast<AutoSizedWidget*>(w);
|
||||
if (aw)
|
||||
{
|
||||
sizes[i] = std::make_pair(aw->getRequestedSize (), vstretch);
|
||||
total_height += aw->getRequestedSize ().height;
|
||||
total_width = std::max(total_width, aw->getRequestedSize ().width);
|
||||
}
|
||||
else
|
||||
{
|
||||
sizes[i] = std::make_pair(w->getSize(), vstretch);
|
||||
total_height += w->getSize().height;
|
||||
|
||||
if (!(w->getUserString("HStretch") == "true"))
|
||||
total_width = std::max(total_width, w->getSize().width);
|
||||
}
|
||||
|
||||
if (i != count-1)
|
||||
total_height += mSpacing;
|
||||
}
|
||||
|
||||
if (mAutoResize && (total_width+mPadding*2 != getSize().width || total_height+mPadding*2 != getSize().height))
|
||||
{
|
||||
setSize(MyGUI::IntSize(total_width+mPadding*2, total_height+mPadding*2));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int curY = 0;
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
{
|
||||
if (i==0)
|
||||
curY += mPadding;
|
||||
|
||||
MyGUI::Widget* w = getChildAt(i);
|
||||
|
||||
bool hidden = w->getUserString("Hidden") == "true";
|
||||
if (hidden)
|
||||
continue;
|
||||
|
||||
bool hstretch = w->getUserString ("HStretch") == "true";
|
||||
int maxWidth = getSize().width - mPadding*2;
|
||||
int width = hstretch ? maxWidth : sizes[i].first.width;
|
||||
|
||||
MyGUI::IntCoord widgetCoord;
|
||||
widgetCoord.top = curY;
|
||||
widgetCoord.left = mPadding + (getSize().width-mPadding*2 - width) / 2;
|
||||
int height = sizes[i].second ? sizes[i].first.height + (getSize().height-mPadding*2 - total_height)/v_stretched_count
|
||||
: sizes[i].first.height;
|
||||
widgetCoord.height = height;
|
||||
widgetCoord.width = width;
|
||||
w->setCoord(widgetCoord);
|
||||
curY += height;
|
||||
|
||||
if (i != count-1)
|
||||
curY += mSpacing;
|
||||
}
|
||||
}
|
||||
|
||||
void VBox::setPropertyOverride(const std::string& _key, const std::string& _value)
|
||||
{
|
||||
if (!Box::_setPropertyImpl (_key, _value))
|
||||
MyGUI::Widget::setPropertyOverride(_key, _value);
|
||||
}
|
||||
|
||||
void VBox::setSize (const MyGUI::IntSize& _value)
|
||||
{
|
||||
MyGUI::Widget::setSize (_value);
|
||||
align();
|
||||
}
|
||||
|
||||
void VBox::setCoord (const MyGUI::IntCoord& _value)
|
||||
{
|
||||
MyGUI::Widget::setCoord (_value);
|
||||
align();
|
||||
}
|
||||
|
||||
MyGUI::IntSize VBox::getRequestedSize ()
|
||||
{
|
||||
MyGUI::IntSize size(0,0);
|
||||
for (unsigned int i = 0; i < getChildCount (); ++i)
|
||||
{
|
||||
bool hidden = getChildAt(i)->getUserString("Hidden") == "true";
|
||||
if (hidden)
|
||||
continue;
|
||||
|
||||
AutoSizedWidget* w = dynamic_cast<AutoSizedWidget*>(getChildAt(i));
|
||||
if (w)
|
||||
{
|
||||
MyGUI::IntSize requested = w->getRequestedSize ();
|
||||
size.width = std::max(size.width, requested.width);
|
||||
size.height = size.height + requested.height;
|
||||
if (i != getChildCount()-1)
|
||||
size.height += mSpacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
MyGUI::IntSize requested = getChildAt(i)->getSize ();
|
||||
size.width = std::max(size.width, requested.width);
|
||||
|
||||
if (getChildAt(i)->getUserString("VStretch") != "true")
|
||||
size.height = size.height + requested.height;
|
||||
|
||||
if (i != getChildCount()-1)
|
||||
size.height += mSpacing;
|
||||
}
|
||||
size.height += mPadding*2;
|
||||
size.width += mPadding*2;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
void VBox::onWidgetCreated(MyGUI::Widget* _widget)
|
||||
{
|
||||
align();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
#ifndef OPENMW_WIDGETS_BOX_H
|
||||
#define OPENMW_WIDGETS_BOX_H
|
||||
|
||||
#include <MyGUI_Widget.h>
|
||||
#include <MyGUI_TextBox.h>
|
||||
#include <MyGUI_EditBox.h>
|
||||
#include <MyGUI_Button.h>
|
||||
|
||||
namespace Gui
|
||||
{
|
||||
|
||||
class AutoSizedWidget
|
||||
{
|
||||
public:
|
||||
virtual MyGUI::IntSize getRequestedSize() = 0;
|
||||
|
||||
protected:
|
||||
void notifySizeChange(MyGUI::Widget* w);
|
||||
|
||||
MyGUI::Align mExpandDirection;
|
||||
};
|
||||
|
||||
class AutoSizedTextBox : public AutoSizedWidget, public MyGUI::TextBox
|
||||
{
|
||||
MYGUI_RTTI_DERIVED( AutoSizedTextBox )
|
||||
|
||||
public:
|
||||
virtual MyGUI::IntSize getRequestedSize();
|
||||
virtual void setCaption(const MyGUI::UString& _value);
|
||||
|
||||
protected:
|
||||
virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
|
||||
};
|
||||
|
||||
class AutoSizedEditBox : public AutoSizedWidget, public MyGUI::EditBox
|
||||
{
|
||||
MYGUI_RTTI_DERIVED( AutoSizedEditBox )
|
||||
|
||||
public:
|
||||
virtual MyGUI::IntSize getRequestedSize();
|
||||
virtual void setCaption(const MyGUI::UString& _value);
|
||||
|
||||
protected:
|
||||
virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
|
||||
};
|
||||
|
||||
class AutoSizedButton : public AutoSizedWidget, public MyGUI::Button
|
||||
{
|
||||
MYGUI_RTTI_DERIVED( AutoSizedButton )
|
||||
|
||||
public:
|
||||
virtual MyGUI::IntSize getRequestedSize();
|
||||
virtual void setCaption(const MyGUI::UString& _value);
|
||||
|
||||
protected:
|
||||
virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A container widget that automatically sizes its children
|
||||
* @note the box being an AutoSizedWidget as well allows to put boxes inside a box
|
||||
*/
|
||||
class Box : public AutoSizedWidget
|
||||
{
|
||||
public:
|
||||
Box();
|
||||
|
||||
void notifyChildrenSizeChanged();
|
||||
|
||||
protected:
|
||||
virtual void align() = 0;
|
||||
|
||||
virtual bool _setPropertyImpl(const std::string& _key, const std::string& _value);
|
||||
|
||||
int mSpacing; // how much space to put between elements
|
||||
|
||||
int mPadding; // outer padding
|
||||
|
||||
bool mAutoResize; // auto resize the box so that it exactly fits all elements
|
||||
};
|
||||
|
||||
class HBox : public Box, public MyGUI::Widget
|
||||
{
|
||||
MYGUI_RTTI_DERIVED( HBox )
|
||||
|
||||
public:
|
||||
virtual void setSize (const MyGUI::IntSize &_value);
|
||||
virtual void setCoord (const MyGUI::IntCoord &_value);
|
||||
|
||||
protected:
|
||||
virtual void align();
|
||||
virtual MyGUI::IntSize getRequestedSize();
|
||||
|
||||
virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
|
||||
|
||||
virtual void onWidgetCreated(MyGUI::Widget* _widget);
|
||||
};
|
||||
|
||||
class VBox : public Box, public MyGUI::Widget
|
||||
{
|
||||
MYGUI_RTTI_DERIVED( VBox)
|
||||
|
||||
public:
|
||||
virtual void setSize (const MyGUI::IntSize &_value);
|
||||
virtual void setCoord (const MyGUI::IntCoord &_value);
|
||||
|
||||
protected:
|
||||
virtual void align();
|
||||
virtual MyGUI::IntSize getRequestedSize();
|
||||
|
||||
virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
|
||||
|
||||
virtual void onWidgetCreated(MyGUI::Widget* _widget);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -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,138 @@
|
||||
#include "plugin.hpp"
|
||||
|
||||
#include <MyGUI_LogManager.h>
|
||||
#include <MyGUI_FactoryManager.h>
|
||||
#include <MyGUI_ScrollBar.h>
|
||||
#include <MyGUI_Gui.h>
|
||||
#include <MyGUI_Window.h>
|
||||
|
||||
#include <components/bsa/resources.hpp>
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
#include <components/fontloader/fontloader.hpp>
|
||||
|
||||
#include <components/widgets/imagebutton.hpp>
|
||||
#include <components/widgets/box.hpp>
|
||||
|
||||
#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)
|
||||
};
|
||||
|
||||
const std::string& ResourcePlugin::getName() const
|
||||
{
|
||||
static const std::string name = "OpenMW resource plugin";
|
||||
return name;
|
||||
}
|
||||
|
||||
void ResourcePlugin::install()
|
||||
{
|
||||
|
||||
}
|
||||
void ResourcePlugin::uninstall()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ResourcePlugin::registerResources()
|
||||
{
|
||||
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())
|
||||
("encoding", boost::program_options::value<std::string>()->default_value("win1252"));
|
||||
|
||||
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);
|
||||
|
||||
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");
|
||||
|
||||
MyGUI::FactoryManager::getInstance().registerFactory<Gui::ImageButton>("Widget");
|
||||
MyGUI::FactoryManager::getInstance().registerFactory<Gui::HBox>("Widget");
|
||||
MyGUI::FactoryManager::getInstance().registerFactory<Gui::VBox>("Widget");
|
||||
MyGUI::FactoryManager::getInstance().registerFactory<Gui::AutoSizedTextBox>("Widget");
|
||||
MyGUI::FactoryManager::getInstance().registerFactory<Gui::AutoSizedEditBox>("Widget");
|
||||
MyGUI::FactoryManager::getInstance().registerFactory<Gui::AutoSizedButton>("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 cleanup
|
||||
|
||||
MYGUI_LOGGING("OpenMW_Resource_Plugin", Info, "shutdown");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
#ifndef OPENMW_MYGUI_RESOURCE_PLUGIN_H
|
||||
#define OPENMW_MYGUI_RESOURCE_PLUGIN_H
|
||||
|
||||
#include <MyGUI_Plugin.h>
|
||||
|
||||
namespace MyGUIPlugin
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief MyGUI plugin used to register Morrowind resources, custom widgets used in OpenMW, and load Morrowind fonts.
|
||||
* @paragraph The plugin isn't used in OpenMW itself, but it is useful with the standalone MyGUI tools. To use it,
|
||||
* change EditorPlugin.xml in Media/Tools/LayoutEditor/EditorPlugin.xml and add an entry for this plugin.
|
||||
*/
|
||||
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();
|
||||
|
||||
private:
|
||||
void registerResources();
|
||||
void registerWidgets();
|
||||
void createTransparentBGTexture();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,17 @@
|
||||
#include "plugin.hpp"
|
||||
#include "MyGUI_PluginManager.h"
|
||||
|
||||
MyGUIPlugin::ResourcePlugin* plugin_item = nullptr;
|
||||
|
||||
extern "C" MYGUI_EXPORT_DLL void dllStartPlugin(void)
|
||||
{
|
||||
plugin_item = new MyGUIPlugin::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