ScummVM API documentation
fader.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 * Additional copyright for this file:
8 * Copyright (C) 1995-1997 Presto Studios, Inc.
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24
25#ifndef PEGASUS_FADER_H
26#define PEGASUS_FADER_H
27
28#include "pegasus/elements.h"
29#include "pegasus/timers.h"
30
31namespace Pegasus {
32
33class Fader;
34
36friend class Fader;
37public:
39 _faderScale = kDefaultTimeScale;
40 _numKnots = 0;
41 }
42
43 FaderMoveSpec(const TimeScale scale) {
44 _faderScale = scale;
45 _numKnots = 0;
46 }
47
48 void setFaderScale(const TimeScale scale) { _faderScale = scale; }
49 TimeScale getFaderScale() const { return _faderScale; }
50
51 void makeOneKnotFaderSpec(const int32);
52 void makeTwoKnotFaderSpec(const TimeScale, const TimeValue, const int32, const TimeValue, const int32);
53
54 void insertFaderKnot(const TimeValue, const int32);
55
56 uint32 getNumKnots() const { return _numKnots; }
57 TimeValue getNthKnotTime(const uint32 index) const { return _knots[index].knotTime; }
58 int32 getNthKnotValue(const uint32 index) const { return _knots[index].knotValue; }
59
60protected:
61 struct FaderKnot {
62 TimeValue knotTime;
63 int32 knotValue;
64 };
65
66 TimeScale _faderScale;
67 uint32 _numKnots;
68
69 static const uint32 kMaxFaderKnots = 20;
70 FaderKnot _knots[kMaxFaderKnots];
71};
72
73class Fader : public IdlerTimeBase {
74public:
75 Fader();
76 ~Fader() override {}
77
78 virtual void setFaderValue(const int32);
79 int32 getFaderValue() const { return _currentValue; }
80 virtual void startFader(const FaderMoveSpec &);
81 virtual void startFaderSync(const FaderMoveSpec &);
82 virtual void loopFader(const FaderMoveSpec &);
83 virtual void stopFader();
84 virtual bool isFading() { return isRunning(); }
85
86 void pauseFader();
87 void continueFader();
88
89 void getCurrentFaderMove(FaderMoveSpec &spec) { spec = _currentFaderMove; }
90
91protected:
92 bool initFaderMove(const FaderMoveSpec &);
93 void timeChanged(const TimeValue) override;
94
95 int32 _currentValue;
96 FaderMoveSpec _currentFaderMove;
97};
98
99class FaderAnimation : public DisplayElement, public Fader {
100public:
101 FaderAnimation(const DisplayElementID id) : DisplayElement(id) {}
102 ~FaderAnimation() override {}
103
104 void setFaderValue(const int32) override;
105};
106
107class Sound;
108
109class SoundFader : public Fader {
110friend class Sound;
111public:
112 SoundFader();
113 ~SoundFader() override {}
114
115 void setFaderValue(const int32) override;
116
117 void setMasterVolume(const uint16);
118 uint16 getMasterVolume() const { return _masterVolume; }
119
120protected:
121 void attachSound(Sound *);
122
123 Sound *_sound;
124 uint16 _masterVolume;
125};
126
127} // End of namespace Pegasus
128
129#endif
Definition: elements.h:43
Definition: fader.h:99
Definition: fader.h:73
Definition: fader.h:35
Definition: timers.h:176
Definition: fader.h:109
Definition: sound.h:50
Definition: fader.h:61