From 4c4daf9698ceed026c9c098e1a25de6c41ab7edd Mon Sep 17 00:00:00 2001 From: Benau Date: Thu, 7 Apr 2022 08:51:25 +0800 Subject: [PATCH] Move screen height detection inside CImageLoaderSVG::loadImage --- lib/irrlicht/include/IImageLoader.h | 2 -- lib/irrlicht/source/Irrlicht/CImageLoaderSVG.cpp | 9 ++------- lib/irrlicht/source/Irrlicht/CImageLoaderSVG.h | 6 ------ lib/irrlicht/source/Irrlicht/CNullDriver.cpp | 4 ---- 4 files changed, 2 insertions(+), 19 deletions(-) diff --git a/lib/irrlicht/include/IImageLoader.h b/lib/irrlicht/include/IImageLoader.h index 783115cbf..ba0da6886 100644 --- a/lib/irrlicht/include/IImageLoader.h +++ b/lib/irrlicht/include/IImageLoader.h @@ -45,8 +45,6 @@ public: virtual IImage* loadImage(io::IReadFile* file, bool skip_checking = false) const = 0; virtual core::dimension2du getImageSize(io::IReadFile* file) const { return core::dimension2du(0, 0); } virtual bool supportThreadedLoading() const { return false; } - - virtual void setScreenSize(const core::dimension2d &screen_size) {}; }; diff --git a/lib/irrlicht/source/Irrlicht/CImageLoaderSVG.cpp b/lib/irrlicht/source/Irrlicht/CImageLoaderSVG.cpp index 1377f3805..62aed164d 100644 --- a/lib/irrlicht/source/Irrlicht/CImageLoaderSVG.cpp +++ b/lib/irrlicht/source/Irrlicht/CImageLoaderSVG.cpp @@ -13,6 +13,7 @@ #include "os.h" #include "irrString.h" #include "CNullDriver.h" +#include "ge_main.hpp" namespace irr { @@ -25,12 +26,6 @@ CImageLoaderSVG::CImageLoaderSVG() { } -//! set the screen size -void CImageLoaderSVG::setScreenSize(const core::dimension2d &screen_size) -{ - ScreenSize = screen_size; -} - //! returns true if the file maybe is able to be loaded by this class //! based on the file extension (e.g. ".tga") bool CImageLoaderSVG::isALoadableFileExtension(const io::path& filename) const @@ -109,7 +104,7 @@ IImage* CImageLoaderSVG::loadImage(io::IReadFile* file, bool skip_checking) cons if ( strstr(file->getFileName().c_str(),"gui/icons/") ) { // determine scaling based on screen size - float screen_height = ScreenSize.Height; + float screen_height = (float)GE::getDriver()->getCurrentRenderTargetSize().Height; float desired_icon_size = 0.21*screen_height + 30.0f; // phenomenological scale = desired_icon_size/img->height; } diff --git a/lib/irrlicht/source/Irrlicht/CImageLoaderSVG.h b/lib/irrlicht/source/Irrlicht/CImageLoaderSVG.h index f7c059d9d..59a608f73 100644 --- a/lib/irrlicht/source/Irrlicht/CImageLoaderSVG.h +++ b/lib/irrlicht/source/Irrlicht/CImageLoaderSVG.h @@ -38,9 +38,6 @@ public: //! constructor CImageLoaderSVG(); - // set the screen size, used to determine scaling - virtual void setScreenSize(const core::dimension2d &screen_size); - //! returns true if the file maybe is able to be loaded by this class //! based on the file extension (e.g. ".tga") virtual bool isALoadableFileExtension(const io::path& filename) const; @@ -51,9 +48,6 @@ public: //! creates a surface from the file virtual IImage* loadImage(io::IReadFile* file, bool skip_checking = false) const; -private: - core::dimension2d ScreenSize; - }; diff --git a/lib/irrlicht/source/Irrlicht/CNullDriver.cpp b/lib/irrlicht/source/Irrlicht/CNullDriver.cpp index c0cca02d6..dd1a5dc76 100644 --- a/lib/irrlicht/source/Irrlicht/CNullDriver.cpp +++ b/lib/irrlicht/source/Irrlicht/CNullDriver.cpp @@ -1303,8 +1303,6 @@ IImage* CNullDriver::createImageFromFile(io::IReadFile* file, video::IImageLoade *loader = SurfaceLoader[i]; return 0; } - // pass screen size to ImageLoaderSVG. For other formats (BMP,JPG,PNG), setScreenSize() does nothing - SurfaceLoader[i]->setScreenSize(getCurrentRenderTargetSize()); // reset file position which might have changed due to previous loadImage calls file->seek(0); image = SurfaceLoader[i]->loadImage(file); @@ -1325,8 +1323,6 @@ IImage* CNullDriver::createImageFromFile(io::IReadFile* file, video::IImageLoade *loader = SurfaceLoader[i]; return 0; } - // pass screen size to ImageLoaderSVG. For other formats (BMP,JPG,PNG), setScreenSize() does nothing - SurfaceLoader[i]->setScreenSize(getCurrentRenderTargetSize()); file->seek(0); image = SurfaceLoader[i]->loadImage(file); if (image)