ScummVM API documentation
qd_music_track.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  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef QDENGINE_QDCORE_QD_MUSIC_TRACK_H
23 #define QDENGINE_QDCORE_QD_MUSIC_TRACK_H
24 
25 #include "qdengine/parser/xml_fwd.h"
26 #include "qdengine/qdcore/qd_named_object.h"
27 #include "qdengine/qdcore/qd_conditional_object.h"
28 
29 
30 namespace QDEngine {
31 
33 
38  QD_MUSIC_TRACK_CYCLED = 1,
39  QD_MUSIC_TRACK_DISABLE_RESTART = 2,
40  QD_MUSIC_TRACK_DISABLE_SWITCH_OFF = 4
41 };
42 
44 public:
45  qdMusicTrack();
46  qdMusicTrack(const qdMusicTrack &trk);
47  ~qdMusicTrack();
48 
49  qdMusicTrack &operator = (const qdMusicTrack &trk);
50 
51  int named_object_type() const {
52  return QD_NAMED_OBJECT_MUSIC_TRACK;
53  }
54 
55  void set_file_name(const Common::Path fname) {
56  _file_name = fname;
57  }
58  const Common::Path file_name() const {
59  return _file_name;
60  }
61  bool has_file_name() const {
62  return !_file_name.empty();
63  }
64 
65  void toggle_cycle(bool v) {
66  if (v) set_flag(QD_MUSIC_TRACK_CYCLED);
67  else drop_flag(QD_MUSIC_TRACK_CYCLED);
68  }
69  bool is_cycled() const {
70  return check_flag(QD_MUSIC_TRACK_CYCLED);
71  }
72 
73  int volume() const {
74  return _volume;
75  }
76  void set_volume(int vol) {
77  if (vol < 0) vol = 0;
78  else if (vol > 256) vol = 256;
79  _volume = vol;
80  }
81 
83  bool load_script(const xml::tag *p);
85  bool save_script(Common::WriteStream &fh, int indent = 0) const;
86 
88 
89  static Common::String flag2str(int fl);
90 
91 private:
92 
94  Common::Path _file_name;
95 
97  int _volume;
98 };
99 
100 } // namespace QDEngine
101 
102 #endif // QDENGINE_QDCORE_QD_MUSIC_H
bool load_script(const xml::tag *p)
Чтение данных из скрипта.
Definition: str.h:59
Definition: stream.h:77
Definition: path.h:52
int named_object_type() const
Возвращает тип объекта.
Definition: qd_music_track.h:51
Объект с условиями.
Definition: qd_conditional_object.h:37
bool check_flag(int fl) const
Возвращает true, если установлен флаг fl.
Definition: qd_named_object.h:99
Definition: qd_music_track.h:43
bool empty() const
Definition: path.h:353
XML тег.
Definition: xml_tag.h:33
Базовый класс для игровых ресурсов.
Definition: console.h:28
bool save_script(Common::WriteStream &fh, int indent=0) const
Запись данных в скрипт.
trigger_start_mode
Варианты старта триггера.
Definition: qd_conditional_object.h:122
qdConditionalObject::trigger_start_mode trigger_start()
Активация триггера.
void set_flag(int fl)
Устанавливает флаг.
Definition: qd_named_object.h:91
void drop_flag(int fl)
Скидывает флаг.
Definition: qd_named_object.h:95
qdMusicTrackFlags
Музыкальная композиция.
Definition: qd_music_track.h:37