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
@@ -1,21 +1,20 @@
1
1
  //! \file Platform.hpp
2
2
  //! Macros and utility functions to facilitate programming on all of Gosu's supported platforms.
3
3
 
4
- #ifndef GOSU_PLATFORM_HPP
5
- #define GOSU_PLATFORM_HPP
4
+ #pragma once
6
5
 
7
6
  #ifdef __BIG_ENDIAN__
8
7
  # define GOSU_IS_BIG_ENDIAN
9
- # define IDENTITY_FUN bigToNative
10
- # define IDENTITY_FUN2 nativeToBig
11
- # define CONV_FUN littleToNative
12
- # define CONV_FUN2 nativeToLittle
8
+ # define IDENTITY_FUN big_to_native
9
+ # define IDENTITY_FUN2 native_to_big
10
+ # define CONV_FUN little_to_native
11
+ # define CONV_FUN2 native_to_little
13
12
  #else
14
13
  # define GOSU_IS_LITTLE_ENDIAN
15
- # define IDENTITY_FUN littleToNative
16
- # define IDENTITY_FUN2 nativeToLittle
17
- # define CONV_FUN bigToNative
18
- # define CONV_FUN2 nativeToBig
14
+ # define IDENTITY_FUN little_to_native
15
+ # define IDENTITY_FUN2 native_to_little
16
+ # define CONV_FUN big_to_native
17
+ # define CONV_FUN2 native_to_big
19
18
  #endif
20
19
 
21
20
  #include <algorithm>
@@ -67,28 +66,10 @@ namespace Gosu
67
66
  # define GOSU_IS_MOBILE
68
67
  #endif
69
68
 
70
- #ifndef SWIG
71
- # if _MSC_VER >= 1700 || ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__GXX_EXPERIMENTAL_CXX0X__))
72
- # define GOSU_CPP11_ENABLED
73
- # endif
74
- #endif
75
-
76
- #ifdef GOSU_CPP11_ENABLED
77
- # define GOSU_UNIQUE_PTR std::unique_ptr
78
- # define GOSU_MOVE_UNIQUE_PTR(ptr) std::move(ptr)
79
- #else
80
- # define GOSU_UNIQUE_PTR std::auto_ptr
81
- # define GOSU_MOVE_UNIQUE_PTR(ptr) (ptr)
82
- #endif
83
-
84
69
  #ifndef GOSU_DEPRECATED
85
70
  # if defined(GOSU_IS_WIN)
86
71
  # define GOSU_DEPRECATED __declspec(deprecated)
87
- # elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
88
- # define GOSU_DEPRECATED __attribute__((__deprecated__))
89
72
  # else
90
- # define GOSU_DEPRECATED
73
+ # define GOSU_DEPRECATED __attribute__((__deprecated__))
91
74
  # endif
92
75
  #endif
93
-
94
- #endif
@@ -1,8 +1,7 @@
1
1
  //! \file Text.hpp
2
2
  //! Functions to output text on bitmaps.
3
3
 
4
- #ifndef GOSU_TEXT_HPP
5
- #define GOSU_TEXT_HPP
4
+ #pragma once
6
5
 
7
6
  #include <Gosu/Fwd.hpp>
8
7
  #include <Gosu/Color.hpp>
@@ -13,59 +12,51 @@ namespace Gosu
13
12
  {
14
13
  //! Returns the name of a neutral font that is available on the current
15
14
  //! platform.
16
- std::wstring defaultFontName();
15
+ std::string default_font_name();
17
16
 
18
17
  //! Returns the width an unformatted line of text would span on a bitmap if it were drawn using
19
- //! drawText with the same arguments. This is a very low-level function that does not understand
20
- //! any of Gosu's HTML-like markup.
18
+ //! draw_text with the same arguments. This is a very low-level function that does not
19
+ //! understand any of Gosu's HTML-like markup.
21
20
  //! \param text Unformatted text.
22
- //! \param fontName Name of a system font, or a filename to a TTF file (must contain '/').
23
- unsigned textWidth(const std::wstring& text,
24
- const std::wstring& fontName, unsigned fontHeight,
25
- unsigned fontFlags = 0);
21
+ //! \param font_name Name of a system font, or a filename to a TTF file (must contain '/').
22
+ unsigned text_width(const std::string& text, const std::string& font_name, unsigned font_height,
23
+ unsigned font_flags = 0);
26
24
 
27
- //! Draws a line of unformatted text on a bitmap. This is a very low-level function that does not understand
28
- //! any of Gosu's HTML-like markup.
25
+ //! Draws a line of unformatted text on a bitmap. This is a very low-level function that does
26
+ //! not understand any of Gosu's HTML-like markup.
29
27
  //! \param text Unformatted text.
30
- //! \param fontName Name of a system font, or a filename to a TTF file (must contain '/').
31
- //! \param fontHeight Height, in pixels, of the text.
32
- //! \param fontFlags Binary combination of members of the FontFlags
28
+ //! \param font_name Name of a system font, or a filename to a TTF file (must contain '/').
29
+ //! \param font_height Height, in pixels, of the text.
30
+ //! \param font_flags Binary combination of members of the FontFlags
33
31
  //! enum.
34
- void drawText(Bitmap& bitmap, const std::wstring& text, int x, int y,
35
- Color c, const std::wstring& fontName, unsigned fontHeight,
36
- unsigned fontFlags = 0);
32
+ void draw_text(Bitmap& bitmap, const std::string& text, int x, int y, Color c,
33
+ const std::string& font_name, unsigned font_height, unsigned font_flags = 0);
37
34
 
38
35
  //! Creates a bitmap that is filled with a line of formatted text given to the function.
39
36
  //! The line can contain line breaks and HTML-like markup.
40
37
  //! \param text Formatted text.
41
- //! \param fontName Name of a system font, or a filename to a TTF file (must contain '/').
42
- //! \param fontHeight Height of the font in pixels.
43
- //! \param fontFlags Binary combination of members of the FontFlags
38
+ //! \param font_name Name of a system font, or a filename to a TTF file (must contain '/').
39
+ //! \param font_height Height of the font in pixels.
40
+ //! \param font_flags Binary combination of members of the FontFlags
44
41
  //! enum.
45
- Bitmap createText(const std::wstring& text,
46
- const std::wstring& fontName, unsigned fontHeight,
47
- unsigned fontFlags = 0);
42
+ Bitmap create_text(const std::string& text, const std::string& font_name, unsigned font_height,
43
+ unsigned font_flags = 0);
48
44
 
49
45
  //! Creates a bitmap that is filled with the formatted text given to the function.
50
46
  //! The line can contain line breaks and HTML-like markup.
51
47
  //! \param text Formatted text.
52
- //! \param fontName Name of a system font, or a filename to a TTF file (must contain '/').
53
- //! \param fontHeight Height of the font in pixels.
54
- //! \param lineSpacing Spacing between two lines of text in pixels. Can be negative to make
48
+ //! \param font_name Name of a system font, or a filename to a TTF file (must contain '/').
49
+ //! \param font_height Height of the font in pixels.
50
+ //! \param line_spacing Spacing between two lines of text in pixels. Can be negative to make
55
51
  //! text stick together more closely.
56
- //! \param width Width of the bitmap that will be returned. Text
57
- //! will be split into multiple lines to avoid drawing over the right
58
- //! border. When a single word is too long, it will be truncated.
59
- //! \param fontFlags Binary combination of members of the FontFlags
60
- //! enum.
61
- Bitmap createText(const std::wstring& text,
62
- const std::wstring& fontName, unsigned fontHeight,
63
- int lineSpacing, unsigned width, TextAlign align,
64
- unsigned fontFlags = 0);
52
+ //! \param width Width of the bitmap that will be returned. Text will be split into multiple
53
+ //! lines to avoid drawing over the right border. When a single word is too long, it will be
54
+ //! truncated.
55
+ //! \param font_flags Binary combination of members of the FontFlags enum.
56
+ Bitmap create_text(const std::string& text, const std::string& font_name, unsigned font_height,
57
+ int line_spacing, unsigned width, Alignment align, unsigned font_flags = 0);
65
58
 
66
59
  //! Registers a new HTML-style entity that can subsequently be used
67
- //! with Gosu::Font and Gosu::createText. The name is given without & and ;.
68
- void registerEntity(const std::wstring& name, const Bitmap& replacement);
60
+ //! with Gosu::Font and Gosu::create_text. The name is given without & and ;.
61
+ void register_entity(const std::string& name, const Bitmap& replacement);
69
62
  }
70
-
71
- #endif
@@ -1,12 +1,11 @@
1
1
  //! \file TextInput.hpp
2
2
  //! Interface of the TextInput class.
3
3
 
4
- #ifndef GOSU_TEXTINPUT_HPP
5
- #define GOSU_TEXTINPUT_HPP
4
+ #pragma once
6
5
 
7
6
  #include <Gosu/Fwd.hpp>
8
7
  #include <Gosu/Platform.hpp>
9
- #include <Gosu/TR1.hpp>
8
+ #include <memory>
10
9
  #include <string>
11
10
 
12
11
  namespace Gosu
@@ -14,57 +13,51 @@ namespace Gosu
14
13
  //! TextInput instances are invisible objects that build a text string from input,
15
14
  //! using the current operating system's keyboard layout.
16
15
  //! At its most basic form, you only need to create a new TextInput instance and
17
- //! pass it to your window via setTextInput. Until you call this function again,
18
- //! passing 0, the TextInput object will build a text that can be accessed via
16
+ //! pass it to your window via set_text_input. Until you call this function again,
17
+ //! passing nullptr, the TextInput object will build a text that can be accessed via
19
18
  //! TextInput::text().
20
- //! A TextInput object is purely abstract, though; drawing the input field is left
21
- //! to the user. As with most of Gosu, how this is handled is completely left open.
22
- //! TextInput only aims to provide enough code for your own GUIs to build upon.
19
+ //! A TextInput object is purely abstract. It is up to you to actually draw a text field.
20
+ //! TextInput only provides a portable base for your own GUI to build upon.
23
21
  class TextInput
24
22
  {
25
23
  struct Impl;
26
- const GOSU_UNIQUE_PTR<Impl> pimpl;
27
- #if defined(GOSU_CPP11_ENABLED)
28
- TextInput(TextInput&&) = delete;
29
- TextInput& operator=(TextInput&&) = delete;
30
- TextInput(const TextInput&) = delete;
31
- TextInput& operator=(const TextInput&) = delete;
32
- #endif
24
+ // Non-movable (const) to avoid dangling references to TextInput instances.
25
+ const std::unique_ptr<Impl> pimpl;
33
26
 
34
27
  public:
35
28
  TextInput();
36
29
  virtual ~TextInput();
37
30
 
38
- std::wstring text() const;
31
+ std::string text() const;
39
32
 
40
33
  //! Replaces the current text by the given string and positions the cursor
41
34
  //! at the end of the text, with an empty selection.
42
- void setText(const std::wstring& text);
43
-
44
- //! Position of the caret as the index of the character that it's left to.
45
- unsigned caretPos() const;
46
- //! Sets the caret position as returned by caretPos.
47
- //! You usually also want to use setSelectionStart.
48
- void setCaretPos(unsigned pos);
49
-
50
- //! If there is a selection, the selectionStart() member yields its beginning,
51
- //! using the same indexing scheme as caretPos. If there is no selection,
52
- //! selectionStart() is equal to caretPos().
53
- unsigned selectionStart() const;
54
- //! Sets the start of the selection as returned by selectionStart.
55
- void setSelectionStart(unsigned pos);
35
+ void set_text(const std::string& text);
36
+
37
+ //! Index of the character that comes after the caret. When the text is empty, this is
38
+ //! always 0. For ease of use in C++, this counts bytes, not codepoints in the UTF-8 encoded
39
+ //! string.
40
+ unsigned caret_pos() const;
41
+ //! Sets the caret position as returned by caret_pos.
42
+ //! You usually also want to use set_selection_start.
43
+ void set_caret_pos(unsigned pos);
44
+
45
+ //! If there is a selection, the selection_start() member yields its beginning,
46
+ //! using the same indexing scheme as caret_pos. If there is no selection,
47
+ //! selection_start() is equal to caret_pos().
48
+ unsigned selection_start() const;
49
+ //! Sets the start of the selection as returned by selection_start.
50
+ void set_selection_start(unsigned pos);
56
51
 
57
52
  // Platform-specific communication with Gosu::Input.
58
- bool feedSDLEvent(void* event);
53
+ bool feed_sdl_event(void* event);
59
54
 
60
55
  //! Overridable filter that is applied to all new text that is entered.
61
- //! Allows for context-sensitive filtering/extending/... of the text.
62
- //! The text will be inserted at caretPos afterwards.
63
- virtual std::wstring filter(const std::wstring& text) const
56
+ //! Allows for context-sensitive filtering/extending/... of new characters.
57
+ //! The return value will be inserted at caret_pos.
58
+ virtual std::string filter(std::string text) const
64
59
  {
65
60
  return text;
66
61
  }
67
62
  };
68
63
  }
69
-
70
- #endif
@@ -1,16 +1,14 @@
1
- //! \file Timing.hpp
2
- //! Functions for timing.
3
-
4
- #ifndef GOSU_TIMING_HPP
5
- #define GOSU_TIMING_HPP
6
-
7
- namespace Gosu
8
- {
9
- //! Freezes the current thread for at least the specified time.
10
- void sleep(unsigned milliseconds);
11
-
12
- //! Incrementing, possibly wrapping millisecond timer.
13
- unsigned long milliseconds();
14
- }
15
-
16
- #endif
1
+ //! \file Timing.hpp
2
+ //! Functions for timing.
3
+
4
+ #pragma once
5
+
6
+ namespace Gosu
7
+ {
8
+ //! Freezes the current thread for at least the specified time.
9
+ void sleep(unsigned milliseconds);
10
+
11
+ //! Returns the milliseconds since first calling this function.
12
+ //! Can wrap after running for a long time.
13
+ unsigned long milliseconds();
14
+ }
@@ -1,28 +1,23 @@
1
1
  //! \file Utility.hpp
2
2
  //! General purpose utility functions.
3
3
 
4
- #ifndef GOSU_UTILITY_HPP
5
- #define GOSU_UTILITY_HPP
4
+ #pragma once
6
5
 
7
6
  #include <string>
8
- #include <vector>
9
7
 
10
8
  namespace Gosu
11
9
  {
12
- //! Converts an std::string into an std::wstring.
13
- std::wstring utf8ToWstring(const std::string& utf8);
14
- //! Converts an std::wstring into an std::string.
15
- std::string wstringToUTF8(const std::wstring& ws);
10
+ //! Converts an UTF-8 to UCS-4 or UTF-16, depending on the platform's interpretation of wstring.
11
+ std::wstring utf8_to_wstring(const std::string& utf8);
12
+ //! Converts an UCS-4 or UTF-16 to UTF-8, depending on the platform's interpretation of wstring.
13
+ std::string wstring_to_utf8(const std::wstring& ws);
16
14
 
17
- //! Converts an std::string into an std::wstring using local encoding.
18
- std::wstring widen(const std::string& s);
19
- //! Converts an std::wstring into an std::string using local encoding.
20
- std::string narrow(const std::wstring& ws);
15
+ //! Returns true if the filename has the given extension.
16
+ //! The comparison is case-insensitive, but you must pass the extension in lower case.
17
+ bool has_extension(const std::string& filename, const char* extension);
21
18
 
22
19
  //! Returns the user's preferred language, at the moment of calling the function. Expect return
23
- //! values such as 'en_US', 'de_DE.UTF-8', 'ja', 'zh-Hans'. You can rely only on the first two letters
24
- //! being a common language abbreviation.
20
+ //! values such as 'en_US', 'de_DE.UTF-8', 'ja', 'zh-Hans'.
21
+ //! The first two letters will always be a language code.
25
22
  std::string language();
26
23
  }
27
-
28
- #endif
@@ -1,17 +1,16 @@
1
- #ifndef GOSU_VERSION_HPP
2
- #define GOSU_VERSION_HPP
1
+ #pragma once
2
+
3
+ #include <string>
3
4
 
4
5
  #define GOSU_MAJOR_VERSION 0
5
- #define GOSU_MINOR_VERSION 10
6
- #define GOSU_POINT_VERSION 9
7
- #define GOSU_VERSION "0.10.9.pre1"
6
+ #define GOSU_MINOR_VERSION 11
7
+ #define GOSU_POINT_VERSION 0
8
8
 
9
- #define GOSU_COPYRIGHT_NOTICE \
10
- "This software uses the following third-party libraries:\n" \
11
- "\n" \
12
- "Gosu, https://www.libgosu.org, MIT License, http://opensource.org/licenses/MIT\n" \
13
- "SDL 2, http://www.libsdl.org, MIT License, http://opensource.org/licenses/MIT\n" \
14
- "libsndfile, http://www.mega-nerd.com/libsndfile, GNU LGPL 3, http://www.gnu.org/copyleft/lesser.html\n" \
15
- "OpenAL Soft, http://kcat.strangesoft.net/openal.html, GNU LGPL 2, http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html\n"
16
-
17
- #endif
9
+ namespace Gosu
10
+ {
11
+ //! A string that contains the full version of the Gosu library, like "0.7.50" or "1.0.0.pre5".
12
+ extern const std::string VERSION;
13
+
14
+ //! A block of legal copy that your game is obliged to display somewhere.
15
+ extern const std::string LICENSES;
16
+ }
@@ -1,13 +1,11 @@
1
1
  //! \file Window.hpp
2
2
  //! Interface of the Window class.
3
3
 
4
- #ifndef GOSU_WINDOW_HPP
5
- #define GOSU_WINDOW_HPP
4
+ #pragma once
6
5
 
7
6
  #include <Gosu/Fwd.hpp>
8
- #include <Gosu/Platform.hpp>
9
7
  #include <Gosu/Input.hpp>
10
- #include <Gosu/TR1.hpp>
8
+ #include <Gosu/Platform.hpp>
11
9
  #include <memory>
12
10
  #include <string>
13
11
 
@@ -21,60 +19,59 @@
21
19
  namespace Gosu
22
20
  {
23
21
  //! Returns the width (in pixels) of the user's primary screen.
24
- unsigned screenWidth();
22
+ unsigned screen_width();
25
23
 
26
24
  //! Returns the height (in pixels) of the user's primary screen.
27
- unsigned screenHeight();
25
+ unsigned screen_height();
28
26
 
29
27
  //! Returns the maximum width (in 'points') that is available for a non-fullscreen Window.
30
28
  //! All windows larger than this size will automatically be shrunk to fit.
31
- unsigned availableWidth();
29
+ unsigned available_width();
32
30
 
33
31
  //! Returns the maximum height (in 'points') that is available for a non-fullscreen Window.
34
32
  //! All windows larger than this size will automatically be shrunk to fit.
35
- unsigned availableHeight();
33
+ unsigned available_height();
36
34
 
37
- //! Convenient all-in-one class that serves as the foundation of a standard
38
- //! Gosu application. Manages initialization of all of Gosu's core components
39
- //! and provides timing functionality.
35
+ //! Convenient all-in-one class that serves as the foundation of a standard Gosu application.
36
+ //! Manages initialization of all of Gosu's core components and provides timing functionality.
40
37
  //! Note that you should really only use one instance of this class at the same time.
41
- //! This may or may not change later.
42
38
  class Window
43
39
  {
44
40
  struct Impl;
45
- const GOSU_UNIQUE_PTR<Impl> pimpl;
46
- #if defined(GOSU_CPP11_ENABLED)
47
- Window(Window&&) = delete;
48
- Window& operator=(Window&&) = delete;
49
- Window(const Window&) = delete;
50
- Window& operator=(const Window&) = delete;
51
- #endif
52
-
41
+ // Non-movable (const) to avoid dangling internal references.
42
+ const std::unique_ptr<Impl> pimpl;
43
+
53
44
  public:
54
45
  //! Constructs a Window.
55
- //! \param width Width of the window in points; that is, pixels on a normal display, and 'virtual pixels' on a
56
- //! high-resolution display.
46
+ //! \param width Width of the window in points; that is, pixels on a normal display, and
47
+ //! 'points' on a high-resolution display.
57
48
  //! \param height See width.
58
- //! \param updateInterval Interval in milliseconds between two calls
59
- //! to the update member function.
49
+ //! \param update_interval Interval in milliseconds between two calls to the update member
50
+ //! function.
60
51
  Window(unsigned width, unsigned height, bool fullscreen = false,
61
- double updateInterval = 16.666666);
52
+ double update_interval = 16.666666);
62
53
  virtual ~Window();
63
54
 
64
- std::wstring caption() const;
65
- void setCaption(const std::wstring& caption);
66
-
67
- double updateInterval() const;
55
+ unsigned width() const;
56
+ unsigned height() const;
57
+ bool fullscreen() const;
58
+ void resize(unsigned width, unsigned height, bool fullscreen);
68
59
 
60
+ double update_interval() const;
61
+ void set_update_interval(double update_interval);
62
+
63
+ std::string caption() const;
64
+ void set_caption(const std::string& caption);
65
+
69
66
  //! Enters a modal loop where the Window is visible on screen and
70
67
  //! receives calls to draw, update etc.
71
68
  virtual void show();
72
69
 
73
70
  //! Performs a single mainloop step.
74
- //! This method is only useful if you want to integrate Gosu with
75
- //! another library that has its own main loop.
76
- //! This method implicitly shows the window if it was hidden before, and
77
- //! returns false when the window has been closed.
71
+ //! This method is only useful if you want to integrate Gosu with another library that has
72
+ //! its own main loop.
73
+ //! This method implicitly shows the window if it was hidden before, and returns false when
74
+ //! the window has been closed.
78
75
  //! If you discard the return value and keep calling tick(), the window will be shown again,
79
76
  //! or keep being shown.
80
77
  virtual bool tick();
@@ -82,66 +79,54 @@ namespace Gosu
82
79
  //! Closes the window if it is currently shown.
83
80
  void close();
84
81
 
85
- //! Called every updateInterval milliseconds while the window is being
86
- //! shown. Your application's main game logic goes here.
82
+ //! Called every update_interval milliseconds while the window is being shown.
83
+ //! Your application's main game logic goes here.
87
84
  virtual void update() {}
88
- //! Called after every update and when the OS wants the window to
89
- //! repaint itself. Your application's rendering code goes here.
85
+
86
+ //! Called after every update and when the OS wants the window to repaint itself.
87
+ //! Your application's rendering code goes here.
90
88
  virtual void draw() {}
91
89
 
92
90
  //! Gives the game a chance to say no to being redrawn.
93
- //! This is not a definitive answer. The operating system can still force
94
- //! the window to redraw itself.
91
+ //! This is not a definitive answer. The operating system can still force the window to
92
+ //! redraw itself.
95
93
  //! By default, the window is redrawn all the time.
96
- virtual bool needsRedraw() const { return true; }
94
+ virtual bool needs_redraw() const { return true; }
97
95
 
98
- //! If this function returns true, the system arrow cursor is drawn while
99
- //! over the window.
100
- virtual bool needsCursor() const { return false; }
96
+ //! If this function returns true, the system arrow cursor is drawn while over the window.
97
+ virtual bool needs_cursor() const { return false; }
101
98
 
102
99
  //! This function is called when the window loses focus on some platforms.
103
- //! Most importantly, it is called on the iPhone or iPad when the user
104
- //! locks the screen.
105
- virtual void loseFocus() {}
100
+ //! Most importantly, it is called on the i_phone or i_pad when the user locks the screen.
101
+ virtual void lose_focus() {}
106
102
 
107
103
  //! This function is called when the operating system's memory is low.
108
104
  //! So far, it is only called in iOS applications.
109
- virtual void releaseMemory() {}
105
+ virtual void release_memory() {}
110
106
 
111
- //! Called before update when the user pressed a button while the
112
- //! window had the focus.
113
- virtual void buttonDown(Gosu::Button) {}
114
- //! Same as buttonDown. Called then the user released a button.
115
- virtual void buttonUp(Gosu::Button) {}
107
+ //! Called before update when the user pressed a button while the window had the focus.
108
+ virtual void button_down(Gosu::Button) {}
109
+
110
+ //! Same as button_down. Called then the user released a button.
111
+ virtual void button_up(Gosu::Button) {}
116
112
 
117
113
  // Ignore when SWIG is wrapping this class for Ruby/Gosu.
118
114
  #ifndef SWIG
119
-
120
115
  // Callbacks for touch events. So far these are only used on iOS.
121
- virtual void touchBegan(Touch touch) {}
122
- virtual void touchMoved(Touch touch) {}
123
- virtual void touchEnded(Touch touch) {}
124
- virtual void touchCancelled(Touch touch) {}
116
+ virtual void touch_began(Touch touch) {}
117
+ virtual void touch_moved(Touch touch) {}
118
+ virtual void touch_ended(Touch touch) {}
119
+ virtual void touch_cancelled(Touch touch) {}
125
120
 
126
121
  const Graphics& graphics() const;
127
122
  Graphics& graphics();
128
123
 
129
124
  const Input& input() const;
130
125
  Input& input();
126
+ #endif
131
127
 
132
128
  #ifdef GOSU_IS_IPHONE
133
129
  void* UIWindow() const;
134
- #endif
135
-
136
- GOSU_DEPRECATED const Audio& audio() const;
137
- GOSU_DEPRECATED Audio& audio();
138
-
139
130
  #endif
140
131
  };
141
132
  }
142
-
143
- #ifdef GOSU_IS_IPHONE
144
- Gosu::Window& windowInstance();
145
- #endif
146
-
147
- #endif