2024-07-21 23:11:02 +02:00
|
|
|
/*
|
|
|
|
* ImageScaled.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../render/IImage.h"
|
2024-07-24 15:35:30 +02:00
|
|
|
#include "../render/IRenderHandler.h"
|
2024-07-21 23:11:02 +02:00
|
|
|
|
2024-07-25 12:38:48 +02:00
|
|
|
#include "../../lib/Color.h"
|
|
|
|
#include "../../lib/constants/EntityIdentifiers.h"
|
|
|
|
|
2024-07-21 23:11:02 +02:00
|
|
|
struct SDL_Palette;
|
|
|
|
|
2024-07-24 15:04:45 +02:00
|
|
|
class SDLImageShared;
|
2024-07-21 23:11:02 +02:00
|
|
|
|
2024-07-25 12:38:48 +02:00
|
|
|
// Upscaled image with several mechanisms to emulate H3 palette effects
|
|
|
|
class ImageScaled final : public IImage
|
2024-07-21 23:11:02 +02:00
|
|
|
{
|
2024-07-25 12:38:48 +02:00
|
|
|
private:
|
2024-07-21 23:11:02 +02:00
|
|
|
|
2024-07-25 12:38:48 +02:00
|
|
|
/// Original unscaled image
|
2024-11-16 17:40:05 +02:00
|
|
|
std::shared_ptr<const ISharedImage> source;
|
2024-07-21 23:11:02 +02:00
|
|
|
|
2024-07-25 12:38:48 +02:00
|
|
|
/// Upscaled shadow of our image, may be null
|
2024-11-16 17:40:05 +02:00
|
|
|
std::shared_ptr<const ISharedImage> shadow;
|
2024-07-21 23:11:02 +02:00
|
|
|
|
2024-07-25 12:38:48 +02:00
|
|
|
/// Upscaled main part of our image, may be null
|
2024-11-16 17:40:05 +02:00
|
|
|
std::shared_ptr<const ISharedImage> body;
|
2024-07-21 23:11:02 +02:00
|
|
|
|
2024-07-25 12:38:48 +02:00
|
|
|
/// Upscaled overlay (player color, selection highlight) of our image, may be null
|
2024-11-16 17:40:05 +02:00
|
|
|
std::shared_ptr<const ISharedImage> overlay;
|
2024-07-25 12:38:48 +02:00
|
|
|
|
|
|
|
ImageLocator locator;
|
|
|
|
|
|
|
|
ColorRGBA colorMultiplier;
|
|
|
|
PlayerColor playerColor = PlayerColor::CANNOT_DETERMINE;
|
2024-07-21 23:11:02 +02:00
|
|
|
|
|
|
|
uint8_t alphaValue;
|
|
|
|
EImageBlitMode blitMode;
|
|
|
|
|
2024-11-17 19:54:55 +02:00
|
|
|
void prepareImages();
|
2024-07-21 23:11:02 +02:00
|
|
|
public:
|
2024-11-16 17:40:05 +02:00
|
|
|
ImageScaled(const ImageLocator & locator, const std::shared_ptr<const ISharedImage> & source, EImageBlitMode mode);
|
2024-07-21 23:11:02 +02:00
|
|
|
|
2024-07-25 20:22:27 +02:00
|
|
|
void scaleInteger(int factor) override;
|
|
|
|
void scaleTo(const Point & size) override;
|
2024-07-21 23:11:02 +02:00
|
|
|
void exportBitmap(const boost::filesystem::path & path) const override;
|
|
|
|
bool isTransparent(const Point & coords) const override;
|
|
|
|
Point dimensions() const override;
|
|
|
|
void setAlpha(uint8_t value) override;
|
|
|
|
void setBlitMode(EImageBlitMode mode) override;
|
|
|
|
void draw(SDL_Surface * where, const Point & pos, const Rect * src) const override;
|
2024-07-25 12:38:48 +02:00
|
|
|
void setOverlayColor(const ColorRGBA & color) override;
|
2024-07-21 23:11:02 +02:00
|
|
|
void playerColored(PlayerColor player) override;
|
|
|
|
void shiftPalette(uint32_t firstColorID, uint32_t colorsToMove, uint32_t distanceToMove) override;
|
|
|
|
void adjustPalette(const ColorFilter & shifter, uint32_t colorsToSkipMask) override;
|
2024-07-25 12:38:48 +02:00
|
|
|
|
2024-11-16 17:40:05 +02:00
|
|
|
std::shared_ptr<const ISharedImage> getSharedImage() const override;
|
2024-07-21 23:11:02 +02:00
|
|
|
};
|