SuperTuxKart
Loading...
Searching...
No Matches
CGUISpriteBank.hpp
1// Copyright (C) 2002-2015 Nikolaus Gebhardt, modified by Marianne Gagnon
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5#ifndef __C_GUI_MODIFIED_SPRITE_BANK_H_INCLUDED__
6#define __C_GUI_MODIFIED_SPRITE_BANK_H_INCLUDED__
7
8#include "IrrCompileConfig.h"
9#ifdef _IRR_COMPILE_WITH_GUI_
10#include <cassert>
11#include "IGUISpriteBank.h"
12#include "utils/leak_check.hpp"
13
14namespace irr
15{
16
17namespace video
18{
19 class IVideoDriver;
20 class ITexture;
21}
22
23namespace gui
24{
25
26 class IGUIEnvironment;
27
29class STKModifiedSpriteBank : public IGUISpriteBank
30{
31public:
32
33 LEAK_CHECK()
34
35 STKModifiedSpriteBank(IGUIEnvironment* env);
36 virtual ~STKModifiedSpriteBank();
37
38 virtual core::array< core::rect<s32> >& getPositions();
39 virtual core::array< SGUISprite >& getSprites();
40
41 virtual u32 getTextureCount() const;
42 virtual video::ITexture* getTexture(u32 index) const;
43 virtual void addTexture(video::ITexture* texture);
44 virtual void setTexture(u32 index, video::ITexture* texture);
45
47 virtual s32 addTextureAsSprite(video::ITexture* texture);
48
50 virtual void clear();
51
53 virtual void draw2DSprite(u32 index, const core::position2di& pos, const core::rect<s32>* clip=0,
54 const video::SColor& color= video::SColor(255,255,255,255),
55 u32 starttime=0, u32 currenttime=0, bool loop=true, bool center=false);
56
58 virtual void draw2DSpriteBatch(const core::array<u32>& indices, const core::array<core::position2di>& pos,
59 const core::rect<s32>* clip=0,
60 const video::SColor& color= video::SColor(255,255,255,255),
61 u32 starttime=0, u32 currenttime=0,
62 bool loop=true, bool center=false);
63
64 void setScale(float scale)
65 {
66 assert( m_magic_number == 0xCAFEC001 );
67 m_scale = scale;
68 }
69
70 void scaleToHeight(int height);
71
72 void setTargetIconSize(int width, int height)
73 { m_target_icon_size = core::dimension2du(width, height); }
74
75protected:
76
77 // this object was getting access after being freed, I wanna see when/why
78 unsigned int m_magic_number;
79
80 float m_scale;
81 int m_height;
82
83 struct SDrawBatch
84 {
85 core::array<core::position2di> positions;
86 core::array<core::recti> sourceRects;
87 u32 textureNumber;
88 };
89
90 core::dimension2du m_target_icon_size;
91 //FIXME: ugly hack to work around irrLicht limitations, see STKModifiedSpriteBank::getPositions()
92 // for all the gory details.
93 core::array< core::rect<s32> > copy;
94
95 core::array<SGUISprite> Sprites;
96 core::array< core::rect<s32> > Rectangles;
97 core::array<video::ITexture*> Textures;
98 IGUIEnvironment* Environment;
99 video::IVideoDriver* Driver;
100
101 s32 getScaledWidth(s32 width) const;
102 s32 getScaledHeight(s32 height) const;
103};
104
105} // end namespace gui
106} // end namespace irr
107
108#endif // _IRR_COMPILE_WITH_GUI_
109
110#endif // __C_GUI_SPRITE_BANK_H_INCLUDED__
111