2023-10-03 20:37:00 +02:00
|
|
|
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "IGUISpriteBank.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace video
|
|
|
|
{
|
2024-03-20 19:35:52 +01:00
|
|
|
class IVideoDriver;
|
|
|
|
class ITexture;
|
2023-10-03 20:37:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace gui
|
|
|
|
{
|
|
|
|
|
2024-03-20 19:35:52 +01:00
|
|
|
class IGUIEnvironment;
|
2023-10-03 20:37:00 +02:00
|
|
|
|
|
|
|
//! Sprite bank interface.
|
|
|
|
class CGUISpriteBank : public IGUISpriteBank
|
|
|
|
{
|
|
|
|
public:
|
2024-03-20 19:35:52 +01:00
|
|
|
CGUISpriteBank(IGUIEnvironment *env);
|
2023-10-03 20:37:00 +02:00
|
|
|
virtual ~CGUISpriteBank();
|
|
|
|
|
2024-03-20 19:35:52 +01:00
|
|
|
core::array<core::rect<s32>> &getPositions() override;
|
|
|
|
core::array<SGUISprite> &getSprites() override;
|
2023-10-03 20:37:00 +02:00
|
|
|
|
|
|
|
u32 getTextureCount() const override;
|
2024-03-20 19:35:52 +01:00
|
|
|
video::ITexture *getTexture(u32 index) const override;
|
|
|
|
void addTexture(video::ITexture *texture) override;
|
|
|
|
void setTexture(u32 index, video::ITexture *texture) override;
|
2023-10-03 20:37:00 +02:00
|
|
|
|
|
|
|
//! Add the texture and use it for a single non-animated sprite.
|
2024-03-20 19:35:52 +01:00
|
|
|
s32 addTextureAsSprite(video::ITexture *texture) override;
|
2023-10-03 20:37:00 +02:00
|
|
|
|
|
|
|
//! clears sprites, rectangles and textures
|
|
|
|
void clear() override;
|
|
|
|
|
|
|
|
//! Draws a sprite in 2d with position and color
|
2024-03-20 19:35:52 +01:00
|
|
|
virtual void draw2DSprite(u32 index, const core::position2di &pos, const core::rect<s32> *clip = 0,
|
|
|
|
const video::SColor &color = video::SColor(255, 255, 255, 255),
|
|
|
|
u32 starttime = 0, u32 currenttime = 0, bool loop = true, bool center = false) override;
|
2023-10-03 20:37:00 +02:00
|
|
|
|
|
|
|
//! Draws a sprite in 2d with destination rectangle and colors
|
2024-03-20 19:35:52 +01:00
|
|
|
virtual void draw2DSprite(u32 index, const core::rect<s32> &destRect,
|
|
|
|
const core::rect<s32> *clip = 0,
|
|
|
|
const video::SColor *const colors = 0,
|
2023-10-03 20:37:00 +02:00
|
|
|
u32 timeTicks = 0,
|
2024-03-20 19:35:52 +01:00
|
|
|
bool loop = true) override;
|
2023-10-03 20:37:00 +02:00
|
|
|
|
|
|
|
//! Draws a sprite batch in 2d using an array of positions and a color
|
2024-03-20 19:35:52 +01:00
|
|
|
virtual void draw2DSpriteBatch(const core::array<u32> &indices, const core::array<core::position2di> &pos,
|
|
|
|
const core::rect<s32> *clip = 0,
|
|
|
|
const video::SColor &color = video::SColor(255, 255, 255, 255),
|
|
|
|
u32 starttime = 0, u32 currenttime = 0,
|
|
|
|
bool loop = true, bool center = false) override;
|
2023-10-03 20:37:00 +02:00
|
|
|
|
|
|
|
protected:
|
2024-03-20 19:35:52 +01:00
|
|
|
bool getFrameNr(u32 &frameNr, u32 index, u32 time, bool loop) const;
|
2023-10-03 20:37:00 +02:00
|
|
|
|
|
|
|
struct SDrawBatch
|
|
|
|
{
|
|
|
|
core::array<core::position2di> positions;
|
|
|
|
core::array<core::recti> sourceRects;
|
|
|
|
u32 textureNumber;
|
|
|
|
};
|
|
|
|
|
|
|
|
core::array<SGUISprite> Sprites;
|
2024-03-20 19:35:52 +01:00
|
|
|
core::array<core::rect<s32>> Rectangles;
|
|
|
|
core::array<video::ITexture *> Textures;
|
|
|
|
IGUIEnvironment *Environment;
|
|
|
|
video::IVideoDriver *Driver;
|
2023-10-03 20:37:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace gui
|
|
|
|
} // end namespace irr
|