gosu 1.1.0.pre2 → 1.3.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/COPYING +1 -1
- data/ext/gosu/extconf.rb +5 -1
- data/include/Gosu/Color.hpp +48 -100
- data/include/Gosu/Font.hpp +7 -9
- data/include/Gosu/Fwd.hpp +1 -1
- data/include/Gosu/Graphics.hpp +6 -4
- data/include/Gosu/GraphicsBase.hpp +6 -6
- data/include/Gosu/Image.hpp +3 -3
- data/include/Gosu/ImageData.hpp +1 -1
- data/include/Gosu/Math.hpp +4 -16
- data/include/Gosu/Platform.hpp +1 -51
- data/include/Gosu/Text.hpp +37 -40
- data/include/Gosu/Utility.hpp +10 -8
- data/include/Gosu/Version.hpp +1 -1
- data/include/Gosu/Window.hpp +2 -0
- data/lib/gosu/compat.rb +4 -0
- data/lib/gosu/swig_patches.rb +31 -3
- data/rdoc/gosu.rb +9 -1
- data/src/Bitmap.cpp +13 -13
- data/src/Color.cpp +50 -46
- data/src/EmptyImageData.hpp +1 -1
- data/src/Font.cpp +4 -4
- data/src/GosuViewController.cpp +2 -0
- data/src/Graphics.cpp +4 -4
- data/src/Image.cpp +4 -3
- data/src/Input.cpp +1 -10
- data/src/LargeImageData.cpp +20 -20
- data/src/LargeImageData.hpp +1 -1
- data/src/Macro.cpp +100 -143
- data/src/Macro.hpp +1 -1
- data/src/RenderState.hpp +5 -5
- data/src/Resolution.cpp +107 -59
- data/src/RubyGosu.cxx +465 -496
- data/src/RubyGosu.h +3 -2
- data/src/TexChunk.cpp +1 -1
- data/src/TexChunk.hpp +1 -1
- data/src/Text.cpp +31 -32
- data/src/TrueTypeFont.cpp +1 -1
- data/src/TrueTypeFontApple.cpp +10 -3
- data/src/Utility.cpp +82 -23
- data/src/WinUtility.hpp +2 -1
- data/src/Window.cpp +9 -9
- data/src/WindowUIKit.cpp +2 -2
- metadata +5 -7
- data/src/UtilityApple.cpp +0 -16
- data/src/UtilityWin.cpp +0 -17
data/src/RubyGosu.h
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* ----------------------------------------------------------------------------
|
2
2
|
* This file was automatically generated by SWIG (http://www.swig.org).
|
3
|
-
* Version 4.
|
3
|
+
* Version 4.0.2
|
4
4
|
*
|
5
5
|
* This file is not intended to be easily readable and contains a number of
|
6
6
|
* coding conventions designed to improve portability and efficiency. Do not make
|
@@ -28,7 +28,7 @@ public:
|
|
28
28
|
class SwigDirector_Window : public Gosu::Window, public Swig::Director {
|
29
29
|
|
30
30
|
public:
|
31
|
-
SwigDirector_Window(VALUE self,int width,int height,unsigned int window_flags=Gosu::WF_WINDOWED,double update_interval=16.666666);
|
31
|
+
SwigDirector_Window(VALUE self, int width, int height, unsigned int window_flags = Gosu::WF_WINDOWED, double update_interval = 16.666666);
|
32
32
|
virtual ~SwigDirector_Window();
|
33
33
|
virtual void show();
|
34
34
|
virtual bool tick();
|
@@ -37,6 +37,7 @@ public:
|
|
37
37
|
virtual void draw();
|
38
38
|
virtual bool needs_redraw() const;
|
39
39
|
virtual bool needs_cursor() const;
|
40
|
+
virtual void gain_focus();
|
40
41
|
virtual void lose_focus();
|
41
42
|
virtual void release_memory();
|
42
43
|
virtual void button_down(Gosu::Button arg0);
|
data/src/TexChunk.cpp
CHANGED
@@ -44,7 +44,7 @@ Gosu::TexChunk::~TexChunk()
|
|
44
44
|
}
|
45
45
|
|
46
46
|
void Gosu::TexChunk::draw(double x1, double y1, Color c1, double x2, double y2, Color c2,
|
47
|
-
double x3, double y3, Color c3, double x4, double y4, Color c4, ZPos z,
|
47
|
+
double x3, double y3, Color c3, double x4, double y4, Color c4, ZPos z, BlendMode mode) const
|
48
48
|
{
|
49
49
|
DrawOp op;
|
50
50
|
op.render_state.texture = texture;
|
data/src/TexChunk.hpp
CHANGED
@@ -29,7 +29,7 @@ public:
|
|
29
29
|
double x2, double y2, Color c2,
|
30
30
|
double x3, double y3, Color c3,
|
31
31
|
double x4, double y4, Color c4,
|
32
|
-
ZPos z,
|
32
|
+
ZPos z, BlendMode mode) const override;
|
33
33
|
|
34
34
|
const GLTexInfo* gl_tex_info() const override { return &info; }
|
35
35
|
|
data/src/Text.cpp
CHANGED
@@ -1,36 +1,34 @@
|
|
1
|
+
#include "GraphicsImpl.hpp"
|
1
2
|
#include "MarkupParser.hpp"
|
2
3
|
#include "TextBuilder.hpp"
|
3
|
-
#include "GraphicsImpl.hpp"
|
4
4
|
#include "TrueTypeFont.hpp"
|
5
5
|
#include <Gosu/Text.hpp>
|
6
|
-
#include <cassert>
|
7
|
-
#include <cmath>
|
8
6
|
#include <algorithm>
|
9
|
-
#include <
|
7
|
+
#include <cmath>
|
10
8
|
#include <stdexcept>
|
11
|
-
|
9
|
+
#include <vector>
|
12
10
|
|
13
|
-
double Gosu::text_width(const u32string& text,
|
14
|
-
const string& font_name, double font_height, unsigned font_flags)
|
11
|
+
double Gosu::text_width(const std::u32string& text,
|
12
|
+
const std::string& font_name, double font_height, unsigned font_flags)
|
15
13
|
{
|
16
|
-
if (font_height <= 0) throw invalid_argument
|
17
|
-
if (font_flags >= FF_COMBINATIONS) throw invalid_argument
|
18
|
-
|
19
|
-
|
14
|
+
if (font_height <= 0) throw std::invalid_argument{"font_height must be > 0"};
|
15
|
+
if (font_flags >= FF_COMBINATIONS) throw std::invalid_argument{"Invalid font_flags"};
|
16
|
+
|
17
|
+
TrueTypeFont& font = font_by_name(font_name, font_flags);
|
20
18
|
return font.draw_text(text, font_height, nullptr, 0, 0, Gosu::Color::NONE);
|
21
19
|
}
|
22
20
|
|
23
|
-
double Gosu::draw_text(Bitmap& bitmap, double x, double y, Color c, const u32string& text,
|
24
|
-
const string& font_name, double font_height, unsigned font_flags)
|
21
|
+
double Gosu::draw_text(Bitmap& bitmap, double x, double y, Color c, const std::u32string& text,
|
22
|
+
const std::string& font_name, double font_height, unsigned font_flags)
|
25
23
|
{
|
26
|
-
if (font_height <= 0) throw invalid_argument("font_height must be > 0");
|
27
|
-
if (font_flags >= FF_COMBINATIONS) throw invalid_argument("Invalid font_flags");
|
24
|
+
if (font_height <= 0) throw std::invalid_argument("font_height must be > 0");
|
25
|
+
if (font_flags >= FF_COMBINATIONS) throw std::invalid_argument("Invalid font_flags");
|
28
26
|
|
29
|
-
|
27
|
+
TrueTypeFont& font = font_by_name(font_name, font_flags);
|
30
28
|
return font.draw_text(text, font_height, &bitmap, x, y, c);
|
31
29
|
}
|
32
30
|
|
33
|
-
Gosu::Bitmap Gosu::layout_text(const string& text, const string& font_name,
|
31
|
+
Gosu::Bitmap Gosu::layout_text(const std::string& text, const std::string& font_name,
|
34
32
|
double font_height, double line_spacing,
|
35
33
|
int width, Alignment align, unsigned font_flags)
|
36
34
|
{
|
@@ -40,55 +38,56 @@ Gosu::Bitmap Gosu::layout_text(const string& text, const string& font_name,
|
|
40
38
|
width, align, font_flags);
|
41
39
|
}
|
42
40
|
|
43
|
-
Gosu::Bitmap Gosu::layout_markup(const string& markup, const string& font_name,
|
41
|
+
Gosu::Bitmap Gosu::layout_markup(const std::string& markup, const std::string& font_name,
|
44
42
|
double font_height, double line_spacing,
|
45
43
|
int width, Alignment align, unsigned font_flags)
|
46
44
|
{
|
47
|
-
if (font_height <= 0) throw invalid_argument
|
48
|
-
if (line_spacing < -font_height) throw invalid_argument
|
49
|
-
if (font_flags >= FF_COMBINATIONS) throw invalid_argument
|
45
|
+
if (font_height <= 0) throw std::invalid_argument{"font_height must be > 0"};
|
46
|
+
if (line_spacing < -font_height) throw std::invalid_argument{"line_spacing must be ≥ -font_height"};
|
47
|
+
if (font_flags >= FF_COMBINATIONS) throw std::invalid_argument{"Invalid font_flags"};
|
50
48
|
|
51
49
|
if (width >= 0) {
|
52
|
-
TextBuilder text_builder
|
50
|
+
TextBuilder text_builder{font_name, static_cast<int>(font_height),
|
51
|
+
static_cast<int>(line_spacing), width, align};
|
53
52
|
|
54
53
|
// Feed all formatted substrings to the TextBuilder, which will construct the result.
|
55
54
|
// Split the input string into words, because this method implements word-wrapping.
|
56
|
-
MarkupParser parser
|
55
|
+
MarkupParser parser{font_flags, true, [&text_builder](std::vector<FormattedString> word) {
|
57
56
|
text_builder.feed_word(move(word));
|
58
|
-
}
|
57
|
+
}};
|
59
58
|
parser.parse(markup);
|
60
59
|
|
61
60
|
return text_builder.move_into_bitmap();
|
62
61
|
}
|
63
62
|
else {
|
64
|
-
vector<vector<FormattedString>> lines;
|
63
|
+
std::vector<std::vector<FormattedString>> lines;
|
65
64
|
|
66
65
|
// Split the text into lines (split_words = false) since this method does not wrap lines.
|
67
|
-
MarkupParser parser
|
66
|
+
MarkupParser parser{font_flags, false, [&lines](std::vector<FormattedString>&& line) {
|
68
67
|
// Remove trailing \n characters from each line to avoid errors from Gosu::text_width().
|
69
|
-
if (line.back().text.back() == '\n') {
|
68
|
+
if (!line.back().text.empty() && line.back().text.back() == '\n') {
|
70
69
|
line.back().text.pop_back();
|
71
70
|
}
|
72
71
|
|
73
72
|
lines.emplace_back(line);
|
74
|
-
}
|
73
|
+
}};
|
75
74
|
parser.parse(markup);
|
76
75
|
|
77
76
|
if (lines.empty()) return Bitmap();
|
78
77
|
|
79
78
|
// Measure every part of every line.
|
80
|
-
vector<double> line_widths;
|
79
|
+
std::vector<double> line_widths;
|
81
80
|
double max_width = 0;
|
82
81
|
for (auto& line : lines) {
|
83
82
|
line_widths.push_back(0);
|
84
83
|
for (auto& part : line) {
|
85
84
|
line_widths.back() += text_width(part.text, font_name, font_height, part.flags);
|
86
85
|
}
|
87
|
-
max_width = max(max_width, line_widths.back());
|
86
|
+
max_width = std::max(max_width, line_widths.back());
|
88
87
|
}
|
89
88
|
|
90
|
-
double height = lines.size() * font_height + (lines.size() - 1) * line_spacing;
|
91
|
-
Bitmap result(ceil(max_width), ceil(height));
|
89
|
+
double height = lines.size() * font_height + (lines.size() - 1.0) * line_spacing;
|
90
|
+
Bitmap result{static_cast<int>(std::ceil(max_width)), static_cast<int>(std::ceil(height))};
|
92
91
|
|
93
92
|
// Render every part of every line.
|
94
93
|
double y = 0;
|
data/src/TrueTypeFont.cpp
CHANGED
@@ -182,7 +182,7 @@ struct Gosu::TrueTypeFont::Impl
|
|
182
182
|
for (int rel_y = 0; rel_y < h; ++rel_y) {
|
183
183
|
for (int rel_x = 0; rel_x < w; ++rel_x) {
|
184
184
|
int pixel = pixels[(src_y + rel_y) * stride + src_x + rel_x];
|
185
|
-
Color c_with_alpha(pixel * c.alpha
|
185
|
+
Color c_with_alpha = c.with_alpha(pixel * c.alpha / 255);
|
186
186
|
bitmap.blend_pixel(x + rel_x, y + rel_y, c_with_alpha);
|
187
187
|
}
|
188
188
|
}
|
data/src/TrueTypeFontApple.cpp
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
#include "TrueTypeFont.hpp"
|
5
5
|
#include "Log.hpp"
|
6
6
|
|
7
|
-
#include <Gosu/IO.hpp>
|
8
7
|
#include <Gosu/Text.hpp>
|
9
8
|
|
10
9
|
#import <CoreText/CoreText.h>
|
@@ -24,8 +23,8 @@ const unsigned char* Gosu::ttf_data_by_name(const string& font_name, unsigned fo
|
|
24
23
|
log("Trying to find a font named '%s', flags=%x", font_name.c_str(), font_flags);
|
25
24
|
|
26
25
|
unsigned symbolic_traits = 0;
|
27
|
-
if (font_flags & Gosu::FF_BOLD) symbolic_traits |=
|
28
|
-
if (font_flags & Gosu::FF_ITALIC) symbolic_traits |=
|
26
|
+
if (font_flags & Gosu::FF_BOLD) symbolic_traits |= kCTFontTraitBold;
|
27
|
+
if (font_flags & Gosu::FF_ITALIC) symbolic_traits |= kCTFontTraitItalic;
|
29
28
|
|
30
29
|
NSDictionary *attributes = @{
|
31
30
|
((__bridge id) kCTFontNameAttribute): [NSString stringWithUTF8String:font_name.c_str()],
|
@@ -39,6 +38,14 @@ const unsigned char* Gosu::ttf_data_by_name(const string& font_name, unsigned fo
|
|
39
38
|
if (descriptor) {
|
40
39
|
CTFontRef font = CTFontCreateWithFontDescriptorAndOptions(descriptor, 20, nullptr, 0);
|
41
40
|
if (font) {
|
41
|
+
if ((CTFontGetSymbolicTraits(font) & symbolic_traits) != symbolic_traits) {
|
42
|
+
// For some reason the initial call to CTFontCreateWithFontDescriptorAndOptions does
|
43
|
+
// not respect the requested font traits. Explicitly requesting the traits again
|
44
|
+
// seems to help. Tested on macOS 11.2.2.
|
45
|
+
CTFontRef correct_font = CTFontCreateCopyWithSymbolicTraits(font, 0.0, nullptr, symbolic_traits, symbolic_traits);
|
46
|
+
CFRelease(font);
|
47
|
+
font = correct_font;
|
48
|
+
}
|
42
49
|
NSURL *url = CFBridgingRelease(CTFontCopyAttribute(font, kCTFontURLAttribute));
|
43
50
|
if (url && url.fileSystemRepresentation) {
|
44
51
|
log("Loading file '%s'", url.fileSystemRepresentation);
|
data/src/Utility.cpp
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
#include <Gosu/Utility.hpp>
|
2
1
|
#include <Gosu/Platform.hpp>
|
2
|
+
#include <Gosu/Utility.hpp>
|
3
3
|
|
4
4
|
#include <utf8proc.h>
|
5
5
|
|
6
6
|
#include <cstring>
|
7
|
+
#include <memory>
|
7
8
|
#include <stdexcept>
|
8
|
-
using namespace std;
|
9
9
|
|
10
|
-
u32string Gosu::utf8_to_composed_utc4(const string& utf8)
|
10
|
+
std::u32string Gosu::utf8_to_composed_utc4(const std::string& utf8)
|
11
11
|
{
|
12
|
-
u32string utc4;
|
12
|
+
std::u32string utc4;
|
13
13
|
utc4.reserve(utf8.size());
|
14
|
-
|
15
|
-
auto* current_byte = reinterpret_cast<const utf8proc_uint8_t*>(utf8.data());
|
14
|
+
|
15
|
+
const auto* current_byte = reinterpret_cast<const utf8proc_uint8_t*>(utf8.data());
|
16
16
|
auto remaining_length = utf8.length();
|
17
|
-
|
17
|
+
|
18
18
|
// First convert from UTF-8 to UTC-4.
|
19
19
|
utf8proc_int32_t codepoint;
|
20
20
|
while (remaining_length) {
|
@@ -30,35 +30,35 @@ u32string Gosu::utf8_to_composed_utc4(const string& utf8)
|
|
30
30
|
remaining_length -= bytes_read;
|
31
31
|
}
|
32
32
|
}
|
33
|
-
|
33
|
+
|
34
34
|
// Now compose characters in-place.
|
35
|
-
auto utc4_data = reinterpret_cast<
|
36
|
-
// Note that this const_cast will not be necessary anymore in C++17.
|
37
|
-
auto writable_utc4_data = const_cast<utf8proc_int32_t*>(utc4_data);
|
35
|
+
auto* utc4_data = reinterpret_cast<utf8proc_int32_t*>(utc4.data());
|
38
36
|
auto options = static_cast<utf8proc_option_t>(UTF8PROC_NLF2LF | UTF8PROC_COMPOSE);
|
39
|
-
auto new_length = utf8proc_normalize_utf32(
|
37
|
+
auto new_length = utf8proc_normalize_utf32(utc4_data, utc4.length(), options);
|
40
38
|
if (new_length < 0) {
|
41
|
-
throw runtime_error
|
39
|
+
throw std::runtime_error{"Could not normalize '" + utf8 +
|
40
|
+
"': " + utf8proc_errmsg(new_length)};
|
42
41
|
}
|
43
42
|
utc4.resize(new_length);
|
44
|
-
|
43
|
+
|
45
44
|
return utc4;
|
46
45
|
}
|
47
46
|
|
48
|
-
bool Gosu::has_extension(string_view filename, string_view extension)
|
47
|
+
bool Gosu::has_extension(std::string_view filename, std::string_view extension)
|
49
48
|
{
|
50
|
-
size_t ext_len = extension.length();
|
49
|
+
std::size_t ext_len = extension.length();
|
51
50
|
if (ext_len > filename.length()) {
|
52
51
|
return false;
|
53
52
|
}
|
54
53
|
|
55
|
-
string_view::iterator filename_iter = filename.end();
|
56
|
-
string_view::iterator ext_iter = extension.end();
|
54
|
+
std::string_view::iterator filename_iter = filename.end();
|
55
|
+
std::string_view::iterator ext_iter = extension.end();
|
57
56
|
while (ext_len--) {
|
58
57
|
--filename_iter;
|
59
58
|
--ext_iter;
|
60
59
|
|
61
|
-
if (tolower((
|
60
|
+
if (std::tolower(static_cast<int>(*filename_iter)) !=
|
61
|
+
std::tolower(static_cast<int>(*ext_iter))) {
|
62
62
|
return false;
|
63
63
|
}
|
64
64
|
}
|
@@ -66,10 +66,69 @@ bool Gosu::has_extension(string_view filename, string_view extension)
|
|
66
66
|
return true;
|
67
67
|
}
|
68
68
|
|
69
|
-
#
|
70
|
-
|
69
|
+
#ifdef GOSU_IS_IPHONE
|
70
|
+
#import <Foundation/Foundation.h>
|
71
|
+
#include <regex>
|
72
|
+
|
73
|
+
std::vector<std::string> Gosu::user_languages()
|
71
74
|
{
|
72
|
-
const
|
73
|
-
|
75
|
+
static const std::regex language_regex{"([a-z]{2})-([A-Z]{2})([^A-Z].*)?"};
|
76
|
+
|
77
|
+
std::vector<std::string> user_languages;
|
78
|
+
|
79
|
+
@autoreleasepool {
|
80
|
+
for (NSString* language in [NSLocale preferredLanguages]) {
|
81
|
+
std::string language_str = language.UTF8String;
|
82
|
+
std::smatch match;
|
83
|
+
if (std::regex_match(language_str, match, language_regex)) {
|
84
|
+
user_languages.push_back(match.str(1) + "_" + match.str(2));
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
return user_languages;
|
74
90
|
}
|
91
|
+
|
92
|
+
#else
|
93
|
+
#include <SDL.h>
|
94
|
+
#if SDL_VERSION_ATLEAST(2, 0, 14)
|
95
|
+
|
96
|
+
std::vector<std::string> Gosu::user_languages()
|
97
|
+
{
|
98
|
+
std::vector<std::string> user_languages;
|
99
|
+
|
100
|
+
std::unique_ptr<SDL_Locale, decltype(SDL_free)*> locales{SDL_GetPreferredLocales(), SDL_free};
|
101
|
+
if (!locales) return user_languages;
|
102
|
+
|
103
|
+
for (const SDL_Locale* locale = locales.get(); locale->language != nullptr; ++locale) {
|
104
|
+
std::string language = locale->language;
|
105
|
+
if (locale->country) {
|
106
|
+
language += "_";
|
107
|
+
language += locale->country;
|
108
|
+
}
|
109
|
+
user_languages.emplace_back(std::move(language));
|
110
|
+
}
|
111
|
+
|
112
|
+
return user_languages;
|
113
|
+
}
|
114
|
+
|
115
|
+
#else
|
116
|
+
#include <cstdlib>
|
117
|
+
#include <regex>
|
118
|
+
|
119
|
+
std::vector<std::string> Gosu::user_languages()
|
120
|
+
{
|
121
|
+
static const std::regex language_regex{"[a-z]{2}_[A-Z]{2}([^A-Z].*)?"};
|
122
|
+
|
123
|
+
const char* locale = std::getenv("LANG");
|
124
|
+
|
125
|
+
if (locale && std::regex_match(locale, language_regex)) {
|
126
|
+
// Trim off anything after the language code.
|
127
|
+
return {std::string{locale, locale + 5}};
|
128
|
+
}
|
129
|
+
|
130
|
+
return {};
|
131
|
+
}
|
132
|
+
|
133
|
+
#endif
|
75
134
|
#endif
|
data/src/WinUtility.hpp
CHANGED
@@ -12,7 +12,8 @@ namespace Gosu
|
|
12
12
|
|
13
13
|
//! Throws an exception according to the error returned by GetLastError(), optionally prefixed
|
14
14
|
//! with "While (action), the following error occured: ".
|
15
|
-
|
15
|
+
[[noreturn]]
|
16
|
+
void throw_last_winapi_error(const std::string& action = "");
|
16
17
|
|
17
18
|
//! Small helper function that throws the last Windows error when val_to_check is false.
|
18
19
|
template<typename T>
|
data/src/Window.cpp
CHANGED
@@ -34,11 +34,7 @@ namespace Gosu
|
|
34
34
|
throw_sdl_error("Could not initialize SDL Video");
|
35
35
|
}
|
36
36
|
|
37
|
-
Uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN;
|
38
|
-
|
39
|
-
#if SDL_VERSION_ATLEAST(2, 0, 1)
|
40
|
-
flags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
41
|
-
#endif
|
37
|
+
Uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN | SDL_WINDOW_ALLOW_HIGHDPI;
|
42
38
|
|
43
39
|
window =
|
44
40
|
SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 64, 64, flags);
|
@@ -192,9 +188,7 @@ void Gosu::Window::resize(int width, int height, bool fullscreen)
|
|
192
188
|
SDL_SetWindowSize(shared_window(), actual_width, actual_height);
|
193
189
|
}
|
194
190
|
|
195
|
-
#if SDL_VERSION_ATLEAST(2, 0, 1)
|
196
191
|
SDL_GL_GetDrawableSize(shared_window(), &actual_width, &actual_height);
|
197
|
-
#endif
|
198
192
|
|
199
193
|
ensure_current_context();
|
200
194
|
|
@@ -221,9 +215,7 @@ bool Gosu::Window::resizable() const
|
|
221
215
|
void Gosu::Window::set_resizable(bool resizable)
|
222
216
|
{
|
223
217
|
pimpl->resizable = resizable;
|
224
|
-
#if SDL_VERSION_ATLEAST(2, 0, 5)
|
225
218
|
SDL_SetWindowResizable(shared_window(), resizable ? SDL_TRUE : SDL_FALSE);
|
226
|
-
#endif
|
227
219
|
}
|
228
220
|
|
229
221
|
bool Gosu::Window::borderless() const
|
@@ -325,6 +317,14 @@ bool Gosu::Window::tick()
|
|
325
317
|
}
|
326
318
|
break;
|
327
319
|
}
|
320
|
+
case SDL_WINDOWEVENT_FOCUS_GAINED: {
|
321
|
+
gain_focus();
|
322
|
+
break;
|
323
|
+
}
|
324
|
+
case SDL_WINDOWEVENT_FOCUS_LOST: {
|
325
|
+
lose_focus();
|
326
|
+
break;
|
327
|
+
}
|
328
328
|
default: {
|
329
329
|
break;
|
330
330
|
}
|
data/src/WindowUIKit.cpp
CHANGED
@@ -25,8 +25,8 @@ Gosu::Window::Window(int width, int height, unsigned window_flags, double update
|
|
25
25
|
pimpl->controller.gosuWindow = this;
|
26
26
|
pimpl->window.rootViewController = pimpl->controller;
|
27
27
|
|
28
|
-
// It is important to load the view before creating the Graphics instance.
|
29
|
-
[pimpl->controller
|
28
|
+
// It is important to (implicitly) load the view before creating the Graphics instance.
|
29
|
+
[pimpl->controller view];
|
30
30
|
|
31
31
|
pimpl->graphics.reset(new Graphics(screen_width(), screen_height()));
|
32
32
|
pimpl->graphics->set_resolution(width, height);
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gosu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Raschke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
2D game development library.
|
@@ -286,8 +286,6 @@ files:
|
|
286
286
|
- src/TrueTypeFontUnix.cpp
|
287
287
|
- src/TrueTypeFontWin.cpp
|
288
288
|
- src/Utility.cpp
|
289
|
-
- src/UtilityApple.cpp
|
290
|
-
- src/UtilityWin.cpp
|
291
289
|
- src/Version.cpp
|
292
290
|
- src/WinUtility.cpp
|
293
291
|
- src/WinUtility.hpp
|
@@ -312,11 +310,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
312
310
|
version: 2.5.0
|
313
311
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
314
312
|
requirements:
|
315
|
-
- - "
|
313
|
+
- - ">="
|
316
314
|
- !ruby/object:Gem::Version
|
317
|
-
version:
|
315
|
+
version: '0'
|
318
316
|
requirements: []
|
319
|
-
rubygems_version: 3.2.
|
317
|
+
rubygems_version: 3.2.22
|
320
318
|
signing_key:
|
321
319
|
specification_version: 4
|
322
320
|
summary: 2D game development library.
|
data/src/UtilityApple.cpp
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#include <Gosu/Platform.hpp>
|
2
|
-
#if defined(GOSU_IS_MAC)
|
3
|
-
|
4
|
-
#import <Gosu/Utility.hpp>
|
5
|
-
#import <Foundation/Foundation.h>
|
6
|
-
using namespace std;
|
7
|
-
|
8
|
-
string Gosu::language()
|
9
|
-
{
|
10
|
-
@autoreleasepool {
|
11
|
-
NSString* language = [NSLocale preferredLanguages][0];
|
12
|
-
return language.UTF8String ?: "en";
|
13
|
-
}
|
14
|
-
}
|
15
|
-
|
16
|
-
#endif
|
data/src/UtilityWin.cpp
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
#include <Gosu/Platform.hpp>
|
2
|
-
#if defined(GOSU_IS_WIN)
|
3
|
-
|
4
|
-
#include <Gosu/Utility.hpp>
|
5
|
-
#include "WinUtility.hpp"
|
6
|
-
#include <windows.h>
|
7
|
-
using namespace std;
|
8
|
-
|
9
|
-
string Gosu::language()
|
10
|
-
{
|
11
|
-
LCID lcid = GetUserDefaultLCID();
|
12
|
-
char buffer[9];
|
13
|
-
winapi_check(GetLocaleInfoA(lcid, LOCALE_SISO639LANGNAME, buffer, sizeof buffer));
|
14
|
-
return buffer;
|
15
|
-
}
|
16
|
-
|
17
|
-
#endif
|