ScummVM API documentation
convo.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 NANCY_SCRIPT_CONVO_H
23
#define NANCY_SCRIPT_CONVO_H
24
25
#include "common/array.h"
26
#include "common/str.h"
27
28
#include "engines/nancy/commontypes.h"
29
#include "engines/nancy/movieplayer.h"
30
31
#include "engines/nancy/script/records.h"
32
33
#include "engines/nancy/ui/ndui/manager.h"
34
35
namespace
Nancy
{
36
namespace
Script {
37
38
// Something the player can say in a conversation: the sound of it, whose name is
39
// also the key of its text, and the record that runs once it has been said.
40
// A response can come with a function that says whether it is on offer.
41
struct
ConvoResponse
{
42
Common::String
soundName;
43
Record
*onFinished =
nullptr
;
44
int
activeFunction = -1;
// in the registry of the scene's scripts
45
};
46
47
// A line of a conversation: a character says something, the player picks one of
48
// the responses on offer, says it, and the record that goes with the response
49
// runs, which as a rule moves on to the scene with the next line. A line without
50
// responses runs its default record when it is over.
51
//
52
// A video conversation shows the character with movies, one for each part of it
53
// (body, head). An XSheet with the name of the line's sound lists the parts, and
54
// the frame of each part's movie to show over time; a part without a frame number
55
// plays through by itself. A sound conversation plays its sounds one after another.
56
//
57
// Only one conversation runs in a scene: the ones that turn active afterwards are
58
// done at once. Its responses stay up until the scene goes away.
59
class
ConvoRecord
:
public
Record
,
public
UI::NDUI::EngineTarget
{
60
public
:
61
ConvoRecord
(
SceneContext
&context,
bool
isVideo);
62
virtual
~
ConvoRecord
();
63
64
void
updateGraphics()
override
;
65
66
// Responses can be added while the scripts named by the record are run
67
void
addResponse(
ConvoResponse
*response) { _responses.push_back(response); }
68
69
// The UI reports the response the player picked
70
void
onEngineAction(
const
UI::NDUI::Action
&action)
override
;
71
72
protected
:
73
void
readTable(
int
tableIndex)
override
;
74
void
runOnce()
override
;
75
void
run(
double
sceneTime,
double
elapsedTime)
override
;
76
void
onZChanged()
override
;
77
78
private
:
79
enum
State {
80
kStartLine,
81
kWaitForLine,
// until the sound has started
82
kPlayLine,
83
kWaitForLineEnd,
84
kStartResponse,
85
kWaitForResponse,
// until the sound has started
86
kPlayResponse
87
};
88
89
// One part of the character
90
struct
Tree {
91
MoviePlayer
player;
92
RecordGraphic
graphic;
93
Common::Rect
dest;
94
Common::Array<int32>
frames;
// the movie frame to show at each frame of the XSheet
95
int32 shownFrame = -1;
96
};
97
98
static
const
int32 kFreeRunning = -1;
99
100
bool
loadXSheet(
const
Common::String
&name);
101
void
showFrame(uint frame);
102
void
showMovieFrame(Tree &tree, int32 movieFrame);
103
void
drawTree(Tree &tree,
const
Graphics::Surface
&frame);
104
bool
isTreeFreeRunning(
const
Tree &tree)
const
;
105
bool
isVideoDone()
const
;
106
107
void
playSound(
const
Common::String
&name, uint16 channel);
108
bool
isResponseOnOffer(
const
ConvoResponse
&response);
109
void
conclude();
110
111
bool
_isVideo;
112
Common::Array<Common::String>
_soundNames;
113
Common::Array<Common::String>
_responseFiles;
114
Common::Array<ConvoResponse *>
_responses;
115
Record
*_default =
nullptr
;
116
117
Common::Array<Tree *>
_trees;
118
uint _numFrames = 0;
119
uint32 _framesPerSecond = 0;
120
uint _frame = 0;
121
122
State _state = kStartLine;
123
uint _curSound = 0;
124
SoundDescription
_sound;
125
bool
_hasSoundStarted =
false
;
126
double
_lineStartTime = 0.0;
127
128
Common::Array<ConvoResponse *>
_offeredResponses;
129
int
_pickedResponse = -1;
130
bool
_hasDialog =
false
;
131
};
132
133
void
registerConvoAPI(
lua_State
*L);
134
135
}
// End of namespace Script
136
}
// End of namespace Nancy
137
138
#endif // NANCY_SCRIPT_CONVO_H
Common::String
Definition:
str.h:59
Graphics::Surface
Definition:
surface.h:67
Nancy::MoviePlayer
Definition:
movieplayer.h:56
Common::Array< int32 >
Nancy::Script::RecordGraphic
Definition:
records.h:75
Common::Rect
Definition:
rect.h:536
lua_State
Definition:
lstate.h:100
Nancy::Script::SceneContext
Definition:
scenecontext.h:52
Nancy::Script::ConvoRecord
Definition:
convo.h:59
Nancy::Script::ConvoResponse
Definition:
convo.h:41
Nancy::Script::Record
Definition:
record.h:71
Nancy::SoundDescription
Definition:
commontypes.h:306
Nancy::UI::NDUI::EngineTarget
Definition:
manager.h:51
Nancy::UI::NDUI::Action
Definition:
common.h:117
Nancy
Definition:
actionmanager.h:32
engines
nancy
script
convo.h
Generated on Thu Oct 22 2026 09:23:54 for ScummVM API documentation by
1.8.13