gosu 1.0.0.pre1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/gosu/extconf.rb +4 -24
- data/include/Gosu/Buttons.hpp +18 -17
- data/include/Gosu/Font.hpp +1 -1
- data/include/Gosu/Fwd.hpp +0 -5
- data/include/Gosu/Input.hpp +13 -40
- data/include/Gosu/Utility.hpp +14 -3
- data/include/Gosu/Version.hpp +3 -3
- data/include/Gosu/Window.hpp +25 -21
- data/lib/OpenAL32.dll +0 -0
- data/lib/gosu/patches.rb +0 -14
- data/lib/gosu/preview.rb +1 -3
- data/lib/gosu/swig_patches.rb +11 -10
- data/lib64/OpenAL32.dll +0 -0
- data/rdoc/gosu.rb +20 -6
- data/src/AudioFile.hpp +3 -0
- data/src/Input.cpp +28 -38
- data/src/Resolution.cpp +8 -8
- data/src/RubyGosu.cxx +646 -91
- data/src/RubyGosu.h +1 -1
- data/src/TrueTypeFontWin.cpp +3 -3
- data/src/Window.cpp +60 -31
- data/src/WindowUIKit.cpp +21 -9
- metadata +5 -31
- data/include/Gosu/AutoLink.hpp +0 -14
- data/include/Gosu/Channel.h +0 -25
- data/include/Gosu/Color.h +0 -38
- data/include/Gosu/Font.h +0 -36
- data/include/Gosu/Gosu.h +0 -82
- data/include/Gosu/Image.h +0 -54
- data/include/Gosu/Sample.h +0 -19
- data/include/Gosu/Song.h +0 -24
- data/include/Gosu/TextInput.h +0 -30
- data/include/Gosu/Window.h +0 -63
- data/lib/gosu/zen.rb +0 -89
- data/lib/libmpg123.dll +0 -0
- data/lib/libsndfile.dll +0 -0
- data/lib64/libmpg123.dll +0 -0
- data/lib64/libsndfile.dll +0 -0
- data/src/ChannelWrapper.cpp +0 -50
- data/src/ColorWrapper.cpp +0 -126
- data/src/Constants.cpp +0 -334
- data/src/FontWrapper.cpp +0 -74
- data/src/GosuWrapper.cpp +0 -251
- data/src/ImageWrapper.cpp +0 -168
- data/src/MPEGFile.hpp +0 -90
- data/src/SampleWrapper.cpp +0 -30
- data/src/SongWrapper.cpp +0 -52
- data/src/TextInputWrapper.cpp +0 -101
- data/src/WindowWrapper.cpp +0 -317
data/src/MPEGFile.hpp
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
|
3
|
-
#include "AudioFile.hpp"
|
4
|
-
#include <Gosu/IO.hpp>
|
5
|
-
#include <algorithm>
|
6
|
-
#include <stdexcept>
|
7
|
-
#include <string>
|
8
|
-
|
9
|
-
#include <mpg123.h>
|
10
|
-
|
11
|
-
namespace Gosu
|
12
|
-
{
|
13
|
-
class MPEGFile : public AudioFile
|
14
|
-
{
|
15
|
-
Gosu::Buffer contents_;
|
16
|
-
off_t position_ = 0;
|
17
|
-
mpg123_handle* handle_;
|
18
|
-
|
19
|
-
enum {
|
20
|
-
SAMPLE_RATE = 44100,
|
21
|
-
INPUT_SIZE = 16384
|
22
|
-
};
|
23
|
-
|
24
|
-
public:
|
25
|
-
MPEGFile(Gosu::Reader reader)
|
26
|
-
{
|
27
|
-
contents_.resize(reader.resource().size() - reader.position());
|
28
|
-
reader.read(contents_.data(), contents_.size());
|
29
|
-
|
30
|
-
static int init_error = mpg123_init();
|
31
|
-
if (init_error != MPG123_OK) {
|
32
|
-
throw std::runtime_error("Cannot initialize mpg123: " +
|
33
|
-
std::string(mpg123_plain_strerror(init_error)));
|
34
|
-
}
|
35
|
-
|
36
|
-
int new_error;
|
37
|
-
handle_ = mpg123_new(nullptr, &new_error);
|
38
|
-
if (handle_ == nullptr) {
|
39
|
-
throw std::runtime_error("Cannot initialize mpg123 decoder: " +
|
40
|
-
std::string(mpg123_plain_strerror(new_error)));
|
41
|
-
}
|
42
|
-
|
43
|
-
mpg123_param(handle_, MPG123_FORCE_RATE, SAMPLE_RATE, 0);
|
44
|
-
mpg123_param(handle_, MPG123_FLAGS, MPG123_FORCE_STEREO, 0);
|
45
|
-
|
46
|
-
mpg123_open_feed(handle_);
|
47
|
-
}
|
48
|
-
|
49
|
-
~MPEGFile() override
|
50
|
-
{
|
51
|
-
mpg123_delete(handle_);
|
52
|
-
}
|
53
|
-
|
54
|
-
ALenum format() const override
|
55
|
-
{
|
56
|
-
return AL_FORMAT_STEREO16;
|
57
|
-
}
|
58
|
-
|
59
|
-
ALuint sample_rate() const override
|
60
|
-
{
|
61
|
-
return SAMPLE_RATE;
|
62
|
-
}
|
63
|
-
|
64
|
-
std::size_t read_data(void* dest, std::size_t length) override
|
65
|
-
{
|
66
|
-
std::size_t written = 0;
|
67
|
-
int error = 0;
|
68
|
-
|
69
|
-
error = mpg123_read(handle_, static_cast<unsigned char*>(dest), length, &written);
|
70
|
-
while (written == 0
|
71
|
-
&& (error == MPG123_NEED_MORE || error == MPG123_NEW_FORMAT)
|
72
|
-
&& position_ != contents_.size()) {
|
73
|
-
auto bytes = std::min<std::size_t>(contents_.size() - position_, INPUT_SIZE);
|
74
|
-
// (Not sure what to do about the return value of mpg123_feed here.)
|
75
|
-
mpg123_feed(handle_, static_cast<unsigned char*>(contents_.data()) + position_,
|
76
|
-
bytes);
|
77
|
-
position_ += bytes;
|
78
|
-
error = mpg123_read(handle_, static_cast<unsigned char*>(dest), length, &written);
|
79
|
-
}
|
80
|
-
|
81
|
-
return written;
|
82
|
-
}
|
83
|
-
|
84
|
-
void rewind() override
|
85
|
-
{
|
86
|
-
mpg123_feedseek(handle_, 0, SEEK_SET, &position_);
|
87
|
-
assert (position_ >= 0 && position_ <= contents_.size());
|
88
|
-
}
|
89
|
-
};
|
90
|
-
}
|
data/src/SampleWrapper.cpp
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
#include <Gosu/Audio.hpp>
|
2
|
-
#include <Gosu/Sample.h>
|
3
|
-
|
4
|
-
extern "C" {
|
5
|
-
|
6
|
-
Gosu_Sample *Gosu_Sample_create(const char *filename)
|
7
|
-
{
|
8
|
-
return reinterpret_cast<Gosu_Sample *>( new Gosu::Sample(filename) );
|
9
|
-
}
|
10
|
-
|
11
|
-
void Gosu_Sample_destroy(Gosu_Sample *sample)
|
12
|
-
{
|
13
|
-
delete( reinterpret_cast<Gosu::Sample *>( sample ) );
|
14
|
-
}
|
15
|
-
|
16
|
-
Gosu_Channel *Gosu_Sample_play(Gosu_Sample *sample, double volume, double speed, bool looping)
|
17
|
-
{
|
18
|
-
Gosu::Channel channel = reinterpret_cast<Gosu::Sample *>( sample )->play(volume, speed, looping);
|
19
|
-
|
20
|
-
return reinterpret_cast<Gosu_Channel *>( new Gosu::Channel(channel) );
|
21
|
-
}
|
22
|
-
|
23
|
-
Gosu_Channel *Gosu_Sample_play_pan(Gosu_Sample *sample, double pan, double volume, double speed, bool looping)
|
24
|
-
{
|
25
|
-
Gosu::Channel channel = reinterpret_cast<Gosu::Sample *>( sample )->play_pan(pan, volume, speed, looping);
|
26
|
-
|
27
|
-
return reinterpret_cast<Gosu_Channel *>( new Gosu::Channel(channel) );
|
28
|
-
}
|
29
|
-
|
30
|
-
}
|
data/src/SongWrapper.cpp
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
#include <Gosu/Audio.hpp>
|
2
|
-
#include <Gosu/Song.h>
|
3
|
-
|
4
|
-
extern "C" {
|
5
|
-
Gosu_Song* Gosu_Song_create(const char* filename)
|
6
|
-
{
|
7
|
-
return reinterpret_cast<Gosu_Song*>( new Gosu::Song(filename) );
|
8
|
-
}
|
9
|
-
|
10
|
-
void Gosu_Song_destroy(Gosu_Song* song)
|
11
|
-
{
|
12
|
-
delete( reinterpret_cast<Gosu::Song*>( song ));
|
13
|
-
}
|
14
|
-
|
15
|
-
void Gosu_Song_play(Gosu_Song* song, bool looping)
|
16
|
-
{
|
17
|
-
reinterpret_cast<Gosu::Song*>( song )->play(looping);
|
18
|
-
}
|
19
|
-
|
20
|
-
bool Gosu_Song_playing(Gosu_Song* song)
|
21
|
-
{
|
22
|
-
return reinterpret_cast<Gosu::Song*>( song )->playing();
|
23
|
-
}
|
24
|
-
|
25
|
-
void Gosu_Song_pause(Gosu_Song* song)
|
26
|
-
{
|
27
|
-
reinterpret_cast<Gosu::Song*>( song )->pause();
|
28
|
-
}
|
29
|
-
|
30
|
-
bool Gosu_Song_paused(Gosu_Song* song)
|
31
|
-
{
|
32
|
-
return reinterpret_cast<Gosu::Song*>( song )->paused();
|
33
|
-
}
|
34
|
-
|
35
|
-
void Gosu_Song_stop(Gosu_Song* song)
|
36
|
-
{
|
37
|
-
reinterpret_cast<Gosu::Song*>( song )->stop();
|
38
|
-
}
|
39
|
-
|
40
|
-
double Gosu_Song_volume(Gosu_Song* song){
|
41
|
-
return reinterpret_cast<Gosu::Song*>( song )->volume();
|
42
|
-
}
|
43
|
-
|
44
|
-
void Gosu_Song_set_volume(Gosu_Song* song, double volume){
|
45
|
-
return reinterpret_cast<Gosu::Song*>( song )->set_volume(volume);
|
46
|
-
}
|
47
|
-
|
48
|
-
Gosu_Song* Gosu_Song_current_song()
|
49
|
-
{
|
50
|
-
return reinterpret_cast<Gosu_Song*>(Gosu::Song::current_song());
|
51
|
-
}
|
52
|
-
}
|
data/src/TextInputWrapper.cpp
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
#include <Gosu/Gosu.hpp>
|
2
|
-
|
3
|
-
namespace Gosu
|
4
|
-
{
|
5
|
-
class TextInputForWrapper : public Gosu::TextInput
|
6
|
-
{
|
7
|
-
public:
|
8
|
-
TextInputForWrapper();
|
9
|
-
std::string filter(std::string text) const override;
|
10
|
-
std::function<void (const char *text)> filter_callback;
|
11
|
-
std::string filter_result = "";
|
12
|
-
};
|
13
|
-
} // namespace Gosu
|
14
|
-
|
15
|
-
Gosu::TextInputForWrapper::TextInputForWrapper() : Gosu::TextInput()
|
16
|
-
{
|
17
|
-
}
|
18
|
-
|
19
|
-
std::string Gosu::TextInputForWrapper::filter(std::string text) const
|
20
|
-
{
|
21
|
-
if (filter_callback != nullptr) {
|
22
|
-
filter_callback(text.c_str());
|
23
|
-
return filter_result;
|
24
|
-
}
|
25
|
-
else {
|
26
|
-
return text;
|
27
|
-
}
|
28
|
-
}
|
29
|
-
|
30
|
-
extern "C" {
|
31
|
-
#include <Gosu/TextInput.h>
|
32
|
-
|
33
|
-
Gosu_TextInput *Gosu_TextInput_create()
|
34
|
-
{
|
35
|
-
return reinterpret_cast<Gosu_TextInput *>(new Gosu::TextInputForWrapper());
|
36
|
-
}
|
37
|
-
|
38
|
-
const char *Gosu_TextInput_text(Gosu_TextInput *text_input)
|
39
|
-
{
|
40
|
-
thread_local std::string string;
|
41
|
-
string = reinterpret_cast<Gosu::TextInputForWrapper *>(text_input)->text();
|
42
|
-
|
43
|
-
return string.c_str();
|
44
|
-
}
|
45
|
-
|
46
|
-
void Gosu_TextInput_set_text(Gosu_TextInput *text_input, const char *text)
|
47
|
-
{
|
48
|
-
reinterpret_cast<Gosu::TextInputForWrapper *>(text_input)->set_text(text);
|
49
|
-
}
|
50
|
-
|
51
|
-
unsigned Gosu_TextInput_caret_pos(Gosu_TextInput *text_input)
|
52
|
-
{
|
53
|
-
return reinterpret_cast<Gosu::TextInputForWrapper *>(text_input)->caret_pos();
|
54
|
-
}
|
55
|
-
|
56
|
-
void Gosu_TextInput_set_caret_pos(Gosu_TextInput *text_input, unsigned pos)
|
57
|
-
{
|
58
|
-
return reinterpret_cast<Gosu::TextInputForWrapper *>(text_input)->set_caret_pos(pos);
|
59
|
-
}
|
60
|
-
|
61
|
-
unsigned Gosu_TextInput_selection_start(Gosu_TextInput *text_input)
|
62
|
-
{
|
63
|
-
return reinterpret_cast<Gosu::TextInputForWrapper *>(text_input)->selection_start();
|
64
|
-
}
|
65
|
-
|
66
|
-
void Gosu_TextInput_set_selection_start(Gosu_TextInput *text_input, unsigned pos)
|
67
|
-
{
|
68
|
-
return reinterpret_cast<Gosu::TextInputForWrapper *>(text_input)->set_selection_start(pos);
|
69
|
-
}
|
70
|
-
|
71
|
-
void Gosu_TextInput_set_filter(Gosu_TextInput *text_input, void function(void *data, const char *text), void *data)
|
72
|
-
{
|
73
|
-
reinterpret_cast<Gosu::TextInputForWrapper *>(text_input)->filter_callback = [=](const char *text) { function(data, text); };
|
74
|
-
}
|
75
|
-
|
76
|
-
void Gosu_TextInput_set_filter_result(Gosu_TextInput *text_input, const char *result)
|
77
|
-
{
|
78
|
-
reinterpret_cast<Gosu::TextInputForWrapper *>(text_input)->filter_result = result;
|
79
|
-
}
|
80
|
-
|
81
|
-
void Gosu_TextInput_insert_text(Gosu_TextInput *text_input, const char *text)
|
82
|
-
{
|
83
|
-
reinterpret_cast<Gosu::TextInputForWrapper *>(text_input)->insert_text(text);
|
84
|
-
}
|
85
|
-
|
86
|
-
void Gosu_TextInput_delete_backward(Gosu_TextInput *text_input)
|
87
|
-
{
|
88
|
-
reinterpret_cast<Gosu::TextInputForWrapper *>(text_input)->delete_backward();
|
89
|
-
}
|
90
|
-
|
91
|
-
void Gosu_TextInput_delete_forward(Gosu_TextInput *text_input)
|
92
|
-
{
|
93
|
-
reinterpret_cast<Gosu::TextInputForWrapper *>(text_input)->delete_forward();
|
94
|
-
}
|
95
|
-
|
96
|
-
void Gosu_TextInput_destroy(Gosu_TextInput *text_input)
|
97
|
-
{
|
98
|
-
delete (reinterpret_cast<Gosu::TextInputForWrapper *>(text_input));
|
99
|
-
}
|
100
|
-
|
101
|
-
}
|
data/src/WindowWrapper.cpp
DELETED
@@ -1,317 +0,0 @@
|
|
1
|
-
#include <Gosu/Gosu.hpp>
|
2
|
-
|
3
|
-
namespace Gosu
|
4
|
-
{
|
5
|
-
class WindowForWrapper : public Gosu::Window
|
6
|
-
{
|
7
|
-
public:
|
8
|
-
WindowForWrapper(int width, int height, bool fullscreen, double update_interval, bool resizable);
|
9
|
-
void update() override;
|
10
|
-
void draw() override;
|
11
|
-
void default_button_down(unsigned btn); // Enables fullscreen toggle
|
12
|
-
void button_down(Gosu::Button btn) override;
|
13
|
-
void button_up(Gosu::Button btn) override;
|
14
|
-
void gamepad_connected(int id) override;
|
15
|
-
void gamepad_disconnected(int id) override;
|
16
|
-
void drop(const std::string &filename) override;
|
17
|
-
bool needs_redraw() const override;
|
18
|
-
bool needs_cursor() const override;
|
19
|
-
void close() override;
|
20
|
-
|
21
|
-
void close_immediately();
|
22
|
-
|
23
|
-
std::function<void ()> update_callback;
|
24
|
-
std::function<void ()> draw_callback;
|
25
|
-
std::function<void (unsigned btn)> button_down_callback;
|
26
|
-
std::function<void (unsigned btn)> button_up_callback;
|
27
|
-
std::function<void (int id)> gamepad_connected_callback;
|
28
|
-
std::function<void (int id)> gamepad_disconnected_callback;
|
29
|
-
std::function<void (const char *filename)> drop_callback;
|
30
|
-
std::function<bool ()> needs_redraw_callback;
|
31
|
-
std::function<bool ()> needs_cursor_callback;
|
32
|
-
std::function<void ()> close_callback;
|
33
|
-
};
|
34
|
-
} // namespace Gosu
|
35
|
-
|
36
|
-
Gosu::WindowForWrapper::WindowForWrapper(int width, int height, bool fullscreen,
|
37
|
-
double update_interval, bool resizable)
|
38
|
-
: Gosu::Window(width, height, fullscreen, update_interval, resizable)
|
39
|
-
{
|
40
|
-
}
|
41
|
-
|
42
|
-
void Gosu::WindowForWrapper::update()
|
43
|
-
{
|
44
|
-
if (update_callback != nullptr) {
|
45
|
-
update_callback();
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
|
-
void Gosu::WindowForWrapper::draw()
|
50
|
-
{
|
51
|
-
if (draw_callback != nullptr) {
|
52
|
-
draw_callback();
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
void Gosu::WindowForWrapper::default_button_down(unsigned btn)
|
57
|
-
{
|
58
|
-
Gosu::Window::button_down(Gosu::ButtonName(btn));
|
59
|
-
}
|
60
|
-
|
61
|
-
void Gosu::WindowForWrapper::button_down(Gosu::Button btn)
|
62
|
-
{
|
63
|
-
if (button_down_callback != nullptr) {
|
64
|
-
button_down_callback(btn.id());
|
65
|
-
}
|
66
|
-
}
|
67
|
-
|
68
|
-
void Gosu::WindowForWrapper::button_up(Gosu::Button btn)
|
69
|
-
{
|
70
|
-
if (button_up_callback != nullptr) {
|
71
|
-
button_up_callback(btn.id());
|
72
|
-
}
|
73
|
-
}
|
74
|
-
|
75
|
-
void Gosu::WindowForWrapper::gamepad_connected(int id)
|
76
|
-
{
|
77
|
-
if (gamepad_connected_callback != nullptr) {
|
78
|
-
gamepad_connected_callback(id);
|
79
|
-
}
|
80
|
-
}
|
81
|
-
|
82
|
-
void Gosu::WindowForWrapper::gamepad_disconnected(int id)
|
83
|
-
{
|
84
|
-
if (gamepad_disconnected_callback != nullptr) {
|
85
|
-
gamepad_disconnected_callback(id);
|
86
|
-
}
|
87
|
-
}
|
88
|
-
|
89
|
-
void Gosu::WindowForWrapper::drop(const std::string &filename)
|
90
|
-
{
|
91
|
-
if (drop_callback != nullptr) {
|
92
|
-
drop_callback(filename.c_str());
|
93
|
-
}
|
94
|
-
}
|
95
|
-
|
96
|
-
bool Gosu::WindowForWrapper::needs_redraw() const
|
97
|
-
{
|
98
|
-
if (needs_redraw_callback != nullptr) {
|
99
|
-
return needs_redraw_callback();
|
100
|
-
}
|
101
|
-
else {
|
102
|
-
return true;
|
103
|
-
}
|
104
|
-
}
|
105
|
-
|
106
|
-
bool Gosu::WindowForWrapper::needs_cursor() const
|
107
|
-
{
|
108
|
-
if (needs_cursor_callback != nullptr) {
|
109
|
-
return needs_cursor_callback();
|
110
|
-
}
|
111
|
-
else {
|
112
|
-
return false;
|
113
|
-
}
|
114
|
-
}
|
115
|
-
|
116
|
-
void Gosu::WindowForWrapper::close()
|
117
|
-
{
|
118
|
-
if (close_callback != nullptr) {
|
119
|
-
close_callback();
|
120
|
-
}
|
121
|
-
else {
|
122
|
-
Gosu::Window::close();
|
123
|
-
}
|
124
|
-
}
|
125
|
-
|
126
|
-
void Gosu::WindowForWrapper::close_immediately()
|
127
|
-
{
|
128
|
-
Gosu::Window::close();
|
129
|
-
}
|
130
|
-
|
131
|
-
extern "C" {
|
132
|
-
#include <Gosu/Window.h>
|
133
|
-
#include <Gosu/TextInput.h>
|
134
|
-
|
135
|
-
// Constructor
|
136
|
-
Gosu_Window *Gosu_Window_create(int width, int height, bool fullscreen, double update_interval, bool resizable)
|
137
|
-
{
|
138
|
-
return reinterpret_cast<Gosu_Window *>(new Gosu::WindowForWrapper(width, height, fullscreen, update_interval, resizable));
|
139
|
-
};
|
140
|
-
|
141
|
-
// Callbacks
|
142
|
-
void Gosu_Window_set_draw(Gosu_Window *window, void function(void *data), void *data)
|
143
|
-
{
|
144
|
-
reinterpret_cast<Gosu::WindowForWrapper *>(window)->draw_callback = [=]() { function(data); };
|
145
|
-
}
|
146
|
-
|
147
|
-
void Gosu_Window_set_update(Gosu_Window *window, void function(void *data), void *data)
|
148
|
-
{
|
149
|
-
reinterpret_cast<Gosu::WindowForWrapper *>(window)->update_callback = [=]() { function(data); };
|
150
|
-
}
|
151
|
-
|
152
|
-
void Gosu_Window_set_button_down(Gosu_Window *window, void function(void *data, unsigned btn), void *data)
|
153
|
-
{
|
154
|
-
reinterpret_cast<Gosu::WindowForWrapper *>(window)->button_down_callback = [=](unsigned btn) { function(data, btn); };
|
155
|
-
}
|
156
|
-
|
157
|
-
void Gosu_Window_default_button_down(Gosu_Window *window, unsigned btn)
|
158
|
-
{
|
159
|
-
reinterpret_cast<Gosu::WindowForWrapper *>(window)->default_button_down(btn);
|
160
|
-
}
|
161
|
-
|
162
|
-
void Gosu_Window_set_button_up(Gosu_Window *window, void function(void *data, unsigned btn), void *data)
|
163
|
-
{
|
164
|
-
reinterpret_cast<Gosu::WindowForWrapper *>(window)->button_up_callback = [=](unsigned btn) { function(data, btn); };
|
165
|
-
}
|
166
|
-
|
167
|
-
void Gosu_Window_set_gamepad_connected(Gosu_Window *window, void function(void *data, int id), void *data)
|
168
|
-
{
|
169
|
-
reinterpret_cast<Gosu::WindowForWrapper *>(window)->gamepad_connected_callback = [=](int id) { function(data, id); };
|
170
|
-
}
|
171
|
-
|
172
|
-
void Gosu_Window_set_gamepad_disconnected(Gosu_Window *window, void function(void *data, int id), void *data)
|
173
|
-
{
|
174
|
-
reinterpret_cast<Gosu::WindowForWrapper *>(window)->gamepad_disconnected_callback = [=](int id) { function(data, id); };
|
175
|
-
}
|
176
|
-
|
177
|
-
void Gosu_Window_set_drop(Gosu_Window *window, void function(void *data, const char *filename), void *data)
|
178
|
-
{
|
179
|
-
reinterpret_cast<Gosu::WindowForWrapper *>(window)->drop_callback = [=](const char *filename) { function(data, filename); };
|
180
|
-
}
|
181
|
-
|
182
|
-
void Gosu_Window_set_needs_redraw(Gosu_Window *window, bool function(void *data), void *data)
|
183
|
-
{
|
184
|
-
reinterpret_cast<Gosu::WindowForWrapper *>(window)->needs_redraw_callback = [=]() -> bool { return function(data); };
|
185
|
-
}
|
186
|
-
|
187
|
-
void Gosu_Window_set_needs_cursor(Gosu_Window *window, bool function(void *data), void *data)
|
188
|
-
{
|
189
|
-
reinterpret_cast<Gosu::WindowForWrapper *>(window)->needs_cursor_callback = [=]() -> bool { return function(data); };
|
190
|
-
}
|
191
|
-
|
192
|
-
void Gosu_Window_set_close(Gosu_Window *window, void function(void *data), void *data)
|
193
|
-
{
|
194
|
-
reinterpret_cast<Gosu::WindowForWrapper *>(window)->close_callback = [=]() { function(data); };
|
195
|
-
}
|
196
|
-
|
197
|
-
Gosu_TextInput *Gosu_Window_text_input(Gosu_Window *window)
|
198
|
-
{
|
199
|
-
Gosu::Window *gosu_window = reinterpret_cast<Gosu::WindowForWrapper *>(window);
|
200
|
-
return reinterpret_cast<Gosu_TextInput *>(gosu_window->input().text_input());
|
201
|
-
}
|
202
|
-
|
203
|
-
void Gosu_Window_set_text_input(Gosu_Window *window, Gosu_TextInput *text_input)
|
204
|
-
{
|
205
|
-
Gosu::Window *gosu_window = reinterpret_cast<Gosu::WindowForWrapper *>(window);
|
206
|
-
gosu_window->input().set_text_input(reinterpret_cast<Gosu::TextInput *>(text_input));
|
207
|
-
}
|
208
|
-
|
209
|
-
void Gosu_Window_show(Gosu_Window *window)
|
210
|
-
{
|
211
|
-
reinterpret_cast<Gosu::WindowForWrapper *>(window)->show();
|
212
|
-
}
|
213
|
-
|
214
|
-
bool Gosu_Window_tick(Gosu_Window *window)
|
215
|
-
{
|
216
|
-
return reinterpret_cast<Gosu::WindowForWrapper *>(window)->tick();
|
217
|
-
}
|
218
|
-
|
219
|
-
void Gosu_Window_close_immediately(Gosu_Window *window)
|
220
|
-
{
|
221
|
-
reinterpret_cast<Gosu::WindowForWrapper *>(window)->close_immediately();
|
222
|
-
}
|
223
|
-
|
224
|
-
bool Gosu_Window_is_fullscreen(Gosu_Window *window)
|
225
|
-
{
|
226
|
-
return reinterpret_cast<Gosu::WindowForWrapper *>(window)->fullscreen();
|
227
|
-
}
|
228
|
-
|
229
|
-
bool Gosu_Window_is_resizable(Gosu_Window *window)
|
230
|
-
{
|
231
|
-
return reinterpret_cast<Gosu::WindowForWrapper *>(window)->resizable();
|
232
|
-
}
|
233
|
-
|
234
|
-
const char *Gosu_Window_caption(Gosu_Window *window)
|
235
|
-
{
|
236
|
-
static thread_local std::string caption;
|
237
|
-
caption = reinterpret_cast<Gosu::WindowForWrapper *>(window)->caption();
|
238
|
-
|
239
|
-
return caption.c_str();
|
240
|
-
}
|
241
|
-
|
242
|
-
void Gosu_Window_set_caption(Gosu_Window *window, const char *caption)
|
243
|
-
{
|
244
|
-
reinterpret_cast<Gosu::WindowForWrapper *>(window)->set_caption(caption);
|
245
|
-
}
|
246
|
-
|
247
|
-
double Gosu_Window_update_interval(Gosu_Window *window)
|
248
|
-
{
|
249
|
-
return reinterpret_cast<Gosu::WindowForWrapper *>(window)->update_interval();
|
250
|
-
}
|
251
|
-
|
252
|
-
void Gosu_Window_set_update_interval(Gosu_Window *window, double update_interval)
|
253
|
-
{
|
254
|
-
reinterpret_cast<Gosu::WindowForWrapper *>(window)->set_update_interval(update_interval);
|
255
|
-
}
|
256
|
-
|
257
|
-
void Gosu_Window_set_mouse_x(Gosu_Window *window, double x)
|
258
|
-
{
|
259
|
-
Gosu::Window *gosu_window = reinterpret_cast<Gosu::WindowForWrapper *>(window);
|
260
|
-
gosu_window->input().set_mouse_position(x, gosu_window->input().mouse_x());
|
261
|
-
}
|
262
|
-
|
263
|
-
void Gosu_Window_set_mouse_y(Gosu_Window *window, double y)
|
264
|
-
{
|
265
|
-
Gosu::Window *gosu_window = reinterpret_cast<Gosu::WindowForWrapper *>(window);
|
266
|
-
gosu_window->input().set_mouse_position(gosu_window->input().mouse_x(), y);
|
267
|
-
}
|
268
|
-
|
269
|
-
double Gosu_Window_mouse_x(Gosu_Window *window)
|
270
|
-
{
|
271
|
-
return reinterpret_cast<Gosu::WindowForWrapper *>(window)->input().mouse_x();
|
272
|
-
}
|
273
|
-
|
274
|
-
double Gosu_Window_mouse_y(Gosu_Window *window)
|
275
|
-
{
|
276
|
-
return reinterpret_cast<Gosu::WindowForWrapper *>(window)->input().mouse_y();
|
277
|
-
}
|
278
|
-
|
279
|
-
int Gosu_Window_width(Gosu_Window *window)
|
280
|
-
{
|
281
|
-
return reinterpret_cast<Gosu::WindowForWrapper *>(window)->width();
|
282
|
-
}
|
283
|
-
|
284
|
-
void Gosu_Window_set_width(Gosu_Window *window, int width)
|
285
|
-
{
|
286
|
-
Gosu::Window *gosu_window = reinterpret_cast<Gosu::WindowForWrapper *>(window);
|
287
|
-
gosu_window->resize(width, gosu_window->height(), gosu_window->fullscreen());
|
288
|
-
}
|
289
|
-
|
290
|
-
int Gosu_Window_height(Gosu_Window *window)
|
291
|
-
{
|
292
|
-
return reinterpret_cast<Gosu::WindowForWrapper *>(window)->height();
|
293
|
-
}
|
294
|
-
|
295
|
-
void Gosu_Window_set_height(Gosu_Window *window, int height)
|
296
|
-
{
|
297
|
-
Gosu::Window *gosu_window = reinterpret_cast<Gosu::WindowForWrapper *>(window);
|
298
|
-
gosu_window->resize(gosu_window->width(), height, gosu_window->fullscreen());
|
299
|
-
}
|
300
|
-
|
301
|
-
void Gosu_Window_resize(Gosu_Window *window, int width, int height, bool fullscreen)
|
302
|
-
{
|
303
|
-
reinterpret_cast<Gosu::WindowForWrapper *>(window)->resize(width, height, fullscreen);
|
304
|
-
}
|
305
|
-
|
306
|
-
int Gosu_Window_is_button_down(Gosu_Window *window, unsigned btn)
|
307
|
-
{
|
308
|
-
return reinterpret_cast<Gosu::WindowForWrapper *>(window)->input().down(Gosu::Button(btn));
|
309
|
-
}
|
310
|
-
|
311
|
-
// Destructor
|
312
|
-
void Gosu_Window_destroy(Gosu_Window *window)
|
313
|
-
{
|
314
|
-
delete (reinterpret_cast<Gosu::WindowForWrapper *>(window));
|
315
|
-
}
|
316
|
-
|
317
|
-
}
|