gosu 0.9.2-x64-mingw32 → 0.10.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,156 +0,0 @@
1
- //! \file Sockets.hpp
2
- //! Interface of the three socket classes, MessageSocket, CommSocket and ListenerSocket.
3
-
4
- #ifndef GOSU_SOCKETS_HPP
5
- #define GOSU_SOCKETS_HPP
6
-
7
- #include <Gosu/TR1.hpp>
8
- #include <cstddef>
9
- #include <string>
10
- #include <Gosu/Platform.hpp>
11
-
12
- namespace Gosu
13
- {
14
- //! Addresses are returned from and given to Gosu functions in host byte order.
15
- typedef std::tr1::uint32_t SocketAddress;
16
-
17
- //! Ports are returned from and given to Gosu functions in host byte order.
18
- typedef std::tr1::uint16_t SocketPort;
19
-
20
- //! Constant that can be used as a placeholder for an arbitrary port, e.g. when
21
- //! starting to listen.
22
- const SocketPort anyPort = 0;
23
-
24
- //! Tries to convert a dotted IP4 string into an address suitable for
25
- //! socket functions. If the string supplied is not such a string, it
26
- //! tries to look up the host via DNS. If both methods fail, zero is
27
- //! returned.
28
- SocketAddress stringToAddress(const std::string& s);
29
- //! Converts an address into a dotted IP4 string.
30
- std::string addressToString(SocketAddress address);
31
-
32
- //! Wraps an UDP socket. Message sockets can send data to and receive
33
- //! data from arbitrary addresses. Also, message sockets send messages
34
- //! (packets) which are limited in size and can arrive in any order, or
35
- //! not at all.
36
- class MessageSocket
37
- {
38
- struct Impl;
39
- const GOSU_UNIQUE_PTR<Impl> pimpl;
40
- #if defined(GOSU_CPP11_ENABLED)
41
- MessageSocket(const MessageSocket&) = delete;
42
- MessageSocket& operator=(const MessageSocket&) = delete;
43
- MessageSocket(MessageSocket&&) = delete;
44
- MessageSocket& operator=(MessageSocket&&) = delete;
45
- #endif
46
-
47
- public:
48
- //! Opens a message socket for listening at the specified port.
49
- //! Gosu::anyPort may be passed to have the message socket use
50
- //! a random free port.
51
- explicit MessageSocket(SocketPort port);
52
- ~MessageSocket();
53
-
54
- //! Returns the local address of the socket.
55
- SocketAddress address() const;
56
- //! Returns the local port of the socket.
57
- SocketPort port() const;
58
- //! Returns the maximum size, in bytes, of a packet that can be sent
59
- //! from this socket.
60
- std::size_t maxMessageSize() const;
61
-
62
- //! Collects all the packets that were sent to this socket and
63
- //! calls onReceive for each of them.
64
- void update();
65
-
66
- //! Sends something to the given port of the computer identified
67
- //! by the address.
68
- void send(SocketAddress address, SocketPort port,
69
- const void* buffer, std::size_t size);
70
- /*void broadcast(SocketPort port, const void* buffer,
71
- std::size_t size);*/
72
-
73
- //! If assigned, will be called by update for every packet received.
74
- std::tr1::function<void (SocketAddress, SocketPort, const void*,
75
- std::size_t)> onReceive;
76
- };
77
-
78
- //! Defines the way in which data is collected until the onReceive event
79
- //! is called for CommSockets.
80
- enum CommMode
81
- {
82
- cmRaw,
83
- //cmLines,
84
- cmManaged
85
- };
86
-
87
- class Socket;
88
-
89
- //! Wraps a TCP socket that is used for one part of bi-directional
90
- //! communication.
91
- class CommSocket
92
- {
93
- struct Impl;
94
- const GOSU_UNIQUE_PTR<Impl> pimpl;
95
- #if defined(GOSU_CPP11_ENABLED)
96
- CommSocket(const CommSocket&) = delete;
97
- CommSocket& operator=(const CommSocket&) = delete;
98
- CommSocket(CommSocket&&) = delete;
99
- CommSocket& operator=(CommSocket&&) = delete;
100
- #endif
101
-
102
- public:
103
- CommSocket(CommMode mode, SocketAddress targetAddress,
104
- SocketPort targetPort);
105
- CommSocket(CommMode mode, Socket& socket);
106
- ~CommSocket();
107
-
108
- SocketAddress address() const;
109
- SocketPort port() const;
110
- SocketAddress remoteAddress() const;
111
- SocketPort remotePort() const;
112
- CommMode mode() const;
113
-
114
- bool connected() const;
115
- void disconnect();
116
- bool keepAlive() const;
117
- void setKeepAlive(bool value);
118
-
119
- void update();
120
- void send(const void* buffer, std::size_t size);
121
- void sendPendingData();
122
- std::size_t pendingBytes() const;
123
-
124
- std::tr1::function<void (const void*, std::size_t)> onReceive;
125
- std::tr1::function<void ()> onDisconnection;
126
- };
127
-
128
- //! Wraps a TCP socket that waits on a specific port and can create
129
- //! CommSocket instances via its onConnection event.
130
- class ListenerSocket
131
- {
132
- struct Impl;
133
- const GOSU_UNIQUE_PTR<Impl> pimpl;
134
- #if defined(GOSU_CPP11_ENABLED)
135
- ListenerSocket(const ListenerSocket&) = delete;
136
- ListenerSocket& operator=(const ListenerSocket&) = delete;
137
- ListenerSocket(ListenerSocket&&) = delete;
138
- ListenerSocket& operator=(ListenerSocket&&) = delete;
139
- #endif
140
-
141
- public:
142
- ListenerSocket(SocketPort port);
143
- ~ListenerSocket();
144
-
145
- SocketAddress address() const;
146
- SocketPort port() const;
147
-
148
- void update();
149
-
150
- //! This signal is fired by update() whenever someone connects
151
- //! to the port which is currently listened on.
152
- std::tr1::function<void (Socket&)> onConnection;
153
- };
154
- }
155
-
156
- #endif
@@ -1,56 +0,0 @@
1
- //! \file TR1.hpp
2
- //! Includes all parts of C++03 (TR1) that are relevant for Gosu. It makes available the following members of the std::tr1 namespace: array, bind, function, shared_ptr, uint*_t and int*_t.
3
-
4
- #ifndef GOSU_TR1_HPP
5
- #define GOSU_TR1_HPP
6
-
7
- #include <memory>
8
-
9
- #if defined(_MSC_VER) || defined(_LIBCPP_MEMORY)
10
- #include <array>
11
- #include <functional>
12
- namespace std
13
- {
14
- namespace tr1
15
- {
16
- typedef unsigned char uint8_t;
17
- typedef unsigned short uint16_t;
18
- typedef unsigned int uint32_t;
19
- typedef unsigned long long uint64_t;
20
- typedef signed char int8_t;
21
- typedef signed short int16_t;
22
- typedef signed int int32_t;
23
- typedef signed long long int64_t;
24
-
25
- #ifdef _LIBCPP_MEMORY
26
- namespace placeholders
27
- {
28
- using namespace std::placeholders;
29
- }
30
- using std::array;
31
- using std::bind;
32
- using std::function;
33
- using std::shared_ptr;
34
- #endif
35
- }
36
- }
37
- #else
38
- #include <tr1/array>
39
- #include <tr1/memory>
40
- #include <tr1/functional>
41
- #if defined(__GNUC__) && (__GNUC__ < 4 || __GNUC_MINOR__ < 2)
42
- #include <stdint.h>
43
- namespace std
44
- {
45
- namespace tr1
46
- {
47
- using ::int8_t; using ::int16_t; using ::int32_t; using ::int64_t;
48
- using ::uint8_t; using ::uint16_t; using ::uint32_t; using ::uint64_t;
49
- }
50
- }
51
- #else
52
- #include <tr1/cstdint>
53
- #endif
54
- #endif
55
-
56
- #endif
@@ -1,71 +0,0 @@
1
- //! \file Text.hpp
2
- //! Functions to output text on bitmaps.
3
-
4
- #ifndef GOSU_TEXT_HPP
5
- #define GOSU_TEXT_HPP
6
-
7
- #include <Gosu/Fwd.hpp>
8
- #include <Gosu/Color.hpp>
9
- #include <Gosu/GraphicsBase.hpp>
10
- #include <string>
11
-
12
- namespace Gosu
13
- {
14
- //! Returns the name of a neutral font that is available on the current
15
- //! platform.
16
- std::wstring defaultFontName();
17
-
18
- //! 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.
21
- //! \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);
26
-
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.
29
- //! \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
33
- //! 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);
37
-
38
- //! Creates a bitmap that is filled with a line of formatted text given to the function.
39
- //! The line can contain line breaks and HTML-like markup.
40
- //! \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
44
- //! enum.
45
- Bitmap createText(const std::wstring& text,
46
- const std::wstring& fontName, unsigned fontHeight,
47
- unsigned fontFlags = 0);
48
-
49
- //! Creates a bitmap that is filled with the formatted text given to the function.
50
- //! The line can contain line breaks and HTML-like markup.
51
- //! \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
55
- //! 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);
65
-
66
- //! 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);
69
- }
70
-
71
- #endif
@@ -1,70 +0,0 @@
1
- //! \file TextInput.hpp
2
- //! Interface of the TextInput class.
3
-
4
- #ifndef GOSU_TEXTINPUT_HPP
5
- #define GOSU_TEXTINPUT_HPP
6
-
7
- #include <Gosu/Fwd.hpp>
8
- #include <Gosu/Platform.hpp>
9
- #include <Gosu/TR1.hpp>
10
- #include <string>
11
-
12
- namespace Gosu
13
- {
14
- //! TextInput instances are invisible objects that build a text string from input,
15
- //! using the current operating system's keyboard layout.
16
- //! 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
19
- //! 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.
23
- class TextInput
24
- {
25
- 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
33
-
34
- public:
35
- TextInput();
36
- virtual ~TextInput();
37
-
38
- std::wstring text() const;
39
-
40
- //! Replaces the current text by the given string and positions the cursor
41
- //! 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);
56
-
57
- // Platform-specific communication with Gosu::Input.
58
- bool feedSDLEvent(void* event);
59
-
60
- //! 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
64
- {
65
- return text;
66
- }
67
- };
68
- }
69
-
70
- #endif
@@ -1,16 +0,0 @@
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,28 +0,0 @@
1
- //! \file Utility.hpp
2
- //! General purpose utility functions.
3
-
4
- #ifndef GOSU_UTILITY_HPP
5
- #define GOSU_UTILITY_HPP
6
-
7
- #include <string>
8
- #include <vector>
9
-
10
- namespace Gosu
11
- {
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);
16
-
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);
21
-
22
- //! 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.
25
- std::string language();
26
- }
27
-
28
- #endif
@@ -1,19 +0,0 @@
1
- #ifndef GOSU_VERSION_HPP
2
- #define GOSU_VERSION_HPP
3
-
4
- #define GOSU_MAJOR_VERSION 0
5
- #define GOSU_MINOR_VERSION 9
6
- #define GOSU_POINT_VERSION 2
7
- #define GOSU_VERSION "0.9.2"
8
-
9
- #define GOSU_COPYRIGHT_NOTICE \
10
- "This software uses the following third-party libraries:\n" \
11
- "\n" \
12
- "Gosu, http://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
- "FreeImage, http://freeimage.sourceforge.net, FreeImage Public License\n" \
15
- "libogg & libvorbis, http://www.xiph.org, BSD License, 3-Clause Version, http://www.xiph.org/licenses/bsd\n" \
16
- "libsndfile, http://www.mega-nerd.com/libsndfile, GNU LGPL 3, http://www.gnu.org/copyleft/lesser.html\n" \
17
- "OpenAL Soft, http://kcat.strangesoft.net/openal.html, GNU LGPL 2, http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html\n"
18
-
19
- #endif
@@ -1,75 +0,0 @@
1
- //! \file WinUtility.hpp
2
- //! Contains some functions which are used to implement Gosu on Windows and
3
- //! might be useful for advanced users who try to integrate Gosu in a Win32
4
- //! application.
5
-
6
- #ifndef GOSU_WINUTILITY_HPP
7
- #define GOSU_WINUTILITY_HPP
8
-
9
- #include <windows.h>
10
- #include <Gosu/Platform.hpp>
11
- #include <Gosu/TR1.hpp>
12
- #include <string>
13
-
14
- namespace Gosu
15
- {
16
- //! Implementation helpers for the Windows platform.
17
- namespace Win
18
- {
19
- //! Returns the instance handle of the application.
20
- HINSTANCE instance();
21
-
22
- //! Blocking function which waits for the next message, processes it,
23
- //! then returns.
24
- void handleMessage();
25
-
26
- //! Non-blocking function which processes all waiting messages but does
27
- //! not wait for further incoming messages.
28
- void processMessages();
29
-
30
- //! Registers a function to be called by handleMessage and
31
- //! processMessages. Every message is passed to the hooks and not
32
- //! processed further if any hook function returns true.
33
- void registerMessageHook(const std::tr1::function<bool (MSG&)>& hook);
34
-
35
- //! Throws an exception according to the error which GetLastError()
36
- //! returns, optionally prefixed with "While (action), the following
37
- //! error occured: ".
38
- GOSU_NORETURN void throwLastError(const std::string& action = "");
39
-
40
- //! Small helper function that throws an exception whenever the value
41
- //! passed through is false. Note that this doesn't make sense for all
42
- //! Windows API functions, but for most of them.
43
- template<typename T>
44
- inline T check(T valToCheck, const std::string& action = "")
45
- {
46
- if (!valToCheck)
47
- throwLastError(action);
48
- return valToCheck;
49
- }
50
-
51
- // IMPR: Why can't I use mem_fn for releasing objects even though it is
52
- // shown like that in the shared_ptr documentation?
53
- template<typename T>
54
- void releaseComPtr(T* ptr)
55
- {
56
- ptr->Release();
57
- }
58
-
59
- //! Small helper function that transfers ownership of a COM interface
60
- //! to a std::tr1::shared_ptr.
61
- template<typename T>
62
- inline std::tr1::shared_ptr<T> shareComPtr(T* ptr)
63
- {
64
- return std::tr1::shared_ptr<T>(ptr, releaseComPtr<T>);
65
- }
66
-
67
- //! Returns the executable's filename.
68
- std::wstring appFilename();
69
-
70
- //! Returns the executable's containing directory.
71
- std::wstring appDirectory();
72
- }
73
- }
74
-
75
- #endif