diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index e4e0c3167..3755de07e 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -183,6 +183,8 @@ namespace MWGui MyGUI::Gui* gui = new MyGUI::Gui; gui->initialise(""); + createTextures(); + MyGUI::LanguageManager::getInstance().eventRequestTag = MyGUI::newDelegate(this, &WindowManager::onRetrieveTag); // Load fonts @@ -1084,6 +1086,8 @@ namespace MWGui mCrosshairEnabled = Settings::Manager::getBool ("crosshair", "HUD"); else if (it->first == "GUI" && it->second == "subtitles") mSubtitlesEnabled = Settings::Manager::getBool ("subtitles", "GUI"); + else if (it->first == "GUI" && it->second == "menu transparency") + setMenuTransparency(Settings::Manager::getFloat("menu transparency", "GUI")); } } @@ -1929,4 +1933,56 @@ namespace MWGui return Misc::ResourceHelpers::correctTexturePath(path, mResourceSystem->getVFS()); } + void WindowManager::createTextures() + { + { + MyGUI::ITexture* tex = MyGUI::RenderManager::getInstance().createTexture("white.png"); + tex->createManual(8, 8, MyGUI::TextureUsage::Write, MyGUI::PixelFormat::R8G8B8); + unsigned char* data = reinterpret_cast(tex->lock(MyGUI::TextureUsage::Write)); + for (int x=0; x<8; ++x) + for (int y=0; y<8; ++y) + { + *(data++) = 255; + *(data++) = 255; + *(data++) = 255; + } + tex->unlock(); + } + + { + MyGUI::ITexture* tex = MyGUI::RenderManager::getInstance().createTexture("black.png"); + tex->createManual(8, 8, MyGUI::TextureUsage::Write, MyGUI::PixelFormat::R8G8B8); + unsigned char* data = reinterpret_cast(tex->lock(MyGUI::TextureUsage::Write)); + for (int x=0; x<8; ++x) + for (int y=0; y<8; ++y) + { + *(data++) = 0; + *(data++) = 0; + *(data++) = 0; + } + tex->unlock(); + } + + { + MyGUI::ITexture* tex = MyGUI::RenderManager::getInstance().createTexture("transparent.png"); + tex->createManual(8, 8, MyGUI::TextureUsage::Write, MyGUI::PixelFormat::R8G8B8A8); + setMenuTransparency(Settings::Manager::getFloat("menu transparency", "GUI")); + } + } + + void WindowManager::setMenuTransparency(float value) + { + MyGUI::ITexture* tex = MyGUI::RenderManager::getInstance().getTexture("transparent.png"); + unsigned char* data = reinterpret_cast(tex->lock(MyGUI::TextureUsage::Write)); + for (int x=0; x<8; ++x) + for (int y=0; y<8; ++y) + { + *(data++) = 255; + *(data++) = 255; + *(data++) = 255; + *(data++) = static_cast(value*255); + } + tex->unlock(); + } + } diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 7fccff2d8..325881889 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -499,6 +499,9 @@ namespace MWGui void onClipboardChanged(const std::string& _type, const std::string& _data); void onClipboardRequested(const std::string& _type, std::string& _data); + + void createTextures(); + void setMenuTransparency(float value); }; } diff --git a/components/myguiplatform/myguirendermanager.cpp b/components/myguiplatform/myguirendermanager.cpp index 3ebbd957a..87464f22d 100644 --- a/components/myguiplatform/myguirendermanager.cpp +++ b/components/myguiplatform/myguirendermanager.cpp @@ -420,6 +420,9 @@ void RenderManager::destroyTexture(MyGUI::ITexture *texture) MyGUI::ITexture* RenderManager::getTexture(const std::string &name) { + if (name.empty()) + return NULL; + MapTexture::const_iterator item = mTextures.find(name); if(item == mTextures.end()) {