diff --git a/code/nel/include/nel/3d/driver.h b/code/nel/include/nel/3d/driver.h index 51ea013c3..aced27f92 100644 --- a/code/nel/include/nel/3d/driver.h +++ b/code/nel/include/nel/3d/driver.h @@ -755,11 +755,13 @@ public: // Display a cursor from its name (case unsensitive) virtual void setCursor(const std::string &name, NLMISC::CRGBA col, uint8 rot, sint hotSpotX, sint hotSpotY, bool forceRebuild = false) = 0; + // Change default scale for all cursors + virtual void setCursorScale(float scale) = 0; + /** Check whether there is a low level device manager available, and get its interface. Return NULL if not available * From this interface you can deal with mouse and keyboard as above, but you can also manage game device (joysticks, joypads ...) */ virtual NLMISC::IInputDeviceManager *getLowLevelInputDeviceManager() = 0; - // @} /// Get the width and the height of the window diff --git a/code/nel/include/nel/3d/driver_user.h b/code/nel/include/nel/3d/driver_user.h index bb21b01a6..81016186f 100644 --- a/code/nel/include/nel/3d/driver_user.h +++ b/code/nel/include/nel/3d/driver_user.h @@ -440,6 +440,8 @@ public: // Display a cursor from its name (case unsensitive) virtual void setCursor(const std::string &name, NLMISC::CRGBA col, uint8 rot, sint hotSpotX, sint hotSpotY, bool forceRebuild = false); + // Change default scale for all cursors + virtual void setCursorScale(float scale); // @} diff --git a/code/nel/include/nel/3d/u_driver.h b/code/nel/include/nel/3d/u_driver.h index 173ac4b9e..3c120737d 100644 --- a/code/nel/include/nel/3d/u_driver.h +++ b/code/nel/include/nel/3d/u_driver.h @@ -604,6 +604,9 @@ public: // Display a cursor from its name (case unsensitive) virtual void setCursor(const std::string &name, NLMISC::CRGBA col, uint8 rot, sint hotSpotX, sint hotSpotY, bool forceRebuild = false) = 0; + // Change default scale for all cursors + virtual void setCursorScale(float scale) = 0; + // @} /// \name Misc. diff --git a/code/nel/include/nel/net/module_builder_parts.h b/code/nel/include/nel/net/module_builder_parts.h index 22b863abb..b080e521f 100644 --- a/code/nel/include/nel/net/module_builder_parts.h +++ b/code/nel/include/nel/net/module_builder_parts.h @@ -127,6 +127,8 @@ namespace NLNET class IModuleTrackerCb { public: + virtual ~IModuleTrackerCb() { } + virtual void onTrackedModuleUp(IModuleProxy *moduleProxy) =0; virtual void onTrackedModuleDown(IModuleProxy *moduleProxy) =0; }; diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp index febc34286..5a9aa051b 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp @@ -173,7 +173,7 @@ CDriverD3D::CDriverD3D() _CurrRot = 0; _CurrHotSpotX = 0; _CurrHotSpotY = 0; - _CursorScale = 0.85f; + _CursorScale = 1.f; _UserViewMtx.identity(); _UserModelMtx.identity(); @@ -2722,6 +2722,7 @@ bool CDriverD3D::fillPresentParameter (D3DPRESENT_PARAMETERS ¶meters, D3DFOR D3DFMT_D24FS8, //D3DFMT_D16, }; + const uint zbufferFormatCount = sizeof(zbufferFormats)/sizeof(D3DFORMAT); uint i; for (i=0; i0 && rect.Height>0; } -void CDriverD3D::getZBufferPart (std::vector &/* zbuffer */, NLMISC::CRect &/* rect */) +void CDriverD3D::getZBuffer(std::vector &zbuffer) +{ + H_AUTO_D3D(CDriverD3D_getZBuffer); + + CRect rect(0, 0); + getWindowSize(rect.Width, rect.Height); + getZBufferPart(zbuffer, rect); +} + +void CDriverD3D::getZBufferPart (std::vector &zbuffer, NLMISC::CRect &rect) { -/* ace: currently not working zbuffer.clear(); - if(clipRect(rect)) + IDirect3DSurface9 *surface; + if (SUCCEEDED(_DeviceInterface->GetDepthStencilSurface(&surface))) { - IDirect3DSurface9 *surface; - if(_DeviceInterface->GetDepthStencilSurface(&surface)== D3D_OK) + if (clipRect(rect)) { - // Surface desc - D3DSURFACE_DESC desc; - if (surface->GetDesc(&desc) == D3D_OK) + RECT winRect; + winRect.left = rect.left(); + winRect.right = rect.right(); + winRect.top = rect.top(); + winRect.bottom = rect.bottom(); + + // Lock the surface + D3DLOCKED_RECT lock; + if (SUCCEEDED(surface->LockRect (&lock, &winRect, D3DLOCK_READONLY))) { - // 32 bits format supported - if (desc.Format == D3DFMT_D24S8) + zbuffer.resize(rect.Width*rect.Height); + + // Surface desc + D3DSURFACE_DESC desc; + if (SUCCEEDED(surface->GetDesc(&desc))) { - // Lock the surface - D3DLOCKED_RECT lock; - ::RECT winRect; - winRect.left = rect.left(); - winRect.right = rect.right(); - winRect.top = rect.top(); - winRect.bottom = rect.bottom(); - const uint lineCount = rect.Height; - const uint width = rect.Width; - HRESULT hr = surface->LockRect (&lock, &winRect, D3DLOCK_READONLY); - if (hr == D3D_OK) + const uint8* pBits = (uint8*)lock.pBits; + + for(uint y=0; y::max(); + } + } + else if (desc.Format == D3DFMT_D16_LOCKABLE) + { + uint16* pRow = (uint16*)(pBits + lock.Pitch * y); + while(offset != end) + { + uint16 value = *pRow++; + zbuffer[offset++] = (float)value / (float)std::numeric_limits::max(); + } } - surface->UnlockRect (); } } + + surface->UnlockRect (); } - surface->Release(); } + + surface->Release(); } -*/ } @@ -3932,9 +3963,4 @@ bool CDriverD3D::convertBitmapToIcon(const NLMISC::CBitmap &bitmap, HICON &icon, return true; } -bool CDriverD3D::convertBitmapToCursor(const NLMISC::CBitmap &bitmap, nlCursor &cursor, uint iconWidth, uint iconHeight, uint iconDepth, const NLMISC::CRGBA &col, sint hotSpotX, sint hotSpotY) -{ - return convertBitmapToIcon(bitmap, cursor, iconWidth, iconHeight, iconDepth, col, hotSpotX, hotSpotY, true); -} - } // NL3D diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.h b/code/nel/src/3d/driver/direct3d/driver_direct3d.h index 83e85dc1d..f17531520 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.h +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.h @@ -822,9 +822,8 @@ public: virtual void setDepthRange(float znear, float zfar); virtual void getDepthRange(float &znear, float &zfar) const; - // todo hulud d3d buffers - virtual void getZBuffer (std::vector &/* zbuffer */) {} - virtual void getBufferPart (CBitmap &bitmap, NLMISC::CRect &rect); // Only 32 bits back buffer supported + virtual void getZBuffer (std::vector &zbuffer); + virtual void getBufferPart (CBitmap &bitmap, NLMISC::CRect &rect); // return true if driver support Bloom effect. virtual bool supportBloomEffect() const; @@ -923,14 +922,15 @@ public: // see if system cursor is currently captured virtual bool isSystemCursorCaptured(); - virtual void setHardwareCursorScale(float scale) { _CursorScale = scale; } - // Add a new cursor (name is case unsensitive) virtual void addCursor(const std::string &name, const NLMISC::CBitmap &bitmap); // Display a cursor from its name (case unsensitive) virtual void setCursor(const std::string &name, NLMISC::CRGBA col, uint8 rot, sint hotSpotX, sint hotSpotY, bool forceRebuild = false); + // Change default scale for all cursors + virtual void setCursorScale(float scale); + virtual NLMISC::IMouseDevice *enableLowLevelMouse(bool enable, bool exclusive); virtual NLMISC::IKeyboardDevice *enableLowLevelKeyboard(bool enable); virtual NLMISC::IInputDeviceManager *getLowLevelInputDeviceManager(); @@ -2093,18 +2093,18 @@ private: // cursors enum TColorDepth { ColorDepth16 = 0, ColorDepth32, ColorDepthCount }; - TColorDepth _ColorDepth; - std::string _CurrName; - NLMISC::CRGBA _CurrCol; - uint8 _CurrRot; - uint _CurrHotSpotX; - uint _CurrHotSpotY; - float _CursorScale; + TColorDepth _ColorDepth; + std::string _CurrName; + NLMISC::CRGBA _CurrCol; + uint8 _CurrRot; + uint _CurrHotSpotX; + uint _CurrHotSpotY; + float _CursorScale; - nlCursor _DefaultCursor; + nlCursor _DefaultCursor; - bool _AlphaBlendedCursorSupported; - bool _AlphaBlendedCursorSupportRetrieved; + bool _AlphaBlendedCursorSupported; + bool _AlphaBlendedCursorSupportRetrieved; class CCursor { diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_inputs.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_inputs.cpp index c2c456fcc..e64585ad7 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_inputs.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_inputs.cpp @@ -177,11 +177,8 @@ void CDriverD3D::addCursor(const std::string &name, const NLMISC::CBitmap &curso CCursor &curs = _Cursors[name]; curs = CCursor(); // erase possible previous cursor - uint destWidth; - uint destHeight; - - destWidth = GetSystemMetrics(SM_CXCURSOR); - destHeight = GetSystemMetrics(SM_CYCURSOR); + uint destWidth = GetSystemMetrics(SM_CXCURSOR); + uint destHeight = GetSystemMetrics(SM_CYCURSOR); // build a square bitmap uint tmpSize = std::max(maxX - minX + 1, maxY - minY + 1); @@ -198,9 +195,12 @@ void CDriverD3D::addCursor(const std::string &name, const NLMISC::CBitmap &curso // first resampling, same for all cursors tmpSize = (uint) (tmpSize * curs.HotspotScale); if (tmpSize == 0) tmpSize = 1; -/* - curs.Src.resample(tmpSize, tmpSize); -*/ + + if (curs.HotspotScale < 1.f) + { + curs.Src.resample(tmpSize, tmpSize); + } + // shrink if necessary if (tmpSize > destWidth || tmpSize > destHeight) // need to shrink ? { @@ -300,17 +300,19 @@ void CDriverD3D::setCursor(const std::string &name, NLMISC::CRGBA col, uint8 rot } +// ************************************************************************************* +void CDriverD3D::setCursorScale(float scale) +{ + _CursorScale = scale; +} + // ************************************************************************************* nlCursor CDriverD3D::buildCursor(const CBitmap &src, NLMISC::CRGBA col, uint8 rot, sint hotSpotX, sint hotSpotY) { nlassert(isAlphaBlendedCursorSupported()); - uint mouseW; - uint mouseH; - - // use cursor size from system - mouseW = GetSystemMetrics(SM_CXCURSOR); - mouseH = GetSystemMetrics(SM_CYCURSOR); + uint mouseW = GetSystemMetrics(SM_CXCURSOR); + uint mouseH = GetSystemMetrics(SM_CYCURSOR); CBitmap rotSrc = src; if (rot > 3) rot = 3; // mimic behavior of 'CViewRenderer::drawRotFlipBitmapTiled' (why not rot & 3 ??? ...) @@ -374,6 +376,7 @@ void CDriverD3D::setMousePos(float x, float y) if (_HWnd == EmptyWindow) return; + // convert position size from float to pixels sint x1 = (sint)((float)_CurrentMode.Width*x); sint y1 = (sint)((float)_CurrentMode.Height*(1.0f-y)); @@ -385,6 +388,28 @@ void CDriverD3D::setMousePos(float x, float y) SetCursorPos(pt.x, pt.y); } +// *************************************************************************** +void CDriverD3D::setCapture (bool b) +{ + H_AUTO_D3D(CDriverD3D_setCapture); + + if (b && isSystemCursorInClientArea() && !isSystemCursorCaptured()) + { + SetCapture(_HWnd); + } + else if (!b && isSystemCursorCaptured()) + { + // if hardware mouse and not in client area, then force to update its aspect by updating its pos + if (!isSystemCursorInClientArea()) + { + // force update + showCursor(true); + } + + ReleaseCapture(); + } +} + // *************************************************************************** bool CDriverD3D::isSystemCursorInClientArea() { @@ -433,28 +458,6 @@ bool CDriverD3D::isSystemCursorInClientArea() return true; } -// *************************************************************************** -void CDriverD3D::setCapture (bool b) -{ - H_AUTO_D3D(CDriverD3D_setCapture); - - if (b && isSystemCursorInClientArea() && !isSystemCursorCaptured()) - { - SetCapture(_HWnd); - } - else if (!b && isSystemCursorCaptured()) - { - // if hardware mouse and not in client area, then force to update its aspect by updating its pos - if (!isSystemCursorInClientArea()) - { - // force update - showCursor(true); - } - - ReleaseCapture(); - } -} - // *************************************************************************** bool CDriverD3D::isSystemCursorCaptured() { @@ -578,4 +581,9 @@ uint CDriverD3D::getDoubleClickDelay(bool hardwareMouse) return res; } +bool CDriverD3D::convertBitmapToCursor(const NLMISC::CBitmap &bitmap, nlCursor &cursor, uint iconWidth, uint iconHeight, uint iconDepth, const NLMISC::CRGBA &col, sint hotSpotX, sint hotSpotY) +{ + return convertBitmapToIcon(bitmap, cursor, iconWidth, iconHeight, iconDepth, col, hotSpotX, hotSpotY, true); +} + } // NL3D diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index cf9a911da..38a6c3cff 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -223,7 +223,7 @@ CDriverGL::CDriverGL() _CurrRot = 0; _CurrHotSpotX = 0; _CurrHotSpotY = 0; - _CursorScale = 0.85f; + _CursorScale = 1.f; _MouseCaptured = false; _NeedToRestaureGammaRamp = false; diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index 5b3b11dfe..b06a4c83a 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -523,14 +523,15 @@ public: // see if system cursor is currently captured virtual bool isSystemCursorCaptured(); - virtual void setHardwareCursorScale(float scale) { _CursorScale = scale; } - // Add a new cursor (name is case unsensitive) virtual void addCursor(const std::string &name, const NLMISC::CBitmap &bitmap); // Display a cursor from its name (case unsensitive) virtual void setCursor(const std::string &name, NLMISC::CRGBA col, uint8 rot, sint hotSpotX, sint hotSpotY, bool forceRebuild = false); + // Change default scale for all cursors + virtual void setCursorScale(float scale); + virtual NLMISC::IMouseDevice *enableLowLevelMouse(bool enable, bool exclusive); virtual NLMISC::IKeyboardDevice *enableLowLevelKeyboard(bool enable); @@ -1003,6 +1004,9 @@ private: // Convert a NLMISC::CBitmap to nlCursor bool convertBitmapToCursor(const NLMISC::CBitmap &bitmap, nlCursor &cursor, uint iconWidth, uint iconHeight, uint iconDepth, const NLMISC::CRGBA &col, sint hotSpotX, sint hotSpotY); + // Return the best cursor size depending on specified width and height + bool getBestCursorSize(uint srcWidth, uint srcHeight, uint &dstWidth, uint &dstHeight); + // build a cursor from src, src should have the same size that the hardware cursor // or a assertion is thrown nlCursor buildCursor(const NLMISC::CBitmap &src, NLMISC::CRGBA col, uint8 rot, sint hotSpotX, sint hotSpotY); diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_inputs.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_inputs.cpp index 70c2ce9d6..aea0dfe3d 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_inputs.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_inputs.cpp @@ -24,6 +24,9 @@ # include # include # include +# ifdef HAVE_XRENDER +# include +# endif // HAVE_XRENDER #endif // NL_OS_UNIX #include "nel/misc/mouse_device.h" @@ -205,20 +208,8 @@ void CDriverGL::addCursor(const std::string &name, const NLMISC::CBitmap &cursor CCursor &curs = _Cursors[name]; curs = CCursor(); // erase possible previous cursor - uint destWidth; - uint destHeight; - -#ifdef NL_OS_WINDOWS - - destWidth = GetSystemMetrics(SM_CXCURSOR); - destHeight = GetSystemMetrics(SM_CYCURSOR); - -#elif defined(NL_OS_MAC) -#elif defined(NL_OS_UNIX) - - Status res = XQueryBestCursor(_dpy, _win, width, height, &destWidth, &destHeight); - -#endif + uint destWidth = 32, destHeight = 32; + getBestCursorSize(width, height, destWidth, destHeight); // build a square bitmap uint tmpSize = std::max(maxX - minX + 1, maxY - minY + 1); @@ -379,27 +370,19 @@ void CDriverGL::setCursor(const std::string &name, NLMISC::CRGBA col, uint8 rot, } +// ************************************************************************************* +void CDriverGL::setCursorScale(float scale) +{ + _CursorScale = scale; +} + // ************************************************************************************* nlCursor CDriverGL::buildCursor(const CBitmap &src, NLMISC::CRGBA col, uint8 rot, sint hotSpotX, sint hotSpotY) { nlassert(isAlphaBlendedCursorSupported()); - uint mouseW; - uint mouseH; - -#ifdef NL_OS_WINDOWS - - // use cursor size from system - mouseW = GetSystemMetrics(SM_CXCURSOR); - mouseH = GetSystemMetrics(SM_CYCURSOR); - -#elif defined(NL_OS_MAC) -#elif defined(NL_OS_UNIX) - - // use best cursor size for bitmap - Status res = XQueryBestCursor(_dpy, _win, src.getWidth(), src.getHeight(), &mouseW, &mouseH); - -#endif + uint mouseW = 32, mouseH = 32; + getBestCursorSize(src.getWidth(), src.getHeight(), mouseW, mouseH); CBitmap rotSrc = src; if (rot > 3) rot = 3; // mimic behavior of 'CViewRenderer::drawRotFlipBitmapTiled' (why not rot & 3 ??? ...) @@ -437,7 +420,7 @@ void CDriverGL::setSystemArrow() #endif } -// -------------------------------------------------- +// *************************************************************************** void CDriverGL::showCursor(bool b) { H_AUTO_OGL(CDriverGL_showCursor); @@ -504,7 +487,7 @@ void CDriverGL::showCursor(bool b) #endif // NL_OS_UNIX } -// -------------------------------------------------- +// *************************************************************************** void CDriverGL::setMousePos(float x, float y) { H_AUTO_OGL(CDriverGL_setMousePos) @@ -558,9 +541,10 @@ void CDriverGL::setMousePos(float x, float y) #endif // NL_OS_UNIX } +// *************************************************************************** void CDriverGL::setCapture (bool b) { - H_AUTO_OGL(CDriverGL_setCapture ) + H_AUTO_OGL(CDriverGL_setCapture); #ifdef NL_OS_WINDOWS @@ -603,6 +587,7 @@ void CDriverGL::setCapture (bool b) #endif // NL_OS_UNIX } +// *************************************************************************** bool CDriverGL::isSystemCursorInClientArea() { if (_FullScreen /* || !IsMouseCursorHardware() */) @@ -811,4 +796,161 @@ uint CDriverGL::getDoubleClickDelay(bool hardwareMouse) return res; } +bool CDriverGL::getBestCursorSize(uint srcWidth, uint srcHeight, uint &dstWidth, uint &dstHeight) +{ +#ifdef NL_OS_WINDOWS + + // Windows provides default size for cursors + dstWidth = (uint)GetSystemMetrics(SM_CXCURSOR); + dstHeight = (uint)GetSystemMetrics(SM_CYCURSOR); + +#elif defined(NL_OS_MAC) +#elif defined(NL_OS_UNIX) + + Status res = XQueryBestCursor(_dpy, _win, srcWidth, srcHeight, &dstWidth, &dstHeight); + nlwarning("XQueryBestCursor returned %d", (sint)res); + +#endif + + return true; +} + +bool CDriverGL::convertBitmapToCursor(const NLMISC::CBitmap &bitmap, nlCursor &cursor, uint iconWidth, uint iconHeight, uint iconDepth, const NLMISC::CRGBA &col, sint hotSpotX, sint hotSpotY) +{ +#if defined(NL_OS_WINDOWS) + + return convertBitmapToIcon(bitmap, cursor, iconWidth, iconHeight, iconDepth, col, hotSpotX, hotSpotY, true); + +#elif defined(NL_OS_UNIX) && defined(HAVE_XRENDER) && !defined(NL_OS_MAC) + + CBitmap src = bitmap; + + // resample bitmap if necessary + if (src.getWidth() != iconWidth || src.getHeight() != iconHeight) + { + src.resample(iconWidth, iconHeight); + } + + CBitmap colorBm; + colorBm.resize(iconWidth, iconHeight, CBitmap::RGBA); + const CRGBA *srcColorPtr = (CRGBA *) &(src.getPixels()[0]); + const CRGBA *srcColorPtrLast = srcColorPtr + (iconWidth * iconHeight); + CRGBA *destColorPtr = (CRGBA *) &(colorBm.getPixels()[0]); + + do + { + // colorize icon + destColorPtr->modulateFromColor(*srcColorPtr, col); + + // X11 wants BGRA pixels : swap red and blue channels + std::swap(destColorPtr->R, destColorPtr->B); + + // premultiplied alpha + if (destColorPtr->A < 255) + { + destColorPtr->R = (destColorPtr->R * destColorPtr->A) / 255; + destColorPtr->G = (destColorPtr->G * destColorPtr->A) / 255; + destColorPtr->B = (destColorPtr->B * destColorPtr->A) / 255; + } + + ++ srcColorPtr; + ++ destColorPtr; + } + while (srcColorPtr != srcColorPtrLast); + + // use malloc() because X will free() data itself + CRGBA *src32 = (CRGBA*)malloc(colorBm.getSize()*4); + memcpy(src32, &colorBm.getPixels(0)[0], colorBm.getSize()*4); + + uint size = iconWidth * iconHeight; + + // Create the icon pixmap + sint screen = DefaultScreen(_dpy); + Visual *visual = DefaultVisual(_dpy, screen); + + if (!visual) + { + nlwarning("Failed to get a default visual for screen %d", screen); + return false; + } + + // create the icon pixmap + XImage* image = XCreateImage(_dpy, visual, 32, ZPixmap, 0, (char*)src32, iconWidth, iconHeight, 32, 0); + + if (!image) + { + nlwarning("Failed to set the window's icon"); + return false; + } + + Pixmap pixmap = XCreatePixmap(_dpy, _win, iconWidth, iconHeight, 32 /* defDepth */); + + if (!pixmap) + { + nlwarning("Failed to create a pixmap %ux%ux%d", iconWidth, iconHeight, 32); + return false; + } + + GC gc = XCreateGC(_dpy, pixmap, 0, NULL); + + if (!gc) + { + nlwarning("Failed to create a GC"); + return false; + } + + sint res = XPutImage(_dpy, pixmap, gc, image, 0, 0, 0, 0, iconWidth, iconHeight); + // should return 0 + nlwarning("XPutImage returned %d", res); + + res = XFreeGC(_dpy, gc); + // should return 1 + nlwarning("XFreeGC returned %d", res); + + if (image->data) + { + free(image->data); + image->data = NULL; + } + + XDestroyImage(image); + + XRenderPictFormat *format = XRenderFindStandardFormat(_dpy, PictStandardARGB32); + + if (!format) + { + nlwarning("Failed to find a standard format"); + return false; + } + + Picture picture = XRenderCreatePicture(_dpy, pixmap, format, 0, 0); + + if (!picture) + { + nlwarning("Failed to create picture"); + return false; + } + + cursor = XRenderCreateCursor(_dpy, picture, (uint)hotSpotX, (uint)hotSpotY); + + if (!cursor) + { + nlwarning("Failed to create cursor"); + return false; + } + + XRenderFreePicture(_dpy, picture); + res = XFreePixmap(_dpy, pixmap); + // should return 1 + nlwarning("XFreePixmap returned %d", res); + + return true; + +#else + + return false; + +#endif +} + } // NL3D diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp index 8afce2f80..b7cc6153b 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -2659,7 +2659,7 @@ bool CDriverGL::convertBitmapToIcon(const NLMISC::CBitmap &bitmap, HICON &icon, const CRGBA *srcColorPtr = (CRGBA *) &(src.getPixels()[0]); const CRGBA *srcColorPtrLast = srcColorPtr + (iconWidth * iconHeight); CRGBA *destColorPtr = (CRGBA *) &(colorBm.getPixels()[0]); - static volatile uint8 alphaThreshold = 127; + static uint8 alphaThreshold = 127; do { destColorPtr->modulateFromColor(*srcColorPtr, col); @@ -2687,7 +2687,7 @@ bool CDriverGL::convertBitmapToIcon(const NLMISC::CBitmap &bitmap, HICON &icon, for (uint k = 0;k < colorBm16.size(); ++k) { - if (src32[k].A <= 120) + if (src32[k].A <= alphaThreshold) { bitMask[k / 8] |= (0x80 >> (k & 7)); } @@ -2720,18 +2720,8 @@ bool CDriverGL::convertBitmapToIcon(const NLMISC::CBitmap &bitmap, HICON &icon, return true; } -bool CDriverGL::convertBitmapToCursor(const NLMISC::CBitmap &bitmap, nlCursor &cursor, uint iconWidth, uint iconHeight, uint iconDepth, const NLMISC::CRGBA &col, sint hotSpotX, sint hotSpotY) -{ - return convertBitmapToIcon(bitmap, cursor, iconWidth, iconHeight, iconDepth, col, hotSpotX, hotSpotY, true); -} - #elif defined(NL_OS_MAC) -bool CDriverGL::convertBitmapToCursor(const NLMISC::CBitmap &bitmap, nlCursor &cursor, uint iconWidth, uint iconHeight, uint iconDepth, const NLMISC::CRGBA &col, sint hotSpotX, sint hotSpotY) -{ - return false; -} - #elif defined(NL_OS_UNIX) bool CDriverGL::convertBitmapToIcon(const NLMISC::CBitmap &bitmap, std::vector &icon) @@ -2758,140 +2748,6 @@ bool CDriverGL::convertBitmapToIcon(const NLMISC::CBitmap &bitmap, std::vectormodulateFromColor(*srcColorPtr, col); - - // X11 wants BGRA pixels : swap red and blue channels - std::swap(destColorPtr->R, destColorPtr->B); - - // premultiplied alpha - if (destColorPtr->A < 255) - { - destColorPtr->R = (destColorPtr->R * destColorPtr->A) / 255; - destColorPtr->G = (destColorPtr->G * destColorPtr->A) / 255; - destColorPtr->B = (destColorPtr->B * destColorPtr->A) / 255; - } - - ++ srcColorPtr; - ++ destColorPtr; - } - while (srcColorPtr != srcColorPtrLast); - - // use malloc() because X will free() data itself - CRGBA *src32 = (CRGBA*)malloc(colorBm.getSize()*4); - memcpy(src32, &colorBm.getPixels(0)[0], colorBm.getSize()*4); - - uint size = iconWidth * iconHeight; - - // Create the icon pixmap - sint screen = DefaultScreen(_dpy); - Visual *visual = DefaultVisual(_dpy, screen); - - if (!visual) - { - nlwarning("Failed to get a default visual for screen %d", screen); - return false; - } - - // create the icon pixmap - XImage* image = XCreateImage(_dpy, visual, 32, ZPixmap, 0, (char*)src32, iconWidth, iconHeight, 32, 0); - - if (!image) - { - nlwarning("Failed to set the window's icon"); - return false; - } - - Pixmap pixmap = XCreatePixmap(_dpy, _win, iconWidth, iconHeight, 32 /* defDepth */); - - if (!pixmap) - { - nlwarning("Failed to create a pixmap %ux%ux%d", iconWidth, iconHeight, 32); - return false; - } - - GC gc = XCreateGC(_dpy, pixmap, 0, NULL); - - if (!gc) - { - nlwarning("Failed to create a GC"); - return false; - } - - sint res = XPutImage(_dpy, pixmap, gc, image, 0, 0, 0, 0, iconWidth, iconHeight); - // should return 0 - nlwarning("XPutImage returned %d", res); - - res = XFreeGC(_dpy, gc); - // should return 1 - nlwarning("XFreeGC returned %d", res); - - if (image->data) - { - free(image->data); - image->data = NULL; - } - - XDestroyImage(image); - - XRenderPictFormat *format = XRenderFindStandardFormat(_dpy, PictStandardARGB32); - - if (!format) - { - nlwarning("Failed to find a standard format"); - return false; - } - - Picture picture = XRenderCreatePicture(_dpy, pixmap, format, 0, 0); - - if (!picture) - { - nlwarning("Failed to create picture"); - return false; - } - - cursor = XRenderCreateCursor(_dpy, picture, (uint)hotSpotX, (uint)hotSpotY); - - if (!cursor) - { - nlwarning("Failed to create cursor"); - return false; - } - - XRenderFreePicture(_dpy, picture); - res = XFreePixmap(_dpy, pixmap); - // should return 1 - nlwarning("XFreePixmap returned %d", res); - - return true; - -#else - - return false; - -#endif -} - #endif } // NL3D diff --git a/code/nel/src/3d/driver_user.cpp b/code/nel/src/3d/driver_user.cpp index b26a4b951..6d2bdcb53 100644 --- a/code/nel/src/3d/driver_user.cpp +++ b/code/nel/src/3d/driver_user.cpp @@ -1664,6 +1664,13 @@ void CDriverUser::setCursor(const std::string &name, NLMISC::CRGBA col, uint8 _Driver->setCursor(name, col, rot, hotSpotX, hotSpotY, forceRebuild); } +void CDriverUser::setCursorScale(float scale) +{ + NL3D_HAUTO_UI_DRIVER; + + _Driver->setCursorScale(scale); +} + // *************************************************************************** // *************************************************************************** // Async Texture loading mgt diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/config.xml b/code/ryzom/client/data/gamedev/interfaces_v3/config.xml index 88306afc5..e1b5be456 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/config.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/config.xml @@ -2960,12 +2960,18 @@ This MUST follow the Enum MISSION_DESC::TIconId + + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml b/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml index f15f3adc9..bd4b7ed40 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml @@ -1605,14 +1605,23 @@ posparent="cc_univ" x="0" y="-4" /> + + y="-8" /> + + +