mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-19 19:53:53 +00:00
Merge branch 'mygui-upgrade' into 'master'
MyGUI 3.4.1 compatibility Closes #5806 See merge request OpenMW/openmw!560
This commit is contained in:
commit
787a976fb8
10 changed files with 75 additions and 40 deletions
|
@ -53,7 +53,7 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
static const int fontHeight = MWBase::Environment::get().getWindowManager()->getFontHeight();
|
static const int fontHeight = MWBase::Environment::get().getWindowManager()->getFontHeight();
|
||||||
|
|
||||||
MyGUI::GlyphInfo* gi = font->getGlyphInfo(ch);
|
const MyGUI::GlyphInfo* gi = font->getGlyphInfo(ch);
|
||||||
if (gi)
|
if (gi)
|
||||||
{
|
{
|
||||||
const float scale = font->getDefaultHeight() / (float) fontHeight;
|
const float scale = font->getDefaultHeight() / (float) fontHeight;
|
||||||
|
|
12
components/myguiplatform/myguicompat.h
Normal file
12
components/myguiplatform/myguicompat.h
Normal file
|
@ -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;
|
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::string fullpath = getDataPath(name);
|
||||||
std::unique_ptr<boost::filesystem::ifstream> stream;
|
std::unique_ptr<boost::filesystem::ifstream> stream;
|
||||||
|
@ -34,13 +34,13 @@ void DataManager::freeData(MyGUI::IDataStream *data)
|
||||||
delete 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;
|
std::string fullpath = mResourcePath + "/" + name;
|
||||||
return boost::filesystem::exists(fullpath);
|
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?)
|
// TODO: pattern matching (unused?)
|
||||||
static MyGUI::VectorString strings;
|
static MyGUI::VectorString strings;
|
||||||
|
@ -49,7 +49,7 @@ const MyGUI::VectorString &DataManager::getDataListNames(const std::string &patt
|
||||||
return strings;
|
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;
|
static std::string result;
|
||||||
result.clear();
|
result.clear();
|
||||||
|
|
|
@ -3,10 +3,11 @@
|
||||||
|
|
||||||
#include <MyGUI_DataManager.h>
|
#include <MyGUI_DataManager.h>
|
||||||
|
|
||||||
|
#include "myguicompat.h"
|
||||||
|
|
||||||
namespace osgMyGUI
|
namespace osgMyGUI
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
class DataManager : public MyGUI::DataManager
|
class DataManager : public MyGUI::DataManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -18,7 +19,7 @@ public:
|
||||||
/** Get data stream from specified resource name.
|
/** Get data stream from specified resource name.
|
||||||
@param _name Resource name (usually file 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.
|
/** Free data stream.
|
||||||
@param _data Data stream.
|
@param _data Data stream.
|
||||||
|
@ -28,18 +29,18 @@ public:
|
||||||
/** Is data with specified name exist.
|
/** Is data with specified name exist.
|
||||||
@param _name Resource name.
|
@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.
|
/** Get all data names with names that matches pattern.
|
||||||
@param _pattern Pattern to match (for example "*.layout").
|
@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.
|
/** Get full path to data.
|
||||||
@param _name Resource name.
|
@param _name Resource name.
|
||||||
@return Return full path to specified data.
|
@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:
|
private:
|
||||||
std::string mResourcePath;
|
std::string mResourcePath;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include <components/resource/imagemanager.hpp>
|
#include <components/resource/imagemanager.hpp>
|
||||||
|
|
||||||
|
#include "myguicompat.h"
|
||||||
#include "myguitexture.hpp"
|
#include "myguitexture.hpp"
|
||||||
|
|
||||||
#define MYGUI_PLATFORM_LOG_SECTION "Platform"
|
#define MYGUI_PLATFORM_LOG_SECTION "Platform"
|
||||||
|
@ -263,7 +264,7 @@ public:
|
||||||
osg::VertexBufferObject* getVertexBuffer();
|
osg::VertexBufferObject* getVertexBuffer();
|
||||||
|
|
||||||
void setVertexCount(size_t count) override;
|
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;
|
MyGUI::Vertex *lock() override;
|
||||||
void unlock() override;
|
void unlock() override;
|
||||||
|
@ -290,7 +291,7 @@ void OSGVertexBuffer::setVertexCount(size_t count)
|
||||||
mNeedVertexCount = count;
|
mNeedVertexCount = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t OSGVertexBuffer::getVertexCount()
|
size_t OSGVertexBuffer::getVertexCount() OPENMW_MYGUI_CONST_GETTER_3_4_1
|
||||||
{
|
{
|
||||||
return mNeedVertexCount;
|
return mNeedVertexCount;
|
||||||
}
|
}
|
||||||
|
@ -560,4 +561,14 @@ bool RenderManager::checkTexture(MyGUI::ITexture* _texture)
|
||||||
return true;
|
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 <osg/ref_ptr>
|
||||||
|
|
||||||
|
#include "myguicompat.h"
|
||||||
|
|
||||||
namespace Resource
|
namespace Resource
|
||||||
{
|
{
|
||||||
class ImageManager;
|
class ImageManager;
|
||||||
|
@ -70,7 +72,8 @@ public:
|
||||||
const MyGUI::IntSize& getViewSize() const override { return mViewSize; }
|
const MyGUI::IntSize& getViewSize() const override { return mViewSize; }
|
||||||
|
|
||||||
/** @see RenderManager::getVertexFormat */
|
/** @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 */
|
/** @see RenderManager::isFormatSupported */
|
||||||
bool isFormatSupported(MyGUI::PixelFormat format, MyGUI::TextureUsage usage) override;
|
bool isFormatSupported(MyGUI::PixelFormat format, MyGUI::TextureUsage usage) override;
|
||||||
|
@ -102,17 +105,22 @@ public:
|
||||||
void setInjectState(osg::StateSet* stateSet);
|
void setInjectState(osg::StateSet* stateSet);
|
||||||
|
|
||||||
/** @see IRenderTarget::getInfo */
|
/** @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);
|
bool checkTexture(MyGUI::ITexture* _texture);
|
||||||
|
|
||||||
// setViewSize() is a part of MyGUI::RenderManager interface since 3.4.0 release
|
// setViewSize() is a part of MyGUI::RenderManager interface since 3.4.0 release
|
||||||
#if MYGUI_VERSION < MYGUI_DEFINE_VERSION(3,4,0)
|
#if MYGUI_VERSION < MYGUI_DEFINE_VERSION(3, 4, 0)
|
||||||
void setViewSize(int width, int height);
|
void setViewSize(int width, int height);
|
||||||
#else
|
#else
|
||||||
void setViewSize(int width, int height) override;
|
void setViewSize(int width, int height) override;
|
||||||
#endif
|
#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:*/
|
/*internal:*/
|
||||||
|
|
||||||
void collectDrawCalls();
|
void collectDrawCalls();
|
||||||
|
|
|
@ -115,16 +115,6 @@ namespace osgMyGUI
|
||||||
Log(Debug::Warning) << "Would save image to file " << fname;
|
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*/)
|
void *OSGTexture::lock(MyGUI::TextureUsage /*access*/)
|
||||||
{
|
{
|
||||||
if (!mTexture.valid())
|
if (!mTexture.valid())
|
||||||
|
@ -167,15 +157,14 @@ namespace osgMyGUI
|
||||||
mLockedImage = nullptr;
|
mLockedImage = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OSGTexture::isLocked()
|
|
||||||
{
|
|
||||||
return mLockedImage.valid();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render-to-texture not currently implemented.
|
// Render-to-texture not currently implemented.
|
||||||
MyGUI::IRenderTarget* OSGTexture::getRenderTarget()
|
MyGUI::IRenderTarget* OSGTexture::getRenderTarget()
|
||||||
{
|
{
|
||||||
return nullptr;
|
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>
|
#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
|
namespace osg
|
||||||
{
|
{
|
||||||
class Image;
|
class Image;
|
||||||
|
@ -47,17 +53,22 @@ namespace osgMyGUI
|
||||||
|
|
||||||
void* lock(MyGUI::TextureUsage access) override;
|
void* lock(MyGUI::TextureUsage access) override;
|
||||||
void unlock() override;
|
void unlock() override;
|
||||||
bool isLocked() override;
|
bool isLocked() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mLockedImage.valid(); }
|
||||||
|
|
||||||
int getWidth() override;
|
int getWidth() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mWidth; }
|
||||||
int getHeight() override;
|
int getHeight() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mHeight; }
|
||||||
|
|
||||||
MyGUI::PixelFormat getFormat() override { return mFormat; }
|
MyGUI::PixelFormat getFormat() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mFormat; }
|
||||||
MyGUI::TextureUsage getUsage() override { return mUsage; }
|
MyGUI::TextureUsage getUsage() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mUsage; }
|
||||||
size_t getNumElemBytes() override { return mNumElemBytes; }
|
size_t getNumElemBytes() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mNumElemBytes; }
|
||||||
|
|
||||||
MyGUI::IRenderTarget *getRenderTarget() override;
|
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:*/
|
/*internal:*/
|
||||||
osg::Texture2D *getTexture() const { return mTexture.get(); }
|
osg::Texture2D *getTexture() const { return mTexture.get(); }
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#include <MyGUI_RenderManager.h>
|
#include <MyGUI_RenderManager.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "myguicompat.h"
|
||||||
|
|
||||||
namespace osgMyGUI
|
namespace osgMyGUI
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -37,7 +39,7 @@ namespace osgMyGUI
|
||||||
mTarget->doRender(_buffer, _texture, _count);
|
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 = mTarget->getInfo();
|
||||||
mInfo.hOffset = mHOffset;
|
mInfo.hOffset = mHOffset;
|
||||||
|
@ -51,7 +53,7 @@ namespace osgMyGUI
|
||||||
MyGUI::IRenderTarget* mTarget;
|
MyGUI::IRenderTarget* mTarget;
|
||||||
MyGUI::IntSize mViewSize;
|
MyGUI::IntSize mViewSize;
|
||||||
float mHOffset, mVOffset;
|
float mHOffset, mVOffset;
|
||||||
MyGUI::RenderTargetInfo mInfo;
|
mutable MyGUI::RenderTargetInfo mInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
MyGUI::ILayerItem *ScalingLayer::getLayerItemByPoint(int _left, int _top) const
|
MyGUI::ILayerItem *ScalingLayer::getLayerItemByPoint(int _left, int _top) const
|
||||||
|
|
5
extern/CMakeLists.txt
vendored
5
extern/CMakeLists.txt
vendored
|
@ -59,6 +59,7 @@ if(NOT OPENMW_USE_SYSTEM_MYGUI)
|
||||||
set(MYGUI_BUILD_DEMOS OFF CACHE BOOL "")
|
set(MYGUI_BUILD_DEMOS OFF CACHE BOOL "")
|
||||||
set(MYGUI_BUILD_PLUGINS OFF CACHE BOOL "")
|
set(MYGUI_BUILD_PLUGINS OFF CACHE BOOL "")
|
||||||
set(MYGUI_BUILD_TOOLS OFF CACHE BOOL "")
|
set(MYGUI_BUILD_TOOLS OFF CACHE BOOL "")
|
||||||
|
set(MYGUI_DONT_USE_OBSOLETE ON CACHE BOOL "")
|
||||||
|
|
||||||
if(MYGUI_STATIC)
|
if(MYGUI_STATIC)
|
||||||
set(BUILD_SHARED_LIBS OFF)
|
set(BUILD_SHARED_LIBS OFF)
|
||||||
|
@ -68,8 +69,8 @@ if(NOT OPENMW_USE_SYSTEM_MYGUI)
|
||||||
|
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
FetchContent_Declare(mygui
|
FetchContent_Declare(mygui
|
||||||
URL https://github.com/MyGUI/mygui/archive/MyGUI3.4.0.zip
|
URL https://github.com/MyGUI/mygui/archive/MyGUI3.4.1.zip
|
||||||
URL_HASH MD5=9e990a4240430cbf567bfe73488a274e
|
URL_HASH MD5=952d4033854612c99a5d9bf4b8550c26
|
||||||
SOURCE_DIR fetched/mygui
|
SOURCE_DIR fetched/mygui
|
||||||
)
|
)
|
||||||
FetchContent_MakeAvailableExcludeFromAll(mygui)
|
FetchContent_MakeAvailableExcludeFromAll(mygui)
|
||||||
|
|
Loading…
Reference in a new issue