diff options
-rw-r--r-- | platform/windows/detect.py | 2 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 88 | ||||
-rw-r--r-- | scene/resources/dynamic_font_stb.cpp | 4 | ||||
-rw-r--r-- | tools/SCsub | 17 |
4 files changed, 87 insertions, 24 deletions
diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 4edae9cceb..97d2461e58 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -243,7 +243,7 @@ def configure(env): env.Append(CCFLAGS=['/DGLES2_ENABLED']) env.Append(CCFLAGS=['/DGLEW_ENABLED']) - LIBS=['winmm','opengl32','dsound','kernel32','ole32','oleaut32','user32','gdi32', 'IPHLPAPI','Shcore','Shlwapi', 'wsock32', 'shell32','advapi32','dinput8','dxguid'] + LIBS=['winmm','opengl32','dsound','kernel32','ole32','oleaut32','user32','gdi32', 'IPHLPAPI','Shlwapi', 'wsock32', 'shell32','advapi32','dinput8','dxguid'] env.Append(LINKFLAGS=[p+env["LIBSUFFIX"] for p in LIBS]) env.Append(LIBPATH=[os.getenv("WindowsSdkDir")+"/Lib"]) diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 8bb5de5d5d..4f2bfd46ae 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -57,13 +57,6 @@ #include <regstr.h> #include <process.h> -#if (_MSC_VER >= 1700) -#define HIDPI_SUPPORT -#endif - -#ifdef HIDPI_SUPPORT -#include <ShellScalingAPI.h> -#endif static const WORD MAX_CONSOLE_LINES = 1500; extern "C" { @@ -781,6 +774,8 @@ LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) { } + + void OS_Windows::process_key_events() { for(int i=0;i<key_event_pos;i++) { @@ -852,6 +847,75 @@ void OS_Windows::process_key_events() { key_event_pos=0; } +enum _MonitorDpiType +{ + MDT_Effective_DPI = 0, + MDT_Angular_DPI = 1, + MDT_Raw_DPI = 2, + MDT_Default = MDT_Effective_DPI +}; + + +static int QueryDpiForMonitor(HMONITOR hmon, _MonitorDpiType dpiType= MDT_Default) +{ + + + int dpiX = 96, dpiY = 96; + + static HMODULE Shcore = NULL; + typedef HRESULT (WINAPI* GetDPIForMonitor_t)(HMONITOR hmonitor, _MonitorDpiType dpiType, UINT *dpiX, UINT *dpiY); + static GetDPIForMonitor_t getDPIForMonitor = NULL; + + if (Shcore == NULL) + { + Shcore = LoadLibraryW(L"Shcore.dll"); + getDPIForMonitor = Shcore ? (GetDPIForMonitor_t)GetProcAddress(Shcore, "GetDpiForMonitor") : NULL; + + if ((Shcore == NULL) || (getDPIForMonitor == NULL)) + { + if (Shcore) + FreeLibrary(Shcore); + Shcore = (HMODULE)INVALID_HANDLE_VALUE; + } + } + + UINT x = 0, y = 0; + HRESULT hr = E_FAIL; + bool bSet = false; + if (hmon && (Shcore != (HMODULE)INVALID_HANDLE_VALUE)) + { + hr = getDPIForMonitor(hmon, dpiType/*MDT_Effective_DPI*/, &x, &y); + if (SUCCEEDED(hr) && (x > 0) && (y > 0)) + { + + dpiX = (int)x; + dpiY = (int)y; + } + } + else + { + static int overallX = 0, overallY = 0; + if (overallX <= 0 || overallY <= 0) + { + HDC hdc = GetDC(NULL); + if (hdc) + { + overallX = GetDeviceCaps(hdc, LOGPIXELSX); + overallY = GetDeviceCaps(hdc, LOGPIXELSY); + ReleaseDC(NULL, hdc); + } + } + if (overallX > 0 && overallY > 0) + { + dpiX = overallX; dpiY = overallY; + } + } + + + return (dpiX+dpiY)/2; +} + + BOOL CALLBACK OS_Windows::MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) { OS_Windows *self=(OS_Windows*)OS::get_singleton(); MonitorInfo minfo; @@ -861,13 +925,9 @@ BOOL CALLBACK OS_Windows::MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPR minfo.rect.pos.y=lprcMonitor->top; minfo.rect.size.x=lprcMonitor->right - lprcMonitor->left; minfo.rect.size.y=lprcMonitor->bottom - lprcMonitor->top; -#ifdef HIDPI_SUPPORT - UINT dpix,dpiy; - GetDpiForMonitor(hMonitor,MDT_EFFECTIVE_DPI,&dpix,&dpiy); - minfo.dpi=(dpix + dpiy)/2; -#else - minfo.dpi=72; -#endif + + minfo.dpi = QueryDpiForMonitor(hMonitor); + self->monitor_info.push_back(minfo); return TRUE; diff --git a/scene/resources/dynamic_font_stb.cpp b/scene/resources/dynamic_font_stb.cpp index 344043fcdd..0b9f95da4f 100644 --- a/scene/resources/dynamic_font_stb.cpp +++ b/scene/resources/dynamic_font_stb.cpp @@ -384,8 +384,8 @@ void DynamicFont::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_size","data"),&DynamicFont::set_size); ObjectTypeDB::bind_method(_MD("get_size"),&DynamicFont::get_size); - ADD_PROPERTY(PropertyInfo(Variant::INT,"size"),_SCS("set_size"),_SCS("get_size")); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"font",PROPERTY_HINT_RESOURCE_TYPE,"DynamicFontData"),_SCS("set_font_data"),_SCS("get_font_data")); + ADD_PROPERTY(PropertyInfo(Variant::INT,"font/size"),_SCS("set_size"),_SCS("get_size")); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"font/font",PROPERTY_HINT_RESOURCE_TYPE,"DynamicFontData"),_SCS("set_font_data"),_SCS("get_font_data")); } diff --git a/tools/SCsub b/tools/SCsub index 7a0feb6e3d..f6c14a13fb 100644 --- a/tools/SCsub +++ b/tools/SCsub @@ -21,17 +21,20 @@ def make_translations_header(target,source,env): g.write("#ifndef _EDITOR_TRANSLATIONS_H\n") g.write("#define _EDITOR_TRANSLATIONS_H\n") + import zlib + import os.path + + paths = [node.srcnode().abspath for node in source] + sorted_paths = sorted(paths, key=lambda path: os.path.splitext(os.path.basename(path))[0]) + xl_names=[] - for i in range(len(source)): - print("Appending translation: "+source[i].srcnode().abspath) - f = open(source[i].srcnode().abspath,"rb") + for i in range(len(sorted_paths)): + print("Appending translation: "+sorted_paths[i]) + f = open(sorted_paths[i],"rb") buf = f.read() decomp_size = len(buf) - import zlib - import os.path buf = zlib.compress(buf) - - name = os.path.splitext(os.path.basename(source[i].srcnode().abspath))[0] + name = os.path.splitext(os.path.basename(sorted_paths[i]))[0] #g.write("static const int _translation_"+name+"_compressed_size="+str(len(buf))+";\n") #g.write("static const int _translation_"+name+"_uncompressed_size="+str(decomp_size)+";\n") |