gosu 0.8.6-x86-mingw32 → 0.8.7-x86-mingw32
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 +171 -171
- data/Gosu/Bitmap.hpp +96 -96
- data/Gosu/Color.hpp +204 -204
- data/Gosu/Directories.hpp +36 -36
- data/Gosu/Font.hpp +83 -83
- data/Gosu/Gosu.hpp +34 -34
- data/Gosu/Graphics.hpp +115 -115
- data/Gosu/GraphicsBase.hpp +110 -110
- data/Gosu/IO.hpp +269 -269
- data/Gosu/Image.hpp +122 -122
- data/Gosu/ImageData.hpp +61 -61
- data/Gosu/Input.hpp +149 -149
- data/Gosu/Inspection.hpp +14 -14
- data/Gosu/Math.hpp +135 -135
- data/Gosu/Platform.hpp +93 -93
- data/Gosu/Sockets.hpp +156 -156
- data/Gosu/TR1.hpp +56 -56
- data/Gosu/Text.hpp +71 -71
- data/Gosu/TextInput.hpp +70 -70
- data/Gosu/Utility.hpp +28 -28
- data/Gosu/Version.hpp +19 -19
- data/Gosu/Window.hpp +145 -145
- data/examples/ChipmunkIntegration.rb +275 -275
- data/examples/CptnRuby.rb +223 -223
- data/examples/GosuZen.rb +68 -68
- data/examples/MoreChipmunkAndRMagick.rb +155 -155
- data/examples/OpenGLIntegration.rb +225 -225
- data/examples/RMagickIntegration.rb +417 -417
- data/examples/TextInput.rb +154 -154
- data/examples/Tutorial.rb +130 -130
- data/examples/media/Beep.wav +0 -0
- data/examples/media/CptnRuby Map.txt b/data/examples/media/CptnRuby → Map.txt +0 -0
- data/examples/media/Explosion.wav +0 -0
- data/examples/media/Landscape.svg +9 -9
- data/examples/media/Space.png +0 -0
- data/examples/media/Star.png +0 -0
- data/examples/media/Starfighter.bmp +0 -0
- data/lib/1.8/gosu.so +0 -0
- data/lib/1.9/gosu.so +0 -0
- data/lib/2.0/gosu.so +0 -0
- data/lib/2.1/gosu.so +0 -0
- data/lib/FreeImage.dll +0 -0
- data/lib/OpenAL32.dll +0 -0
- data/lib/gosu.rb +19 -16
- data/lib/gosu/patches.rb +81 -81
- data/lib/gosu/preview.rb +143 -139
- data/lib/gosu/run.rb +11 -11
- data/lib/gosu/swig_patches.rb +60 -60
- data/lib/gosu/zen.rb +89 -89
- metadata +5 -5
data/Gosu/Sockets.hpp
CHANGED
@@ -1,156 +1,156 @@
|
|
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
|
+
//! \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
|
data/Gosu/TR1.hpp
CHANGED
@@ -1,56 +1,56 @@
|
|
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
|
+
//! \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
|
data/Gosu/Text.hpp
CHANGED
@@ -1,71 +1,71 @@
|
|
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
|
+
//! \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
|