gosu 0.7.33 → 0.7.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. data/Gosu/Async.hpp +10 -8
  2. data/Gosu/Audio.hpp +6 -4
  3. data/Gosu/AutoLink.hpp +0 -0
  4. data/Gosu/Bitmap.hpp +4 -5
  5. data/Gosu/ButtonsX.hpp +1 -1
  6. data/Gosu/Color.hpp +8 -8
  7. data/Gosu/Font.hpp +2 -2
  8. data/Gosu/Graphics.hpp +4 -6
  9. data/Gosu/IO.hpp +11 -4
  10. data/Gosu/Image.hpp +9 -7
  11. data/Gosu/ImageData.hpp +10 -4
  12. data/Gosu/Input.hpp +4 -5
  13. data/Gosu/Sockets.hpp +10 -12
  14. data/Gosu/TR1.hpp +44 -0
  15. data/Gosu/TextInput.hpp +2 -2
  16. data/Gosu/Version.hpp +2 -2
  17. data/Gosu/WinUtility.hpp +5 -6
  18. data/Gosu/Window.hpp +5 -6
  19. data/GosuImpl/Async.cpp +4 -3
  20. data/GosuImpl/Audio/ALChannelManagement.hpp +23 -11
  21. data/GosuImpl/Audio/AudioFile.hpp +11 -3
  22. data/GosuImpl/Audio/AudioOpenAL.cpp +613 -0
  23. data/GosuImpl/Audio/AudioOpenAL.mm +1 -605
  24. data/GosuImpl/Audio/AudioSDL.cpp +12 -14
  25. data/GosuImpl/Audio/AudioToolboxFile.hpp +0 -1
  26. data/GosuImpl/Audio/OggFile.hpp +2 -0
  27. data/GosuImpl/Audio/SndFile.hpp +158 -0
  28. data/GosuImpl/DirectoriesWin.cpp +18 -18
  29. data/GosuImpl/Graphics/BitmapApple.mm +17 -19
  30. data/GosuImpl/Graphics/BitmapBMP.cpp +7 -2
  31. data/GosuImpl/Graphics/BitmapFreeImage.cpp +11 -12
  32. data/GosuImpl/Graphics/BitmapGDIplus.cpp +35 -31
  33. data/GosuImpl/Graphics/BitmapUtils.cpp +1 -1
  34. data/GosuImpl/Graphics/BlockAllocator.cpp +7 -8
  35. data/GosuImpl/Graphics/BlockAllocator.hpp +3 -4
  36. data/GosuImpl/Graphics/Common.hpp +3 -2
  37. data/GosuImpl/Graphics/DrawOp.hpp +2 -3
  38. data/GosuImpl/Graphics/DrawOpQueue.hpp +28 -20
  39. data/GosuImpl/Graphics/Font.cpp +13 -13
  40. data/GosuImpl/Graphics/FormattedString.hpp +93 -86
  41. data/GosuImpl/Graphics/Graphics.cpp +16 -14
  42. data/GosuImpl/Graphics/Image.cpp +7 -3
  43. data/GosuImpl/Graphics/LargeImageData.hpp +4 -5
  44. data/GosuImpl/Graphics/Macro.hpp +11 -11
  45. data/GosuImpl/Graphics/RenderState.hpp +5 -4
  46. data/GosuImpl/Graphics/TexChunk.cpp +3 -3
  47. data/GosuImpl/Graphics/TexChunk.hpp +4 -4
  48. data/GosuImpl/Graphics/Text.cpp +29 -30
  49. data/GosuImpl/Graphics/TextMac.cpp +9 -7
  50. data/GosuImpl/Graphics/TextTTFWin.cpp +3 -1
  51. data/GosuImpl/Graphics/TextTouch.mm +0 -1
  52. data/GosuImpl/Graphics/TextUnix.cpp +12 -4
  53. data/GosuImpl/Graphics/TextWin.cpp +4 -2
  54. data/GosuImpl/Graphics/Texture.cpp +7 -6
  55. data/GosuImpl/Graphics/Texture.hpp +3 -4
  56. data/GosuImpl/InputMac.mm +12 -15
  57. data/GosuImpl/InputTouch.mm +3 -3
  58. data/GosuImpl/InputWin.cpp +149 -159
  59. data/GosuImpl/InputX.cpp +0 -0
  60. data/GosuImpl/MacUtility.hpp +9 -4
  61. data/GosuImpl/RubyGosu.swg +38 -43
  62. data/GosuImpl/RubyGosu_wrap.cxx +89 -96
  63. data/GosuImpl/Sockets/CommSocket.cpp +5 -5
  64. data/GosuImpl/Sockets/Sockets.hpp +4 -4
  65. data/GosuImpl/TimingApple.cpp +2 -3
  66. data/GosuImpl/Utility.cpp +18 -0
  67. data/GosuImpl/WinMain.cpp +0 -1
  68. data/GosuImpl/WinUtility.cpp +2 -2
  69. data/GosuImpl/WindowMac.mm +20 -17
  70. data/GosuImpl/WindowTouch.mm +8 -7
  71. data/GosuImpl/WindowWin.cpp +12 -7
  72. data/GosuImpl/WindowX.cpp +67 -18
  73. data/lib/gosu.rb +14 -12
  74. data/linux/extconf.rb +11 -6
  75. metadata +8 -7
  76. data/GosuImpl/Audio/AudioAudiere.cpp +0 -448
  77. data/GosuImpl/RubyGosu_DllMain.cxx +0 -31
@@ -1,16 +1,18 @@
1
1
  require 'rbconfig'
2
2
 
3
- begin
4
- if defined? RUBY_VERSION and RUBY_VERSION[0..2] == '1.9' then
5
- version = '1_9'
6
- else
7
- version = '1_8'
8
- end
9
- require "#{File.dirname(__FILE__)}/gosu.for_#{version}.#{Config::CONFIG['DLEXT']}"
10
- require "#{File.dirname(__FILE__)}/gosu/swig_patches.rb"
11
- rescue LoadError => e
12
- require "#{File.dirname(__FILE__)}/gosu.#{Config::CONFIG['DLEXT']}"
13
- require "#{File.dirname(__FILE__)}/gosu/swig_patches.rb"
3
+ WINDOWS_HINTS = %w(-win32 win32- mswin mingw32)
4
+
5
+ if defined? RUBY_PLATFORM and WINDOWS_HINTS.any? { |hint| RUBY_PLATFORM.include? hint } then
6
+ ENV['PATH'] = "#{File.dirname(__FILE__)};#{ENV['PATH']}"
7
+ end
8
+
9
+ if File.exist? "#{File.dirname(__FILE__)}/gosu.#{Config::CONFIG['DLEXT']}"
10
+ require "gosu.#{Config::CONFIG['DLEXT']}"
11
+ elsif defined? RUBY_VERSION and RUBY_VERSION.split('.')[1].to_i > 8 then
12
+ require "gosu.for_1_9.#{Config::CONFIG['DLEXT']}"
13
+ else
14
+ require "gosu.for_1_8.#{Config::CONFIG['DLEXT']}"
14
15
  end
15
16
 
16
- require "#{File.dirname(__FILE__)}/gosu/patches.rb"
17
+ require "gosu/swig_patches"
18
+ require "gosu/patches"
@@ -18,7 +18,6 @@ BASE_FILES = %w(
18
18
  FileUnix.cpp
19
19
  Graphics/Bitmap.cpp
20
20
  Graphics/BitmapColorKey.cpp
21
- Graphics/BitmapFreeImage.cpp
22
21
  Graphics/BitmapUtils.cpp
23
22
  Graphics/BlockAllocator.cpp
24
23
  Graphics/Color.cpp
@@ -50,6 +49,7 @@ MAC_FILES = %w(
50
49
 
51
50
  LINUX_FILES = %w(
52
51
  Audio/AudioSDL.cpp
52
+ Graphics/BitmapFreeImage.cpp
53
53
  Graphics/TextUnix.cpp
54
54
  InputX.cpp
55
55
  TextInputX.cpp
@@ -64,12 +64,13 @@ $INCFLAGS << " -I../ -I../GosuImpl"
64
64
  if `uname`.chomp == 'Darwin' then
65
65
  SOURCE_FILES = BASE_FILES + MAC_FILES
66
66
 
67
- # The X11 paths are here because Apple curiously distributes libpng only inside X11
68
- $INCFLAGS << " -I/usr/local/include -I/usr/X11/include"
69
- $CFLAGS << " -x objective-c++ -fobjc-gc" # Never hurts!
70
- $LDFLAGS << " -L/usr/local/lib -L/usr/X11/lib -logg -lvorbis -lvorbisfile -liconv"
67
+ # Apple curiously distributes libpng only inside X11
68
+ $INCFLAGS << " -I/usr/X11/include"
69
+ # To make everything work with the Objective C runtime
70
+ $CFLAGS << " -x objective-c++ -fobjc-gc"
71
+ $LDFLAGS << " -L/usr/X11/lib -logg -lvorbis -lvorbisfile -liconv"
71
72
  %w(AudioToolbox IOKit OpenAL OpenGL AppKit ApplicationServices Foundation Carbon).each do |f|
72
- $INCFLAGS << " -framework #{f}"
73
+ #$INCFLAGS << " -framework #{f}" <- not necessary? I only get lots of warnings
73
74
  $LDFLAGS << " -framework #{f}"
74
75
  end
75
76
 
@@ -92,6 +93,10 @@ else
92
93
  have_header('SDL_ttf.h') if have_library('SDL_ttf', 'TTF_RenderUTF8_Blended')
93
94
  have_header('gl.h') if have_library('GL', 'glMatrixMode')
94
95
  have_header('FreeImage.h') if have_library('freeimage', 'FreeImage_ConvertFromRawBits')
96
+ have_header('vorbisfile.h') if have_library('vorbisfile', 'ov_open_callbacks')
97
+ have_header('AL/al.h') if have_library('openal')
98
+ have_header('sndfile.h') if have_library('sndfile')
99
+ have_header('X11/extensions/Xdamage.h')
95
100
  end
96
101
 
97
102
  # Copy all relevant C++ files into the current directory
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gosu
3
3
  version: !ruby/object:Gem::Version
4
- hash: 65
4
+ hash: 69
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 33
10
- version: 0.7.33
9
+ - 35
10
+ version: 0.7.35
11
11
  platform: ruby
12
12
  authors:
13
13
  - Julian Raschke
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-06-13 00:00:00 Z
19
+ date: 2011-08-12 00:00:00 Z
20
20
  dependencies: []
21
21
 
22
22
  description: " 2D game development library.\n\n Gosu features easy to use and game-friendly interfaces to 2D graphics\n and text (accelerated by 3D hardware), sound samples and music as well as\n keyboard, mouse and gamepad/joystick input.\n\n Also includes demos for integration with RMagick, Chipmunk and Ruby-OpenGL.\n"
@@ -55,6 +55,7 @@ files:
55
55
  - Gosu/Text.hpp
56
56
  - Gosu/TextInput.hpp
57
57
  - Gosu/Timing.hpp
58
+ - Gosu/TR1.hpp
58
59
  - Gosu/Utility.hpp
59
60
  - Gosu/Version.hpp
60
61
  - Gosu/Window.hpp
@@ -86,12 +87,13 @@ files:
86
87
  - examples/media/Starfighter.bmp
87
88
  - GosuImpl/Async.cpp
88
89
  - GosuImpl/Audio/ALChannelManagement.hpp
89
- - GosuImpl/Audio/AudioAudiere.cpp
90
90
  - GosuImpl/Audio/AudioFile.hpp
91
+ - GosuImpl/Audio/AudioOpenAL.cpp
91
92
  - GosuImpl/Audio/AudioOpenAL.mm
92
93
  - GosuImpl/Audio/AudioSDL.cpp
93
94
  - GosuImpl/Audio/AudioToolboxFile.hpp
94
95
  - GosuImpl/Audio/OggFile.hpp
96
+ - GosuImpl/Audio/SndFile.hpp
95
97
  - GosuImpl/DirectoriesMac.mm
96
98
  - GosuImpl/DirectoriesTouch.mm
97
99
  - GosuImpl/DirectoriesUnix.cpp
@@ -146,7 +148,6 @@ files:
146
148
  - GosuImpl/Orientation.hpp
147
149
  - GosuImpl/Orientation.mm
148
150
  - GosuImpl/RubyGosu.swg
149
- - GosuImpl/RubyGosu_DllMain.cxx
150
151
  - GosuImpl/RubyGosu_SWIG_GC_PATCH.patch
151
152
  - GosuImpl/RubyGosu_SWIG_RENAME_PATCH.patch
152
153
  - GosuImpl/RubyGosu_SWIG_TYPE_PATCH.patch
@@ -205,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
206
  requirements:
206
207
  - See https://github.com/jlnr/gosu/wiki/Getting-Started-on-Linux
207
208
  rubyforge_project:
208
- rubygems_version: 1.8.4
209
+ rubygems_version: 1.8.7
209
210
  signing_key:
210
211
  specification_version: 3
211
212
  summary: 2D game development library.
@@ -1,448 +0,0 @@
1
- #include <Gosu/Audio.hpp>
2
- #include <Gosu/Math.hpp>
3
- #include <Gosu/IO.hpp>
4
- #include <Gosu/Utility.hpp>
5
- #include <boost/foreach.hpp>
6
- #include <algorithm>
7
- #include <stdexcept>
8
- #include <vector>
9
-
10
- #include <audiere.h>
11
- using namespace audiere;
12
-
13
- namespace Gosu
14
- {
15
- namespace
16
- {
17
- Song* curSong = 0;
18
-
19
- // Gosu::Buffer-based implementation of Audiere's File interface.
20
- // Provided since Audiere uses stdio to open files, which may not support Unicode
21
- // filenames outside of the current codepage on Windows(?).
22
- class MemoryBuffer : boost::noncopyable
23
- {
24
- Gosu::Buffer buffer;
25
- FilePtr file;
26
-
27
- public:
28
- MemoryBuffer(Gosu::Reader reader)
29
- {
30
- buffer.resize(reader.resource().size() - reader.position());
31
- reader.read(buffer.data(), buffer.size());
32
- file = audiere::CreateMemoryFile(buffer.data(), buffer.size());
33
- }
34
-
35
- MemoryBuffer(const std::wstring& filename)
36
- {
37
- Gosu::loadFile(buffer, filename);
38
- file = audiere::CreateMemoryFile(buffer.data(), buffer.size());
39
- }
40
-
41
- operator const FilePtr&()
42
- {
43
- return file;
44
- }
45
- };
46
-
47
- class StreamRegistry : public RefImplementation<StopCallback>, boost::noncopyable
48
- {
49
- struct NumberedStream
50
- {
51
- int extra;
52
- OutputStreamPtr stream;
53
- };
54
- std::vector<NumberedStream> streams;
55
-
56
- ADR_METHOD(void) streamStopped(StopEvent* event)
57
- {
58
- if (event->getReason() == StopEvent::STREAM_ENDED)
59
- BOOST_FOREACH (NumberedStream& stream, streams)
60
- if (stream.stream == event->getOutputStream())
61
- {
62
- stream.stream = 0;
63
- break;
64
- }
65
- }
66
-
67
- public:
68
- StreamRegistry()
69
- {
70
- streams.reserve(100);
71
- }
72
-
73
- OutputStreamPtr get(int handle, int extra) const
74
- {
75
- if (handle < streams.size() && streams[handle].extra == extra)
76
- return streams[handle].stream;
77
- return OutputStreamPtr();
78
- }
79
-
80
- void put(OutputStreamPtr stream, int& handle, int& extra)
81
- {
82
- handle = 0;
83
- for (handle; handle < streams.size(); ++handle)
84
- if (!streams[handle].stream)
85
- {
86
- streams[handle].stream = stream;
87
- extra = ++streams[handle].extra;
88
- return;
89
- }
90
- // handle == streams.size() <3
91
- NumberedStream newStream = { extra = 0, stream };
92
- streams.push_back(newStream);
93
- }
94
-
95
- void clear(int handle)
96
- {
97
- streams.at(handle).stream = 0;
98
- }
99
- };
100
-
101
- // Intentionally leak. Let Windows clean up on program exit.
102
- StreamRegistry& streams = *(new StreamRegistry);
103
-
104
- // Since audiere::OpenDevice is (contains) the first call to audiere.dll, we wrap
105
- // the call in error handling code to see if the lazily linked DLL is there.
106
- bool getDevice(AudioDevice*& device)
107
- {
108
- #ifdef GOSU_IS_WIN
109
- // Copied and pasted from MSDN.
110
- #define FACILITY_VISUALCPP ((LONG)0x6d)
111
- #define VcppException(sev,err) ((sev) | (FACILITY_VISUALCPP<<16) | err)
112
- #define BAD_MOD VcppException(ERROR_SEVERITY_ERROR, ERROR_MOD_NOT_FOUND)
113
-
114
- __try
115
- {
116
- #endif
117
- return (device = OpenDevice());
118
- #ifdef GOSU_IS_WIN
119
- }
120
- __except ((GetExceptionCode() == BAD_MOD) ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
121
- {
122
- return false;
123
- }
124
- #undef BAD_MOD
125
- #undef VcppException
126
- #undef FACILITY_VISUALCPP
127
- #endif
128
- }
129
-
130
- AudioDevice* device()
131
- {
132
- static AudioDevice* device = 0;
133
- if (device == 0)
134
- {
135
- if (!getDevice(device))
136
- throw std::runtime_error("Could not initialize audiere or library not found");
137
-
138
- device->registerCallback(&streams);
139
-
140
- // Never free. Especially important in Ruby version, where GC order is undefined
141
- device->ref();
142
- }
143
- return device;
144
- }
145
- }
146
- }
147
-
148
- Gosu::SampleInstance::SampleInstance(int handle, int extra)
149
- : handle(handle), extra(extra)
150
- {
151
- }
152
-
153
- bool Gosu::SampleInstance::playing() const
154
- {
155
- OutputStreamPtr stream = streams.get(handle, extra);
156
- return stream && stream->isPlaying();
157
- }
158
-
159
- bool Gosu::SampleInstance::paused() const
160
- {
161
- OutputStreamPtr stream = streams.get(handle, extra);
162
- return stream && !stream->isPlaying();
163
- }
164
-
165
- void Gosu::SampleInstance::pause()
166
- {
167
- if (OutputStreamPtr stream = streams.get(handle, extra))
168
- stream->stop();
169
- }
170
-
171
- void Gosu::SampleInstance::resume()
172
- {
173
- if (OutputStreamPtr stream = streams.get(handle, extra))
174
- stream->play();
175
- }
176
-
177
- void Gosu::SampleInstance::stop()
178
- {
179
- if (OutputStreamPtr stream = streams.get(handle, extra))
180
- stream->stop(), streams.clear(handle);
181
- }
182
-
183
- void Gosu::SampleInstance::changeVolume(double volume)
184
- {
185
- if (OutputStreamPtr stream = streams.get(handle, extra))
186
- stream->setVolume(volume);
187
- }
188
-
189
- void Gosu::SampleInstance::changePan(double pan)
190
- {
191
- if (OutputStreamPtr stream = streams.get(handle, extra))
192
- stream->setPan(clamp<float>(pan, -1.f, +1.f));
193
- }
194
-
195
- void Gosu::SampleInstance::changeSpeed(double speed)
196
- {
197
- if (OutputStreamPtr stream = streams.get(handle, extra))
198
- stream->setPitchShift(clamp<float>(speed, 0.5f, 2.0f));
199
- }
200
-
201
- struct Gosu::Sample::SampleData : boost::noncopyable
202
- {
203
- SampleBufferPtr buffer;
204
- };
205
-
206
- Gosu::Sample::Sample(const std::wstring& filename)
207
- : data(new SampleData)
208
- {
209
- device(); // Implicitly open audio device
210
-
211
- SampleSourcePtr source = OpenSampleSource(MemoryBuffer(filename), FF_AUTODETECT);
212
- data->buffer = CreateSampleBuffer(source);
213
- if (!data->buffer)
214
- throw std::runtime_error("Cannot open " + wstringToUTF8(filename));
215
- }
216
-
217
- Gosu::Sample::Sample(Reader reader)
218
- {
219
- device(); // Implicitly open audio device
220
-
221
- SampleSourcePtr source = audiere::OpenSampleSource(MemoryBuffer(reader), FF_AUTODETECT);
222
- data->buffer = CreateSampleBuffer(source);
223
- if (!data->buffer)
224
- throw std::runtime_error("Cannot open audio file");
225
- }
226
-
227
- Gosu::SampleInstance Gosu::Sample::play(double volume, double speed,
228
- bool looping) const
229
- {
230
- OutputStreamPtr stream = device()->openStream(data->buffer->openStream());
231
- int handle, extra;
232
- streams.put(stream, handle, extra);
233
-
234
- SampleInstance instance(handle, extra);
235
- instance.changeVolume(volume);
236
- instance.changeSpeed(speed);
237
- stream->setRepeat(looping);
238
- stream->play();
239
- return instance;
240
- }
241
-
242
- Gosu::SampleInstance Gosu::Sample::playPan(double pan, double volume,
243
- double speed, bool looping) const
244
- {
245
- OutputStreamPtr stream = device()->openStream(data->buffer->openStream());
246
- int handle, extra;
247
- streams.put(stream, handle, extra);
248
-
249
- SampleInstance instance(handle, extra);
250
- instance.changePan(pan);
251
- instance.changeVolume(volume);
252
- instance.changeSpeed(speed);
253
- stream->setRepeat(looping);
254
- stream->play();
255
- return instance;
256
- }
257
-
258
- class Gosu::Song::BaseData : boost::noncopyable
259
- {
260
- double volume_;
261
-
262
- protected:
263
- BaseData() : volume_(1) {}
264
- virtual void applyVolume() = 0;
265
-
266
- public:
267
- virtual ~BaseData() {}
268
-
269
- virtual void play(bool looping) = 0;
270
- virtual bool playing() const = 0;
271
- virtual bool paused() const = 0;
272
- virtual void pause() = 0;
273
- virtual void stop() = 0;
274
-
275
- double volume() const
276
- {
277
- return volume_;
278
- }
279
-
280
- void changeVolume(double volume)
281
- {
282
- volume_ = clamp(volume, 0.0, 1.0);
283
- applyVolume();
284
- }
285
- };
286
-
287
- class Gosu::Song::StreamData : public BaseData
288
- {
289
- MemoryBuffer buffer;
290
- OutputStreamPtr stream;
291
- SampleInstance instance;
292
- bool loop;
293
-
294
- void init()
295
- {
296
- int handle, extra;
297
- stream = OpenSound(device(), buffer, true);
298
- if (!stream)
299
- throw std::runtime_error("Cannot open audio file for streaming");
300
- streams.put(stream, handle, extra);
301
- instance = SampleInstance(handle, extra);
302
- loop = false;
303
- }
304
-
305
- public:
306
- StreamData(Gosu::Reader reader)
307
- : buffer(reader), instance(-1, -1)
308
- {
309
- init();
310
- }
311
-
312
- StreamData(const std::wstring& filename)
313
- : buffer(filename), instance(-1, -1)
314
- {
315
- init();
316
- }
317
-
318
- void play(bool looping)
319
- {
320
- applyVolume();
321
- if (looping != loop)
322
- stream->setRepeat(loop = looping);
323
- stream->play();
324
- }
325
-
326
- bool playing() const
327
- {
328
- return instance.playing();
329
- }
330
-
331
- bool paused() const
332
- {
333
- return instance.paused();
334
- }
335
-
336
- void pause()
337
- {
338
- instance.pause();
339
- }
340
-
341
- void stop()
342
- {
343
- instance.stop();
344
- stream->reset();
345
- }
346
-
347
- void applyVolume()
348
- {
349
- instance.changeVolume(volume());
350
- }
351
- };
352
-
353
- Gosu::Song::Song(const std::wstring& filename)
354
- : data(new StreamData(filename))
355
- {
356
- }
357
-
358
- Gosu::Song::Song(Reader reader)
359
- : data(new StreamData(reader))
360
- {
361
- }
362
-
363
- Gosu::Song::~Song()
364
- {
365
- }
366
-
367
- Gosu::Song* Gosu::Song::currentSong()
368
- {
369
- if (curSong && (curSong->playing() || curSong->paused()))
370
- return curSong;
371
- return curSong = 0;
372
- }
373
-
374
- void Gosu::Song::play(bool looping)
375
- {
376
- if (Gosu::Song* cur = currentSong())
377
- if (cur != this)
378
- {
379
- cur->stop();
380
- assert (currentSong() == 0);
381
- }
382
-
383
- data->play(looping); // May be redundant
384
- curSong = this; // May be redundant
385
- }
386
-
387
- void Gosu::Song::pause()
388
- {
389
- if (curSong == this && data->playing())
390
- data->pause();
391
- }
392
-
393
- bool Gosu::Song::paused() const
394
- {
395
- return curSong == this && data->paused();
396
- }
397
-
398
- void Gosu::Song::stop()
399
- {
400
- if (curSong == this)
401
- {
402
- data->stop();
403
- curSong = 0;
404
- }
405
- }
406
-
407
- bool Gosu::Song::playing() const
408
- {
409
- assert (!(curSong != this && data->playing()));
410
- return data->playing();
411
- }
412
-
413
- double Gosu::Song::volume() const
414
- {
415
- return data->volume();
416
- }
417
-
418
- void Gosu::Song::changeVolume(double volume)
419
- {
420
- data->changeVolume(volume);
421
- }
422
-
423
- void Gosu::Song::update()
424
- {
425
- device()->update();
426
- }
427
-
428
- // Deprecated constructors.
429
-
430
- Gosu::Sample::Sample(Audio& audio, const std::wstring& filename)
431
- {
432
- Sample(filename).data.swap(data);
433
- }
434
-
435
- Gosu::Sample::Sample(Audio& audio, Reader reader)
436
- {
437
- Sample(reader).data.swap(data);
438
- }
439
-
440
- Gosu::Song::Song(Audio& audio, const std::wstring& filename)
441
- {
442
- Song(filename).data.swap(data);
443
- }
444
-
445
- Gosu::Song::Song(Audio& audio, Type type, Reader reader)
446
- {
447
- Song(reader).data.swap(data);
448
- }