MyGUI HEAD compatibility

Makes OpenMW compatible with the current MyGUI HEAD at:
f93d4fb614

Refs #5806
pull/3048/head
Gleb Mazovetskiy 4 years ago
parent e2fc5d87b3
commit 4495b67d77

@ -53,7 +53,7 @@ namespace MWGui
{
static const int fontHeight = MWBase::Environment::get().getWindowManager()->getFontHeight();
MyGUI::GlyphInfo* gi = font->getGlyphInfo(ch);
const MyGUI::GlyphInfo* gi = font->getGlyphInfo(ch);
if (gi)
{
const float scale = font->getDefaultHeight() / (float) fontHeight;

@ -0,0 +1,12 @@
#ifndef OPENMW_COMPONENTS_MYGUIPLATFORM_MYGUICOMPAT_H
#define OPENMW_COMPONENTS_MYGUIPLATFORM_MYGUICOMPAT_H
#include <MyGUI_Prerequest.h>
#if MYGUI_VERSION > MYGUI_DEFINE_VERSION(3, 4, 0)
#define OPENMW_MYGUI_CONST_GETTER_3_4_1 const
#else
#define OPENMW_MYGUI_CONST_GETTER_3_4_1
#endif
#endif // OPENMW_COMPONENTS_MYGUIPLATFORM_MYGUICOMPAT_H

@ -15,7 +15,7 @@ void DataManager::setResourcePath(const std::string &path)
mResourcePath = path;
}
MyGUI::IDataStream *DataManager::getData(const std::string &name)
MyGUI::IDataStream *DataManager::getData(const std::string &name) OPENMW_MYGUI_CONST_GETTER_3_4_1
{
std::string fullpath = getDataPath(name);
std::unique_ptr<boost::filesystem::ifstream> stream;
@ -34,13 +34,13 @@ void DataManager::freeData(MyGUI::IDataStream *data)
delete data;
}
bool DataManager::isDataExist(const std::string &name)
bool DataManager::isDataExist(const std::string &name) OPENMW_MYGUI_CONST_GETTER_3_4_1
{
std::string fullpath = mResourcePath + "/" + name;
return boost::filesystem::exists(fullpath);
}
const MyGUI::VectorString &DataManager::getDataListNames(const std::string &pattern)
const MyGUI::VectorString &DataManager::getDataListNames(const std::string &pattern) OPENMW_MYGUI_CONST_GETTER_3_4_1
{
// TODO: pattern matching (unused?)
static MyGUI::VectorString strings;
@ -49,7 +49,7 @@ const MyGUI::VectorString &DataManager::getDataListNames(const std::string &patt
return strings;
}
const std::string &DataManager::getDataPath(const std::string &name)
const std::string &DataManager::getDataPath(const std::string &name) OPENMW_MYGUI_CONST_GETTER_3_4_1
{
static std::string result;
result.clear();

@ -3,10 +3,11 @@
#include <MyGUI_DataManager.h>
#include "myguicompat.h"
namespace osgMyGUI
{
class DataManager : public MyGUI::DataManager
{
public:
@ -18,7 +19,7 @@ public:
/** Get data stream from specified resource name.
@param _name Resource name (usually file name).
*/
MyGUI::IDataStream* getData(const std::string& _name) override;
MyGUI::IDataStream* getData(const std::string& _name) OPENMW_MYGUI_CONST_GETTER_3_4_1 override;
/** Free data stream.
@param _data Data stream.
@ -28,18 +29,18 @@ public:
/** Is data with specified name exist.
@param _name Resource name.
*/
bool isDataExist(const std::string& _name) override;
bool isDataExist(const std::string& _name) OPENMW_MYGUI_CONST_GETTER_3_4_1 override;
/** Get all data names with names that matches pattern.
@param _pattern Pattern to match (for example "*.layout").
*/
const MyGUI::VectorString& getDataListNames(const std::string& _pattern) override;
const MyGUI::VectorString& getDataListNames(const std::string& _pattern) OPENMW_MYGUI_CONST_GETTER_3_4_1 override;
/** Get full path to data.
@param _name Resource name.
@return Return full path to specified data.
*/
const std::string& getDataPath(const std::string& _name) override;
const std::string& getDataPath(const std::string& _name) OPENMW_MYGUI_CONST_GETTER_3_4_1 override;
private:
std::string mResourcePath;

@ -14,6 +14,7 @@
#include <components/resource/imagemanager.hpp>
#include "myguicompat.h"
#include "myguitexture.hpp"
#define MYGUI_PLATFORM_LOG_SECTION "Platform"
@ -263,7 +264,7 @@ public:
osg::VertexBufferObject* getVertexBuffer();
void setVertexCount(size_t count) override;
size_t getVertexCount() override;
size_t getVertexCount() OPENMW_MYGUI_CONST_GETTER_3_4_1 override;
MyGUI::Vertex *lock() override;
void unlock() override;
@ -290,7 +291,7 @@ void OSGVertexBuffer::setVertexCount(size_t count)
mNeedVertexCount = count;
}
size_t OSGVertexBuffer::getVertexCount()
size_t OSGVertexBuffer::getVertexCount() OPENMW_MYGUI_CONST_GETTER_3_4_1
{
return mNeedVertexCount;
}
@ -560,4 +561,14 @@ bool RenderManager::checkTexture(MyGUI::ITexture* _texture)
return true;
}
#if MYGUI_VERSION > MYGUI_DEFINE_VERSION(3, 4, 0)
void RenderManager::registerShader(
const std::string& _shaderName,
const std::string& _vertexProgramFile,
const std::string& _fragmentProgramFile)
{
MYGUI_PLATFORM_LOG(Warning, "osgMyGUI::RenderManager::registerShader is not implemented");
}
#endif
}

@ -5,6 +5,8 @@
#include <osg/ref_ptr>
#include "myguicompat.h"
namespace Resource
{
class ImageManager;
@ -70,7 +72,8 @@ public:
const MyGUI::IntSize& getViewSize() const override { return mViewSize; }
/** @see RenderManager::getVertexFormat */
MyGUI::VertexColourType getVertexFormat() override { return mVertexFormat; }
MyGUI::VertexColourType getVertexFormat() OPENMW_MYGUI_CONST_GETTER_3_4_1 override
{ return mVertexFormat; }
/** @see RenderManager::isFormatSupported */
bool isFormatSupported(MyGUI::PixelFormat format, MyGUI::TextureUsage usage) override;
@ -102,7 +105,7 @@ public:
void setInjectState(osg::StateSet* stateSet);
/** @see IRenderTarget::getInfo */
const MyGUI::RenderTargetInfo& getInfo() override { return mInfo; }
const MyGUI::RenderTargetInfo& getInfo() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mInfo; }
bool checkTexture(MyGUI::ITexture* _texture);
@ -113,6 +116,11 @@ public:
void setViewSize(int width, int height) override;
#endif
// registerShader() is a part of MyGUI::RenderManager interface since 3.4.1 release
#if MYGUI_VERSION > MYGUI_DEFINE_VERSION(3, 4, 0)
void registerShader(const std::string& _shaderName, const std::string& _vertexProgramFile, const std::string& _fragmentProgramFile) override;
#endif
/*internal:*/
void collectDrawCalls();

@ -115,16 +115,6 @@ namespace osgMyGUI
Log(Debug::Warning) << "Would save image to file " << fname;
}
int OSGTexture::getWidth()
{
return mWidth;
}
int OSGTexture::getHeight()
{
return mHeight;
}
void *OSGTexture::lock(MyGUI::TextureUsage /*access*/)
{
if (!mTexture.valid())
@ -167,15 +157,14 @@ namespace osgMyGUI
mLockedImage = nullptr;
}
bool OSGTexture::isLocked()
{
return mLockedImage.valid();
}
// Render-to-texture not currently implemented.
MyGUI::IRenderTarget* OSGTexture::getRenderTarget()
{
return nullptr;
}
#if MYGUI_VERSION > MYGUI_DEFINE_VERSION(3, 4, 0)
void OSGTexture::setShader(const std::string& _shaderName)
{ Log(Debug::Warning) << "OSGTexture::setShader is not implemented"; }
#endif
}

@ -5,6 +5,12 @@
#include <osg/ref_ptr>
#if MYGUI_VERSION > MYGUI_DEFINE_VERSION(3, 4, 0)
#define OPENMW_MYGUI_CONST_GETTER_3_4_1 const
#else
#define OPENMW_MYGUI_CONST_GETTER_3_4_1
#endif
namespace osg
{
class Image;
@ -47,17 +53,22 @@ namespace osgMyGUI
void* lock(MyGUI::TextureUsage access) override;
void unlock() override;
bool isLocked() override;
bool isLocked() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mLockedImage.valid(); }
int getWidth() override;
int getHeight() override;
int getWidth() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mWidth; }
int getHeight() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mHeight; }
MyGUI::PixelFormat getFormat() override { return mFormat; }
MyGUI::TextureUsage getUsage() override { return mUsage; }
size_t getNumElemBytes() override { return mNumElemBytes; }
MyGUI::PixelFormat getFormat() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mFormat; }
MyGUI::TextureUsage getUsage() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mUsage; }
size_t getNumElemBytes() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mNumElemBytes; }
MyGUI::IRenderTarget *getRenderTarget() override;
// setShader() is a part of MyGUI::RenderManager interface since 3.4.1 release
#if MYGUI_VERSION > MYGUI_DEFINE_VERSION(3, 4, 0)
void setShader(const std::string& _shaderName) override;
#endif
/*internal:*/
osg::Texture2D *getTexture() const { return mTexture.get(); }
};

@ -3,6 +3,8 @@
#include <MyGUI_RenderManager.h>
#include <algorithm>
#include "myguicompat.h"
namespace osgMyGUI
{
@ -37,7 +39,7 @@ namespace osgMyGUI
mTarget->doRender(_buffer, _texture, _count);
}
const MyGUI::RenderTargetInfo& getInfo() override
const MyGUI::RenderTargetInfo& getInfo() OPENMW_MYGUI_CONST_GETTER_3_4_1 override
{
mInfo = mTarget->getInfo();
mInfo.hOffset = mHOffset;
@ -51,7 +53,7 @@ namespace osgMyGUI
MyGUI::IRenderTarget* mTarget;
MyGUI::IntSize mViewSize;
float mHOffset, mVOffset;
MyGUI::RenderTargetInfo mInfo;
mutable MyGUI::RenderTargetInfo mInfo;
};
MyGUI::ILayerItem *ScalingLayer::getLayerItemByPoint(int _left, int _top) const

Loading…
Cancel
Save