ScummVM API documentation
TextManager.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef QDENGINE_MINIGAMES_ADV_TEXT_MANAGER_H
23 #define QDENGINE_MINIGAMES_ADV_TEXT_MANAGER_H
24 
25 #include "qdengine/minigames/adv/ObjectContainer.h"
26 
27 namespace QDEngine {
28 
29 enum TextAlign {
30  ALIGN_LEFT,
31  ALIGN_RIGHT,
32  ALIGN_CENTER
33 };
34 
35 class TextManager {
36 public:
37  TextManager();
38  ~TextManager();
39 
40  int createStaticText(const mgVect3f& screen_pos, int fontID, TextAlign align);
41  void updateStaticText(int textID, const char *txt);
42 
43  void showText(const char *txt, const mgVect2f& pos, int fontID, int escapeID);
44  void showNumber(int num, const mgVect2f& pos, int fontID, int escapeID);
45 
46  void quant(float dt);
47  void updateScore(int score);
48  void updateTime(int seconds);
49 
50 private:
51  struct Font {
52  mgVect2f size;
53  ObjectContainer pool;
54  };
55  typedef Std::vector<Font> Fonts;
56 
57  struct Escape {
58  Escape();
59  int depth;
60  float aliveTime;
61  mgVect2f vel_min;
62  mgVect2f vel_max;
63  mgVect2f accel_min;
64  mgVect2f accel_max;
65  char format[16];
66  };
68 
69  struct StaticTextPreset {
70  StaticTextPreset();
71  mgVect3f pos;
72  int font;
73  TextAlign align;
74  char format[16];
75  int textID;
76  };
77  bool getStaticPreset(StaticTextPreset& preset, const char *name) const;
78 
79  struct StaticMessage {
80  StaticMessage(Font *font = 0, TextAlign _align = ALIGN_CENTER);
81  void release();
82 
83  bool empty() const {
84  return _objects.empty();
85  }
86 
87  void setText(const char *str);
88 
89  int _depth;
90  mgVect2f _pos;
91  TextAlign _align;
92 
93  protected:
94  void update();
95  bool validSymbol(unsigned char ch) const {
96  return ch > ' ' && ch != '_';
97  }
98 
99  private:
100  Font *_font;
101 
102  QDObjects _objects;
103  };
105 
106  struct Message : public StaticMessage {
107  Message(Font *font = 0);
108  void release();
109 
110  void quant(float dt);
111 
112  float _time;
113  mgVect2f _vel;
114  mgVect2f _accel;
115 
116  };
118 
119  Fonts _fonts;
120  Escapes _escapes;
121  StaticTextPreset _show_scores;
122  StaticTextPreset _show_time;
123  StaticMessages _staticMsgs;
124  Messages _flowMsgs;
125 
126  int _targetScore;
127  int _currentScore;
128  float _scoreUpdateTime;
129  float _scoreUpdateTimer;
130 };
131 
132 } // namespace QDEngine
133 
134 #endif // QDENGINE_MINIGAMES_ADV_TEXT_MANAGER_H
Базовый класс для игровых ресурсов.
Definition: console.h:28
Definition: TextManager.h:35
Definition: ObjectContainer.h:27