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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef ILLUSIONS_BBDOU_BBDOU_CREDITS_H
24 #define ILLUSIONS_BBDOU_BBDOU_CREDITS_H
25 
26 #include "illusions/specialcode.h"
27 #include "illusions/thread.h"
28 
29 namespace Illusions {
30 
31 class IllusionsEngine_BBDOU;
32 class BbdouSpecialCode;
33 class Control;
34 
35 struct CreditsItem {
36 	bool isUsed;
37 	uint32 objectId;
38 };
39 
40 const uint kCreditsItemsCount = 64;
41 
42 class BbdouCredits {
43 public:
44 	BbdouCredits(IllusionsEngine_BBDOU *vm);
45 	~BbdouCredits();
46 	void start(uint32 endSignalPropertyId, float speedModifier);
47 	void stop();
48 	void drawNextLine();
49 	void updateTexts(int yIncr);
50 protected:
51 	IllusionsEngine_BBDOU *_vm;
52 	uint32 _endSignalPropertyId;
53 	uint32 _currFontId;
54 	uint _currLineIndex;
55 	bool _split;
56 	CreditsItem _items[kCreditsItemsCount];
57 	const char *getText(uint index);
58 	void drawTextToControl(uint32 objectId, const char *text, uint alignment);
59 	bool readNextLine(uint &leftIndex, uint &rightIndex);
60 	void initCreditsItems();
61 	void freeCreditsItems();
62 	uint32 getNextFreeObjectId();
63 	void removeText(uint32 objectId);
64 	void resetObjectPos(uint32 objectId);
65 	void createCreditsThread(float speedModifier);
66 };
67 
68 class CreditsThread : public Thread {
69 public:
70 	CreditsThread(IllusionsEngine_BBDOU *vm, BbdouCredits *credits, uint32 threadId, float speedModifier);
71 	int onUpdate() override;
72 	void onNotify() override;
73 	void onResume() override;
74 	void onTerminated() override;
75 public:
76 	BbdouCredits *_credits;
77 	float _speedModifier;
78 	float _lastFraction;
79 	uint32 _lastUpdateTime;
80 };
81 
82 } // End of namespace Illusions
83 
84 #endif // ILLUSIONS_BBDOU_BBDOU_CREDITS_H
85