ScummVM API documentation
energymonitor.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_ENERGYMONITOR_H
26 #define PEGASUS_ENERGYMONITOR_H
27 
28 #include "pegasus/elements.h"
29 
30 namespace Pegasus {
31 
32 class Sprite;
33 
34 class Blinker : private IdlerTimeBase {
35 public:
36  Blinker();
37  ~Blinker() override {}
38 
39  void startBlinking(Sprite *sprite, int32 frame1, int32 frame2, uint32 numBlinks, TimeValue blinkDuration, TimeScale blinkScale);
40  void stopBlinking();
41 
42 protected:
43  void timeChanged(const TimeValue) override;
44 
45  Sprite *_sprite;
46  int32 _frame1;
47  int32 _frame2;
48  TimeValue _blinkDuration;
49 };
50 
51 // Energy monitor constants.
52 
53 // These are in seconds.
54 // Max is two hours
55 static const uint32 kMaxJMPEnergy = 7200;
56 
57 static const uint32 kCasualEnergy = kMaxJMPEnergy * 100 / 100; // 100%
58 static const uint32 kWorriedEnergy = kMaxJMPEnergy * 50 / 100; // 50%
59 static const uint32 kNervousEnergy = kMaxJMPEnergy * 25 / 100; // 25%
60 static const uint32 kPanicStrickenEnergy = kMaxJMPEnergy * 5 / 100; // 5%
61 
62 static const uint32 kFullEnergy = kCasualEnergy;
63 
64 static const uint32 kFrameLightOff = 0;
65 static const uint32 kFrameLightYellow = 1;
66 static const uint32 kFrameLightOrange = 2;
67 static const uint32 kFrameLightRed = 3;
68 
69 static const int kEnergyDrainNormal = 1;
70 static const int kMarsReactorEnergyDrainNoShield = 6;
71 static const int kMarsReactorEnergyDrainWithShield = 3;
72 static const int kWSCPoisonEnergyDrainWithDart = 20;
73 static const int kWSCPoisonEnergyDrainNoDart = 10;
74 
75 class EnergyMonitor : private IdlerAnimation {
76 public:
77  EnergyMonitor();
78  ~EnergyMonitor() override;
79 
80  void setEnergyValue(const uint32);
81  void startEnergyDraining();
82  void setEnergyDrainRate(Common::Rational);
83  Common::Rational getEnergyDrainRate();
84  void stopEnergyDraining();
85  void drainEnergy(const int32);
86  int32 getCurrentEnergy();
87 
88  void restoreLastEnergyValue();
89  void saveCurrentEnergyValue();
90 
91  void calibrateEnergyBar();
92 
93 protected:
94  void timeChanged(const TimeValue) override;
95  void calcLevelRect(Common::Rect &);
96  void draw(const Common::Rect &) override;
97 
98  uint32 _barColor;
99  Common::Rect _levelRect;
100  EnergyStage _stage;
101  Sprite _energyLight;
102  Blinker _lightBlinker;
103  bool _calibrating, _dontFlash;
104 };
105 
106 extern EnergyMonitor *g_energyMonitor;
107 
108 } // End of namespace Pegasus
109 
110 #endif
Definition: timers.h:176
Definition: rect.h:144
Definition: elements.h:168
Definition: rational.h:40
Definition: energymonitor.h:75
Definition: energymonitor.h:34
Definition: elements.h:117
Definition: ai_action.h:33