1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* aint32 with this program; if not, write to the Free Software
*
*
* Based on the original sources
* Faery Tale II -- The Halls of the Dead
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
#ifndef SAGA2_SPEECH_H
#define SAGA2_SPEECH_H
#include "saga2/objects.h"
namespace Saga2 {
#define MAX_SPEECH_PTRS 20
#define MAX_SAMPLES 50
#define CHARSPERSECOND 22
#define SHORTEST_DURATION TICKSPERSECOND
void updateSpeech();
bool isVisible(GameObject *obj);
#ifdef FRANKC
void sentenceGenerator(char *);
void abortSpeech();
void abortAllSpeeches();
void queueActorSpeech(
GameObject *obj,
char *text,
int count,
int32 sampleID,
int flags
);
#endif
bool sayVoice(uint32 s[]);
// REM: This function is no longer used by the speech code,
// but it may be useful for other things.
extern int16 speechButtonCount; // count of speech buttons
// Actor speech enums -- move these to include file
enum {
kSpeakContinued = (1 << 0), // Append next speech
kSpeakNoAnimate = (1 << 1), // Don't animate speaking
kSpeakWait = (1 << 2), // wait until speech finished
kSpeakLock = (1 << 3) // lock UI while speech in progress
};
class Speech {
private:
friend class SpeechTaskList;
friend void setNextActive();
friend void deleteSpeech(ObjectID id); // voice sound sample ID
friend void updateSpeech();
friend void queueActorSpeech(
GameObject *obj,
char *text,
int count,
int32 sampleID,
int flags
);
int16 _sampleCount, // number of sound samples
_charCount; // number of characters in buffer
Rect16 _bounds; // bounds of speech.
uint16 _penColor, // penColor to draw in
_outlineColor; // pen color for outline
ObjectID _objID; // ID of speaking object
ThreadID _thread; // SAGA thread to wake up when done
int16 _speechFlags; // flags from speaking
uint32 _sampleID[MAX_SAMPLES];// voice sound sample ID
char _speechBuffer[512];// longest possible speech
public:
int16 _selectedButton; // which button was hit
gPixelMap _speechImage;
gPort _textPort;
private:
// Reconstruct this SpeechTask from an archive buffer
void read(Common::InSaveFile *in);
// Return the number of bytes needed to archive this SpeechTask
int32 archiveSize();
// Archive this SpeechTask in a buffer
void *archive(void *buf);
void write(Common::MemoryWriteStreamDynamic *out);
bool setupActive(); // render speech into temp image
bool displayText();
int16 fits(int16 space);
void setWidth();
bool calcPosition(StaticPoint16 &p); // calculate position
void remove(); // Remove from active list
public:
enum SpeechFlags {
kSpNoAnimate = (1 << 0), // Don't animate actor
kSpHasVoice = (1 << 1), // The audio interface is playing this voice
kSpQueued = (1 << 2), // In active queue
kSpActive = (1 << 3), // Is current active speech
kSpLock = (1 << 4) // Lock UI while speaking
};
// remove speech, dealloc resources
void dispose();
// Append text and samples to speech
bool append(char *text, int32 sampID);
// Move speech to active list
bool activate();
// Set speech to wake up thread when done
void setWakeUp(ThreadID th) {
_thread = th;
}
// See if its time to kill it
bool longEnough();
// Abort the current speech.
void abortSpeech();
};
class SpeechTaskList {
friend void setNextActive();
friend void deleteSpeech(ObjectID id); // voice sound sample ID
friend void updateSpeech();
friend class Speech;
friend void queueActorSpeech(
GameObject *obj,
char *text,
int count,
int32 sampleID,
int flags
);
Common::List<Speech *> _list,
_inactiveList;
int8 _lockFlag;
void SetLock(int newState);
public:
// Constructor
SpeechTaskList();
// Constructor -- reconstruct from archive buffer
SpeechTaskList(void **buf);
SpeechTaskList(Common::InSaveFile *in);
// Return the number of bytes needed to archive the speech tasks
int32 archiveSize();
// Create an archive of the speech tasks in an archive buffer
void *archive(void *buf);
void write(Common::MemoryWriteStreamDynamic *out);
// Cleanup the speech tasks
void cleanup();
// Allocate a new speech task
Speech *newTask(ObjectID id, uint16 flags);
// Find a non-active speech for a given actor
Speech *findSpeech(ObjectID id);
Speech *currentActive() {
if (_list.size() > 0)
return _list.front();
return nullptr;
}
int32 activeCount() {
return _list.size();
}
int speechCount() {
return _list.size() + _inactiveList.size();
}
void remove(Speech *p);
};
extern SpeechTaskList &speechList;
// Initialize the speech task list
void initSpeechTasks();
// Save the speech tasks in a save file
void saveSpeechTasks(Common::OutSaveFile *outS);
void loadSpeechTasks(Common::InSaveFile *in, int32 chunkSize);
// Cleanup the speech task list
void cleanupSpeechTasks();
} // end of namespace Saga2
#endif
|