Colobot
displaytext.h
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsitec.ch; http://colobot.info; http://github.com/colobot
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
20 #pragma once
21 
22 #include "common/error.h"
23 #include "common/event.h"
24 
25 #include <array>
26 
27 class CObject;
28 class CSoundInterface;
29 
30 namespace Gfx
31 {
32 class CEngine;
33 }
34 
35 namespace Ui
36 {
37 
38 class CInterface;
39 
40 enum TextType
41 {
42  TT_ERROR = 1,
43  TT_WARNING = 2,
44  TT_INFO = 3,
45  TT_MESSAGE = 4,
46 };
47 
48 const int MAXDTLINE = 4;
49 
50 
52 {
53 public:
54  CDisplayText();
55  ~CDisplayText();
56 
57  void DeleteObject();
58 
59  bool EventProcess(const Event &event);
60 
61  void DisplayError(Error err, CObject* pObj, float time=10.0f);
62  void DisplayError(Error err, Math::Vector goal, float height=15.0f, float dist=60.0f, float time=10.0f);
63  void DisplayText(const char *text, CObject* pObj, float time=10.0f, TextType type=TT_INFO);
64  void DisplayText(const char *text, Math::Vector goal, float height=15.0f, float dist=60.0f, float time=10.0f, TextType type=TT_INFO);
65  void HideText(bool bHide);
66  void ClearText();
67  bool ClearLastText();
68  void SetDelay(float factor);
69  void SetEnable(bool bEnable);
70 
71  Math::Vector GetVisitGoal(EventType event);
72  float GetVisitDist(EventType event);
73  float GetVisitHeight(EventType event);
74 
75  float GetIdealDist(CObject* pObj);
76  float GetIdealHeight(CObject* pObj);
77 
78  void ClearVisit();
79  void SetVisit(EventType event);
80  bool IsVisit(EventType event);
81 
82 protected:
83  CObject* SearchToto();
84 
85 protected:
86  Gfx::CEngine* m_engine;
87  Ui::CInterface* m_interface;
88  CSoundInterface* m_sound;
89 
90  struct TextLine
91  {
92  bool exist = false;
93  float time = 0.0f;
94  Math::Vector visitGoal;
95  float visitDist = 0.0f;
96  float visitHeight = 0.0f;
97  };
98  std::array<TextLine, MAXDTLINE> m_textLines;
99 
100  bool m_bHide;
101  bool m_bEnable;
102  float m_delayFactor;
103 };
104 
105 
106 } // namespace Ui
Definition: displaytext.h:51
Definition: robotmain.h:108
Definition: displaytext.h:90
Namespace for (new) graphics code.
Definition: app.h:49
The graphics engine.
Definition: engine.h:585
Event types, structs and event queue.
3D (3x1) vector
Definition: vector.h:53
EventType
Type of event message.
Definition: event.h:41
Event sent by system, interface or game.
Definition: event.h:735
Definition: interface.h:59
Base class for all 3D in-game objects.
Definition: object.h:63
Sound plugin interface.
Definition: sound.h:60