diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/javascript/os_javascript.cpp | 52 | ||||
-rw-r--r-- | platform/javascript/os_javascript.h | 1 | ||||
-rw-r--r-- | platform/osx/os_osx.mm | 4 | ||||
-rw-r--r-- | platform/windows/SCsub | 1 | ||||
-rw-r--r-- | platform/windows/godot.natvis | 129 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 4 | ||||
-rw-r--r-- | platform/x11/os_x11.cpp | 4 |
7 files changed, 192 insertions, 3 deletions
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index 3515eeeb60..b0ec3c4245 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -39,6 +39,7 @@ #include "unix/file_access_unix.h" #include <emscripten.h> +#include <png.h> #include <stdlib.h> #include "dom_keys.inc" @@ -912,6 +913,57 @@ void OS_JavaScript::set_window_title(const String &p_title) { /* clang-format on */ } +void OS_JavaScript::set_icon(const Ref<Image> &p_icon) { + + ERR_FAIL_COND(p_icon.is_null()); + Ref<Image> icon = p_icon; + if (icon->is_compressed()) { + icon = icon->duplicate(); + ERR_FAIL_COND(icon->decompress() != OK) + } + if (icon->get_format() != Image::FORMAT_RGBA8) { + if (icon == p_icon) + icon = icon->duplicate(); + icon->convert(Image::FORMAT_RGBA8); + } + + png_image png_meta; + memset(&png_meta, 0, sizeof png_meta); + png_meta.version = PNG_IMAGE_VERSION; + png_meta.width = icon->get_width(); + png_meta.height = icon->get_height(); + png_meta.format = PNG_FORMAT_RGBA; + + PoolByteArray png; + size_t len; + PoolByteArray::Read r = icon->get_data().read(); + ERR_FAIL_COND(!png_image_write_get_memory_size(png_meta, len, 0, r.ptr(), 0, NULL)); + + png.resize(len); + PoolByteArray::Write w = png.write(); + ERR_FAIL_COND(!png_image_write_to_memory(&png_meta, w.ptr(), &len, 0, r.ptr(), 0, NULL)); + w = PoolByteArray::Write(); + + r = png.read(); + /* clang-format off */ + EM_ASM_ARGS({ + var PNG_PTR = $0; + var PNG_LEN = $1; + + var png = new Blob([HEAPU8.slice(PNG_PTR, PNG_PTR + PNG_LEN)], { type: "image/png" }); + var url = URL.createObjectURL(png); + var link = document.getElementById('-gd-engine-icon'); + if (link === null) { + link = document.createElement('link'); + link.rel = 'icon'; + link.id = '-gd-engine-icon'; + document.head.appendChild(link); + } + link.href = url; + }, r.ptr(), len); + /* clang-format on */ +} + String OS_JavaScript::get_executable_path() const { return OS::get_executable_path(); diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index f40fb8fc7e..ddcbf8c7c9 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -135,6 +135,7 @@ public: virtual void alert(const String &p_alert, const String &p_title = "ALERT!"); virtual void set_window_title(const String &p_title); + virtual void set_icon(const Ref<Image> &p_icon); String get_executable_path() const; virtual Error shell_open(String p_uri); virtual String get_name(); diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index b98113baeb..886ff4b332 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1663,7 +1663,9 @@ void OS_OSX::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c cursors[p_shape] = cursor; if (p_shape == cursor_shape) { - [cursor set]; + if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) { + [cursor set]; + } } [imgrep release]; diff --git a/platform/windows/SCsub b/platform/windows/SCsub index 586533e817..5dfb1592e0 100644 --- a/platform/windows/SCsub +++ b/platform/windows/SCsub @@ -29,6 +29,7 @@ prog = env.add_program('#bin/godot', common_win + res_obj, PROGSUFFIX=env["PROGS # Microsoft Visual Studio Project Generation if env['vsproj']: env.vs_srcs = env.vs_srcs + ["platform/windows/" + res_file] + env.vs_srcs = env.vs_srcs + ["platform/windows/godot.natvis"] for x in common_win: env.vs_srcs = env.vs_srcs + ["platform/windows/" + str(x)] diff --git a/platform/windows/godot.natvis b/platform/windows/godot.natvis new file mode 100644 index 0000000000..01963035a1 --- /dev/null +++ b/platform/windows/godot.natvis @@ -0,0 +1,129 @@ +<?xml version="1.0" encoding="utf-8"?> +<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010"> + <Type Name="Vector<*>"> + <Expand> + <Item Name="size">(_cowdata && _cowdata->_ptr) ? (((const unsigned int *)(_cowdata->_ptr))[-1]) : 0</Item> + <ArrayItems> + <Size>(_cowdata && _cowdata->_ptr) ? (((const unsigned int *)(_cowdata->_ptr))[-1]) : 0</Size> + <ValuePointer>(_cowdata) ? (_cowdata->_ptr) : 0</ValuePointer> + </ArrayItems> + </Expand> + </Type> + + <Type Name="PoolVector<*>"> + <Expand> + <Item Name="size">alloc ? (alloc->size / sizeof($T1)) : 0</Item> + <ArrayItems> + <Size>alloc ? (alloc->size / sizeof($T1)) : 0</Size> + <ValuePointer>alloc ? (($T1 *)alloc->mem) : 0</ValuePointer> + </ArrayItems> + </Expand> + </Type> + + <Type Name="Variant"> + <DisplayString Condition="this->type == Variant::NIL">nil</DisplayString> + <DisplayString Condition="this->type == Variant::BOOL">{_data._bool}</DisplayString> + <DisplayString Condition="this->type == Variant::INT">{_data._int}</DisplayString> + <DisplayString Condition="this->type == Variant::REAL">{_data._real}</DisplayString> + <DisplayString Condition="this->type == Variant::TRANSFORM2D">{_data._transform2d}</DisplayString> + <DisplayString Condition="this->type == Variant::AABB">{_data._aabb}</DisplayString> + <DisplayString Condition="this->type == Variant::BASIS">{_data._basis}</DisplayString> + <DisplayString Condition="this->type == Variant::TRANSFORM">{_data._transform}</DisplayString> + <DisplayString Condition="this->type == Variant::ARRAY">{*(Array *)_data._mem}</DisplayString> + <DisplayString Condition="this->type == Variant::STRING && ((String *)(&_data._mem[0]))->_cowdata._ptr == 0">""</DisplayString> + <DisplayString Condition="this->type == Variant::STRING && ((String *)(&_data._mem[0]))->_cowdata._ptr != 0">{((String *)(&_data._mem[0]))->_cowdata._ptr,su}</DisplayString> + <DisplayString Condition="this->type == Variant::VECTOR2">{*(Vector2 *)_data._mem}</DisplayString> + <DisplayString Condition="this->type == Variant::RECT2">{*(Rect2 *)_data._mem}</DisplayString> + <DisplayString Condition="this->type == Variant::VECTOR3">{*(Vector3 *)_data._mem}</DisplayString> + <DisplayString Condition="this->type == Variant::PLANE">{*(Plane *)_data._mem}</DisplayString> + <DisplayString Condition="this->type == Variant::QUAT">{*(Quat *)_data._mem}</DisplayString> + <DisplayString Condition="this->type == Variant::COLOR">{*(Color *)_data._mem}</DisplayString> + <DisplayString Condition="this->type == Variant::NODE_PATH">{*(NodePath *)_data._mem}</DisplayString> + <DisplayString Condition="this->type == Variant::_RID">{*(RID *)_data._mem}</DisplayString> + <DisplayString Condition="this->type == Variant::OBJECT">{*(Object *)_data._mem}</DisplayString> + <DisplayString Condition="this->type == Variant::DICTIONARY">{*(Dictionary *)_data._mem}</DisplayString> + <DisplayString Condition="this->type == Variant::ARRAY">{*(Array *)_data._mem}</DisplayString> + <DisplayString Condition="this->type == Variant::POOL_BYTE_ARRAY">{*(PoolByteArray *)_data._mem}</DisplayString> + <DisplayString Condition="this->type == Variant::POOL_INT_ARRAY">{*(PoolIntArray *)_data._mem}</DisplayString> + <DisplayString Condition="this->type == Variant::POOL_REAL_ARRAY">{*(PoolRealArray *)_data._mem}</DisplayString> + <DisplayString Condition="this->type == Variant::POOL_STRING_ARRAY">{*(PoolStringArray *)_data._mem}</DisplayString> + <DisplayString Condition="this->type == Variant::POOL_VECTOR2_ARRAY">{*(PoolVector2Array *)_data._mem}</DisplayString> + <DisplayString Condition="this->type == Variant::POOL_VECTOR3_ARRAY">{*(PoolVector3Array *)_data._mem}</DisplayString> + <DisplayString Condition="this->type == Variant::POOL_COLOR_ARRAY">{*(PoolColorArray *)_data._mem}</DisplayString> + + <StringView Condition="this->type == Variant::STRING && ((String *)(&_data._mem[0]))->_cowdata._ptr != 0">((String *)(&_data._mem[0]))->_cowdata._ptr,su</StringView> + + <Expand> + <Item Name="value" Condition="this->type == Variant::BOOL">_data._bool</Item> + <Item Name="value" Condition="this->type == Variant::INT">_data._int</Item> + <Item Name="value" Condition="this->type == Variant::REAL">_data._real</Item> + <Item Name="value" Condition="this->type == Variant::TRANSFORM2D">_data._transform2d</Item> + <Item Name="value" Condition="this->type == Variant::AABB">_data._aabb</Item> + <Item Name="value" Condition="this->type == Variant::BASIS">_data._basis</Item> + <Item Name="value" Condition="this->type == Variant::TRANSFORM">_data._transform</Item> + <Item Name="value" Condition="this->type == Variant::ARRAY">*(Array *)_data._mem</Item> + <Item Name="value" Condition="this->type == Variant::STRING">*(String *)_data._mem</Item> + <Item Name="value" Condition="this->type == Variant::VECTOR2">*(Vector2 *)_data._mem</Item> + <Item Name="value" Condition="this->type == Variant::RECT2">*(Rect2 *)_data._mem</Item> + <Item Name="value" Condition="this->type == Variant::VECTOR3">*(Vector3 *)_data._mem</Item> + <Item Name="value" Condition="this->type == Variant::PLANE">*(Plane *)_data._mem</Item> + <Item Name="value" Condition="this->type == Variant::QUAT">*(Quat *)_data._mem</Item> + <Item Name="value" Condition="this->type == Variant::COLOR">*(Color *)_data._mem</Item> + <Item Name="value" Condition="this->type == Variant::NODE_PATH">*(NodePath *)_data._mem</Item> + <Item Name="value" Condition="this->type == Variant::_RID">*(RID *)_data._mem</Item> + <Item Name="value" Condition="this->type == Variant::OBJECT">*(Object *)_data._mem</Item> + <Item Name="value" Condition="this->type == Variant::DICTIONARY">*(Dictionary *)_data._mem</Item> + <Item Name="value" Condition="this->type == Variant::ARRAY">*(Array *)_data._mem</Item> + <Item Name="value" Condition="this->type == Variant::POOL_BYTE_ARRAY">*(PoolByteArray *)_data._mem</Item> + <Item Name="value" Condition="this->type == Variant::POOL_INT_ARRAY">*(PoolIntArray *)_data._mem</Item> + <Item Name="value" Condition="this->type == Variant::POOL_REAL_ARRAY">*(PoolRealArray *)_data._mem</Item> + <Item Name="value" Condition="this->type == Variant::POOL_STRING_ARRAY">*(PoolStringArray *)_data._mem</Item> + <Item Name="value" Condition="this->type == Variant::POOL_VECTOR2_ARRAY">*(PoolVector2Array *)_data._mem</Item> + <Item Name="value" Condition="this->type == Variant::POOL_VECTOR3_ARRAY">*(PoolVector3Array *)_data._mem</Item> + <Item Name="value" Condition="this->type == Variant::POOL_COLOR_ARRAY">*(PoolColorArray *)_data._mem</Item> + </Expand> + </Type> + + <Type Name="String"> + <DisplayString Condition="this->_cowdata._ptr == 0">empty</DisplayString> + <DisplayString Condition="this->_cowdata._ptr != 0">{this->_cowdata._ptr,su}</DisplayString> + <StringView Condition="this->_cowdata._ptr != 0">this->_cowdata._ptr,su</StringView> + </Type> + + <Type Name="Vector2"> + <DisplayString>{{{x},{y}}}</DisplayString> + <Expand> + <Item Name="x">x</Item> + <Item Name="y">y</Item> + </Expand> + </Type> + + <Type Name="Vector3"> + <DisplayString>{{{x},{y},{z}}}</DisplayString> + <Expand> + <Item Name="x">x</Item> + <Item Name="y">y</Item> + <Item Name="z">z</Item> + </Expand> + </Type> + + <Type Name="Quat"> + <DisplayString>Quat {{{x},{y},{z},{w}}}</DisplayString> + <Expand> + <Item Name="x">x</Item> + <Item Name="y">y</Item> + <Item Name="z">z</Item> + <Item Name="w">w</Item> + </Expand> + </Type> + + <Type Name="Color"> + <DisplayString>Color {{{r},{g},{b},{a}}}</DisplayString> + <Expand> + <Item Name="red">r</Item> + <Item Name="green">g</Item> + <Item Name="blue">b</Item> + <Item Name="alpha">a</Item> + </Expand> + </Type> +</AutoVisualizer> diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index f63aebbbd3..d575525f93 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2312,7 +2312,9 @@ void OS_Windows::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shap cursors[p_shape] = CreateIconIndirect(&iconinfo); if (p_shape == cursor_shape) { - SetCursor(cursors[p_shape]); + if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) { + SetCursor(cursors[p_shape]); + } } if (hAndMask != NULL) { diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 24dfe541f9..88036c28e3 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -2607,7 +2607,9 @@ void OS_X11::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c cursors[p_shape] = XcursorImageLoadCursor(x11_display, cursor_image); if (p_shape == current_cursor) { - XDefineCursor(x11_display, x11_window, cursors[p_shape]); + if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) { + XDefineCursor(x11_display, x11_window, cursors[p_shape]); + } } memfree(cursor_image->pixels); |