Planeshift
pseffectobjtext.h
Go to the documentation of this file.
1 /*
2  * Author: Andrew Robberts
3  *
4  * Copyright (C) 2003 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 #ifndef PS_EFFECT_OBJ_TEXT_HEADER
21 #define PS_EFFECT_OBJ_TEXT_HEADER
22 
23 #include "pseffectobjquad.h"
24 #include <imesh/sprite2d.h>
25 
26 #include "pseffectobjtextable.h"
27 
28 struct iGraphics3D;
29 struct iGraphics2D;
30 struct iTextureManager;
31 struct iTextureWrapper;
32 struct iFont;
33 struct iParticle;
34 class psEffect2DRenderer;
35 
36 
42 {
43 private:
44  // needed managers
45  csRef<iGraphics3D> g3d;
46  iGraphics2D* g2d;
47  csRef<iTextureManager> txtmgr;
48 
49  // font
50  csString fontName;
51  int fontSize;
52  csRef<iFont> font;
53 
54  // generated texture
55  csRef<iTextureWrapper> generatedTex;
56  csRef<iMaterialWrapper> generatedMat;
57 
58  int texOriginalWidth;
59  int texOriginalHeight;
60 
61  int texPO2Width;
62  int texPO2Height;
63 
64 public:
65  psEffectObjText(iView* parentView, psEffect2DRenderer* renderer2d);
67 
70  virtual bool SetText(const csArray<psEffectTextElement> &elements);
71  virtual bool SetText(const csArray<psEffectTextRow> &rows);
72  virtual bool SetText(int rows, ...);
73 
74  // inheritted function overloads
75  bool Load(iDocumentNode* node, iLoaderContext* ldr_context);
76  psEffectObj* Clone() const;
77 
78 protected:
82  bool PostSetup();
83 
84  void DrawTextElement(const psEffectTextElement &element);
85 
86  inline int ToPowerOf2(int n)
87  {
88  for(int a=sizeof(int) * 8-1; a>0; --a)
89  {
90  if(n & (1 << a))
91  {
92  if(n == (1 << a))
93  return n;
94  else
95  return (1 << (a+1));
96  }
97  }
98  return 1;
99  };
100 };
101 
104 #endif
virtual bool SetText(const csArray< psEffectTextElement > &elements)
Creates a material that will fit an array of text elements and draws those elements.
The manager of all 2D effect elements.
psEffectObjText(iView *parentView, psEffect2DRenderer *renderer2d)
bool PostSetup()
performs the post setup (after the effect obj has been loaded).
An effect is not much more than a collection of effect objects.
Definition: pseffectobj.h:207
void DrawTextElement(const psEffectTextElement &element)
bool Load(iDocumentNode *node, iLoaderContext *ldr_context)
Loads the effect object from an xml node.
int ToPowerOf2(int n)
psEffectObj * Clone() const
Clones the effect object.
psEffect2DRenderer * renderer2d
Definition: pseffectobj.h:529