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.
- checksums.yaml +4 -4
- data/Gosu/Audio.hpp +35 -66
- data/Gosu/AutoLink.hpp +14 -16
- data/Gosu/Bitmap.hpp +50 -37
- data/Gosu/Buttons.hpp +246 -265
- data/Gosu/Color.hpp +32 -76
- data/Gosu/Directories.hpp +14 -17
- data/Gosu/Font.hpp +28 -34
- data/Gosu/Fwd.hpp +27 -31
- data/Gosu/Gosu.hpp +2 -5
- data/Gosu/Graphics.hpp +31 -48
- data/Gosu/GraphicsBase.hpp +27 -58
- data/Gosu/IO.hpp +44 -56
- data/Gosu/Image.hpp +29 -73
- data/Gosu/ImageData.hpp +13 -17
- data/Gosu/Input.hpp +42 -57
- data/Gosu/Inspection.hpp +2 -6
- data/Gosu/Math.hpp +32 -38
- data/Gosu/Platform.hpp +10 -29
- data/Gosu/Text.hpp +30 -39
- data/Gosu/TextInput.hpp +29 -36
- data/Gosu/Timing.hpp +14 -16
- data/Gosu/Utility.hpp +10 -15
- data/Gosu/Version.hpp +13 -14
- data/Gosu/Window.hpp +53 -68
- data/README.md +23 -11
- data/ext/gosu/extconf.rb +31 -81
- data/lib/gosu/patches.rb +35 -19
- data/lib/gosu/run.rb +13 -4
- data/rdoc/gosu.rb +24 -20
- data/src/ALChannelManagement.hpp +119 -0
- data/src/{Audio/Audio.cpp → Audio.cpp} +177 -211
- data/src/AudioFile.hpp +57 -0
- data/src/AudioToolboxFile.hpp +214 -0
- data/src/Bitmap.cpp +159 -0
- data/src/BitmapIO.cpp +141 -0
- data/src/BlockAllocator.cpp +133 -0
- data/src/{Graphics/BlockAllocator.hpp → BlockAllocator.hpp} +34 -35
- data/src/ClipRectStack.hpp +87 -0
- data/src/{Graphics/Color.cpp → Color.cpp} +30 -28
- data/src/DirectoriesApple.cpp +68 -0
- data/src/DirectoriesUnix.cpp +20 -18
- data/src/DirectoriesWin.cpp +40 -41
- data/src/DrawOp.hpp +168 -0
- data/src/DrawOpQueue.hpp +190 -0
- data/src/FileUnix.cpp +40 -46
- data/src/FileWin.cpp +42 -38
- data/src/Font.cpp +165 -0
- data/src/{Text/FormattedString.hpp → FormattedString.hpp} +114 -114
- data/src/GosuAppDelegate.cpp +30 -0
- data/src/{UIKit/GosuAppDelegate.h → GosuAppDelegate.h} +0 -0
- data/src/{UIKit/GosuGLView.mm → GosuGLView.cpp} +22 -17
- data/src/{UIKit/GosuGLView.h → GosuGLView.h} +0 -0
- data/src/GosuViewController.cpp +231 -0
- data/src/{UIKit/GosuViewController.h → GosuViewController.h} +0 -0
- data/src/Graphics.cpp +464 -0
- data/src/{Graphics/Common.hpp → GraphicsImpl.hpp} +29 -32
- data/src/IO.cpp +17 -16
- data/src/Iconv.hpp +13 -22
- data/src/Image.cpp +142 -0
- data/src/Input.cpp +459 -0
- data/src/InputUIKit.cpp +197 -0
- data/src/Inspection.cpp +4 -5
- data/src/LargeImageData.cpp +151 -0
- data/src/LargeImageData.hpp +43 -0
- data/src/{Graphics/Macro.cpp → Macro.cpp} +77 -78
- data/src/Macro.hpp +30 -0
- data/src/Math.cpp +17 -29
- data/src/{Audio/OggFile.hpp → OggFile.hpp} +19 -24
- data/src/RenderState.hpp +205 -0
- data/src/Resolution.cpp +86 -0
- data/src/ResolutionApple.cpp +25 -0
- data/{ext/gosu/gosu_wrap.cxx → src/RubyGosu.cxx} +2256 -1707
- data/{ext/gosu/gosu_wrap.h → src/RubyGosu.h} +9 -9
- data/src/{Audio/SndFile.hpp → SndFile.hpp} +54 -43
- data/src/TexChunk.cpp +117 -0
- data/src/{Graphics/TexChunk.hpp → TexChunk.hpp} +13 -18
- data/src/Text.cpp +371 -0
- data/src/TextApple.cpp +209 -0
- data/src/TextInput.cpp +278 -0
- data/src/TextTTFWin.cpp +251 -0
- data/src/{Text/TextUnix.cpp → TextUnix.cpp} +96 -92
- data/src/TextWin.cpp +194 -0
- data/src/{Graphics/Texture.cpp → Texture.cpp} +35 -38
- data/src/{Graphics/Texture.hpp → Texture.hpp} +9 -13
- data/src/TimingApple.cpp +11 -7
- data/src/TimingUnix.cpp +13 -7
- data/src/TimingWin.cpp +6 -1
- data/src/{Graphics/Transform.cpp → Transform.cpp} +17 -12
- data/src/{Graphics/TransformStack.hpp → TransformStack.hpp} +24 -25
- data/src/Utility.cpp +29 -70
- data/src/UtilityApple.cpp +52 -0
- data/src/UtilityWin.cpp +7 -4
- data/src/Version.cpp +22 -0
- data/src/WinMain.cpp +30 -33
- data/src/WinUtility.cpp +24 -22
- data/src/WinUtility.hpp +11 -20
- data/src/Window.cpp +142 -112
- data/src/WindowUIKit.cpp +155 -0
- data/src/stb_image.h +384 -173
- data/src/stb_vorbis.c +20 -18
- metadata +60 -62
- data/Gosu/TR1.hpp +0 -56
- data/src/AppleUtility.hpp +0 -66
- data/src/Audio/ALChannelManagement.hpp +0 -114
- data/src/Audio/Audio.mm +0 -1
- data/src/Audio/AudioFile.hpp +0 -53
- data/src/Audio/AudioToolboxFile.hpp +0 -207
- data/src/Bitmap/Bitmap.cpp +0 -183
- data/src/Bitmap/BitmapIO.cpp +0 -176
- data/src/DirectoriesApple.mm +0 -71
- data/src/Graphics/BlockAllocator.cpp +0 -142
- data/src/Graphics/ClipRectStack.hpp +0 -93
- data/src/Graphics/DrawOp.hpp +0 -175
- data/src/Graphics/DrawOpQueue.hpp +0 -188
- data/src/Graphics/Graphics.cpp +0 -478
- data/src/Graphics/Image.cpp +0 -193
- data/src/Graphics/LargeImageData.cpp +0 -133
- data/src/Graphics/LargeImageData.hpp +0 -46
- data/src/Graphics/Macro.hpp +0 -36
- data/src/Graphics/RenderState.hpp +0 -211
- data/src/Graphics/Resolution.cpp +0 -91
- data/src/Graphics/ResolutionApple.mm +0 -19
- data/src/Graphics/TexChunk.cpp +0 -112
- data/src/Input/Input.cpp +0 -463
- data/src/Input/InputUIKit.mm +0 -190
- data/src/Input/TextInput.cpp +0 -261
- data/src/Text/Font.cpp +0 -175
- data/src/Text/Text.cpp +0 -391
- data/src/Text/TextApple.mm +0 -227
- data/src/Text/TextTTFWin.cpp +0 -249
- data/src/Text/TextWin.cpp +0 -186
- data/src/UIKit/GosuAppDelegate.mm +0 -24
- data/src/UIKit/GosuViewController.mm +0 -211
- data/src/UtilityApple.mm +0 -63
- data/src/WindowUIKit.mm +0 -139
data/Gosu/Platform.hpp
CHANGED
@@ -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
|
-
#
|
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
|
10
|
-
# define IDENTITY_FUN2
|
11
|
-
# define CONV_FUN
|
12
|
-
# define CONV_FUN2
|
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
|
16
|
-
# define IDENTITY_FUN2
|
17
|
-
# define CONV_FUN
|
18
|
-
# define CONV_FUN2
|
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
|
data/Gosu/Text.hpp
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
//! \file Text.hpp
|
2
2
|
//! Functions to output text on bitmaps.
|
3
3
|
|
4
|
-
#
|
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::
|
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
|
-
//!
|
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
|
23
|
-
unsigned
|
24
|
-
|
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
|
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
|
31
|
-
//! \param
|
32
|
-
//! \param
|
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
|
35
|
-
|
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
|
42
|
-
//! \param
|
43
|
-
//! \param
|
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
|
46
|
-
|
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
|
53
|
-
//! \param
|
54
|
-
//! \param
|
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
|
-
//!
|
58
|
-
//!
|
59
|
-
//! \param
|
60
|
-
|
61
|
-
|
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::
|
68
|
-
void
|
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
|
data/Gosu/TextInput.hpp
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
//! \file TextInput.hpp
|
2
2
|
//! Interface of the TextInput class.
|
3
3
|
|
4
|
-
#
|
5
|
-
#define GOSU_TEXTINPUT_HPP
|
4
|
+
#pragma once
|
6
5
|
|
7
6
|
#include <Gosu/Fwd.hpp>
|
8
7
|
#include <Gosu/Platform.hpp>
|
9
|
-
#include <
|
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
|
18
|
-
//! passing
|
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
|
21
|
-
//!
|
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
|
27
|
-
|
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::
|
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
|
43
|
-
|
44
|
-
//!
|
45
|
-
|
46
|
-
//!
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
//!
|
53
|
-
|
54
|
-
//!
|
55
|
-
|
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
|
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
|
62
|
-
//! The
|
63
|
-
virtual std::
|
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
|
data/Gosu/Timing.hpp
CHANGED
@@ -1,16 +1,14 @@
|
|
1
|
-
//! \file Timing.hpp
|
2
|
-
//! Functions for timing.
|
3
|
-
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
//!
|
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
|
+
}
|
data/Gosu/Utility.hpp
CHANGED
@@ -1,28 +1,23 @@
|
|
1
1
|
//! \file Utility.hpp
|
2
2
|
//! General purpose utility functions.
|
3
3
|
|
4
|
-
#
|
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
|
13
|
-
std::wstring
|
14
|
-
//! Converts an
|
15
|
-
std::string
|
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
|
-
//!
|
18
|
-
|
19
|
-
|
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'.
|
24
|
-
//!
|
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
|
data/Gosu/Version.hpp
CHANGED
@@ -1,17 +1,16 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <string>
|
3
4
|
|
4
5
|
#define GOSU_MAJOR_VERSION 0
|
5
|
-
#define GOSU_MINOR_VERSION
|
6
|
-
#define GOSU_POINT_VERSION
|
7
|
-
#define GOSU_VERSION "0.10.9.pre1"
|
6
|
+
#define GOSU_MINOR_VERSION 11
|
7
|
+
#define GOSU_POINT_VERSION 0
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
"
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
+
}
|
data/Gosu/Window.hpp
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
//! \file Window.hpp
|
2
2
|
//! Interface of the Window class.
|
3
3
|
|
4
|
-
#
|
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/
|
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
|
22
|
+
unsigned screen_width();
|
25
23
|
|
26
24
|
//! Returns the height (in pixels) of the user's primary screen.
|
27
|
-
unsigned
|
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
|
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
|
33
|
+
unsigned available_height();
|
36
34
|
|
37
|
-
//! Convenient all-in-one class that serves as the foundation of a standard
|
38
|
-
//!
|
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
|
46
|
-
|
47
|
-
|
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
|
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
|
59
|
-
//!
|
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
|
52
|
+
double update_interval = 16.666666);
|
62
53
|
virtual ~Window();
|
63
54
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
-
//!
|
76
|
-
//! This method implicitly shows the window if it was hidden before, and
|
77
|
-
//!
|
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
|
86
|
-
//!
|
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
|
-
|
89
|
-
//!
|
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
|
-
//!
|
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
|
94
|
+
virtual bool needs_redraw() const { return true; }
|
97
95
|
|
98
|
-
//! If this function returns true, the system arrow cursor is drawn while
|
99
|
-
|
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
|
104
|
-
|
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
|
105
|
+
virtual void release_memory() {}
|
110
106
|
|
111
|
-
//! Called before update when the user pressed a button while the
|
112
|
-
|
113
|
-
|
114
|
-
//! Same as
|
115
|
-
virtual void
|
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
|
122
|
-
virtual void
|
123
|
-
virtual void
|
124
|
-
virtual void
|
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
|