gosu 0.14.0.pre2 → 0.14.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/Gosu/Bitmap.hpp +4 -0
- data/Gosu/Font.hpp +29 -34
- data/Gosu/Text.hpp +19 -8
- data/Gosu/Utility.hpp +0 -5
- data/Gosu/Version.hpp +2 -2
- data/Gosu/Window.hpp +23 -16
- data/lib/gosu/compat.rb +17 -4
- data/lib/gosu/patches.rb +16 -0
- data/rdoc/gosu.rb +33 -9
- data/src/Bitmap.cpp +20 -0
- data/src/DirectoriesWin.cpp +3 -3
- data/src/DrawOpQueue.hpp +2 -1
- data/src/FileWin.cpp +87 -87
- data/src/Font.cpp +51 -31
- data/src/Graphics.cpp +1 -1
- data/src/GraphicsImpl.hpp +19 -0
- data/src/Input.cpp +30 -12
- data/src/MarkupParser.cpp +11 -8
- data/src/MarkupParser.hpp +2 -2
- data/src/Resolution.cpp +81 -50
- data/src/RubyGosu.cxx +285 -480
- data/src/Text.cpp +77 -50
- data/src/TextBuilder.cpp +1 -1
- data/src/TimingUnix.cpp +1 -1
- data/src/TrueTypeFont.cpp +26 -27
- data/src/TrueTypeFont.hpp +2 -1
- data/src/TrueTypeFontUnix.cpp +1 -1
- data/src/TrueTypeFontWin.cpp +4 -4
- data/src/Utility.cpp +0 -54
- data/src/UtilityApple.cpp +0 -35
- data/src/WinUtility.cpp +60 -41
- data/src/WinUtility.hpp +5 -0
- data/src/Window.cpp +19 -7
- data/src/WindowUIKit.cpp +26 -30
- metadata +4 -5
- data/src/ResolutionApple.cpp +0 -25
data/src/WinUtility.hpp
CHANGED
@@ -5,6 +5,11 @@
|
|
5
5
|
|
6
6
|
namespace Gosu
|
7
7
|
{
|
8
|
+
//! Converts UTF-8 to UTF-16, as it is used in Windows APIs.
|
9
|
+
std::wstring utf8_to_utf16(const std::string& utf8);
|
10
|
+
//! Converts UTF-16 to UTF-8.
|
11
|
+
std::string utf16_to_utf8(const std::wstring& utf16);
|
12
|
+
|
8
13
|
//! Throws an exception according to the error returned by GetLastError(), optionally prefixed
|
9
14
|
//! with "While (action), the following error occured: ".
|
10
15
|
GOSU_NORETURN void throw_last_winapi_error(const std::string& action = "");
|
data/src/Window.cpp
CHANGED
@@ -24,7 +24,7 @@ namespace Gosu
|
|
24
24
|
|
25
25
|
static void cleanup();
|
26
26
|
|
27
|
-
|
27
|
+
SDL_Window* shared_window()
|
28
28
|
{
|
29
29
|
static SDL_Window* window = nullptr;
|
30
30
|
if (window == nullptr) {
|
@@ -148,8 +148,8 @@ void Gosu::Window::resize(unsigned width, unsigned height, bool fullscreen)
|
|
148
148
|
double black_bar_height = 0;
|
149
149
|
|
150
150
|
if (fullscreen) {
|
151
|
-
actual_width
|
152
|
-
actual_height = Gosu::screen_height();
|
151
|
+
actual_width = Gosu::screen_width(this);
|
152
|
+
actual_height = Gosu::screen_height(this);
|
153
153
|
|
154
154
|
double scale_x = 1.0 * actual_width / width;
|
155
155
|
double scale_y = 1.0 * actual_height / height;
|
@@ -163,8 +163,8 @@ void Gosu::Window::resize(unsigned width, unsigned height, bool fullscreen)
|
|
163
163
|
}
|
164
164
|
}
|
165
165
|
else {
|
166
|
-
double max_width
|
167
|
-
double max_height = Gosu::available_height();
|
166
|
+
double max_width = Gosu::available_width(this);
|
167
|
+
double max_height = Gosu::available_height(this);
|
168
168
|
|
169
169
|
if (width > max_width || height > max_height) {
|
170
170
|
scale_factor = min(max_width / width, max_height / height);
|
@@ -257,11 +257,23 @@ bool Gosu::Window::tick()
|
|
257
257
|
SDL_Event e;
|
258
258
|
while (SDL_PollEvent(&e)) {
|
259
259
|
switch (e.type) {
|
260
|
-
|
260
|
+
#ifdef GOSU_IS_MAC
|
261
|
+
// Workaround for https://github.com/gosu/gosu/issues/458
|
262
|
+
// "Resize" the window to its current dimensions after it is shown.
|
263
|
+
// Otherwise it will be black on macOS 10.14 (Mojave) until the user moves it around.
|
264
|
+
// TODO: Since this affects `brew install supertux` as well, maybe file an SDL bug?
|
265
|
+
case SDL_WINDOWEVENT: {
|
266
|
+
if (e.window.event == SDL_WINDOWEVENT_SHOWN) {
|
267
|
+
resize(this->width(), this->height(), fullscreen());
|
268
|
+
}
|
269
|
+
break;
|
270
|
+
}
|
271
|
+
#endif
|
272
|
+
case SDL_QUIT: {
|
261
273
|
close();
|
262
274
|
break;
|
263
275
|
}
|
264
|
-
case
|
276
|
+
case SDL_DROPFILE: {
|
265
277
|
char* dropped_filedir = e.drop.file;
|
266
278
|
if (dropped_filedir == nullptr) break;
|
267
279
|
drop(string(dropped_filedir));
|
data/src/WindowUIKit.cpp
CHANGED
@@ -6,34 +6,6 @@
|
|
6
6
|
|
7
7
|
using namespace std;
|
8
8
|
|
9
|
-
|
10
|
-
namespace Gosu
|
11
|
-
{
|
12
|
-
unsigned screen_width()
|
13
|
-
{
|
14
|
-
static CGSize screen_size = [UIScreen mainScreen].bounds.size;
|
15
|
-
static CGFloat width = MIN(screen_size.width, screen_size.height);
|
16
|
-
return width;
|
17
|
-
}
|
18
|
-
|
19
|
-
unsigned screen_height()
|
20
|
-
{
|
21
|
-
static CGSize screen_size = [UIScreen mainScreen].bounds.size;
|
22
|
-
static CGFloat width = MAX(screen_size.width, screen_size.height);
|
23
|
-
return width;
|
24
|
-
}
|
25
|
-
|
26
|
-
unsigned available_width()
|
27
|
-
{
|
28
|
-
return screen_width();
|
29
|
-
}
|
30
|
-
|
31
|
-
unsigned available_height()
|
32
|
-
{
|
33
|
-
return screen_height();
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
9
|
struct Gosu::Window::Impl
|
38
10
|
{
|
39
11
|
UIWindow* window;
|
@@ -57,11 +29,11 @@ Gosu::Window::Window(unsigned width, unsigned height, bool fullscreen, double up
|
|
57
29
|
// It is important to load the view before creating the Graphics instance.
|
58
30
|
[pimpl->controller loadView];
|
59
31
|
|
60
|
-
pimpl->graphics.reset(new Graphics(
|
32
|
+
pimpl->graphics.reset(new Graphics(screen_width(), screen_height()));
|
61
33
|
pimpl->graphics->set_resolution(width, height);
|
62
34
|
|
63
35
|
pimpl->input.reset(new Input((__bridge void*) pimpl->controller.view, update_interval));
|
64
|
-
pimpl->input->set_mouse_factors(1.0 * width /
|
36
|
+
pimpl->input->set_mouse_factors(1.0 * width / available_width(), 1.0 * height / available_height());
|
65
37
|
|
66
38
|
pimpl->input->on_touch_began = [this](Gosu::Touch touch) { touch_began(touch); };
|
67
39
|
pimpl->input->on_touch_moved = [this](Gosu::Touch touch) { touch_moved(touch); };
|
@@ -162,4 +134,28 @@ void* Gosu::Window::uikit_window() const
|
|
162
134
|
return (__bridge void*) pimpl->window;
|
163
135
|
}
|
164
136
|
|
137
|
+
unsigned Gosu::screen_width(Window*)
|
138
|
+
{
|
139
|
+
return available_width() * [UIScreen mainScreen].scale;
|
140
|
+
}
|
141
|
+
|
142
|
+
unsigned Gosu::screen_height(Window*)
|
143
|
+
{
|
144
|
+
return available_height() * [UIScreen mainScreen].scale;
|
145
|
+
}
|
146
|
+
|
147
|
+
unsigned Gosu::available_width(Window*)
|
148
|
+
{
|
149
|
+
static CGSize screen_size = [UIScreen mainScreen].bounds.size;
|
150
|
+
static CGFloat width = MAX(screen_size.width, screen_size.height);
|
151
|
+
return width;
|
152
|
+
}
|
153
|
+
|
154
|
+
unsigned Gosu::available_height(Window*)
|
155
|
+
{
|
156
|
+
static CGSize screen_size = [UIScreen mainScreen].bounds.size;
|
157
|
+
static CGFloat height = MIN(screen_size.width, screen_size.height);
|
158
|
+
return height;
|
159
|
+
}
|
160
|
+
|
165
161
|
#endif
|
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: 0.14.0
|
4
|
+
version: 0.14.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: 2018-
|
11
|
+
date: 2018-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
2D game development library.
|
@@ -106,7 +106,6 @@ files:
|
|
106
106
|
- src/OggFile.hpp
|
107
107
|
- src/RenderState.hpp
|
108
108
|
- src/Resolution.cpp
|
109
|
-
- src/ResolutionApple.cpp
|
110
109
|
- src/RubyGosu.cxx
|
111
110
|
- src/RubyGosu.h
|
112
111
|
- src/SndFile.hpp
|
@@ -163,9 +162,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
163
162
|
version: 1.9.3
|
164
163
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
164
|
requirements:
|
166
|
-
- - "
|
165
|
+
- - ">="
|
167
166
|
- !ruby/object:Gem::Version
|
168
|
-
version:
|
167
|
+
version: '0'
|
169
168
|
requirements: []
|
170
169
|
rubyforge_project:
|
171
170
|
rubygems_version: 2.7.6
|
data/src/ResolutionApple.cpp
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
#include <Gosu/Platform.hpp>
|
2
|
-
#if defined(GOSU_IS_MAC) && !defined(GOSU_IS_IPHONE)
|
3
|
-
|
4
|
-
#import <Gosu/Gosu.hpp>
|
5
|
-
#import <AppKit/AppKit.h>
|
6
|
-
|
7
|
-
static const NSUInteger STYLE_MASK_FROM_SDL2 =
|
8
|
-
NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask;
|
9
|
-
|
10
|
-
static const NSRect available_frame = [[NSScreen screens][0] visibleFrame];
|
11
|
-
|
12
|
-
static const NSRect available_content_frame =
|
13
|
-
[NSWindow contentRectForFrameRect:available_frame styleMask:STYLE_MASK_FROM_SDL2];
|
14
|
-
|
15
|
-
unsigned Gosu::available_width()
|
16
|
-
{
|
17
|
-
return available_content_frame.size.width;
|
18
|
-
}
|
19
|
-
|
20
|
-
unsigned Gosu::available_height()
|
21
|
-
{
|
22
|
-
return available_content_frame.size.height;
|
23
|
-
}
|
24
|
-
|
25
|
-
#endif
|