diff options
author | sapier <Sapier at GMX dot net> | 2014-04-05 14:12:36 +0200 |
---|---|---|
committer | sapier <Sapier at GMX dot net> | 2014-04-27 21:53:13 +0200 |
commit | 1838a3fd696782b1733a435bbb25accf3e40d1f3 (patch) | |
tree | 9edee41b26d5307b1d2e4626e65bb372a3d8cab7 /src/porting.cpp | |
parent | 8d315347100f1d261bb496b6c73f8cab5d2b7a41 (diff) | |
download | minetest-1838a3fd696782b1733a435bbb25accf3e40d1f3.tar.gz minetest-1838a3fd696782b1733a435bbb25accf3e40d1f3.tar.bz2 minetest-1838a3fd696782b1733a435bbb25accf3e40d1f3.zip |
Add support for dpi based HUD scaling
Add support for (configurable) multiline hotbar
Improved screensize handling
Add userdefined gui scale by BlockMen
Diffstat (limited to 'src/porting.cpp')
-rw-r--r-- | src/porting.cpp | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/src/porting.cpp b/src/porting.cpp index 53b3a3784..d1e3cdd70 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -44,6 +44,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "filesys.h" #include "log.h" #include "util/string.h" +#include "main.h" +#include "settings.h" #include <list> namespace porting @@ -470,8 +472,9 @@ void initializePaths() std::string static_sharedir = STATIC_SHAREDIR; if(static_sharedir != "" && static_sharedir != ".") trylist.push_back(static_sharedir); - trylist.push_back(bindir + "/../share/" + PROJECT_NAME); - trylist.push_back(bindir + "/.."); + trylist.push_back( + bindir + DIR_DELIM + ".." + DIR_DELIM + "share" + DIR_DELIM + PROJECT_NAME); + trylist.push_back(bindir + DIR_DELIM + ".."); for(std::list<std::string>::const_iterator i = trylist.begin(); i != trylist.end(); i++) @@ -528,5 +531,40 @@ void initializePaths() #endif // RUN_IN_PLACE } +static irr::IrrlichtDevice* device; + +void initIrrlicht(irr::IrrlichtDevice * _device) { + device = _device; +} + +#ifndef SERVER +v2u32 getWindowSize() { + return device->getVideoDriver()->getScreenSize(); +} + + +float getDisplayDensity() { + float gui_scaling = g_settings->getFloat("gui_scaling"); + // using Y here feels like a bug, this needs to be discussed later! + if (getWindowSize().Y <= 800) { + return (2.0/3.0) * gui_scaling; + } + if (getWindowSize().Y <= 1280) { + return 1.0 * gui_scaling; + } + + return (4.0/3.0) * gui_scaling; +} + +v2u32 getDisplaySize() { + IrrlichtDevice *nulldevice = createDevice(video::EDT_NULL); + + core::dimension2d<u32> deskres = nulldevice->getVideoModeList()->getDesktopResolution(); + nulldevice -> drop(); + + return deskres; +} +#endif + } //namespace porting |