aboutsummaryrefslogtreecommitdiff
path: root/engines/bladerunner/ui/vk.h
blob: 77a419afb56ff34e8251803d36cde31e56208565 (plain)
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
/* 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 2
 * 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
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#ifndef BLADERUNNER_VK_H
#define BLADERUNNER_VK_H

#include "common/array.h"
#include "common/str.h"

#include "graphics/surface.h"

namespace BladeRunner {

class BladeRunnerEngine;
class VKScript;
class Shape;
class UIImagePicker;
class VQAPlayer;

class VK {
	struct Question {
		bool isPresent;
		bool wasAsked;
		int sentenceId;
		int relatedSentenceId;
	};

	BladeRunnerEngine *_vm;

	VKScript *_script;

	UIImagePicker *_buttons;
	Common::Array<Shape *> _shapes;

	VQAPlayer *_vqaPlayerMain;
	VQAPlayer *_vqaPlayerEye;
	int _vqaFrameMain;
	bool _vqaLoopEnded;

	Graphics::Surface _surfaceEye;

	bool _isOpen;
	int _actorId;
	bool _calibrationStarted;
	bool _testStarted;

	Common::Array<Common::Array<Question> > _questions;

	int _volumeAmbient;
	int _volumeMusic;
	int _soundTrackId1;
	int _soundTrackId2;
	int _soundTrackId3;

	int _calibration;
	int _calibrationRatio;
	int _calibrationCounter;

	int _humanProbability;
	int _humanGauge;
	int _humanGaugeTarget;
	int _humanGaugeDelta;
	int _timeNextHumanGaugeStep;

	int _replicantProbability;
	int _replicantGauge;
	int _replicantGaugeTarget;
	int _replicantGaugeDelta;
	int _timeNextReplicantGaugeStep;

	int _anxiety;

	int _needleValue;
	int _needleValueMax;
	int _needleValueTarget;
	int _needleValueDelta;
	int _timeNextNeedleStep;
	int _timeNextNeedleOscillate;
	int _timeNeedleReturn;

	bool _isClosing;
	int _timeClose;

	int _blinkState;
	int _timeNextBlink;
	int _timeNextGaugesBlink;

	bool _isAdjusting;
	int _adjustment;
	int _adjustmentTarget;
	int _adjustmentDelta;
	int _timeNextAdjustementStep;

	int _eyeLineSelected;
	int _eyeLineX;
	int _eyeLineXLast;
	int _eyeLineY;
	int _eyeLineYLast;
	int _eyeLineXDelta;
	int _eyeLineYDelta;
	int _timeNextEyeLineStep;
	int _timeNextEyeLineStart;

public:
	VK(BladeRunnerEngine *vm);
	~VK();

	void open(int actorId, int calibrationRatio);
	bool isOpen() const;
	void close();

	void tick();

	void resume();

	void handleMouseDown(int mouseX, int mouseY, bool mainButton);
	void handleMouseUp(int mouseX, int mouseY, bool mainButton);

	void playSpeechLine(int actorId, int sentenceId, float duration);
	void addQuestion(int intensity, int sentenceId, int relatedSentenceId);
	void subjectReacts(int intensity, int humanResponse, int replicantResponse, int anxiety);
	void eyeAnimates(int loopId);

private:
	static void mouseDownCallback(int buttonId, void *callbackData);
	static void mouseUpCallback(int buttonId, void *callbackData);
	static void loopEnded(void *callbackData, int frame, int loopId);

	void reset();
	void init();

	void draw();

	void drawNeedle(Graphics::Surface &surface);
	void drawEye(Graphics::Surface &surface);
	void drawEyeCrosshair(Graphics::Surface &surface, int timeNow);
	void drawMouse(Graphics::Surface &surface);
	void drawGauge(Graphics::Surface &surface, int value, int x, int y, int width);
	void drawHumanGauge(Graphics::Surface &surface);
	void drawReplicantGauge(Graphics::Surface &surface);

	void calibrate();
	void beginTest();

	void startAdjustement();
	void stopAdjustement();
	void animateAdjustment(int target);
	void setAdjustment(int x);
	void setAdjustmentFromMouse();

	void askQuestion(int intensity);
};

} // End of namespace BladeRunner
#endif