From 1838a3fd696782b1733a435bbb25accf3e40d1f3 Mon Sep 17 00:00:00 2001 From: sapier Date: Sat, 5 Apr 2014 14:12:36 +0200 Subject: Add support for dpi based HUD scaling Add support for (configurable) multiline hotbar Improved screensize handling Add userdefined gui scale by BlockMen --- src/porting.cpp | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'src/porting.cpp') 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 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::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 deskres = nulldevice->getVideoModeList()->getDesktopResolution(); + nulldevice -> drop(); + + return deskres; +} +#endif + } //namespace porting -- cgit v1.2.3