From 264be2108c51837fa92085f6c839e66aebbcfc9e Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Sun, 28 Jan 2024 20:56:41 +0100 Subject: Added support for map/layer mask A custom "Mask" property on a layer or a "foregroundXmask" property on a map can now be used in combination with the SMSG_MAP_MASK to dynamically disable certain map layers from the server. Feature previously seen on ManaPlus and implemented for Mana client for compatibility. Also added a ResourceRef class for automating the Resource reference counting. Closes #44 --- src/resources/ambientlayer.h | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'src/resources/ambientlayer.h') diff --git a/src/resources/ambientlayer.h b/src/resources/ambientlayer.h index 9ccf5194..def2090b 100644 --- a/src/resources/ambientlayer.h +++ b/src/resources/ambientlayer.h @@ -21,6 +21,8 @@ #ifndef RESOURCES_AMBIENTOVERLAY_H #define RESOURCES_AMBIENTOVERLAY_H +#include "resource.h" + class Graphics; class Image; @@ -31,29 +33,24 @@ class AmbientLayer * Constructor. * * @param img the image this overlay displays - * @param parallax scroll factor based on camera position - * @param speedX scrolling speed in x-direction - * @param speedY scrolling speed in y-direction - * @param keepRatio rescale the image to keep - * the same ratio than in 800x600 resolution mode. */ - AmbientLayer(Image *img, float parallax, - float speedX, float speedY, bool keepRatio = false); - + AmbientLayer(Image *img); ~AmbientLayer(); void update(int timePassed, float dx, float dy); void draw(Graphics *graphics, int x, int y); + float mParallax = 0; /**< Scroll factor based on camera position. */ + float mSpeedX = 0; /**< Scrolling speed in X direction. */ + float mSpeedY = 0; /**< Scrolling speed in Y direction. */ + int mMask = 1; + bool mKeepRatio = false; /**< Keep overlay ratio on every resolution like in 800x600 */ + private: - Image *mImage; - float mParallax; - float mPosX; /**< Current layer X position. */ - float mPosY; /**< Current layer Y position. */ - float mSpeedX; /**< Scrolling speed in X direction. */ - float mSpeedY; /**< Scrolling speed in Y direction. */ - bool mKeepRatio; /**< Keep overlay ratio on every resolution */ + ResourceRef mImage; + float mPosX = 0; /**< Current layer X position. */ + float mPosY = 0; /**< Current layer Y position. */ }; #endif -- cgit v1.2.3-70-g09d2