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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * Copyright 2020 Google 22 * 23 */ 24 #include "common/str.h" 25 #include "common/rect.h" 26 #include "common/noncopyable.h" 27 28 #ifndef HADESCH_AMBIENT_H 29 #define HADESCH_AMBIENT_H 30 31 namespace Hadesch { 32 class AmbientAnim { 33 public: 34 struct AmbientDesc { 35 Common::String _animName; 36 Common::String _soundName; AmbientDescAmbientDesc37 AmbientDesc(Common::String animName, Common::String soundName) { 38 _animName = animName; 39 _soundName = soundName; 40 } 41 }; 42 43 enum PanType { 44 PAN_ANY, 45 PAN_LEFT, 46 PAN_RIGHT 47 }; 48 49 enum AnimType { 50 DISAPPEAR, 51 KEEP_LOOP, 52 BACK_AND_FORTH 53 }; 54 55 AmbientAnim(const Common::String &animName, 56 const Common::String &sound, int zValue, 57 int minint, int maxint, AnimType loop, 58 Common::Point offset, PanType pan); 59 AmbientAnim(const Common::Array<AmbientDesc> &descs, int zValue, 60 int minint, int maxint, AnimType loop, 61 Common::Point offset, PanType pan); 62 AmbientAnim(); 63 void play(bool reschedule); 64 void schedule(); 65 void start(); 66 void pause(); 67 void unpause(); 68 void hide(); 69 void unpauseAndFirstFrame(); 70 void selectFirstFrame(); 71 void playFinished(bool reschedule); 72 bool isReady(); 73 private: 74 class AmbiantAnimInternal : Common::NonCopyable { 75 public: 76 Common::Array<AmbientDesc> _descs; 77 int _minInterval, _maxInterval; 78 int _zValue; 79 AnimType _loopType; 80 bool _isFwd; 81 Common::Point _offset; 82 bool _playing; 83 bool _paused; 84 PanType _pan; 85 }; 86 87 bool isPanOK(); 88 89 Common::SharedPtr<AmbiantAnimInternal> _internal; 90 }; 91 92 93 class AmbientAnimWeightedSet { 94 public: 95 void readTableFilePriamSFX(const TextTable &table); 96 void readTableFileSFX(const TextTable &table, AmbientAnim::PanType pan); 97 void tick(); 98 void firstFrame(); 99 void pause(const Common::String &name); 100 void unpause(const Common::String &name); 101 void unpauseAndFirstFrame(const Common::String &name); 102 void hide(const Common::String &name); 103 void play(const Common::String &name, bool reschedule); 104 private: 105 struct AmbientAnimWeightedSetElement { 106 AmbientAnim anim; 107 int weight; 108 bool valid; 109 Common::String name; 110 }; 111 Common::Array<AmbientAnimWeightedSetElement> _elements; 112 }; 113 114 class AnimClickables { 115 public: 116 void playNext(const Common::String &name, const EventHandlerWrapper &event); 117 void playChosen(const Common::String &name, int counter, const EventHandlerWrapper &event); setTable(const TextTable table)118 void setTable(const TextTable table) { 119 _table = table; 120 } 121 void readTable(Common::SharedPtr<Hadesch::VideoRoom> room, 122 const Common::String &name, 123 const TranscribedSound *transcriptionTable); 124 125 private: 126 TextTable _table; 127 Common::HashMap<Common::String, Common::String> _transcriptions; 128 Common::HashMap<Common::String, int> _counters; 129 }; 130 131 132 } 133 #endif 134