ScummVM API documentation
PopUp.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 /*
23  * This code is based on the CRAB engine
24  *
25  * Copyright (c) Arvind Raja Yadav
26  *
27  * Licensed under MIT
28  *
29  */
30 
31 #ifndef CRAB_POPUP_H
32 #define CRAB_POPUP_H
33 
34 #include "crab/timer.h"
35 #include "crab/event/effect.h"
36 #include "crab/event/triggerset.h"
37 
38 namespace Crab {
39 
40 namespace pyrodactyl {
41 namespace anim {
42 struct PopUp {
43  // The total time the popup stays on the screen
44  Timer _duration;
45 
46  // The time we wait before showing the trigger for the first time
47  Timer _delay;
48 
49  // Should we draw this or not? (Decided by internal events)
50  bool _show;
51 
52  // Popups with "talk key pressed" condition need to be shown once the key is pressed
53  bool _startedShow;
54 
55  // Triggers for when you only want to display this in certain conditions
57 
58  // Effects for changing variables and other related stuff
60 
61  // The text displayed
62  Common::String _text;
63 
64  // The next popup we should go to, negative values means the end
65  int _next;
66 
67  PopUp() {
68  _next = -1;
69  reset();
70  }
71 
72  PopUp(rapidxml::xml_node<char> *node) : PopUp() {
73  load(node);
74  }
75 
76  void reset() {
77  _show = false;
78  _startedShow = false;
79  _delay.stop();
80  _duration.stop();
81  }
82 
83  void load(rapidxml::xml_node<char> *node);
84  void draw(const int &x, const int &y, pyrodactyl::ui::ParagraphData &pop, const Rect &camera);
85 
86  // return true if we should proceed to next event, false otherwise
87  bool internalEvents(pyrodactyl::event::Info &info, const Common::String &playerId,
89 };
90 
92  // Collection of environmental dialog
93  Common::Array<PopUp> _element;
94 
95  // The current dialog being played
96  int _cur;
97 
98  // true if dialog needs to loop, false otherwise
99  bool _loop;
100 
101  PopUpCollection() {
102  _cur = 0;
103  _loop = true;
104  }
105 
106  // Return true if any of the popup dialog is visible, false otherwise
107  bool show() {
108  for (auto &i : _element)
109  if (i._show)
110  return true;
111 
112  return false;
113  }
114 
115  void load(rapidxml::xml_node<char> *node);
116 
117  void internalEvents(pyrodactyl::event::Info &info, const Common::String &playerId,
119 
120  void draw(const int &x, const int &y, pyrodactyl::ui::ParagraphData &pop, const Rect &camera);
121 };
122 } // End of namespace anim
123 } // End of namespace pyrodactyl
124 
125 } // End of namespace Crab
126 
127 #endif // CRAB_POPUP_H
Definition: str.h:59
Definition: Rectangle.h:42
Definition: ParagraphData.h:40
Definition: array.h:52
Definition: GameEventInfo.h:44
Definition: triggerset.h:40
Definition: moveeffect.h:37
Definition: PopUp.h:42
Definition: timer.h:43