gosu 0.10.9.pre1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/Gosu/Audio.hpp +35 -66
  3. data/Gosu/AutoLink.hpp +14 -16
  4. data/Gosu/Bitmap.hpp +50 -37
  5. data/Gosu/Buttons.hpp +246 -265
  6. data/Gosu/Color.hpp +32 -76
  7. data/Gosu/Directories.hpp +14 -17
  8. data/Gosu/Font.hpp +28 -34
  9. data/Gosu/Fwd.hpp +27 -31
  10. data/Gosu/Gosu.hpp +2 -5
  11. data/Gosu/Graphics.hpp +31 -48
  12. data/Gosu/GraphicsBase.hpp +27 -58
  13. data/Gosu/IO.hpp +44 -56
  14. data/Gosu/Image.hpp +29 -73
  15. data/Gosu/ImageData.hpp +13 -17
  16. data/Gosu/Input.hpp +42 -57
  17. data/Gosu/Inspection.hpp +2 -6
  18. data/Gosu/Math.hpp +32 -38
  19. data/Gosu/Platform.hpp +10 -29
  20. data/Gosu/Text.hpp +30 -39
  21. data/Gosu/TextInput.hpp +29 -36
  22. data/Gosu/Timing.hpp +14 -16
  23. data/Gosu/Utility.hpp +10 -15
  24. data/Gosu/Version.hpp +13 -14
  25. data/Gosu/Window.hpp +53 -68
  26. data/README.md +23 -11
  27. data/ext/gosu/extconf.rb +31 -81
  28. data/lib/gosu/patches.rb +35 -19
  29. data/lib/gosu/run.rb +13 -4
  30. data/rdoc/gosu.rb +24 -20
  31. data/src/ALChannelManagement.hpp +119 -0
  32. data/src/{Audio/Audio.cpp → Audio.cpp} +177 -211
  33. data/src/AudioFile.hpp +57 -0
  34. data/src/AudioToolboxFile.hpp +214 -0
  35. data/src/Bitmap.cpp +159 -0
  36. data/src/BitmapIO.cpp +141 -0
  37. data/src/BlockAllocator.cpp +133 -0
  38. data/src/{Graphics/BlockAllocator.hpp → BlockAllocator.hpp} +34 -35
  39. data/src/ClipRectStack.hpp +87 -0
  40. data/src/{Graphics/Color.cpp → Color.cpp} +30 -28
  41. data/src/DirectoriesApple.cpp +68 -0
  42. data/src/DirectoriesUnix.cpp +20 -18
  43. data/src/DirectoriesWin.cpp +40 -41
  44. data/src/DrawOp.hpp +168 -0
  45. data/src/DrawOpQueue.hpp +190 -0
  46. data/src/FileUnix.cpp +40 -46
  47. data/src/FileWin.cpp +42 -38
  48. data/src/Font.cpp +165 -0
  49. data/src/{Text/FormattedString.hpp → FormattedString.hpp} +114 -114
  50. data/src/GosuAppDelegate.cpp +30 -0
  51. data/src/{UIKit/GosuAppDelegate.h → GosuAppDelegate.h} +0 -0
  52. data/src/{UIKit/GosuGLView.mm → GosuGLView.cpp} +22 -17
  53. data/src/{UIKit/GosuGLView.h → GosuGLView.h} +0 -0
  54. data/src/GosuViewController.cpp +231 -0
  55. data/src/{UIKit/GosuViewController.h → GosuViewController.h} +0 -0
  56. data/src/Graphics.cpp +464 -0
  57. data/src/{Graphics/Common.hpp → GraphicsImpl.hpp} +29 -32
  58. data/src/IO.cpp +17 -16
  59. data/src/Iconv.hpp +13 -22
  60. data/src/Image.cpp +142 -0
  61. data/src/Input.cpp +459 -0
  62. data/src/InputUIKit.cpp +197 -0
  63. data/src/Inspection.cpp +4 -5
  64. data/src/LargeImageData.cpp +151 -0
  65. data/src/LargeImageData.hpp +43 -0
  66. data/src/{Graphics/Macro.cpp → Macro.cpp} +77 -78
  67. data/src/Macro.hpp +30 -0
  68. data/src/Math.cpp +17 -29
  69. data/src/{Audio/OggFile.hpp → OggFile.hpp} +19 -24
  70. data/src/RenderState.hpp +205 -0
  71. data/src/Resolution.cpp +86 -0
  72. data/src/ResolutionApple.cpp +25 -0
  73. data/{ext/gosu/gosu_wrap.cxx → src/RubyGosu.cxx} +2256 -1707
  74. data/{ext/gosu/gosu_wrap.h → src/RubyGosu.h} +9 -9
  75. data/src/{Audio/SndFile.hpp → SndFile.hpp} +54 -43
  76. data/src/TexChunk.cpp +117 -0
  77. data/src/{Graphics/TexChunk.hpp → TexChunk.hpp} +13 -18
  78. data/src/Text.cpp +371 -0
  79. data/src/TextApple.cpp +209 -0
  80. data/src/TextInput.cpp +278 -0
  81. data/src/TextTTFWin.cpp +251 -0
  82. data/src/{Text/TextUnix.cpp → TextUnix.cpp} +96 -92
  83. data/src/TextWin.cpp +194 -0
  84. data/src/{Graphics/Texture.cpp → Texture.cpp} +35 -38
  85. data/src/{Graphics/Texture.hpp → Texture.hpp} +9 -13
  86. data/src/TimingApple.cpp +11 -7
  87. data/src/TimingUnix.cpp +13 -7
  88. data/src/TimingWin.cpp +6 -1
  89. data/src/{Graphics/Transform.cpp → Transform.cpp} +17 -12
  90. data/src/{Graphics/TransformStack.hpp → TransformStack.hpp} +24 -25
  91. data/src/Utility.cpp +29 -70
  92. data/src/UtilityApple.cpp +52 -0
  93. data/src/UtilityWin.cpp +7 -4
  94. data/src/Version.cpp +22 -0
  95. data/src/WinMain.cpp +30 -33
  96. data/src/WinUtility.cpp +24 -22
  97. data/src/WinUtility.hpp +11 -20
  98. data/src/Window.cpp +142 -112
  99. data/src/WindowUIKit.cpp +155 -0
  100. data/src/stb_image.h +384 -173
  101. data/src/stb_vorbis.c +20 -18
  102. metadata +60 -62
  103. data/Gosu/TR1.hpp +0 -56
  104. data/src/AppleUtility.hpp +0 -66
  105. data/src/Audio/ALChannelManagement.hpp +0 -114
  106. data/src/Audio/Audio.mm +0 -1
  107. data/src/Audio/AudioFile.hpp +0 -53
  108. data/src/Audio/AudioToolboxFile.hpp +0 -207
  109. data/src/Bitmap/Bitmap.cpp +0 -183
  110. data/src/Bitmap/BitmapIO.cpp +0 -176
  111. data/src/DirectoriesApple.mm +0 -71
  112. data/src/Graphics/BlockAllocator.cpp +0 -142
  113. data/src/Graphics/ClipRectStack.hpp +0 -93
  114. data/src/Graphics/DrawOp.hpp +0 -175
  115. data/src/Graphics/DrawOpQueue.hpp +0 -188
  116. data/src/Graphics/Graphics.cpp +0 -478
  117. data/src/Graphics/Image.cpp +0 -193
  118. data/src/Graphics/LargeImageData.cpp +0 -133
  119. data/src/Graphics/LargeImageData.hpp +0 -46
  120. data/src/Graphics/Macro.hpp +0 -36
  121. data/src/Graphics/RenderState.hpp +0 -211
  122. data/src/Graphics/Resolution.cpp +0 -91
  123. data/src/Graphics/ResolutionApple.mm +0 -19
  124. data/src/Graphics/TexChunk.cpp +0 -112
  125. data/src/Input/Input.cpp +0 -463
  126. data/src/Input/InputUIKit.mm +0 -190
  127. data/src/Input/TextInput.cpp +0 -261
  128. data/src/Text/Font.cpp +0 -175
  129. data/src/Text/Text.cpp +0 -391
  130. data/src/Text/TextApple.mm +0 -227
  131. data/src/Text/TextTTFWin.cpp +0 -249
  132. data/src/Text/TextWin.cpp +0 -186
  133. data/src/UIKit/GosuAppDelegate.mm +0 -24
  134. data/src/UIKit/GosuViewController.mm +0 -211
  135. data/src/UtilityApple.mm +0 -63
  136. data/src/WindowUIKit.mm +0 -139
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a8d2be430ae120903f4155a4b06567356fccc67
4
- data.tar.gz: b2a0e682a342de8b463b041d2edb55675b4a454a
3
+ metadata.gz: 1ad2451369f43dadcb9f88a84fead3c5e3eb2dd3
4
+ data.tar.gz: 284ae60ac4f93bb14e3188c53652ed86bd439168
5
5
  SHA512:
6
- metadata.gz: e7abb1410459e410c226ea129ecb82ddc453cadd468d969b676e5a4962b39380f5a7132d70847ec3eaabcf59d00d7f4f647189da3d4a9364c3c2258838285eac
7
- data.tar.gz: c19fb65453733173aef1b99c3fcfaeaf1639745dbfdf8d8747a12adcd550cfc519be4761024de0be719e7dae953beb85765cdd0cddea33805c823818d8c19bb6
6
+ metadata.gz: b17636aa514351891d603b9dae3a5210e506f130ef8ced28094c2f2d94c66ee299c40bf25f3959dccf9813bd134b9127b7748553999731c9821d0b4af1bbd591
7
+ data.tar.gz: 6be1bb1c2228e69c25936ece224ce831c9f36fd25b12306ad91667439748186bd0d7b7fefdac51e99ad122042592714f49b60c7616873e75fb5967896fb417b3
@@ -1,63 +1,50 @@
1
1
  //! \file Audio.hpp
2
2
  //! Contains all the classes of Gosu's audio system.
3
3
 
4
- #ifndef GOSU_AUDIO_HPP
5
- #define GOSU_AUDIO_HPP
4
+ #pragma once
6
5
 
7
- #ifdef WIN32
8
- #ifndef NOMINMAX
9
- #define NOMINMAX
10
- #endif
11
- #include <windows.h>
12
- #endif
13
6
  #include <Gosu/Fwd.hpp>
14
7
  #include <Gosu/IO.hpp>
15
8
  #include <Gosu/Platform.hpp>
16
- #include <Gosu/TR1.hpp>
17
9
  #include <memory>
18
10
  #include <string>
19
11
 
20
12
  namespace Gosu
21
13
  {
22
- // Deprecated.
23
- #ifndef SWIG
24
- class Audio;
25
- #endif
26
-
27
14
  //! An instance of a Sample playing. Can be used to stop sounds dynamically,
28
15
  //! or to check if they are finished.
29
16
  //! It is recommended that you throw away sample instances if possible,
30
17
  //! as they could accidentally refer to other sounds being played after
31
18
  //! a very long time has passed.
32
- class SampleInstance
33
- {
34
- int handle, extra;
35
- bool alive() const;
19
+ class SampleInstance
20
+ {
21
+ int handle, extra;
22
+ bool alive() const;
36
23
 
37
- public:
38
- //! Called by Sample, do not use.
39
- // TODO: See if we can use 'friend' here.
40
- SampleInstance(int handle, int extra);
24
+ public:
25
+ //! Called internally by Sample, do not use.
26
+ SampleInstance(int handle, int extra);
41
27
 
42
- bool playing() const;
43
- bool paused() const;
44
- //! Pauses this instance to be resumed afterwards. It will still keep a channel filled while paused.
28
+ bool playing() const;
29
+ bool paused() const;
30
+ //! Pauses this instance to be resumed afterwards. It will still keep a channel filled while
31
+ //! paused.
45
32
  void pause();
46
33
  void resume();
47
34
  //! Stops this instance of a sound being played.
48
35
  //! Calling this twice, or too late, does not do any harm.
49
- void stop();
36
+ void stop();
50
37
 
51
38
  //! \param volume Can be anything from 0.0 (silence) to 1.0 (full
52
39
  //! volume).
53
- void changeVolume(double volume);
40
+ void change_volume(double volume);
54
41
  //! \param pan Can be anything from -1.0 (left) to 1.0 (right).
55
- void changePan(double pan);
42
+ void change_pan(double pan);
56
43
  //! \param speed Playback speed is only limited by FMOD's
57
44
  //! capabilities and can accept very high or low values. Use 1.0 for
58
45
  //! normal playback speed.
59
- void changeSpeed(double speed);
60
- };
46
+ void change_speed(double speed);
47
+ };
61
48
 
62
49
  //! A sample is a short sound that is completely loaded in memory, can be
63
50
  //! played multiple times at once and offers very flexible playback
@@ -65,12 +52,12 @@ namespace Gosu
65
52
  class Sample
66
53
  {
67
54
  struct SampleData;
68
- std::tr1::shared_ptr<SampleData> data;
69
-
55
+ std::shared_ptr<SampleData> data;
56
+
70
57
  public:
71
58
  //! Constructs a sample that can be played on the specified audio
72
59
  //! system and loads the sample from a file.
73
- explicit Sample(const std::wstring& filename);
60
+ explicit Sample(const std::string& filename);
74
61
 
75
62
  //! Constructs a sample that can be played on the specified audio
76
63
  //! system and loads the sample data from a stream.
@@ -82,8 +69,7 @@ namespace Gosu
82
69
  //! \param speed Playback speed is only limited by the underlying audio library,
83
70
  //! and can accept very high or low values. Use 1.0 for
84
71
  //! normal playback speed.
85
- SampleInstance play(double volume = 1, double speed = 1,
86
- bool looping = false) const;
72
+ SampleInstance play(double volume = 1, double speed = 1, bool looping = false) const;
87
73
 
88
74
  //! Plays the sample with panning. Even if pan is 0.0, the sample will
89
75
  //! not be as loud as if it were played by calling play() due to the
@@ -94,39 +80,29 @@ namespace Gosu
94
80
  //! \param speed Playback speed is only limited by by the underlying audio library,
95
81
  //! and can accept very high
96
82
  //! or low values. Use 1.0 for normal playback speed.
97
- SampleInstance playPan(double pan, double volume = 1, double speed = 1,
83
+ SampleInstance play_pan(double pan, double volume = 1, double speed = 1,
98
84
  bool looping = false) const;
99
-
100
- #ifndef SWIG
101
- GOSU_DEPRECATED Sample(Audio& audio, const std::wstring& filename);
102
- GOSU_DEPRECATED Sample(Audio& audio, Reader reader);
103
- #endif
104
85
  };
105
86
 
106
- //! Songs are less flexible than samples in that they can only be played
107
- //! one at a time and without panning or speed parameters.
87
+ //! Songs are less flexible than samples. Only Song can be played at any given time,
88
+ //! and there is no way to control its pan (stereo position) or speed.
108
89
  class Song
109
90
  {
110
91
  class BaseData;
111
92
  class ModuleData;
112
93
  class StreamData;
113
- GOSU_UNIQUE_PTR<BaseData> data;
114
-
115
- #if defined(GOSU_CPP11_ENABLED)
94
+ std::unique_ptr<BaseData> data;
95
+
96
+ // Non-movable to avoid dangling internal references.
116
97
  Song(Song&&) = delete;
98
+ // Non-movable to avoid dangling internal references.
117
99
  Song& operator=(Song&&) = delete;
118
- Song(const Song&) = delete;
119
- Song& operator=(const Song&) = delete;
120
- #else
121
- Song(const Song&);
122
- Song& operator=(const Song&);
123
- #endif
124
100
 
125
101
  public:
126
102
  //! Constructs a song that can be played on the provided audio system
127
103
  //! and loads the song from a file. The type is determined from the
128
104
  //! filename.
129
- explicit Song(const std::wstring& filename);
105
+ explicit Song(const std::string& filename);
130
106
 
131
107
  //! Constructs a song of the specified type that can be played on the
132
108
  //! provided audio system and loads the song data from a stream.
@@ -137,36 +113,29 @@ namespace Gosu
137
113
  //! Returns the song currently being played or paused, or 0 if
138
114
  //! no song has been played yet or the last song has finished
139
115
  //! playing.
140
- static Song* currentSong();
116
+ static Song* current_song();
141
117
 
142
118
  //! Starts or resumes playback of the song. This will stop all other
143
119
  //! songs and set the current song to this object.
144
120
  void play(bool looping = false);
145
121
  //! Pauses playback of the song. It is not considered being played.
146
- //! currentSong will stay the same.
122
+ //! current_song will stay the same.
147
123
  void pause();
148
124
  //! Returns true if the song is the current song, but in paused
149
125
  //! mode.
150
126
  bool paused() const;
151
127
  //! Stops playback of this song if it is currently played or paused.
152
- //! Afterwards, currentSong will return 0.
128
+ //! Afterwards, current_song will return nullptr.
153
129
  void stop();
154
130
  //! Returns true if the song is currently playing.
155
131
  bool playing() const;
156
132
  //! Returns the current volume of the song.
157
133
  double volume() const;
158
- //! Changes the volume of the song.
159
- void changeVolume(double volume);
134
+ //! \param volume Can be anything from 0.0 (silence) to 1.0 (full
135
+ //! volume).
136
+ void change_volume(double volume);
160
137
 
161
138
  //! Called every tick by Window for management purposes.
162
139
  static void update();
163
-
164
- #ifndef SWIG
165
- enum Type { stStream, stModule };
166
- GOSU_DEPRECATED Song(Audio&, const std::wstring& filename);
167
- GOSU_DEPRECATED Song(Audio&, Type type, Reader reader);
168
- #endif
169
140
  };
170
141
  }
171
-
172
- #endif
@@ -1,16 +1,14 @@
1
- //! \file AutoLink.hpp
2
- //! Contains pragmas that make MSVC link against all the necessary libraries
3
- //! automatically.
4
-
5
- #ifdef _MSC_VER
6
- #ifndef GOSU_AUTOLINK_HPP
7
- #define GOSU_AUTOLINK_HPP
8
-
9
- #ifdef NDEBUG
10
- #pragma comment(lib, "Gosu.lib")
11
- #else
12
- #pragma comment(lib, "GosuDebug.lib")
13
- #endif
14
-
15
- #endif
16
- #endif
1
+ //! \file AutoLink.hpp
2
+ //! Contains pragmas that make MSVC link against all the necessary libraries
3
+ //! automatically.
4
+
5
+ #ifdef _MSC_VER
6
+ #pragma once
7
+
8
+ #ifdef NDEBUG
9
+ #pragma comment(lib, "Gosu.lib")
10
+ #else
11
+ #pragma comment(lib, "GosuDebug.lib")
12
+ #endif
13
+
14
+ #endif
@@ -1,11 +1,10 @@
1
1
  //! \file Bitmap.hpp
2
2
  //! Interface of the Bitmap class.
3
3
 
4
- #ifndef GOSU_BITMAP_HPP
5
- #define GOSU_BITMAP_HPP
4
+ #pragma once
6
5
 
7
- #include <Gosu/Color.hpp>
8
6
  #include <Gosu/Fwd.hpp>
7
+ #include <Gosu/Color.hpp>
9
8
  #include <Gosu/GraphicsBase.hpp>
10
9
  #include <Gosu/Platform.hpp>
11
10
  #include <string>
@@ -23,11 +22,25 @@ namespace Gosu
23
22
  std::vector<Color> pixels;
24
23
 
25
24
  public:
26
- Bitmap() : w(0), h(0) {}
27
- Bitmap(unsigned w, unsigned h, Color c = Color::NONE) : w(w), h(h), pixels(w * h, c) {}
28
-
29
- unsigned width() const { return w; }
30
- unsigned height() const { return h; }
25
+ Bitmap()
26
+ : w(0), h(0)
27
+ {
28
+ }
29
+
30
+ Bitmap(unsigned w, unsigned h, Color c = Color::NONE)
31
+ : w(w), h(h), pixels(w * h, c)
32
+ {
33
+ }
34
+
35
+ unsigned width() const
36
+ {
37
+ return w;
38
+ }
39
+
40
+ unsigned height() const
41
+ {
42
+ return h;
43
+ }
31
44
 
32
45
  void swap(Bitmap& other);
33
46
 
@@ -35,11 +48,17 @@ namespace Gosu
35
48
 
36
49
  //! Returns the color at the specified position. x and y must be on the
37
50
  //! bitmap.
38
- Color getPixel(unsigned x, unsigned y) const { return pixels[y * w + x]; }
51
+ Color get_pixel(unsigned x, unsigned y) const
52
+ {
53
+ return pixels[y * w + x];
54
+ }
39
55
 
40
56
  //! Sets the pixel at the specified position to a color. x and y must
41
57
  //! be on the bitmap.
42
- void setPixel(unsigned x, unsigned y, Color c) { pixels[y * w + x] = c; }
58
+ void set_pixel(unsigned x, unsigned y, Color c)
59
+ {
60
+ pixels[y * w + x] = c;
61
+ }
43
62
 
44
63
  //! Inserts a bitmap at the given position. Parts of the inserted
45
64
  //! bitmap that would be outside of the target bitmap will be
@@ -49,48 +68,42 @@ namespace Gosu
49
68
  //! Inserts a portion of a bitmap at the given position. Parts of the
50
69
  //! inserted bitmap that would be outside of the target bitmap will be
51
70
  //! clipped away.
52
- void insert(const Bitmap& source, int x, int y, unsigned srcX,
53
- unsigned srcY, unsigned srcWidth, unsigned srcHeight);
71
+ void insert(const Bitmap& source, int x, int y, unsigned src_x, unsigned src_y,
72
+ unsigned src_width, unsigned src_height);
54
73
 
55
74
  //! Direct access to the array of color values. May be useful for optimized
56
75
  //! OpenGL operations.
57
- const Color* data() const { return &pixels[0]; }
58
- Color* data() { return &pixels[0]; }
59
-
60
- // Work with data() instead if you need fast operations.
61
- GOSU_DEPRECATED void fill(Color c);
62
- GOSU_DEPRECATED void replace(Color oldColor, Color newColor);
76
+ const Color* data() const
77
+ {
78
+ return &pixels[0];
79
+ }
80
+
81
+ Color* data()
82
+ {
83
+ return &pixels[0];
84
+ }
63
85
  };
64
86
 
65
87
  //! Loads any supported image into a Bitmap.
66
- void loadImageFile(Bitmap& bitmap, const std::wstring& filename);
88
+ void load_image_file(Bitmap& bitmap, const std::string& filename);
67
89
  //! Loads any supported image into a Bitmap.
68
- void loadImageFile(Bitmap& bitmap, Reader input);
90
+ void load_image_file(Bitmap& bitmap, Reader input);
69
91
 
70
92
  //! Saves a Bitmap to a file.
71
- void saveImageFile(const Bitmap& bitmap, const std::wstring& filename);
93
+ void save_image_file(const Bitmap& bitmap, const std::string& filename);
72
94
  //! Saves a Bitmap to an arbitrary resource.
73
- void saveImageFile(const Bitmap& bitmap, Writer writer,
74
- const std::wstring& formatHint = L"png");
95
+ void save_image_file(const Bitmap& bitmap, Writer writer,
96
+ const std::string& format_hint = "png");
75
97
 
76
98
  //! Set the alpha value of all pixels which are equal to the color key
77
99
  //! to zero. Color values are adjusted so that no borders show up when
78
100
  //! the image is stretched or rotated.
79
- void applyColorKey(Bitmap& bitmap, Color key);
101
+ void apply_color_key(Bitmap& bitmap, Color key);
80
102
 
81
- //! The reverse of applyColorKey. Resets all fully transparent pixels by
103
+ //! The reverse of apply_color_key. Resets all fully transparent pixels by
82
104
  //! a background color, makes all other pixels fully opaque.
83
- void unapplyColorKey(Bitmap& bitmap, Color background);
105
+ void unapply_color_key(Bitmap& bitmap, Color background);
84
106
 
85
- void applyBorderFlags(Bitmap& dest, const Bitmap& source,
86
- unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight,
87
- unsigned borderFlags);
88
-
89
- // Use loadImageFile/saveImageFile instead.
90
- GOSU_DEPRECATED Reader loadFromBMP(Bitmap& bmp, Reader reader);
91
- GOSU_DEPRECATED Writer saveToBMP(const Bitmap& bmp, Writer writer);
92
- GOSU_DEPRECATED Reader loadFromPNG(Bitmap& bmp, Reader reader);
93
- GOSU_DEPRECATED Writer saveToPNG(const Bitmap& bmp, Writer writer);
107
+ void apply_border_flags(Bitmap& dest, const Bitmap& source, unsigned src_x, unsigned src_y,
108
+ unsigned src_width, unsigned src_height, unsigned border_flags);
94
109
  }
95
-
96
- #endif
@@ -1,265 +1,246 @@
1
- #ifndef GOSU_BUTTONS_HPP
2
- #define GOSU_BUTTONS_HPP
3
-
4
- #include <Gosu/Platform.hpp>
5
-
6
- #ifdef GOSU_IS_MAC
7
- #define GOSU_SCANCODE(mac, windows_or_linux) mac
8
- #define GOSU_SPECIAL_SCANCODE(mac, windows, linux) mac
9
- #else
10
- #define GOSU_SCANCODE(mac, linux_or_windows) linux_or_windows
11
- #ifdef GOSU_IS_WIN
12
- #define GOSU_SPECIAL_SCANCODE(mac, windows, linux) windows
13
- #else
14
- #define GOSU_SPECIAL_SCANCODE(mac, windows, linux) linux
15
- #endif
16
- #endif
17
-
18
- namespace Gosu
19
- {
20
- //! List of button ids that can be used with Gosu::Input.
21
- //! This enumeration contains ids for keyboard keys (kb*),
22
- //! mouse buttons and mouse wheel (ms*) and gamepad buttons (gp*).
23
- enum ButtonName
24
- {
25
- kbRangeBegin,
26
- kbEscape = 41,
27
- kbF1 = 58,
28
- kbF2 = 59,
29
- kbF3 = 60,
30
- kbF4 = 61,
31
- kbF5 = 62,
32
- kbF6 = 63,
33
- kbF7 = 64,
34
- kbF8 = 65,
35
- kbF9 = 66,
36
- kbF10 = 67,
37
- kbF11 = 68,
38
- kbF12 = 69,
39
- kb0 = 39,
40
- kb1 = 30,
41
- kb2 = 31,
42
- kb3 = 32,
43
- kb4 = 33,
44
- kb5 = 34,
45
- kb6 = 35,
46
- kb7 = 36,
47
- kb8 = 37,
48
- kb9 = 38,
49
- kbTab = 43,
50
- kbReturn = 40,
51
- kbSpace = 44,
52
- kbLeftShift = 225,
53
- kbRightShift = 229,
54
- kbLeftControl = 224,
55
- kbRightControl = 228,
56
- kbLeftAlt = 226,
57
- kbRightAlt = 230,
58
- kbLeftMeta = 227,
59
- kbRightMeta = 231,
60
- kbBackspace = 42,
61
- kbLeft = 80,
62
- kbRight = 79,
63
- kbUp = 82,
64
- kbDown = 81,
65
- kbHome = 74,
66
- kbEnd = 77,
67
- kbInsert = 73,
68
- kbDelete = 76,
69
- kbPageUp = 75,
70
- kbPageDown = 78,
71
- kbEnter = 88,
72
- kbBacktick = 53,
73
- kbMinus = 45,
74
- kbEqual = 46, // TODO: Rename ->kbEquals
75
- kbBracketLeft = 47, // TODO: Rename ->kbLeftBracket
76
- kbBracketRight = 48, // TODO: Rename ->kbRightBracket
77
- kbBackslash = 49,
78
- kbSemicolon = 51,
79
- kbApostrophe = 52,
80
- kbComma = 54,
81
- kbPeriod = 55,
82
- kbSlash = 49,
83
- kbA = 4,
84
- kbB = 5,
85
- kbC = 6,
86
- kbD = 7,
87
- kbE = 8,
88
- kbF = 9,
89
- kbG = 10,
90
- kbH = 11,
91
- kbI = 12,
92
- kbJ = 13,
93
- kbK = 14,
94
- kbL = 15,
95
- kbM = 16,
96
- kbN = 17,
97
- kbO = 18,
98
- kbP = 19,
99
- kbQ = 20,
100
- kbR = 21,
101
- kbS = 22,
102
- kbT = 23,
103
- kbU = 24,
104
- kbV = 25,
105
- kbW = 26,
106
- kbX = 27,
107
- kbY = 28,
108
- kbZ = 29,
109
- // ` on US/UK Mac, < on EU Mac, \ in US/UK Windows
110
- kbISO = 100,
111
- kbNumpad0 = 98,
112
- kbNumpad1 = 89,
113
- kbNumpad2 = 90,
114
- kbNumpad3 = 91,
115
- kbNumpad4 = 92,
116
- kbNumpad5 = 93,
117
- kbNumpad6 = 94,
118
- kbNumpad7 = 95,
119
- kbNumpad8 = 96,
120
- kbNumpad9 = 97,
121
- kbNumpadAdd = 87, // TODO: Rename ->kbNumpadPlus
122
- kbNumpadSubtract = 86, // TODO: Rename ->kbNumpadMinus
123
- kbNumpadMultiply = 85,
124
- kbNumpadDivide = 84,
125
- kbRangeEnd = 0xff,
126
-
127
- msRangeBegin,
128
- msLeft = msRangeBegin,
129
- msMiddle,
130
- msRight,
131
- msWheelUp,
132
- msWheelDown,
133
- msOther0,
134
- msOther1,
135
- msOther2,
136
- msOther3,
137
- msOther4,
138
- msOther5,
139
- msOther6,
140
- msOther7,
141
- msRangeEnd = 0x110,
142
-
143
- gpRangeBegin,
144
- gpLeft = gpRangeBegin,
145
- gpRight,
146
- gpUp,
147
- gpDown,
148
- gpButton0,
149
- gpButton1,
150
- gpButton2,
151
- gpButton3,
152
- gpButton4,
153
- gpButton5,
154
- gpButton6,
155
- gpButton7,
156
- gpButton8,
157
- gpButton9,
158
- gpButton10,
159
- gpButton11,
160
- gpButton12,
161
- gpButton13,
162
- gpButton14,
163
- gpButton15,
164
-
165
- gp0Left,
166
- gp0Right,
167
- gp0Up,
168
- gp0Down,
169
- gp0Button0,
170
- gp0Button1,
171
- gp0Button2,
172
- gp0Button3,
173
- gp0Button4,
174
- gp0Button5,
175
- gp0Button6,
176
- gp0Button7,
177
- gp0Button8,
178
- gp0Button9,
179
- gp0Button10,
180
- gp0Button11,
181
- gp0Button12,
182
- gp0Button13,
183
- gp0Button14,
184
- gp0Button15,
185
-
186
- gp1Left,
187
- gp1Right,
188
- gp1Up,
189
- gp1Down,
190
- gp1Button0,
191
- gp1Button1,
192
- gp1Button2,
193
- gp1Button3,
194
- gp1Button4,
195
- gp1Button5,
196
- gp1Button6,
197
- gp1Button7,
198
- gp1Button8,
199
- gp1Button9,
200
- gp1Button10,
201
- gp1Button11,
202
- gp1Button12,
203
- gp1Button13,
204
- gp1Button14,
205
- gp1Button15,
206
-
207
- gp2Left,
208
- gp2Right,
209
- gp2Up,
210
- gp2Down,
211
- gp2Button0,
212
- gp2Button1,
213
- gp2Button2,
214
- gp2Button3,
215
- gp2Button4,
216
- gp2Button5,
217
- gp2Button6,
218
- gp2Button7,
219
- gp2Button8,
220
- gp2Button9,
221
- gp2Button10,
222
- gp2Button11,
223
- gp2Button12,
224
- gp2Button13,
225
- gp2Button14,
226
- gp2Button15,
227
-
228
- gp3Left,
229
- gp3Right,
230
- gp3Up,
231
- gp3Down,
232
- gp3Button0,
233
- gp3Button1,
234
- gp3Button2,
235
- gp3Button3,
236
- gp3Button4,
237
- gp3Button5,
238
- gp3Button6,
239
- gp3Button7,
240
- gp3Button8,
241
- gp3Button9,
242
- gp3Button10,
243
- gp3Button11,
244
- gp3Button12,
245
- gp3Button13,
246
- gp3Button14,
247
- gp3Button15,
248
-
249
- gpRangeEnd = gp3Button15,
250
-
251
- numButtons = gpRangeEnd + 1,
252
- numGamepads = 4,
253
- noButton = 0xffffffff,
254
-
255
- kbNum = kbRangeEnd - kbRangeBegin + 1,
256
- msNum = msRangeEnd - msRangeBegin + 1,
257
- gpNum = gpRangeEnd - gpRangeBegin + 1,
258
- gpNumPerGamepad = gpNum / (numGamepads + 1)
259
- };
260
- }
261
-
262
- #undef GOSU_SCANCODE
263
- #undef GOSU_SPECIAL_SCANCODE
264
-
265
- #endif
1
+ #pragma once
2
+
3
+ #include <Gosu/Platform.hpp>
4
+
5
+ namespace Gosu
6
+ {
7
+ //! List of button ids that can be used with Gosu::Input.
8
+ //! This enumeration contains ids for keyboard keys (KB_*),
9
+ //! mouse buttons and mouse wheel (MS_*) and gamepad buttons (GP_*).
10
+ enum ButtonName
11
+ {
12
+ KB_RANGE_BEGIN,
13
+ KB_ESCAPE = 41,
14
+ KB_F1 = 58,
15
+ KB_F2 = 59,
16
+ KB_F3 = 60,
17
+ KB_F4 = 61,
18
+ KB_F5 = 62,
19
+ KB_F6 = 63,
20
+ KB_F7 = 64,
21
+ KB_F8 = 65,
22
+ KB_F9 = 66,
23
+ KB_F10 = 67,
24
+ KB_F11 = 68,
25
+ KB_F12 = 69,
26
+ KB_0 = 39,
27
+ KB_1 = 30,
28
+ KB_2 = 31,
29
+ KB_3 = 32,
30
+ KB_4 = 33,
31
+ KB_5 = 34,
32
+ KB_6 = 35,
33
+ KB_7 = 36,
34
+ KB_8 = 37,
35
+ KB_9 = 38,
36
+ KB_TAB = 43,
37
+ KB_RETURN = 40,
38
+ KB_SPACE = 44,
39
+ KB_LEFT_SHIFT = 225,
40
+ KB_RIGHT_SHIFT = 229,
41
+ KB_LEFT_CONTROL = 224,
42
+ KB_RIGHT_CONTROL = 228,
43
+ KB_LEFT_ALT = 226,
44
+ KB_RIGHT_ALT = 230,
45
+ KB_LEFT_META = 227,
46
+ KB_RIGHT_META = 231,
47
+ KB_BACKSPACE = 42,
48
+ KB_LEFT = 80,
49
+ KB_RIGHT = 79,
50
+ KB_UP = 82,
51
+ KB_DOWN = 81,
52
+ KB_HOME = 74,
53
+ KB_END = 77,
54
+ KB_INSERT = 73,
55
+ KB_DELETE = 76,
56
+ KB_PAGE_UP = 75,
57
+ KB_PAGE_DOWN = 78,
58
+ KB_ENTER = 88,
59
+ KB_BACKTICK = 53,
60
+ KB_MINUS = 45,
61
+ KB_EQUALS = 46,
62
+ KB_LEFT_BRACKET = 47,
63
+ KB_RIGHT_BRACKET = 48,
64
+ KB_BACKSLASH = 49,
65
+ KB_SEMICOLON = 51,
66
+ KB_APOSTROPHE = 52,
67
+ KB_COMMA = 54,
68
+ KB_PERIOD = 55,
69
+ KB_SLASH = 49,
70
+ KB_A = 4,
71
+ KB_B = 5,
72
+ KB_C = 6,
73
+ KB_D = 7,
74
+ KB_E = 8,
75
+ KB_F = 9,
76
+ KB_G = 10,
77
+ KB_H = 11,
78
+ KB_I = 12,
79
+ KB_J = 13,
80
+ KB_K = 14,
81
+ KB_L = 15,
82
+ KB_M = 16,
83
+ KB_N = 17,
84
+ KB_O = 18,
85
+ KB_P = 19,
86
+ KB_Q = 20,
87
+ KB_R = 21,
88
+ KB_S = 22,
89
+ KB_T = 23,
90
+ KB_U = 24,
91
+ KB_V = 25,
92
+ KB_W = 26,
93
+ KB_X = 27,
94
+ KB_Y = 28,
95
+ KB_Z = 29,
96
+ KB_ISO = 100, // ` on US/UK macOS, < ON EU macOS, \ in US/UK Windows
97
+ KB_NUMPAD_0 = 98,
98
+ KB_NUMPAD_1 = 89,
99
+ KB_NUMPAD_2 = 90,
100
+ KB_NUMPAD_3 = 91,
101
+ KB_NUMPAD_4 = 92,
102
+ KB_NUMPAD_5 = 93,
103
+ KB_NUMPAD_6 = 94,
104
+ KB_NUMPAD_7 = 95,
105
+ KB_NUMPAD_8 = 96,
106
+ KB_NUMPAD_9 = 97,
107
+ KB_NUMPAD_PLUS = 87,
108
+ KB_NUMPAD_MINUS = 86,
109
+ KB_NUMPAD_MULTIPLY = 85,
110
+ KB_NUMPAD_DIVIDE = 84,
111
+ KB_RANGE_END = 0xff,
112
+
113
+ MS_RANGE_BEGIN,
114
+ MS_LEFT = MS_RANGE_BEGIN,
115
+ MS_MIDDLE,
116
+ MS_RIGHT,
117
+ MS_WHEEL_UP,
118
+ MS_WHEEL_DOWN,
119
+ MS_OTHER_0,
120
+ MS_OTHER_1,
121
+ MS_OTHER_2,
122
+ MS_OTHER_3,
123
+ MS_OTHER_4,
124
+ MS_OTHER_5,
125
+ MS_OTHER_6,
126
+ MS_OTHER_7,
127
+ MS_RANGE_END = 0x110,
128
+
129
+ GP_RANGE_BEGIN,
130
+ GP_LEFT = GP_RANGE_BEGIN,
131
+ GP_RIGHT,
132
+ GP_UP,
133
+ GP_DOWN,
134
+ GP_BUTTON_0,
135
+ GP_BUTTON_1,
136
+ GP_BUTTON_2,
137
+ GP_BUTTON_3,
138
+ GP_BUTTON_4,
139
+ GP_BUTTON_5,
140
+ GP_BUTTON_6,
141
+ GP_BUTTON_7,
142
+ GP_BUTTON_8,
143
+ GP_BUTTON_9,
144
+ GP_BUTTON_10,
145
+ GP_BUTTON_11,
146
+ GP_BUTTON_12,
147
+ GP_BUTTON_13,
148
+ GP_BUTTON_14,
149
+ GP_BUTTON_15,
150
+
151
+ GP_0_LEFT,
152
+ GP_0_RIGHT,
153
+ GP_0_UP,
154
+ GP_0_DOWN,
155
+ GP_0_BUTTON_0,
156
+ GP_0_BUTTON_1,
157
+ GP_0_BUTTON_2,
158
+ GP_0_BUTTON_3,
159
+ GP_0_BUTTON_4,
160
+ GP_0_BUTTON_5,
161
+ GP_0_BUTTON_6,
162
+ GP_0_BUTTON_7,
163
+ GP_0_BUTTON_8,
164
+ GP_0_BUTTON_9,
165
+ GP_0_BUTTON_10,
166
+ GP_0_BUTTON_11,
167
+ GP_0_BUTTON_12,
168
+ GP_0_BUTTON_13,
169
+ GP_0_BUTTON_14,
170
+ GP_0_BUTTON_15,
171
+
172
+ GP_1_LEFT,
173
+ GP_1_RIGHT,
174
+ GP_1_UP,
175
+ GP_1_DOWN,
176
+ GP_1_BUTTON_0,
177
+ GP_1_BUTTON_1,
178
+ GP_1_BUTTON_2,
179
+ GP_1_BUTTON_3,
180
+ GP_1_BUTTON_4,
181
+ GP_1_BUTTON_5,
182
+ GP_1_BUTTON_6,
183
+ GP_1_BUTTON_7,
184
+ GP_1_BUTTON_8,
185
+ GP_1_BUTTON_9,
186
+ GP_1_BUTTON_10,
187
+ GP_1_BUTTON_11,
188
+ GP_1_BUTTON_12,
189
+ GP_1_BUTTON_13,
190
+ GP_1_BUTTON_14,
191
+ GP_1_BUTTON_15,
192
+
193
+ GP_2_LEFT,
194
+ GP_2_RIGHT,
195
+ GP_2_UP,
196
+ GP_2_DOWN,
197
+ GP_2_BUTTON_0,
198
+ GP_2_BUTTON_1,
199
+ GP_2_BUTTON_2,
200
+ GP_2_BUTTON_3,
201
+ GP_2_BUTTON_4,
202
+ GP_2_BUTTON_5,
203
+ GP_2_BUTTON_6,
204
+ GP_2_BUTTON_7,
205
+ GP_2_BUTTON_8,
206
+ GP_2_BUTTON_9,
207
+ GP_2_BUTTON_10,
208
+ GP_2_BUTTON_11,
209
+ GP_2_BUTTON_12,
210
+ GP_2_BUTTON_13,
211
+ GP_2_BUTTON_14,
212
+ GP_2_BUTTON_15,
213
+
214
+ GP_3_LEFT,
215
+ GP_3_RIGHT,
216
+ GP_3_UP,
217
+ GP_3_DOWN,
218
+ GP_3_BUTTON_0,
219
+ GP_3_BUTTON_1,
220
+ GP_3_BUTTON_2,
221
+ GP_3_BUTTON_3,
222
+ GP_3_BUTTON_4,
223
+ GP_3_BUTTON_5,
224
+ GP_3_BUTTON_6,
225
+ GP_3_BUTTON_7,
226
+ GP_3_BUTTON_8,
227
+ GP_3_BUTTON_9,
228
+ GP_3_BUTTON_10,
229
+ GP_3_BUTTON_11,
230
+ GP_3_BUTTON_12,
231
+ GP_3_BUTTON_13,
232
+ GP_3_BUTTON_14,
233
+ GP_3_BUTTON_15,
234
+
235
+ GP_RANGE_END = GP_3_BUTTON_15,
236
+
237
+ NUM_BUTTONS = GP_RANGE_END + 1,
238
+ NUM_GAMEPADS = 4,
239
+ NO_BUTTON = 0xffffffff,
240
+
241
+ KB_NUM = KB_RANGE_END - KB_RANGE_BEGIN + 1,
242
+ MS_NUM = MS_RANGE_END - MS_RANGE_BEGIN + 1,
243
+ GP_NUM = GP_RANGE_END - GP_RANGE_BEGIN + 1,
244
+ GP_NUM_PER_GAMEPAD = GP_NUM / (NUM_GAMEPADS + 1)
245
+ };
246
+ }