1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 18:35:20 +00:00

Merge remote-tracking branch 'scrawl/myguiplugin'

This commit is contained in:
Marc Zinnschlag 2014-09-14 10:45:26 +02:00
commit 9b7f61b4ba
44 changed files with 930 additions and 638 deletions

View File

@ -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_UNITTESTS "Enable Unittests with Google C++ Unittest and GMock frameworks" 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
option(OPENMW_OSX_DEPLOYMENT OFF)
@ -103,32 +104,32 @@ cmake_minimum_required(VERSION 2.6)
# source directory: libs
set(LIBDIR ${CMAKE_SOURCE_DIR}/libs)
set(LIBS_DIR ${CMAKE_SOURCE_DIR}/libs)
set(OENGINE_OGRE
${LIBDIR}/openengine/ogre/renderer.cpp
${LIBDIR}/openengine/ogre/lights.cpp
${LIBDIR}/openengine/ogre/selectionbuffer.cpp
${LIBDIR}/openengine/ogre/imagerotate.cpp
${LIBS_DIR}/openengine/ogre/renderer.cpp
${LIBS_DIR}/openengine/ogre/lights.cpp
${LIBS_DIR}/openengine/ogre/selectionbuffer.cpp
${LIBS_DIR}/openengine/ogre/imagerotate.cpp
)
set(OENGINE_GUI
${LIBDIR}/openengine/gui/loglistener.cpp
${LIBDIR}/openengine/gui/manager.cpp
${LIBDIR}/openengine/gui/layout.hpp
${LIBS_DIR}/openengine/gui/loglistener.cpp
${LIBS_DIR}/openengine/gui/manager.cpp
${LIBS_DIR}/openengine/gui/layout.hpp
)
set(OENGINE_BULLET
${LIBDIR}/openengine/bullet/BtOgre.cpp
${LIBDIR}/openengine/bullet/BtOgreExtras.h
${LIBDIR}/openengine/bullet/BtOgreGP.h
${LIBDIR}/openengine/bullet/BtOgrePG.h
${LIBDIR}/openengine/bullet/physic.cpp
${LIBDIR}/openengine/bullet/physic.hpp
${LIBDIR}/openengine/bullet/BulletShapeLoader.cpp
${LIBDIR}/openengine/bullet/BulletShapeLoader.h
${LIBDIR}/openengine/bullet/trace.cpp
${LIBDIR}/openengine/bullet/trace.h
${LIBS_DIR}/openengine/bullet/BtOgre.cpp
${LIBS_DIR}/openengine/bullet/BtOgreExtras.h
${LIBS_DIR}/openengine/bullet/BtOgreGP.h
${LIBS_DIR}/openengine/bullet/BtOgrePG.h
${LIBS_DIR}/openengine/bullet/physic.cpp
${LIBS_DIR}/openengine/bullet/physic.hpp
${LIBS_DIR}/openengine/bullet/BulletShapeLoader.cpp
${LIBS_DIR}/openengine/bullet/BulletShapeLoader.h
${LIBS_DIR}/openengine/bullet/trace.cpp
${LIBS_DIR}/openengine/bullet/trace.h
)
@ -261,7 +262,7 @@ include_directories("."
${MYGUI_INCLUDE_DIRS}
${MYGUI_PLATFORM_INCLUDE_DIRS}
${OPENAL_INCLUDE_DIR}
${LIBDIR}
${LIBS_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)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${APP_BUNDLE_DIR}/Contents/MacOS")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${APP_BUNDLE_DIR}/Contents/MacOS")
else (APPLE)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${OpenMW_BINARY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${OpenMW_BINARY_DIR}")
endif (APPLE)
# Other files
@ -379,6 +382,7 @@ IF(NOT WIN32 AND NOT APPLE)
# Linux building
# Paths
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(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")
@ -405,6 +409,9 @@ IF(NOT WIN32 AND NOT APPLE)
IF(BUILD_NIFTEST)
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/niftest" DESTINATION "${BINDIR}" )
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(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(FILES "${OpenMW_BINARY_DIR}/opencs.ini" DESTINATION ".")
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 ".")
@ -521,6 +531,11 @@ add_subdirectory (extern/sdl4ogre)
# Components
add_subdirectory (components)
# Plugins
if (BUILD_MYGUI_PLUGIN)
add_subdirectory(plugins/mygui_resource_plugin)
endif()
#Testing
if (BUILD_NIFTEST)
add_subdirectory(components/nif/tests/)

View File

@ -36,10 +36,10 @@ add_openmw_dir (mwgui
formatting inventorywindow container hud countdialog tradewindow settingswindow
confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu
itemselection spellbuyingwindow loadingscreen levelupdialog waitdialog spellcreationdialog
enchantingdialog trainingwindow travelwindow imagebutton exposedwindow cursor spellicons
enchantingdialog trainingwindow travelwindow exposedwindow cursor spellicons
merchantrepair repair soulgemdialog companionwindow bookpage journalviewmodel journalbooks
keywordsearch itemmodel containeritemmodel inventoryitemmodel sortfilteritemmodel itemview
tradeitemmodel companionitemmodel pickpocketitemmodel fontloader controllers savegamedialog
tradeitemmodel companionitemmodel pickpocketitemmodel controllers savegamedialog
recharge mode videowidget backgroundimage itemwidget screenfader
)

View File

@ -145,8 +145,6 @@ namespace MWBase
virtual MWGui::SpellWindow* getSpellWindow() = 0;
virtual MWGui::Console* getConsole() = 0;
virtual MyGUI::Gui* getGui() const = 0;
virtual void wmUpdateFps(float fps, unsigned int triangleCount, unsigned int batchCount) = 0;
/// Set value for the given ID.

View File

@ -193,7 +193,7 @@ namespace MWGui
}
}
void BookWindow::adjustButton (MWGui::ImageButton* button)
void BookWindow::adjustButton (Gui::ImageButton* button)
{
MyGUI::IntSize diff = button->getSize() - button->getRequestedSize();
button->setSize(button->getRequestedSize());

View File

@ -5,7 +5,7 @@
#include "../mwworld/ptr.hpp"
#include "imagebutton.hpp"
#include <components/widgets/imagebutton.hpp>
namespace MWGui
{
@ -31,13 +31,13 @@ namespace MWGui
void updatePages();
void clearPages();
void adjustButton(MWGui::ImageButton* button);
void adjustButton(Gui::ImageButton* button);
private:
MWGui::ImageButton* mCloseButton;
MWGui::ImageButton* mTakeButton;
MWGui::ImageButton* mNextPageButton;
MWGui::ImageButton* mPrevPageButton;
Gui::ImageButton* mCloseButton;
Gui::ImageButton* mTakeButton;
Gui::ImageButton* mNextPageButton;
Gui::ImageButton* mPrevPageButton;
MyGUI::TextBox* mLeftPageNumber;
MyGUI::TextBox* mRightPageNumber;
MyGUI::Widget* mLeftPage;

View File

@ -140,6 +140,7 @@ namespace MWGui
void Console::close()
{
// Apparently, hidden widgets can retain key focus
// Remove for MyGUI 3.2.2
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(NULL);
}

View File

@ -7,7 +7,7 @@ namespace MWGui
namespace Controllers
{
ControllerRepeatClick::ControllerRepeatClick() :
ControllerRepeatEvent::ControllerRepeatEvent() :
mInit(0.5),
mStep(0.1),
mEnabled(true),
@ -15,11 +15,11 @@ namespace MWGui
{
}
ControllerRepeatClick::~ControllerRepeatClick()
ControllerRepeatEvent::~ControllerRepeatEvent()
{
}
bool ControllerRepeatClick::addTime(MyGUI::Widget* _widget, float _time)
bool ControllerRepeatEvent::addTime(MyGUI::Widget* _widget, float _time)
{
if(mTimeLeft == 0)
mTimeLeft = mInit;
@ -33,22 +33,22 @@ namespace MWGui
return true;
}
void ControllerRepeatClick::setRepeat(float init, float step)
void ControllerRepeatEvent::setRepeat(float init, float step)
{
mInit = init;
mStep = step;
}
void ControllerRepeatClick::setEnabled(bool enable)
void ControllerRepeatEvent::setEnabled(bool enable)
{
mEnabled = enable;
}
void ControllerRepeatClick::setProperty(const std::string& _key, const std::string& _value)
void ControllerRepeatEvent::setProperty(const std::string& _key, const std::string& _value)
{
}
void ControllerRepeatClick::prepareItem(MyGUI::Widget* _widget)
void ControllerRepeatEvent::prepareItem(MyGUI::Widget* _widget)
{
}

View File

@ -9,14 +9,15 @@ namespace MWGui
{
namespace Controllers
{
class ControllerRepeatClick :
// Should be removed when upgrading to MyGUI 3.2.2 (current git), it has ControllerRepeatClick
class ControllerRepeatEvent :
public MyGUI::ControllerItem
{
MYGUI_RTTI_DERIVED( ControllerRepeatClick )
MYGUI_RTTI_DERIVED( ControllerRepeatEvent )
public:
ControllerRepeatClick();
virtual ~ControllerRepeatClick();
ControllerRepeatEvent();
virtual ~ControllerRepeatEvent();
void setRepeat(float init, float step);
void setEnabled(bool enable);

View File

@ -266,7 +266,7 @@ namespace MWGui
BookPage::ClickCallback callback = boost::bind (&DialogueWindow::notifyLinkClicked, this, _1);
mHistory->adviseLinkClicked(callback);
static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &DialogueWindow::onWindowResize);
mMainWidget->castType<MyGUI::Window>()->eventWindowChangeCoord += MyGUI::newDelegate(this, &DialogueWindow::onWindowResize);
}
void DialogueWindow::exit()

View File

@ -42,7 +42,7 @@ namespace MWGui
, mSelectedItem(-1)
, mGuiMode(GM_Inventory)
{
static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &InventoryWindow::onWindowResize);
mMainWidget->castType<MyGUI::Window>()->eventWindowChangeCoord += MyGUI::newDelegate(this, &InventoryWindow::onWindowResize);
getWidget(mAvatar, "Avatar");
getWidget(mAvatarImage, "AvatarImage");
@ -367,7 +367,7 @@ namespace MWGui
mItemView->update();
static_cast<MyGUI::Button*>(_sender)->setStateSelected(true);
_sender->castType<MyGUI::Button>()->setStateSelected(true);
}
void InventoryWindow::onPinToggled()

View File

@ -15,9 +15,10 @@
#include <boost/function.hpp>
#include "boost/lexical_cast.hpp"
#include <components/widgets/imagebutton.hpp>
#include "bookpage.hpp"
#include "windowbase.hpp"
#include "imagebutton.hpp"
#include "journalviewmodel.hpp"
#include "journalbooks.hpp"
#include "list.hpp"
@ -82,7 +83,7 @@ namespace
void adviseButtonClick (char const * name, void (JournalWindowImpl::*Handler) (MyGUI::Widget* _sender))
{
getWidget <MWGui::ImageButton> (name) ->
getWidget <Gui::ImageButton> (name) ->
eventMouseButtonClick += newDelegate(this, Handler);
}
@ -146,12 +147,12 @@ namespace
adjustButton(ShowActiveBTN, true);
adjustButton(JournalBTN);
MWGui::ImageButton* optionsButton = getWidget<MWGui::ImageButton>(OptionsBTN);
Gui::ImageButton* optionsButton = getWidget<Gui::ImageButton>(OptionsBTN);
if (optionsButton->getWidth() == 0)
{
// If tribunal is not installed (-> no options button), we still want the Topics button available,
// so place it where the options button would have been
MWGui::ImageButton* topicsButton = getWidget<MWGui::ImageButton>(TopicsBTN);
Gui::ImageButton* topicsButton = getWidget<Gui::ImageButton>(TopicsBTN);
topicsButton->detachFromWidget();
topicsButton->attachToWidget(optionsButton->getParent());
topicsButton->setPosition(optionsButton->getPosition());
@ -159,7 +160,7 @@ namespace
topicsButton->eventMouseButtonClick += MyGUI::newDelegate(this, &JournalWindowImpl::notifyOptions);
}
MWGui::ImageButton* nextButton = getWidget<MWGui::ImageButton>(NextPageBTN);
Gui::ImageButton* nextButton = getWidget<Gui::ImageButton>(NextPageBTN);
if (nextButton->getSize().width == 64)
{
// english button has a 7 pixel wide strip of garbage on its right edge
@ -182,7 +183,7 @@ namespace
void adjustButton (char const * name, bool optional = false)
{
MWGui::ImageButton* button = getWidget<MWGui::ImageButton>(name);
Gui::ImageButton* button = getWidget<Gui::ImageButton>(name);
MyGUI::IntSize diff = button->getSize() - button->getRequestedSize(!optional);
button->setSize(button->getRequestedSize(!optional));

View File

@ -154,7 +154,7 @@ namespace MWGui
void MWList::onItemSelected(MyGUI::Widget* _sender)
{
std::string name = static_cast<MyGUI::Button*>(_sender)->getCaption();
std::string name = _sender->castType<MyGUI::Button>()->getCaption();
int id = *_sender->getUserData<int>();
eventItemSelected(name, id);
eventWidgetSelected(_sender);

View File

@ -4,6 +4,8 @@
#include <components/version/version.hpp>
#include <components/widgets/imagebutton.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/soundmanager.hpp"
@ -16,7 +18,6 @@
#include "savegamedialog.hpp"
#include "confirmationdialog.hpp"
#include "imagebutton.hpp"
#include "backgroundimage.hpp"
#include "videowidget.hpp"
@ -249,7 +250,7 @@ namespace MWGui
{
if (mButtons.find(*it) == mButtons.end())
{
MWGui::ImageButton* button = mButtonBox->createWidget<MWGui::ImageButton>
Gui::ImageButton* button = mButtonBox->createWidget<Gui::ImageButton>
("ImageBox", MyGUI::IntCoord(0, curH, 0, 0), MyGUI::Align::Default);
button->setProperty("ImageHighlighted", "textures\\menu_" + *it + "_over.dds");
button->setProperty("ImageNormal", "textures\\menu_" + *it + ".dds");
@ -262,7 +263,7 @@ namespace MWGui
// Start by hiding all buttons
int maxwidth = 0;
for (std::map<std::string, MWGui::ImageButton*>::iterator it = mButtons.begin(); it != mButtons.end(); ++it)
for (std::map<std::string, Gui::ImageButton*>::iterator it = mButtons.begin(); it != mButtons.end(); ++it)
{
it->second->setVisible(false);
MyGUI::IntSize requested = it->second->getRequestedSize();
@ -274,7 +275,7 @@ namespace MWGui
for (std::vector<std::string>::iterator it = buttons.begin(); it != buttons.end(); ++it)
{
assert(mButtons.find(*it) != mButtons.end());
MWGui::ImageButton* button = mButtons[*it];
Gui::ImageButton* button = mButtons[*it];
button->setVisible(true);
MyGUI::IntSize requested = button->getRequestedSize();

View File

@ -3,10 +3,14 @@
#include <openengine/gui/layout.hpp>
namespace Gui
{
class ImageButton;
}
namespace MWGui
{
class ImageButton;
class BackgroundImage;
class SaveGameDialog;
class VideoWidget;
@ -39,7 +43,7 @@ namespace MWGui
MyGUI::ImageBox* mVideoBackground;
VideoWidget* mVideo; // For animated main menus
std::map<std::string, MWGui::ImageButton*> mButtons;
std::map<std::string, Gui::ImageButton*> mButtons;
void onButtonClicked (MyGUI::Widget* sender);
void onNewGameConfirmed();

View File

@ -862,6 +862,15 @@ namespace MWGui
}
}
void MapWindow::setAlpha(float alpha)
{
NoDrop::setAlpha(alpha);
// can't allow showing map with partial transparency, as the fog of war will also go transparent
// and reveal parts of the map you shouldn't be able to see
for (std::vector<MyGUI::ImageBox*>::iterator it = mMapWidgets.begin(); it != mMapWidgets.end(); ++it)
(*it)->setVisible(alpha == 1);
}
// -------------------------------------------------------------------
EditNoteDialog::EditNoteDialog()

View File

@ -171,6 +171,8 @@ namespace MWGui
void setCellName(const std::string& cellName);
virtual void setAlpha(float alpha);
void renderGlobalMap(Loading::Listener* loadingListener);
// adds the marker to the global map

View File

@ -213,6 +213,7 @@ namespace MWGui
void SaveGameDialog::accept(bool reallySure)
{
// Remove for MyGUI 3.2.2
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(NULL);
if (mSaving)

View File

@ -13,7 +13,7 @@
namespace
{
void adjustButton (MWGui::ImageButton* button)
void adjustButton (Gui::ImageButton* button)
{
MyGUI::IntSize diff = button->getSize() - button->getRequestedSize();
button->setSize(button->getRequestedSize());

View File

@ -2,7 +2,8 @@
#define MWGUI_SCROLLWINDOW_H
#include "windowbase.hpp"
#include "imagebutton.hpp"
#include <components/widgets/imagebutton.hpp>
#include "../mwworld/ptr.hpp"
@ -23,8 +24,8 @@ namespace MWGui
void onTakeButtonClicked (MyGUI::Widget* _sender);
private:
MWGui::ImageButton* mCloseButton;
MWGui::ImageButton* mTakeButton;
Gui::ImageButton* mCloseButton;
Gui::ImageButton* mTakeButton;
MyGUI::ScrollView* mTextView;
MWWorld::Ptr mScroll;

View File

@ -370,10 +370,10 @@ namespace MWGui
void SettingsWindow::onShaderModeToggled(MyGUI::Widget* _sender)
{
std::string val = static_cast<MyGUI::Button*>(_sender)->getCaption();
std::string val = _sender->castType<MyGUI::Button>()->getCaption();
val = hlslGlsl();
static_cast<MyGUI::Button*>(_sender)->setCaption(val);
_sender->castType<MyGUI::Button>()->setCaption(val);
Settings::Manager::setString("shader mode", "General", val);
@ -483,7 +483,7 @@ namespace MWGui
{
int actionId = *_sender->getUserData<int>();
static_cast<MyGUI::Button*>(_sender)->setCaptionWithReplacing("#{sNone}");
_sender->castType<MyGUI::Button>()->setCaptionWithReplacing("#{sNone}");
MWBase::Environment::get().getWindowManager ()->staticMessageBox ("#{sControlsMenu3}");
MWBase::Environment::get().getWindowManager ()->disallowMouse();

View File

@ -66,7 +66,7 @@ namespace MWGui
mSkillWidgetMap.insert(std::pair<int, MyGUI::TextBox*>(i, (MyGUI::TextBox*)NULL));
}
MyGUI::WindowPtr t = static_cast<MyGUI::WindowPtr>(mMainWidget);
MyGUI::Window* t = mMainWidget->castType<MyGUI::Window>();
t->eventWindowChangeCoord += MyGUI::newDelegate(this, &StatsWindow::onWindowResize);
}
@ -90,7 +90,7 @@ namespace MWGui
void StatsWindow::setBar(const std::string& name, const std::string& tname, int val, int max)
{
MyGUI::ProgressPtr pt;
MyGUI::ProgressBar* pt;
getWidget(pt, name);
pt->setProgressRange(max);
pt->setProgressPosition(val);
@ -102,7 +102,7 @@ namespace MWGui
void StatsWindow::setPlayerName(const std::string& playerName)
{
static_cast<MyGUI::Window*>(mMainWidget)->setCaption(playerName);
mMainWidget->castType<MyGUI::Window>()->setCaption(playerName);
adjustWindowCaption();
}

View File

@ -37,7 +37,7 @@ namespace MWGui
void setBounty (int bounty) { if (bounty != mBounty) mChanged = true; this->mBounty = bounty; }
void updateSkillArea();
virtual void open() { onWindowResize(static_cast<MyGUI::Window*>(mMainWidget)); }
virtual void open() { onWindowResize(mMainWidget->castType<MyGUI::Window>()); }
private:
void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);

View File

@ -138,7 +138,7 @@ namespace MWGui
mFilterMagic->setStateSelected(false);
mFilterMisc->setStateSelected(false);
static_cast<MyGUI::Button*>(_sender)->setStateSelected(true);
_sender->castType<MyGUI::Button>()->setStateSelected(true);
mItemView->update();
}
@ -393,8 +393,8 @@ namespace MWGui
void TradeWindow::addRepeatController(MyGUI::Widget *widget)
{
MyGUI::ControllerItem* item = MyGUI::ControllerManager::getInstance().createItem(Controllers::ControllerRepeatClick::getClassTypeName());
Controllers::ControllerRepeatClick* controller = item->castType<Controllers::ControllerRepeatClick>();
MyGUI::ControllerItem* item = MyGUI::ControllerManager::getInstance().createItem(Controllers::ControllerRepeatEvent::getClassTypeName());
Controllers::ControllerRepeatEvent* controller = item->castType<Controllers::ControllerRepeatEvent>();
controller->eventRepeatClick += MyGUI::newDelegate(this, &TradeWindow::onRepeatClick);
controller->setRepeat(sBalanceChangeInitialPause, sBalanceChangeInterval);
MyGUI::ControllerManager::getInstance().addItem(widget, controller);

View File

@ -2,6 +2,8 @@
#include <boost/lexical_cast.hpp>
#include <components/widgets/box.hpp>
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
@ -190,7 +192,10 @@ namespace MWGui
mSleeping = canRest;
dynamic_cast<Widgets::Box*>(mMainWidget)->notifyChildrenSizeChanged();
Gui::Box* box = dynamic_cast<Gui::Box*>(mMainWidget);
if (box == NULL)
throw std::runtime_error("main widget must be a box");
box->notifyChildrenSizeChanged();
center();
}

View File

@ -59,18 +59,18 @@ namespace MWGui
{
if (mSkillId == ESM::Skill::Length)
{
static_cast<MyGUI::TextBox*>(mSkillNameWidget)->setCaption("");
mSkillNameWidget->setCaption("");
}
else
{
const std::string &name = MWBase::Environment::get().getWindowManager()->getGameSettingString(ESM::Skill::sSkillNameIds[mSkillId], "");
static_cast<MyGUI::TextBox*>(mSkillNameWidget)->setCaption(name);
mSkillNameWidget->setCaption(name);
}
}
if (mSkillValueWidget)
{
SkillValue::Type modified = mValue.getModified(), base = mValue.getBase();
static_cast<MyGUI::TextBox*>(mSkillValueWidget)->setCaption(boost::lexical_cast<std::string>(modified));
mSkillValueWidget->setCaption(boost::lexical_cast<std::string>(modified));
if (modified > base)
mSkillValueWidget->_setWidgetState("increased");
else if (modified < base)
@ -145,7 +145,7 @@ namespace MWGui
{
if (mId < 0 || mId >= 8)
{
static_cast<MyGUI::TextBox*>(mAttributeNameWidget)->setCaption("");
mAttributeNameWidget->setCaption("");
}
else
{
@ -160,13 +160,13 @@ namespace MWGui
"sAttributeLuck"
};
const std::string &name = MWBase::Environment::get().getWindowManager()->getGameSettingString(attributes[mId], "");
static_cast<MyGUI::TextBox*>(mAttributeNameWidget)->setCaption(name);
mAttributeNameWidget->setCaption(name);
}
}
if (mAttributeValueWidget)
{
int modified = mValue.getModified(), base = mValue.getBase();
static_cast<MyGUI::TextBox*>(mAttributeValueWidget)->setCaption(boost::lexical_cast<std::string>(modified));
mAttributeValueWidget->setCaption(boost::lexical_cast<std::string>(modified));
if (modified > base)
mAttributeValueWidget->_setWidgetState("increased");
else if (modified < base)
@ -256,9 +256,9 @@ namespace MWGui
const ESM::Spell *spell = store.get<ESM::Spell>().search(mId);
if (spell)
static_cast<MyGUI::TextBox*>(mSpellNameWidget)->setCaption(spell->mName);
mSpellNameWidget->setCaption(spell->mName);
else
static_cast<MyGUI::TextBox*>(mSpellNameWidget)->setCaption("");
mSpellNameWidget->setCaption("");
}
}
@ -310,7 +310,7 @@ namespace MWGui
// ... then adjust the size for all widgets
for (std::vector<MyGUI::Widget*>::iterator it = effects.begin(); it != effects.end(); ++it)
{
effect = static_cast<MWSpellEffectPtr>(*it);
effect = (*it)->castType<MWSpellEffect>();
bool needcenter = center && (maxwidth > effect->getRequestedWidth());
int diff = maxwidth - effect->getRequestedWidth();
if (needcenter)
@ -470,7 +470,7 @@ namespace MWGui
}
}
static_cast<MyGUI::TextBox*>(mTextWidget)->setCaptionWithReplacing(spellLine);
mTextWidget->setCaptionWithReplacing(spellLine);
mRequestedWidth = mTextWidget->getTextSize().width + 24;
mImageWidget->setImageTexture(Misc::ResourceHelpers::correctIconPath(magicEffect->mIcon));
@ -515,13 +515,13 @@ namespace MWGui
{
std::stringstream out;
out << mValue << "/" << mMax;
static_cast<MyGUI::TextBox*>(mBarTextWidget)->setCaption(out.str().c_str());
mBarTextWidget->setCaption(out.str().c_str());
}
}
void MWDynamicStat::setTitle(const std::string& text)
{
if (mTextWidget)
static_cast<MyGUI::TextBox*>(mTextWidget)->setCaption(text);
mTextWidget->setCaption(text);
}
MWDynamicStat::~MWDynamicStat()
@ -537,412 +537,6 @@ namespace MWGui
assignWidget(mBarTextWidget, "BarText");
}
// ---------------------------------------------------------------------------------------------------------------------
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();
}
MWScrollBar::MWScrollBar()
: mEnableRepeat(true)
, mRepeatTriggerTime(0.5)
@ -1023,8 +617,8 @@ namespace MWGui
void MWScrollBar::onDecreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
{
mIsIncreasing = false;
MyGUI::ControllerItem* item = MyGUI::ControllerManager::getInstance().createItem(MWGui::Controllers::ControllerRepeatClick::getClassTypeName());
MWGui::Controllers::ControllerRepeatClick* controller = item->castType<MWGui::Controllers::ControllerRepeatClick>();
MyGUI::ControllerItem* item = MyGUI::ControllerManager::getInstance().createItem(MWGui::Controllers::ControllerRepeatEvent::getClassTypeName());
MWGui::Controllers::ControllerRepeatEvent* controller = item->castType<MWGui::Controllers::ControllerRepeatEvent>();
controller->eventRepeatClick += newDelegate(this, &MWScrollBar::repeatClick);
controller->setEnabled(mEnableRepeat);
controller->setRepeat(mRepeatTriggerTime, mRepeatStepTime);
@ -1039,8 +633,8 @@ namespace MWGui
void MWScrollBar::onIncreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
{
mIsIncreasing = true;
MyGUI::ControllerItem* item = MyGUI::ControllerManager::getInstance().createItem(MWGui::Controllers::ControllerRepeatClick::getClassTypeName());
MWGui::Controllers::ControllerRepeatClick* controller = item->castType<MWGui::Controllers::ControllerRepeatClick>();
MyGUI::ControllerItem* item = MyGUI::ControllerManager::getInstance().createItem(MWGui::Controllers::ControllerRepeatEvent::getClassTypeName());
MWGui::Controllers::ControllerRepeatEvent* controller = item->castType<MWGui::Controllers::ControllerRepeatEvent>();
controller->eventRepeatClick += newDelegate(this, &MWScrollBar::repeatClick);
controller->setEnabled(mEnableRepeat);
controller->setRepeat(mRepeatTriggerTime, mRepeatStepTime);

View File

@ -122,8 +122,8 @@ namespace MWGui
ESM::Skill::SkillEnum mSkillId;
SkillValue mValue;
MyGUI::Widget* mSkillNameWidget;
MyGUI::Widget* mSkillValueWidget;
MyGUI::TextBox* mSkillNameWidget;
MyGUI::TextBox* mSkillValueWidget;
};
typedef MWSkill* MWSkillPtr;
@ -162,8 +162,8 @@ namespace MWGui
int mId;
AttributeValue mValue;
MyGUI::Widget* mAttributeNameWidget;
MyGUI::Widget* mAttributeValueWidget;
MyGUI::TextBox* mAttributeNameWidget;
MyGUI::TextBox* mAttributeValueWidget;
};
typedef MWAttribute* MWAttributePtr;
@ -293,123 +293,12 @@ namespace MWGui
int mValue, mMax;
MyGUI::TextBox* mTextWidget;
MyGUI::ProgressPtr mBarWidget;
MyGUI::ProgressBar* mBarWidget;
MyGUI::TextBox* mBarTextWidget;
};
typedef MWDynamicStat* MWDynamicStatPtr;
// ---------------------------------------------------------------------------------------------------------------------
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);
};
// Should be removed when upgrading to MyGUI 3.2.2 (current git), it has ScrollBar autorepeat support
class MWScrollBar : public MyGUI::ScrollBar
{
MYGUI_RTTI_DERIVED(MWScrollBar)

View File

@ -23,6 +23,7 @@ void WindowBase::setVisible(bool visible)
close();
// This is needed as invisible widgets can retain key focus.
// Remove for MyGUI 3.2.2
if (!visible)
{
MyGUI::Widget* keyFocus = MyGUI::InputManager::getInstance().getKeyFocusWidget();
@ -96,11 +97,16 @@ void NoDrop::onFrame(float dt)
if (mTransparent)
{
mWidget->setNeedMouseFocus(false); // Allow click-through
mWidget->setAlpha(std::max(0.13f, mWidget->getAlpha() - dt*5));
setAlpha(std::max(0.13f, mWidget->getAlpha() - dt*5));
}
else
{
mWidget->setNeedMouseFocus(true);
mWidget->setAlpha(std::min(1.0f, mWidget->getAlpha() + dt*5));
setAlpha(std::min(1.0f, mWidget->getAlpha() + dt*5));
}
}
void NoDrop::setAlpha(float alpha)
{
mWidget->setAlpha(alpha);
}

View File

@ -55,6 +55,7 @@ namespace MWGui
NoDrop(DragAndDrop* drag, MyGUI::Widget* widget);
void onFrame(float dt);
virtual void setAlpha(float alpha);
private:
MyGUI::Widget* mWidget;

View File

@ -16,6 +16,10 @@
#include <extern/sdl4ogre/sdlcursormanager.hpp>
#include <components/fontloader/fontloader.hpp>
#include <components/widgets/box.hpp>
#include "../mwbase/inputmanager.hpp"
#include "../mwbase/statemanager.hpp"
@ -63,7 +67,6 @@
#include "inventorywindow.hpp"
#include "bookpage.hpp"
#include "itemview.hpp"
#include "fontloader.hpp"
#include "videowidget.hpp"
#include "backgroundimage.hpp"
#include "itemwidget.hpp"
@ -146,10 +149,9 @@ namespace MWGui
{
// Set up the GUI system
mGuiManager = new OEngine::GUI::MyGUIManager(mRendering->getWindow(), mRendering->getScene(), false, logpath);
mGui = mGuiManager->getGui();
// Load fonts
FontLoader fontLoader (encoding);
Gui::FontLoader fontLoader (encoding);
fontLoader.loadAllFonts(exportFonts);
//Register own widgets with MyGUI
@ -160,12 +162,12 @@ namespace MWGui
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSpellEffect>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWDynamicStat>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWList>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::HBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::VBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::AutoSizedTextBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::AutoSizedEditBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::AutoSizedButton>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::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");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::ImageButton>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::ExposedWindow>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWScrollBar>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<VideoWidget>("Widget");
@ -174,7 +176,7 @@ namespace MWGui
ItemView::registerComponents();
ItemWidget::registerComponents();
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Controllers::ControllerRepeatClick>("Controller");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Controllers::ControllerRepeatEvent>("Controller");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Controllers::ControllerFollowMouse>("Controller");
MyGUI::FactoryManager::getInstance().registerFactory<ResourceImageSetPointerFix>("Resource", "ResourceImageSetPointer");
@ -269,7 +271,7 @@ namespace MWGui
trackWindow(mCompanionWindow, "companion");
mScreenFader = new ScreenFader();
mInputBlocker = mGui->createWidget<MyGUI::Widget>("",0,0,w,h,MyGUI::Align::Stretch,"Overlay");
mInputBlocker = MyGUI::Gui::getInstance().createWidget<MyGUI::Widget>("",0,0,w,h,MyGUI::Align::Stretch,"Overlay");
mHud->setVisible(mHudEnabled);
@ -1205,8 +1207,6 @@ namespace MWGui
mBatchCount = batchCount;
}
MyGUI::Gui* WindowManager::getGui() const { return mGui; }
MWGui::DialogueWindow* WindowManager::getDialogueWindow() { return mDialogueWindow; }
MWGui::ContainerWindow* WindowManager::getContainerWindow() { return mContainerWindow; }
MWGui::InventoryWindow* WindowManager::getInventoryWindow() { return mInventoryWindow; }
@ -1450,6 +1450,7 @@ namespace MWGui
forceHide((GuiWindow)(MWGui::GW_Inventory | MWGui::GW_Magic));
}
// Remove this method for MyGUI 3.2.2
void WindowManager::setKeyFocusWidget(MyGUI::Widget *widget)
{
if (widget == NULL)

View File

@ -161,8 +161,6 @@ namespace MWGui
virtual MWGui::SpellWindow* getSpellWindow();
virtual MWGui::Console* getConsole();
virtual MyGUI::Gui* getGui() const;
virtual void wmUpdateFps(float fps, unsigned int triangleCount, unsigned int batchCount);
///< Set value for the given ID.

View File

@ -7,7 +7,7 @@ namespace MWGui
WindowPinnableBase::WindowPinnableBase(const std::string& parLayout)
: WindowBase(parLayout), mPinned(false)
{
ExposedWindow* window = static_cast<ExposedWindow*>(mMainWidget);
ExposedWindow* window = mMainWidget->castType<ExposedWindow>();
mPinButton = window->getSkinWidget ("Button");
mPinButton->eventMouseButtonClick += MyGUI::newDelegate(this, &WindowPinnableBase::onPinButtonClicked);

View File

@ -91,6 +91,14 @@ add_component_dir (ogreinit
ogreinit ogreplugin
)
add_component_dir (widgets
box imagebutton
)
add_component_dir (fontloader
fontloader
)
add_component_dir (version
version
)
@ -112,6 +120,12 @@ if(QT_QTGUI_LIBRARY AND QT_QTCORE_LIBRARY)
QT4_WRAP_CPP(MOC_SRCS ${COMPONENT_MOC_FILES})
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})
add_library(components STATIC ${COMPONENT_FILES} ${MOC_SRCS} ${ESM_UI_HDR})

View File

@ -123,7 +123,7 @@ namespace
}
namespace MWGui
namespace Gui
{
FontLoader::FontLoader(ToUTF8::FromType encoding)

View File

@ -3,7 +3,7 @@
#include <components/to_utf8/to_utf8.hpp>
namespace MWGui
namespace Gui
{

407
components/widgets/box.cpp Normal file
View File

@ -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();
}
}

118
components/widgets/box.hpp Normal file
View File

@ -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

View File

@ -1,8 +1,8 @@
#include "imagebutton.hpp"
#include <OgreTextureManager.h>
#include <MyGUI_RenderManager.h>
namespace MWGui
namespace Gui
{
void ImageButton::setPropertyOverride(const std::string &_key, const std::string &_value)
@ -44,8 +44,8 @@ namespace MWGui
MyGUI::IntSize ImageButton::getRequestedSize(bool logError)
{
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().getByName(mImageNormal);
if (texture.isNull())
MyGUI::ITexture* texture = MyGUI::RenderManager::getInstance().getTexture(mImageNormal);
if (!texture)
{
if (logError)
std::cerr << "ImageButton: can't find " << mImageNormal << std::endl;

View File

@ -3,7 +3,7 @@
#include <MyGUI_ImageBox.h>
namespace MWGui
namespace Gui
{
/**

View File

@ -23,6 +23,7 @@ namespace MyGUI
* As of MyGUI 3.2.0, MyGUI::OgreDataManager::isDataExist is unnecessarily complex
* this override fixes the resulting performance issue.
*/
// Remove for MyGUI 3.2.2
class FixedOgreDataManager : public MyGUI::OgreDataManager
{
public:

View File

@ -49,8 +49,6 @@ namespace GUI
void setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging=false, const std::string& logDir = std::string(""));
void shutdown();
MyGUI::Gui *getGui() { return mGui; }
};
}
}

View 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
)

View File

@ -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");
}
}

View File

@ -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

View File

@ -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;
}