ScummVM API documentation
osd_message_queue.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 COMMON_OSD_MESSAGE_QUEUE_H
23 #define COMMON_OSD_MESSAGE_QUEUE_H
24 
25 #include "common/events.h"
26 #include "common/singleton.h"
27 #include "common/str.h"
28 #include "common/ustr.h"
29 #include "common/queue.h"
30 #include "common/mutex.h"
31 
32 namespace Graphics {
33 struct Surface;
34 }
35 
36 namespace Common {
37 
49 class OSDMessageQueue : public Singleton<OSDMessageQueue>, public EventSource {
50 public:
52  ~OSDMessageQueue();
53 
54  void registerEventSource();
55 
56  enum {
57  kMinimumDelay = 1000,
58  kIconCleanupDelay = 2 * 1000,
59  };
60 
64  void addMessage(const Common::U32String &msg);
65 
69  void addImage(const Graphics::Surface *surface);
70 
80  bool pollEvent(Common::Event &event) override;
81 
82 private:
83  struct OSDQueueEntry {
84  Common::U32String *_text;
85  Graphics::Surface *_image;
86 
87  OSDQueueEntry(const Common::U32String &msg);
88  OSDQueueEntry(const Graphics::Surface *surface);
89  ~OSDQueueEntry();
90  };
91 
92  Mutex _mutex;
93  Queue<OSDQueueEntry *> _messages;
94  uint32 _lastUpdate;
95  bool _iconWasShown;
96 };
97 
100 } // End of namespace Common
101 
102 #endif
Definition: surface.h:67
Definition: queue.h:42
Definition: osd_message_queue.h:49
Definition: ustr.h:57
Definition: events.h:210
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: mutex.h:67
Definition: events.h:270
Definition: singleton.h:42