1 /*
2  * Copyright 2011-2012 Arx Libertatis Team (see the AUTHORS file)
3  *
4  * This file is part of Arx Libertatis.
5  *
6  * Arx Libertatis 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  * Arx Libertatis 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.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Arx Libertatis.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 /* Based on:
20 ===========================================================================
21 ARX FATALIS GPL Source Code
22 Copyright (C) 1999-2010 Arkane Studios SA, a ZeniMax Media company.
23 
24 This file is part of the Arx Fatalis GPL Source Code ('Arx Fatalis Source Code').
25 
26 Arx Fatalis Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
27 License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
28 
29 Arx Fatalis Source Code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
30 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
31 
32 You should have received a copy of the GNU General Public License along with Arx Fatalis Source Code.  If not, see
33 <http://www.gnu.org/licenses/>.
34 
35 In addition, the Arx Fatalis Source Code is also subject to certain additional terms. You should have received a copy of these
36 additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Arx
37 Fatalis Source Code. If not, please request a copy in writing from Arkane Studios at the address below.
38 
39 If you have questions concerning this license or the applicable additional terms, you may contact in writing Arkane Studios, c/o
40 ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
41 ===========================================================================
42 */
43 // Code: Cyril Meynier
44 //
45 // Copyright (c) 1999-2000 ARKANE Studios SA. All rights reserved
46 
47 #ifndef ARX_GUI_SPEECH_H
48 #define ARX_GUI_SPEECH_H
49 
50 #include <string>
51 
52 #include "audio/AudioTypes.h"
53 #include "math/Angle.h"
54 
55 struct EERIE_CAMERA;
56 struct EERIE_SCRIPT;
57 class Entity;
58 
59 const size_t MAX_SPEECH = 9;
60 
61 enum CinematicSpeechMode {
62 	ARX_CINE_SPEECH_NONE,
63 	ARX_CINE_SPEECH_ZOOM, // uses start/endangle alpha & beta, startpos & endpos
64 	ARX_CINE_SPEECH_CCCTALKER_L,
65 	ARX_CINE_SPEECH_CCCTALKER_R,
66 	ARX_CINE_SPEECH_CCCLISTENER_L,
67 	ARX_CINE_SPEECH_CCCLISTENER_R,
68 	ARX_CINE_SPEECH_SIDE,
69 	ARX_CINE_SPEECH_KEEP,
70 	ARX_CINE_SPEECH_SIDE_LEFT
71 };
72 
73 struct CinematicSpeech {
74 
75 	CinematicSpeechMode type;
76 	Anglef startangle;
77 	Anglef endangle;
78 	float startpos;
79 	float endpos;
80 	float f0;
81 	float f1;
82 	float f2;
83 	long ionum;
84 	Vec3f pos1;
85 	Vec3f pos2;
86 
clearCinematicSpeech87 	void clear() {
88 		type = ARX_CINE_SPEECH_NONE;
89 		startangle = Anglef::ZERO;
90 		endangle = Anglef::ZERO;
91 		startpos = 0;
92 		endpos = 0;
93 		f0 = 0;
94 		f1 = 0;
95 		ionum = 0;
96 		pos1 = Vec3f::ZERO;
97 		pos2 = Vec3f::ZERO;
98 	}
99 
100 };
101 
102 const size_t MAX_ACTORS = 10;
103 struct ARX_CONVERSATION_STRUCT {
104 	long actors_nb;
105 	long actors[MAX_ACTORS];
106 	long current;
107 };
108 
109 struct Notification {
110 
111 	unsigned long timecreation;
112 	unsigned long duration;
113 	std::string text;
114 
clearNotification115 	void clear() {
116 		timecreation = 0;
117 		duration = 0;
118 		text.clear();
119 	}
120 
121 };
122 
123 enum SpeechFlag {
124 	ARX_SPEECH_FLAG_UNBREAKABLE = (1<<0),
125 	ARX_SPEECH_FLAG_OFFVOICE    = (1<<1),
126 	ARX_SPEECH_FLAG_NOTEXT      = (1<<2),
127 	ARX_SPEECH_FLAG_DIRECT_TEXT = (1<<3)
128 };
129 DECLARE_FLAGS(SpeechFlag, SpeechFlags);
130 DECLARE_FLAGS_OPERATORS(SpeechFlags);
131 
132 struct ARX_SPEECH {
133 
134 	long exist;
135 	audio::SampleId sample;
136 	long mood;
137 	SpeechFlags flags;
138 	unsigned long time_creation;
139 	unsigned long duration;
140 	float fDeltaY;
141 	int iTimeScroll;
142 	float fPixelScroll;
143 	std::string text;
144 	Entity * io;
145 	Entity * ioscript;
146 	CinematicSpeech cine;
147 	EERIE_SCRIPT * es;
148 	long scrpos;
149 
clearARX_SPEECH150 	void clear() {
151 		exist = 0;
152 		sample = 0;
153 		mood = 0;
154 		flags = 0;
155 		time_creation = 0;
156 		duration = 0;
157 		fDeltaY = 0;
158 		iTimeScroll = 0;
159 		fPixelScroll = 0;
160 		text.clear();
161 		io = NULL;
162 		ioscript = NULL;
163 		cine.clear();
164 		es = NULL;
165 		scrpos = 0;
166 	}
167 
168 };
169 
170 const size_t MAX_ASPEECH = 100;
171 extern ARX_SPEECH aspeech[MAX_ASPEECH];
172 extern ARX_CONVERSATION_STRUCT main_conversation;
173 
174 void ARX_CONVERSATION_FirstInit();
175 void ARX_CONVERSATION_Reset();
176 
177 void ARX_SPEECH_FirstInit();
178 void ARX_SPEECH_Reset();
179 void ARX_SPEECH_Update();
180 void ARX_SPEECH_Init();
181 void ARX_SPEECH_Check();
182 
183 /*!
184  * Add a raw text message to the "system" log (top of the screen).
185  * This message will be displayed as-is.
186  */
187 long ARX_SPEECH_Add(const std::string & text, long duration = -1);
188 void ARX_SPEECH_ClearAll();
189 
190 /*!
191  * Add an entry to the conversation view.
192  * @param data is a sample name / localised string id
193  */
194 long ARX_SPEECH_AddSpeech(Entity * io, const std::string & data, long mood, SpeechFlags flags = 0);
195 void ARX_SPEECH_ReleaseIOSpeech(Entity * io);
196 void ARX_SPEECH_ClearIOSpeech(Entity * io);
197 void ARX_SPEECH_Launch_No_Unicode_Seek(const std::string & string, Entity * io_source, long mood = 0);
198 bool ApplySpeechPos(EERIE_CAMERA * conversationcamera, long is);
199 
200 #endif // ARX_GUI_SPEECH_H
201