aboutsummaryrefslogtreecommitdiff
path: root/src/script
Commit message (Expand)AuthorAge
...
* Refactor decoration-related codekwolekr2014-10-29
* Prevent invalid memory access under failure conditionskwolekr2014-10-28
* Add NodeResolver and clean up node name -> content ID resolution systemkwolekr2014-10-26
* Custom collision boxes node property.RealBadAngel2014-10-19
* Add meshnode drawtype.RealBadAngel2014-10-18
* Fix object reference pushing functions when called from coroutinesShadowNinja2014-10-07
* Add optional framed glasslike drawtypeBlockMen2014-10-02
* Add firelike drawtypeTriBlade92014-09-21
* Split settings into seperate source and header filesShadowNinja2014-09-21
* Add compression APIShadowNinja2014-09-20
* Simplify and optimize schematic replacementsShadowNinja2014-09-11
* Add LuaVoxelManip methods: get_node_at() and set_node_at()kwolekr2014-09-01
* Update Mapgen VoxelManipulator on buffer invalidationkwolekr2014-09-01
* Add lua exception handling test codesapier2014-08-23
* Fix LuaJIT exception wrapperKahrl2014-08-23
* Fix seg fault if popping from empty stack (L-system trees)Craig Robbins2014-08-23
* Add video driver selection to settings menu (based uppon idea from webdesigne...sapier2014-08-23
* Don't call a player event without having player to do a event forsapier2014-08-21
* Mod profiling supportsapier2014-08-19
* Fix the *CDP displaySmallJoker2014-08-15
* Fix issue 1527Craig Robbins2014-07-29
* Clear inventory before setting listsShadowNinja2014-06-23
* Remove a lot of superfluous ifndef USE_CURL checkssapier2014-06-19
* Fix regression dirt texture not beeing default in non cloud menusapier2014-06-14
* Small cleanup of hud add/remove codesapier2014-05-31
* Fix over-poping and only push the core onceShadowNinja2014-05-30
* Make print() NUL-safeShadowNinja2014-05-15
* Use "core" namespace internallyShadowNinja2014-05-08
* Organize builtin into subdirectoriesShadowNinja2014-05-07
* Add write_json() to the async APIShadowNinja2014-05-07
* Fix heart + bubble bar size on different texture packssapier2014-05-07
* Add proper lua api deprecated handlingsapier2014-04-29
* Fix code style of async APIShadowNinja2014-04-27
* Remove dependency on marshal and many other async changesShadowNinja2014-04-27
* Only push the Lua error handler onceShadowNinja2014-04-27
* Add support for dpi based HUD scalingsapier2014-04-27
* Remove liquid_finite and weatherproller2014-04-18
* Fix all warnings reported by clangSfan52014-04-15
* Use integers instead of float valuesBlockMen2014-04-12
* Add player:set_eye_offset() by @MirceaKitsune and clean upBlockMen2014-04-12
* Add third person viewBlockMen2014-04-12
* Add support for named threads (atm linux only)sapier2014-04-09
* Minor fixes for file/modlist download in mainmenusapier2014-04-09
* Cleanup client init states by bumping protocol versionsapier2014-04-08
* Add more informative error messages for inventory and item method errorsShadowNinja2014-03-15
* Remove lua_State parameter from LuaError::LuaErrorShadowNinja2014-03-15
* Revert "Make sure we get a stacktrace for as many lua errors as possible"ShadowNinja2014-03-15
* Make sure we get a stacktrace for as many lua errors as possibleSfan52014-03-15
* Pass arguments by referenceSelat2014-03-12
* Correct misleading detached inventory error messageCiaran Gultnieks2014-03-09
t">.clear(); } /* Get a cached, high-quality pre-scaled texture for display purposes. If the * texture is not already cached, attempt to create it. Returns a pre-scaled texture, * or the original texture if unable to pre-scale it. */ video::ITexture *guiScalingResizeCached(video::IVideoDriver *driver, video::ITexture *src, const core::rect<s32> &srcrect, const core::rect<s32> &destrect) { if (src == NULL) return src; if (!g_settings->getBool("gui_scaling_filter")) return src; // Calculate scaled texture name. char rectstr[200]; porting::mt_snprintf(rectstr, sizeof(rectstr), "%d:%d:%d:%d:%d:%d", srcrect.UpperLeftCorner.X, srcrect.UpperLeftCorner.Y, srcrect.getWidth(), srcrect.getHeight(), destrect.getWidth(), destrect.getHeight()); io::path origname = src->getName().getPath(); io::path scalename = origname + "@guiScalingFilter:" + rectstr; // Search for existing scaled texture. video::ITexture *scaled = g_txrCache[scalename]; if (scaled) return scaled; // Try to find the texture converted to an image in the cache. // If the image was not found, try to extract it from the texture. video::IImage* srcimg = g_imgCache[origname]; if (srcimg == NULL) { if (!g_settings->getBool("gui_scaling_filter_txr2img")) return src; srcimg = driver->createImageFromData(src->getColorFormat(), src->getSize(), src->lock(), false); src->unlock(); g_imgCache[origname] = srcimg; } // Create a new destination image and scale the source into it. imageCleanTransparent(srcimg, 0); video::IImage *destimg = driver->createImage(src->getColorFormat(), core::dimension2d<u32>((u32)destrect.getWidth(), (u32)destrect.getHeight())); imageScaleNNAA(srcimg, srcrect, destimg); #if ENABLE_GLES // Some platforms are picky about textures being powers of 2, so expand // the image dimensions to the next power of 2, if necessary. if (!hasNPotSupport()) { video::IImage *po2img = driver->createImage(src->getColorFormat(), core::dimension2d<u32>(npot2((u32)destrect.getWidth()), npot2((u32)destrect.getHeight()))); po2img->fill(video::SColor(0, 0, 0, 0)); destimg->copyTo(po2img); destimg->drop(); destimg = po2img; } #endif // Convert the scaled image back into a texture. scaled = driver->addTexture(scalename, destimg, NULL); destimg->drop(); g_txrCache[scalename] = scaled; return scaled; } /* Convenience wrapper for guiScalingResizeCached that accepts parameters that * are available at GUI imagebutton creation time. */ video::ITexture *guiScalingImageButton(video::IVideoDriver *driver, video::ITexture *src, s32 width, s32 height) { if (src == NULL) return src; return guiScalingResizeCached(driver, src, core::rect<s32>(0, 0, src->getSize().Width, src->getSize().Height), core::rect<s32>(0, 0, width, height)); } /* Replacement for driver->draw2DImage() that uses the high-quality pre-scaled * texture, if configured. */ void draw2DImageFilterScaled(video::IVideoDriver *driver, video::ITexture *txr, const core::rect<s32> &destrect, const core::rect<s32> &srcrect, const core::rect<s32> *cliprect, const video::SColor *const colors, bool usealpha) { // Attempt to pre-scale image in software in high quality. video::ITexture *scaled = guiScalingResizeCached(driver, txr, srcrect, destrect); if (scaled == NULL) return; // Correct source rect based on scaled image. const core::rect<s32> mysrcrect = (scaled != txr) ? core::rect<s32>(0, 0, destrect.getWidth(), destrect.getHeight()) : srcrect; driver->draw2DImage(scaled, destrect, mysrcrect, cliprect, colors, usealpha); } void draw2DImage9Slice(video::IVideoDriver *driver, video::ITexture *texture, const core::rect<s32> &rect, const core::rect<s32> &middle) { const video::SColor color(255,255,255,255); const video::SColor colors[] = {color,color,color,color}; auto originalSize = texture->getOriginalSize(); core::vector2di lowerRightOffset = core::vector2di(originalSize.Width, originalSize.Height) - middle.LowerRightCorner; for (int y = 0; y < 3; ++y) { for (int x = 0; x < 3; ++x) { core::rect<s32> src({0, 0}, originalSize); core::rect<s32> dest = rect; switch (x) { case 0: dest.LowerRightCorner.X = rect.UpperLeftCorner.X + middle.UpperLeftCorner.X; src.LowerRightCorner.X = middle.UpperLeftCorner.X; break; case 1: dest.UpperLeftCorner.X += middle.UpperLeftCorner.X; dest.LowerRightCorner.X -= lowerRightOffset.X; src.UpperLeftCorner.X = middle.UpperLeftCorner.X; src.LowerRightCorner.X = middle.LowerRightCorner.X; break; case 2: dest.UpperLeftCorner.X = rect.LowerRightCorner.X - lowerRightOffset.X; src.UpperLeftCorner.X = middle.LowerRightCorner.X; break; } switch (y) { case 0: dest.LowerRightCorner.Y = rect.UpperLeftCorner.Y + middle.UpperLeftCorner.Y; src.LowerRightCorner.Y = middle.UpperLeftCorner.Y; break; case 1: dest.UpperLeftCorner.Y += middle.UpperLeftCorner.Y; dest.LowerRightCorner.Y -= lowerRightOffset.Y; src.UpperLeftCorner.Y = middle.UpperLeftCorner.Y; src.LowerRightCorner.Y = middle.LowerRightCorner.Y; break; case 2: dest.UpperLeftCorner.Y = rect.LowerRightCorner.Y - lowerRightOffset.Y; src.UpperLeftCorner.Y = middle.LowerRightCorner.Y; break; } draw2DImageFilterScaled(driver, texture, dest, src, NULL/*&AbsoluteClippingRect*/, colors, true); } } }