aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Hoops2011-09-29 01:29:42 -0400
committerMatthew Hoops2011-09-29 01:29:42 -0400
commit34fd248f8a0fcc95ab08743106daed6715274c2d (patch)
treec87dd014176023402fafd7ce29394f6cdf20fb0b
parent6440d4d5f6b4183cd857ee685cebd08937137cf8 (diff)
downloadscummvm-rg350-34fd248f8a0fcc95ab08743106daed6715274c2d.tar.gz
scummvm-rg350-34fd248f8a0fcc95ab08743106daed6715274c2d.tar.bz2
scummvm-rg350-34fd248f8a0fcc95ab08743106daed6715274c2d.zip
PEGASUS: Add the SoundLevel class
-rw-r--r--engines/pegasus/elements.cpp41
-rw-r--r--engines/pegasus/elements.h17
2 files changed, 58 insertions, 0 deletions
diff --git a/engines/pegasus/elements.cpp b/engines/pegasus/elements.cpp
index bd3b4db2cb..905be501e3 100644
--- a/engines/pegasus/elements.cpp
+++ b/engines/pegasus/elements.cpp
@@ -524,4 +524,45 @@ void ScreenDimmer::draw(const Common::Rect &r) {
#undef DRAW_PIXEL
#undef SKIP_PIXEL
+SoundLevel::SoundLevel(const tDisplayElementID id) : DisplayElement(id) {
+ _soundLevel = 0;
+}
+
+void SoundLevel::incrementLevel() {
+ if (_soundLevel < 12) {
+ _soundLevel++;
+ triggerRedraw();
+ }
+}
+
+void SoundLevel::decrementLevel() {
+ if (_soundLevel > 0) {
+ _soundLevel--;
+ triggerRedraw();
+ }
+}
+
+uint16 SoundLevel::getSoundLevel() {
+ return CLIP<int>(_soundLevel * 22, 0, 256);
+}
+
+void SoundLevel::setSoundLevel(uint16 level) {
+ uint16 newLevel = (level + 21) / 22;
+
+ if (newLevel != _soundLevel) {
+ _soundLevel = newLevel;
+ triggerRedraw();
+ }
+}
+
+void SoundLevel::draw(const Common::Rect &r) {
+ Common::Rect levelRect(_bounds.right - (8 * (_soundLevel - 12)), _bounds.top, _bounds.right, _bounds.bottom);
+ levelRect = r.findIntersectingRect(levelRect);
+
+ if (!levelRect.isEmpty()) {
+ Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getWorkArea();
+ screen->fillRect(levelRect, g_system->getScreenFormat().RGBToColor(0, 0, 0));
+ }
+}
+
} // End of namespace Pegasus
diff --git a/engines/pegasus/elements.h b/engines/pegasus/elements.h
index 84c390aa02..6e20e72201 100644
--- a/engines/pegasus/elements.h
+++ b/engines/pegasus/elements.h
@@ -232,6 +232,23 @@ public:
virtual void draw(const Common::Rect &);
};
+class SoundLevel : public DisplayElement {
+public:
+ SoundLevel(const tDisplayElementID);
+ virtual ~SoundLevel() {}
+
+ void incrementLevel();
+ void decrementLevel();
+
+ uint16 getSoundLevel();
+ void setSoundLevel(uint16);
+
+ void draw(const Common::Rect &);
+
+protected:
+ uint16 _soundLevel;
+};
+
} // End of namespace Pegasus
#endif