sfml.js 0.0.1-preview.45 → 0.0.1-preview.46
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.
- package/README.md +2 -1
- package/lib/clock.d.ts +1 -1
- package/lib/drawable/text.js +1 -1
- package/package.json +1 -1
- package/src/clock.cc +10 -1
- package/src/font.cc +7 -1
- package/src/font.h +1 -0
- package/src/texture.cc +4 -4
- package/src/time.cc +1 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Node.js binding for <a href="https://www.sfml-dev.org/">SFML</a> - a Simple and
|
|
|
15
15
|
</a>
|
|
16
16
|
<!-- [](https://www.npmjs.org/package/sfml.js) -->
|
|
17
17
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
18
|
-
<a href="#contributors-"><img src="https://img.shields.io/badge/
|
|
18
|
+
<a href="#contributors-"><img src="https://img.shields.io/badge/3-ALL%20CONTRIBUTORS?style=for-the-badge&colorA=FF69b4&colorB=cc47a4&label=ALL%20CONTRIBUTORS" />
|
|
19
19
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
20
20
|
<a href="https://github.com/XadillaX/node-sfml">
|
|
21
21
|
<img src="https://img.shields.io/github/stars/XadillaX/node-sfml.svg?style=for-the-badge&colorA=FBBD30&colorB=F2AA08&label=STAR" />
|
|
@@ -52,6 +52,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
52
52
|
<tr>
|
|
53
53
|
<td align="center"><a href="https://xcoder.in/"><img src="https://avatars.githubusercontent.com/u/2842176?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Khaidi Chu</b></sub></a><br /><a href="#maintenance-XadillaX" title="Maintenance">🚧</a> <a href="https://github.com/XadillaX/node-sfml/commits?author=XadillaX" title="Code">💻</a></td>
|
|
54
54
|
<td align="center"><a href="https://pokemonworkshop.com/forum"><img src="https://avatars.githubusercontent.com/u/7335788?v=4?s=100" width="100px;" alt=""/><br /><sub><b>NuriYuri</b></sub></a><br /><a href="https://github.com/XadillaX/node-sfml/commits?author=NuriYuri" title="Code">💻</a></td>
|
|
55
|
+
<td align="center"><a href="https://godot.id"><img src="https://avatars.githubusercontent.com/u/40712686?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Hanz</b></sub></a><br /><a href="https://github.com/XadillaX/node-sfml/commits?author=HanzCEO" title="Code">💻</a></td>
|
|
55
56
|
</tr>
|
|
56
57
|
</table>
|
|
57
58
|
|
package/lib/clock.d.ts
CHANGED
package/lib/drawable/text.js
CHANGED
package/package.json
CHANGED
package/src/clock.cc
CHANGED
|
@@ -52,7 +52,16 @@ NAN_METHOD(Clock::GetElapsedTime) {
|
|
|
52
52
|
|
|
53
53
|
NAN_METHOD(Clock::Restart) {
|
|
54
54
|
Clock* clock = Nan::ObjectWrap::Unwrap<Clock>(info.Holder());
|
|
55
|
-
clock->_clock.restart();
|
|
55
|
+
sf::Time time = clock->_clock.restart();
|
|
56
|
+
Nan::TryCatch try_catch;
|
|
57
|
+
MaybeLocal<Object> time_wrap =
|
|
58
|
+
time::Time::NewInstance(info.GetIsolate(), time);
|
|
59
|
+
if (time_wrap.IsEmpty()) {
|
|
60
|
+
try_catch.ReThrow();
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
info.GetReturnValue().Set(time_wrap.ToLocalChecked());
|
|
56
65
|
}
|
|
57
66
|
|
|
58
67
|
Clock::Clock() : _clock() {}
|
package/src/font.cc
CHANGED
|
@@ -61,6 +61,7 @@ NAN_METHOD(Font::LoadFromFile) {
|
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
font->_related_buffer.Reset();
|
|
64
65
|
font->_loading = true;
|
|
65
66
|
Local<String> v8_filename = info[0].As<String>();
|
|
66
67
|
Nan::Utf8String utf8_filename(v8_filename);
|
|
@@ -78,6 +79,7 @@ NAN_METHOD(Font::LoadFromFile) {
|
|
|
78
79
|
|
|
79
80
|
NAN_METHOD(Font::LoadFromFileSync) {
|
|
80
81
|
Font* font = Nan::ObjectWrap::Unwrap<Font>(info.Holder());
|
|
82
|
+
font->_related_buffer.Reset();
|
|
81
83
|
Nan::Utf8String filename(info[0].As<String>());
|
|
82
84
|
info.GetReturnValue().Set(font->_font->loadFromFile(*filename));
|
|
83
85
|
}
|
|
@@ -89,6 +91,7 @@ NAN_METHOD(Font::LoadFromMemory) {
|
|
|
89
91
|
return;
|
|
90
92
|
}
|
|
91
93
|
|
|
94
|
+
fnt->_related_buffer.Reset(info[0].As<Object>());
|
|
92
95
|
const char* buff = node::Buffer::Data(info[0]);
|
|
93
96
|
size_t length = node::Buffer::Length(info[0]);
|
|
94
97
|
info.GetReturnValue().Set(fnt->_font->loadFromMemory(buff, length));
|
|
@@ -195,9 +198,12 @@ NAN_METHOD(Font::GetUnderlineThickness) {
|
|
|
195
198
|
}
|
|
196
199
|
|
|
197
200
|
Font::Font() : _font(new sf::Font()) {}
|
|
198
|
-
Font::Font(const sf::Font& copy) : _font(new sf::Font(copy)) {
|
|
201
|
+
Font::Font(const sf::Font& copy) : _font(new sf::Font(copy)) {
|
|
202
|
+
_related_buffer.Reset();
|
|
203
|
+
}
|
|
199
204
|
|
|
200
205
|
Font::~Font() {
|
|
206
|
+
_related_buffer.Reset();
|
|
201
207
|
if (_font != nullptr) {
|
|
202
208
|
delete _font;
|
|
203
209
|
_font = nullptr;
|
package/src/font.h
CHANGED
package/src/texture.cc
CHANGED
|
@@ -189,16 +189,16 @@ NAN_METHOD(Texture::UpdateByPixels) {
|
|
|
189
189
|
size_t x = 0;
|
|
190
190
|
size_t y = 0;
|
|
191
191
|
if (!info[1]->IsUndefined()) {
|
|
192
|
-
width = Nan::To<sf::Uint32>(info[
|
|
192
|
+
width = Nan::To<sf::Uint32>(info[1]).FromJust();
|
|
193
193
|
}
|
|
194
194
|
if (!info[2]->IsUndefined()) {
|
|
195
|
-
height = Nan::To<sf::Uint32>(info[
|
|
195
|
+
height = Nan::To<sf::Uint32>(info[2]).FromJust();
|
|
196
196
|
}
|
|
197
197
|
if (!info[3]->IsUndefined()) {
|
|
198
|
-
x = Nan::To<sf::Uint32>(info[
|
|
198
|
+
x = Nan::To<sf::Uint32>(info[3]).FromJust();
|
|
199
199
|
}
|
|
200
200
|
if (!info[4]->IsUndefined()) {
|
|
201
|
-
y = Nan::To<sf::Uint32>(info[
|
|
201
|
+
y = Nan::To<sf::Uint32>(info[4]).FromJust();
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
Local<Object> buffer_object = info[0].As<Object>();
|
package/src/time.cc
CHANGED
|
@@ -70,7 +70,7 @@ MaybeLocal<Object> Time::NewInstance(Isolate* isolate, const sf::Time& src) {
|
|
|
70
70
|
Time* time_wrap = Nan::ObjectWrap::Unwrap<Time>(time);
|
|
71
71
|
memcpy(&time_wrap->_time, &src, sizeof(sf::Time));
|
|
72
72
|
|
|
73
|
-
return time;
|
|
73
|
+
return scope.Escape(time);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
NAN_METHOD(Time::New) {
|