sfml.js 0.0.1-preview.3 → 0.0.1-preview.30
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/binding.gyp +115 -0
- package/index.d.ts +1 -0
- package/lib/clock.d.ts +1 -3
- package/lib/clock.js +3 -1
- package/lib/color.d.ts +2 -2
- package/lib/color.js +1 -1
- package/lib/common.js +33 -7
- package/lib/drawable/circle_shape.d.ts +2 -2
- package/lib/drawable/circle_shape.js +3 -3
- package/lib/drawable/convex_shape.d.ts +5 -0
- package/lib/drawable/convex_shape.js +35 -0
- package/lib/drawable/drawable.d.ts +6 -0
- package/lib/drawable/{base.js → drawable.js} +7 -4
- package/lib/drawable/plugin_package.d.ts +31 -0
- package/lib/drawable/plugin_package.js +102 -0
- package/lib/drawable/rectangle_shape.d.ts +6 -3
- package/lib/drawable/rectangle_shape.js +14 -2
- package/lib/drawable/shape.d.ts +8 -32
- package/lib/drawable/shape.js +16 -115
- package/lib/drawable/sprite.d.ts +15 -0
- package/lib/drawable/sprite.js +48 -0
- package/lib/drawable/text.d.ts +26 -0
- package/lib/drawable/text.js +88 -0
- package/lib/drawable/transformable.d.ts +28 -0
- package/lib/drawable/transformable.js +113 -0
- package/lib/font.d.ts +23 -0
- package/lib/font.js +132 -0
- package/lib/image.d.ts +3 -0
- package/lib/image.js +10 -0
- package/lib/keyboard.d.ts +2 -0
- package/lib/keyboard.js +12 -0
- package/lib/mouse.d.ts +6 -0
- package/lib/mouse.js +39 -0
- package/lib/poll_event.d.ts +2 -4
- package/lib/rect.d.ts +1 -1
- package/lib/rect.js +1 -1
- package/lib/render_window.d.ts +25 -14
- package/lib/render_window.js +54 -6
- package/lib/sfml.d.ts +26 -0
- package/lib/sfml.js +20 -9
- package/lib/sound/base.d.ts +33 -0
- package/lib/sound/base.js +109 -0
- package/lib/sound/music.d.ts +14 -0
- package/lib/sound/music.js +59 -0
- package/lib/sound/sound.d.ts +16 -0
- package/lib/sound/sound.js +55 -0
- package/lib/sound/sound_buffer.d.ts +14 -0
- package/lib/sound/sound_buffer.js +78 -0
- package/lib/texture.d.ts +19 -0
- package/lib/texture.js +102 -0
- package/lib/time.d.ts +2 -2
- package/lib/vector2.d.ts +24 -0
- package/lib/vector2.js +62 -7
- package/lib/video_mode.d.ts +2 -4
- package/lib/video_mode.js +1 -1
- package/package.json +28 -11
- package/src/base_class_with_loading.h +19 -0
- package/src/clock.cc +3 -3
- package/src/clock.h +5 -2
- package/src/color.cc +14 -7
- package/src/color.h +8 -3
- package/src/drawable/circle_shape.cc +9 -9
- package/src/drawable/circle_shape.h +4 -1
- package/src/drawable/convex_shape.cc +57 -0
- package/src/drawable/convex_shape.h +29 -0
- package/src/drawable/drawable-inl.h +29 -0
- package/src/drawable/drawable.cc +41 -0
- package/src/drawable/drawable.h +26 -38
- package/src/drawable/package_plugin-inl.h +190 -0
- package/src/drawable/package_plugin.h +60 -0
- package/src/drawable/rectangle_shape.cc +42 -7
- package/src/drawable/rectangle_shape.h +7 -1
- package/src/drawable/shape.cc +65 -0
- package/src/drawable/shape.h +13 -28
- package/src/drawable/sprite.cc +107 -0
- package/src/drawable/sprite.h +47 -0
- package/src/drawable/text.cc +133 -0
- package/src/drawable/text.h +54 -0
- package/src/font.cc +193 -0
- package/src/font.h +42 -0
- package/src/image.cc +56 -0
- package/src/image.h +32 -0
- package/src/keyboard.cc +39 -0
- package/src/keyboard.h +8 -1
- package/src/load_from_file_worker.h +79 -0
- package/src/mouse.cc +79 -0
- package/src/mouse.h +9 -1
- package/src/plugins/transformable_plugin-inl.h +121 -0
- package/src/plugins/transformable_plugin.h +42 -0
- package/src/poll_event.h +2 -1
- package/src/rect-inl.h +9 -8
- package/src/rect.h +9 -7
- package/src/render_window.cc +65 -6
- package/src/render_window.h +24 -2
- package/src/resizable_buffer.h +88 -0
- package/src/sfml.cc +25 -0
- package/src/sound/music.cc +100 -0
- package/src/sound/music.h +34 -0
- package/src/sound/sound.cc +116 -0
- package/src/sound/sound.h +41 -0
- package/src/sound/sound_buffer.cc +257 -0
- package/src/sound/sound_buffer.h +44 -0
- package/src/sound/sound_source.cc +124 -0
- package/src/sound/sound_source.h +80 -0
- package/src/texture.cc +183 -0
- package/src/texture.h +45 -0
- package/src/time.h +2 -1
- package/src/utils-inl.h +19 -0
- package/src/utils.h +6 -0
- package/src/vector2-inl.h +93 -9
- package/src/vector2.cc +4 -3
- package/src/vector2.h +39 -9
- package/src/video_mode.cc +9 -9
- package/src/video_mode.h +9 -2
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Audio/AlResource.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Audio/Export.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Audio/InputSoundFile.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Audio/Listener.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Audio/Music.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Audio/OutputSoundFile.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Audio/Sound.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Audio/SoundBuffer.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Audio/SoundBufferRecorder.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Audio/SoundFileFactory.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Audio/SoundFileFactory.inl +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Audio/SoundFileReader.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Audio/SoundFileWriter.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Audio/SoundRecorder.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Audio/SoundSource.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Audio/SoundStream.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Audio.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Config.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/GpuPreference.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/BlendMode.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/CircleShape.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/Color.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/ConvexShape.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/Drawable.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/Export.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/Font.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/Glsl.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/Glsl.inl +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/Glyph.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/Image.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/PrimitiveType.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/Rect.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/Rect.inl +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/RectangleShape.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/RenderStates.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/RenderTarget.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/RenderTexture.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/RenderWindow.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/Shader.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/Shape.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/Sprite.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/Text.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/Texture.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/Transform.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/Transformable.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/Vertex.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/VertexArray.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/VertexBuffer.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics/View.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Graphics.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Main.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Network/Export.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Network/Ftp.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Network/Http.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Network/IpAddress.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Network/Packet.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Network/Socket.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Network/SocketHandle.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Network/SocketSelector.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Network/TcpListener.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Network/TcpSocket.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Network/UdpSocket.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Network.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/OpenGL.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/Clock.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/Err.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/Export.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/FileInputStream.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/InputStream.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/Lock.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/MemoryInputStream.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/Mutex.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/NativeActivity.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/NonCopyable.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/Sleep.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/String.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/String.inl +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/Thread.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/Thread.inl +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/ThreadLocal.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/ThreadLocalPtr.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/ThreadLocalPtr.inl +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/Time.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/Utf.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/Utf.inl +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/Vector2.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/Vector2.inl +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/Vector3.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System/Vector3.inl +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/System.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Window/Clipboard.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Window/Context.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Window/ContextSettings.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Window/Cursor.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Window/Event.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Window/Export.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Window/GlResource.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Window/Joystick.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Window/Keyboard.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Window/Mouse.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Window/Sensor.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Window/Touch.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Window/VideoMode.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Window/Window.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Window/WindowHandle.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Window/WindowStyle.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml}/include/SFML/Window.hpp +0 -0
- package/third_party/sfml/platform/linux/lib/libsfml-audio.so.2.5.1 +0 -0
- package/third_party/sfml/platform/linux/lib/libsfml-graphics.so.2.5.1 +0 -0
- package/third_party/sfml/platform/linux/lib/libsfml-network.so.2.5.1 +0 -0
- package/third_party/sfml/platform/linux/lib/libsfml-system.so.2.5.1 +0 -0
- package/third_party/sfml/platform/linux/lib/libsfml-window.so.2.5.1 +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/FLAC.framework/Versions/A/FLAC +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/FLAC.framework/Versions/A/Resources/Info.plist +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/OpenAL.framework/Versions/A/OpenAL +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/OpenAL.framework/Versions/A/Resources/Info.plist +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/AlResource.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/Export.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/InputSoundFile.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/Listener.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/Music.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/OutputSoundFile.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/Sound.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/SoundBuffer.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/SoundBufferRecorder.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/SoundFileFactory.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/SoundFileFactory.inl +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/SoundFileReader.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/SoundFileWriter.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/SoundRecorder.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/SoundSource.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/SoundStream.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Config.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/GpuPreference.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/BlendMode.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/CircleShape.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Color.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/ConvexShape.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Drawable.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Export.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Font.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Glsl.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Glsl.inl +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Glyph.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Image.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/PrimitiveType.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Rect.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Rect.inl +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/RectangleShape.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/RenderStates.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/RenderTarget.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/RenderTexture.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/RenderWindow.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Shader.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Shape.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Sprite.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Text.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Texture.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Transform.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Transformable.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Vertex.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/VertexArray.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/VertexBuffer.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/View.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Main.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/Export.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/Ftp.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/Http.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/IpAddress.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/Packet.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/Socket.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/SocketHandle.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/SocketSelector.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/TcpListener.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/TcpSocket.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/UdpSocket.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/OpenGL.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Clock.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Err.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Export.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/FileInputStream.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/InputStream.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Lock.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/MemoryInputStream.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Mutex.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/NativeActivity.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/NonCopyable.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Sleep.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/String.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/String.inl +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Thread.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Thread.inl +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/ThreadLocal.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/ThreadLocalPtr.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/ThreadLocalPtr.inl +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Time.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Utf.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Utf.inl +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Vector2.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Vector2.inl +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Vector3.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Vector3.inl +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Clipboard.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Context.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/ContextSettings.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Cursor.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Event.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Export.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/GlResource.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Joystick.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Keyboard.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Mouse.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Sensor.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Touch.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/VideoMode.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Window.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/WindowHandle.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/WindowStyle.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window.hpp +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Resources/CMake/SFMLConfig.cmake +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Resources/CMake/SFMLConfigDependencies.cmake +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Resources/CMake/SFMLConfigVersion.cmake +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Resources/CMake/SFMLSharedTargets-release.cmake +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Resources/CMake/SFMLSharedTargets.cmake +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/Resources/Info.plist +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/SFML.framework/Versions/2.5.1/SFML +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/freetype.framework/Versions/A/Resources/Info.plist +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/freetype.framework/Versions/A/freetype +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/ogg.framework/Versions/A/Resources/Info.plist +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/ogg.framework/Versions/A/ogg +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/sfml-audio.framework/Versions/2.5.1/Resources/Info.plist +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/sfml-audio.framework/Versions/2.5.1/sfml-audio +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/sfml-graphics.framework/Versions/2.5.1/Resources/Info.plist +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/sfml-graphics.framework/Versions/2.5.1/sfml-graphics +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/sfml-network.framework/Versions/2.5.1/Resources/Info.plist +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/sfml-network.framework/Versions/2.5.1/sfml-network +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/sfml-system.framework/Versions/2.5.1/Resources/Info.plist +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/sfml-system.framework/Versions/2.5.1/sfml-system +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/sfml-window.framework/Versions/2.5.1/Resources/Info.plist +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/sfml-window.framework/Versions/2.5.1/sfml-window +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/vorbis.framework/Versions/A/Resources/Info.plist +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/vorbis.framework/Versions/A/vorbis +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/vorbisenc.framework/Versions/A/Resources/Info.plist +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/vorbisenc.framework/Versions/A/vorbisenc +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/vorbisfile.framework/Versions/A/Resources/Info.plist +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/Frameworks/vorbisfile.framework/Versions/A/vorbisfile +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/lib/libsfml-audio.2.5.1.dylib +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/lib/libsfml-graphics.2.5.1.dylib +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/lib/libsfml-network.2.5.1.dylib +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/lib/libsfml-system.2.5.1.dylib +0 -0
- package/third_party/{SFML-2.5.1 → sfml/platform}/macOS/lib/libsfml-window.2.5.1.dylib +0 -0
- package/tools/clang_format.js +9 -0
- package/tools/keycode.js +7 -7
- package/tools/mouse_button.js +10 -10
- package/tools/symlinks.js +107 -0
- package/tsconfig.json +8 -0
- package/lib/drawable/base.d.ts +0 -3
- package/src/drawable/shape-inl.h +0 -231
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#ifndef SRC_LOAD_FROM_FILE_WORKER_H_
|
|
2
|
+
#define SRC_LOAD_FROM_FILE_WORKER_H_
|
|
3
|
+
|
|
4
|
+
#include <nan.h>
|
|
5
|
+
|
|
6
|
+
namespace node_sfml {
|
|
7
|
+
namespace load_from_file_worker {
|
|
8
|
+
|
|
9
|
+
typedef bool (*OpenFileFunction)(void* target,
|
|
10
|
+
const std::string& filename,
|
|
11
|
+
void* context);
|
|
12
|
+
|
|
13
|
+
template <class T, typename CTX_TYPE>
|
|
14
|
+
class LoadFromFileWorker : public Nan::AsyncWorker {
|
|
15
|
+
public:
|
|
16
|
+
LoadFromFileWorker(v8::Local<v8::Object> object,
|
|
17
|
+
const std::string& filename,
|
|
18
|
+
OpenFileFunction open_file,
|
|
19
|
+
std::shared_ptr<CTX_TYPE> context,
|
|
20
|
+
Nan::Callback* callback)
|
|
21
|
+
: Nan::AsyncWorker(callback),
|
|
22
|
+
_open_file(open_file),
|
|
23
|
+
_core(Nan::ObjectWrap::Unwrap<T>(object)),
|
|
24
|
+
_filename(filename),
|
|
25
|
+
_context(context),
|
|
26
|
+
_loaded(false),
|
|
27
|
+
_async_resource("load_from_file_worker") {
|
|
28
|
+
_object.Reset(object);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
~LoadFromFileWorker() {
|
|
32
|
+
_object.Reset();
|
|
33
|
+
_core = nullptr;
|
|
34
|
+
_context = nullptr;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
inline virtual void Execute() {
|
|
38
|
+
_loaded = _open_file(_core, _filename, _context.get());
|
|
39
|
+
if (!_loaded) {
|
|
40
|
+
char error[1024];
|
|
41
|
+
snprintf(
|
|
42
|
+
error, sizeof error, "Failed to load %s.", this->_filename.c_str());
|
|
43
|
+
SetErrorMessage(error);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
inline virtual void HandleOKCallback() {
|
|
48
|
+
_core->SetLoading(false);
|
|
49
|
+
|
|
50
|
+
Nan::HandleScope scope;
|
|
51
|
+
callback->Call(0, nullptr, &_async_resource);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
inline virtual void HandleErrorCallback() {
|
|
55
|
+
_core->SetLoading(false);
|
|
56
|
+
|
|
57
|
+
Nan::HandleScope scope;
|
|
58
|
+
v8::Local<v8::Value> argv[1] = {Nan::Error(ErrorMessage())};
|
|
59
|
+
callback->Call(1, argv, &_async_resource);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
inline Nan::AsyncResource* async_resource() { return &_async_resource; }
|
|
63
|
+
|
|
64
|
+
private:
|
|
65
|
+
OpenFileFunction _open_file;
|
|
66
|
+
|
|
67
|
+
T* _core;
|
|
68
|
+
std::string _filename;
|
|
69
|
+
std::shared_ptr<CTX_TYPE> _context;
|
|
70
|
+
|
|
71
|
+
Nan::Persistent<v8::Object> _object;
|
|
72
|
+
bool _loaded;
|
|
73
|
+
Nan::AsyncResource _async_resource;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
} // namespace load_from_file_worker
|
|
77
|
+
} // namespace node_sfml
|
|
78
|
+
|
|
79
|
+
#endif // SRC_LOAD_FROM_FILE_WORKER_H_
|
package/src/mouse.cc
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
#include "mouse.h"
|
|
2
|
+
#include "render_window.h"
|
|
3
|
+
#include "vector2-inl.h"
|
|
2
4
|
|
|
3
5
|
namespace node_sfml {
|
|
4
6
|
namespace gen {
|
|
@@ -7,8 +9,85 @@ extern void InitMouseButton();
|
|
|
7
9
|
|
|
8
10
|
namespace mouse {
|
|
9
11
|
|
|
12
|
+
using std::map;
|
|
13
|
+
using std::string;
|
|
14
|
+
using v8::Local;
|
|
15
|
+
using v8::MaybeLocal;
|
|
16
|
+
using v8::Object;
|
|
17
|
+
using v8::String;
|
|
18
|
+
|
|
10
19
|
NAN_MODULE_INIT(Init) {
|
|
11
20
|
gen::InitMouseButton();
|
|
21
|
+
|
|
22
|
+
Nan::SetMethod(target, "isButtonPressed", IsButtonPressed);
|
|
23
|
+
Nan::SetMethod(target, "getPosition", GetPosition);
|
|
24
|
+
Nan::SetMethod(target, "setPosition", SetPosition);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
NAN_METHOD(IsButtonPressed) {
|
|
28
|
+
if (info[0]->IsInt32()) {
|
|
29
|
+
sf::Int32 code = Nan::To<sf::Int32>(info[0]).FromJust();
|
|
30
|
+
if (code >= sf::Mouse::Button::ButtonCount || code < 0) {
|
|
31
|
+
Nan::ThrowRangeError("Out of button range.");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
info.GetReturnValue().Set(
|
|
36
|
+
sf::Mouse::isButtonPressed(static_cast<sf::Mouse::Button>(code)));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
Local<String> v8_button_str = info[0].As<String>();
|
|
41
|
+
Nan::Utf8String button_str_utf8(v8_button_str);
|
|
42
|
+
|
|
43
|
+
map<string, int>::iterator code_it =
|
|
44
|
+
gen::mouse_button_atoi.find(*button_str_utf8);
|
|
45
|
+
if (code_it == gen::mouse_button_atoi.end()) {
|
|
46
|
+
Nan::ThrowRangeError("No such button.");
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
info.GetReturnValue().Set(sf::Mouse::isButtonPressed(
|
|
51
|
+
static_cast<sf::Mouse::Button>(code_it->second)));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
NAN_METHOD(GetPosition) {
|
|
55
|
+
sf::Vector2i pos;
|
|
56
|
+
if (info.Length() == 0) {
|
|
57
|
+
pos = sf::Mouse::getPosition();
|
|
58
|
+
} else {
|
|
59
|
+
Local<Object> window_object = info[0].As<Object>();
|
|
60
|
+
render_window::RenderWindow* render_window =
|
|
61
|
+
Nan::ObjectWrap::Unwrap<render_window::RenderWindow>(window_object);
|
|
62
|
+
sf::RenderWindow* window = render_window->window();
|
|
63
|
+
|
|
64
|
+
pos = sf::Mouse::getPosition(*window);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
Nan::TryCatch try_catch;
|
|
68
|
+
MaybeLocal<Object> ret =
|
|
69
|
+
vector2::Vector2I::NewRealInstance(info.GetIsolate(), pos);
|
|
70
|
+
if (ret.IsEmpty()) {
|
|
71
|
+
try_catch.ReThrow();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
info.GetReturnValue().Set(ret.ToLocalChecked());
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
NAN_METHOD(SetPosition) {
|
|
79
|
+
vector2::Vector2I* pos =
|
|
80
|
+
Nan::ObjectWrap::Unwrap<vector2::Vector2I>(info[0].As<Object>());
|
|
81
|
+
|
|
82
|
+
if (info.Length() <= 1) {
|
|
83
|
+
sf::Mouse::setPosition(pos->vector2());
|
|
84
|
+
} else {
|
|
85
|
+
Local<Object> window_object = info[1].As<Object>();
|
|
86
|
+
render_window::RenderWindow* render_window =
|
|
87
|
+
Nan::ObjectWrap::Unwrap<render_window::RenderWindow>(window_object);
|
|
88
|
+
sf::RenderWindow* window = render_window->window();
|
|
89
|
+
sf::Mouse::setPosition(pos->vector2(), *window);
|
|
90
|
+
}
|
|
12
91
|
}
|
|
13
92
|
|
|
14
93
|
} // namespace mouse
|
package/src/mouse.h
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
#define SRC_MOUSE_H_
|
|
3
3
|
|
|
4
4
|
#include <nan.h>
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
#include <map>
|
|
7
|
+
#include <string>
|
|
8
|
+
|
|
9
|
+
#include <SFML/Window/Mouse.hpp>
|
|
6
10
|
|
|
7
11
|
namespace node_sfml {
|
|
8
12
|
namespace gen {
|
|
@@ -16,6 +20,10 @@ namespace mouse {
|
|
|
16
20
|
|
|
17
21
|
NAN_MODULE_INIT(Init);
|
|
18
22
|
|
|
23
|
+
NAN_METHOD(IsButtonPressed);
|
|
24
|
+
NAN_METHOD(GetPosition);
|
|
25
|
+
NAN_METHOD(SetPosition);
|
|
26
|
+
|
|
19
27
|
} // namespace mouse
|
|
20
28
|
} // namespace node_sfml
|
|
21
29
|
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#ifndef SRC_PLUGINS_TRANSFORMABLE_PLUGIN_INL_H_
|
|
2
|
+
#define SRC_PLUGINS_TRANSFORMABLE_PLUGIN_INL_H_
|
|
3
|
+
|
|
4
|
+
#include "../vector2.h"
|
|
5
|
+
#include "transformable_plugin.h"
|
|
6
|
+
|
|
7
|
+
namespace node_sfml {
|
|
8
|
+
namespace transformable {
|
|
9
|
+
|
|
10
|
+
template <class T>
|
|
11
|
+
inline void SetPrototype(v8::Local<v8::FunctionTemplate>* _tpl) {
|
|
12
|
+
v8::Local<v8::FunctionTemplate>& tpl = *_tpl;
|
|
13
|
+
|
|
14
|
+
Nan::SetPrototypeMethod(tpl, "setPosition", SetPosition<T>);
|
|
15
|
+
Nan::SetPrototypeMethod(tpl, "getPosition", GetPosition<T>);
|
|
16
|
+
|
|
17
|
+
Nan::SetPrototypeMethod(tpl, "setScale", SetScale<T>);
|
|
18
|
+
Nan::SetPrototypeMethod(tpl, "getScale", GetScale<T>);
|
|
19
|
+
|
|
20
|
+
Nan::SetPrototypeMethod(tpl, "setOrigin", SetOrigin<T>);
|
|
21
|
+
Nan::SetPrototypeMethod(tpl, "getOrigin", GetOrigin<T>);
|
|
22
|
+
|
|
23
|
+
Nan::SetPrototypeMethod(tpl, "setRotation", SetRotation<T>);
|
|
24
|
+
Nan::SetPrototypeMethod(tpl, "getRotation", GetRotation<T>);
|
|
25
|
+
|
|
26
|
+
Nan::SetPrototypeMethod(tpl, "move", Move<T>);
|
|
27
|
+
Nan::SetPrototypeMethod(tpl, "scale", Scale<T>);
|
|
28
|
+
Nan::SetPrototypeMethod(tpl, "rotate", Rotate<T>);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
template <class T>
|
|
32
|
+
inline NAN_METHOD(SetRotation) {
|
|
33
|
+
T* target = Nan::ObjectWrap::Unwrap<T>(info.Holder());
|
|
34
|
+
float rotation = static_cast<float>(Nan::To<double>(info[0]).FromJust());
|
|
35
|
+
target->transformable().setRotation(rotation);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
template <class T>
|
|
39
|
+
inline NAN_METHOD(GetRotation) {
|
|
40
|
+
T* target = Nan::ObjectWrap::Unwrap<T>(info.Holder());
|
|
41
|
+
float rotation = target->transformable().getRotation();
|
|
42
|
+
info.GetReturnValue().Set(static_cast<double>(rotation));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
template <class T>
|
|
46
|
+
inline NAN_METHOD(Rotate) {
|
|
47
|
+
T* target = Nan::ObjectWrap::Unwrap<T>(info.Holder());
|
|
48
|
+
float rotation = static_cast<float>(Nan::To<double>(info[0]).FromJust());
|
|
49
|
+
target->transformable().rotate(rotation);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
#define VECTOR2F_ACTION(name, call) \
|
|
53
|
+
template <class T> \
|
|
54
|
+
inline NAN_METHOD(name) { \
|
|
55
|
+
T* target = Nan::ObjectWrap::Unwrap<T>(info.Holder()); \
|
|
56
|
+
\
|
|
57
|
+
if (info.Length() == 1) { \
|
|
58
|
+
vector2::Vector2F* vec = Nan::ObjectWrap::Unwrap<vector2::Vector2F>( \
|
|
59
|
+
info[0].As<v8::Object>()); \
|
|
60
|
+
target->transformable().call(vec->vector2()); \
|
|
61
|
+
return; \
|
|
62
|
+
} \
|
|
63
|
+
\
|
|
64
|
+
float x = static_cast<float>(Nan::To<double>(info[0]).FromJust()); \
|
|
65
|
+
float y = static_cast<float>(Nan::To<double>(info[1]).FromJust()); \
|
|
66
|
+
target->transformable().call(x, y); \
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#define VECTOR2F_GETTER_SETTER(name) \
|
|
70
|
+
template <class T> \
|
|
71
|
+
inline NAN_METHOD(Set##name) { \
|
|
72
|
+
T* target = Nan::ObjectWrap::Unwrap<T>(info.Holder()); \
|
|
73
|
+
\
|
|
74
|
+
switch (info.Length()) { \
|
|
75
|
+
case 1: { \
|
|
76
|
+
vector2::Vector2F* vec = Nan::ObjectWrap::Unwrap<vector2::Vector2F>( \
|
|
77
|
+
info[0].As<v8::Object>()); \
|
|
78
|
+
target->transformable().set##name(vec->vector2()); \
|
|
79
|
+
break; \
|
|
80
|
+
} \
|
|
81
|
+
\
|
|
82
|
+
case 2: \
|
|
83
|
+
default: { \
|
|
84
|
+
float x = static_cast<float>(Nan::To<double>(info[0]).FromJust()); \
|
|
85
|
+
float y = static_cast<float>(Nan::To<double>(info[1]).FromJust()); \
|
|
86
|
+
target->transformable().set##name(x, y); \
|
|
87
|
+
break; \
|
|
88
|
+
} \
|
|
89
|
+
} \
|
|
90
|
+
} \
|
|
91
|
+
\
|
|
92
|
+
template <class T> \
|
|
93
|
+
inline NAN_METHOD(Get##name) { \
|
|
94
|
+
T* target = Nan::ObjectWrap::Unwrap<T>(info.Holder()); \
|
|
95
|
+
\
|
|
96
|
+
const sf::Vector2f& vec = target->transformable().get##name(); \
|
|
97
|
+
\
|
|
98
|
+
Nan::TryCatch try_catch; \
|
|
99
|
+
v8::MaybeLocal<v8::Object> maybe_vec = \
|
|
100
|
+
vector2::Vector2F::NewRealInstance(info.GetIsolate(), vec); \
|
|
101
|
+
if (maybe_vec.IsEmpty()) { \
|
|
102
|
+
try_catch.ReThrow(); \
|
|
103
|
+
return; \
|
|
104
|
+
} \
|
|
105
|
+
\
|
|
106
|
+
info.GetReturnValue().Set(maybe_vec.ToLocalChecked()); \
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
VECTOR2F_ACTION(Move, move);
|
|
110
|
+
VECTOR2F_ACTION(Scale, scale);
|
|
111
|
+
VECTOR2F_GETTER_SETTER(Position);
|
|
112
|
+
VECTOR2F_GETTER_SETTER(Scale);
|
|
113
|
+
VECTOR2F_GETTER_SETTER(Origin);
|
|
114
|
+
|
|
115
|
+
#undef VECTOR2F_ACTION
|
|
116
|
+
#undef VECTOR2F_GETTER_SETTER
|
|
117
|
+
|
|
118
|
+
} // namespace transformable
|
|
119
|
+
} // namespace node_sfml
|
|
120
|
+
|
|
121
|
+
#endif // SRC_PLUGINS_TRANSFORMABLE_PLUGIN_INL_H_
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#ifndef SRC_PLUGINS_TRANSFORMABLE_PLUGIN_H_
|
|
2
|
+
#define SRC_PLUGINS_TRANSFORMABLE_PLUGIN_H_
|
|
3
|
+
|
|
4
|
+
#include <nan.h>
|
|
5
|
+
|
|
6
|
+
namespace node_sfml {
|
|
7
|
+
namespace transformable {
|
|
8
|
+
|
|
9
|
+
template <class T>
|
|
10
|
+
inline void SetPrototype(v8::Local<v8::FunctionTemplate>* _tpl);
|
|
11
|
+
|
|
12
|
+
template <class T>
|
|
13
|
+
inline static NAN_METHOD(SetPosition);
|
|
14
|
+
template <class T>
|
|
15
|
+
inline static NAN_METHOD(GetPosition);
|
|
16
|
+
|
|
17
|
+
template <class T>
|
|
18
|
+
inline static NAN_METHOD(SetScale);
|
|
19
|
+
template <class T>
|
|
20
|
+
inline static NAN_METHOD(GetScale);
|
|
21
|
+
|
|
22
|
+
template <class T>
|
|
23
|
+
inline static NAN_METHOD(SetOrigin);
|
|
24
|
+
template <class T>
|
|
25
|
+
inline static NAN_METHOD(GetOrigin);
|
|
26
|
+
|
|
27
|
+
template <class T>
|
|
28
|
+
inline static NAN_METHOD(SetRotation);
|
|
29
|
+
template <class T>
|
|
30
|
+
inline static NAN_METHOD(GetRotation);
|
|
31
|
+
|
|
32
|
+
template <class T>
|
|
33
|
+
inline static NAN_METHOD(Move);
|
|
34
|
+
template <class T>
|
|
35
|
+
inline static NAN_METHOD(Scale);
|
|
36
|
+
template <class T>
|
|
37
|
+
inline static NAN_METHOD(Rotate);
|
|
38
|
+
|
|
39
|
+
} // namespace transformable
|
|
40
|
+
} // namespace node_sfml
|
|
41
|
+
|
|
42
|
+
#endif // SRC_PLUGINS_TRANSFORMABLE_PLUGIN_H_
|
package/src/poll_event.h
CHANGED
package/src/rect-inl.h
CHANGED
|
@@ -64,11 +64,11 @@ NAN_METHOD(Rect<TEMPLATE_INNER>::Contains) {
|
|
|
64
64
|
vector2::Vector2<T, NAN_T, V8_T>* point =
|
|
65
65
|
Nan::ObjectWrap::Unwrap<vector2::Vector2<T, NAN_T, V8_T>>(
|
|
66
66
|
info[0].As<v8::Object>());
|
|
67
|
-
info.GetReturnValue().Set(rect->contains(
|
|
67
|
+
info.GetReturnValue().Set(rect->_rect.contains(point->vector2()));
|
|
68
68
|
} else {
|
|
69
69
|
T val[2];
|
|
70
70
|
if (!ParseParameters<T, NAN_T, V8_T>(info, 2, val)) return;
|
|
71
|
-
info.GetReturnValue().Set(rect->contains(val[0], val[1]));
|
|
71
|
+
info.GetReturnValue().Set(rect->_rect.contains(val[0], val[1]));
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -88,7 +88,7 @@ NAN_METHOD(Rect<TEMPLATE_INNER>::Intersects) {
|
|
|
88
88
|
Rect<T, NAN_T, V8_T>* ret_rect =
|
|
89
89
|
Nan::ObjectWrap::Unwrap<Rect<T, NAN_T, V8_T>>(ret);
|
|
90
90
|
|
|
91
|
-
bool succ = rect->intersects(
|
|
91
|
+
bool succ = rect->_rect.intersects(another->_rect, ret_rect->_rect);
|
|
92
92
|
if (succ) {
|
|
93
93
|
info.GetReturnValue().Set(ret);
|
|
94
94
|
} else {
|
|
@@ -101,7 +101,8 @@ NAN_METHOD(Rect<TEMPLATE_INNER>::Intersects) {
|
|
|
101
101
|
NAN_METHOD(Rect<TEMPLATE_INNER>::name##Getter) { \
|
|
102
102
|
Rect<T, NAN_T, V8_T>* rect = \
|
|
103
103
|
Nan::ObjectWrap::Unwrap<Rect<T, NAN_T, V8_T>>(info.Holder()); \
|
|
104
|
-
v8::Local<V8_T> ret =
|
|
104
|
+
v8::Local<V8_T> ret = \
|
|
105
|
+
Nan::New<V8_T>(static_cast<NAN_T>(rect->_rect.lowercase)); \
|
|
105
106
|
info.GetReturnValue().Set(ret); \
|
|
106
107
|
} \
|
|
107
108
|
\
|
|
@@ -115,7 +116,7 @@ NAN_METHOD(Rect<TEMPLATE_INNER>::Intersects) {
|
|
|
115
116
|
NAN_T val = maybe_value.ToLocalChecked()->Value(); \
|
|
116
117
|
Rect<T, NAN_T, V8_T>* rect = \
|
|
117
118
|
Nan::ObjectWrap::Unwrap<Rect<T, NAN_T, V8_T>>(info.Holder()); \
|
|
118
|
-
rect->lowercase = static_cast<T>(val);
|
|
119
|
+
rect->_rect.lowercase = static_cast<T>(val); \
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
RECT_PROPERTIES(V);
|
|
@@ -127,16 +128,16 @@ NAN_METHOD(Rect<TEMPLATE_INNER>::SetRealConstructor) {
|
|
|
127
128
|
}
|
|
128
129
|
|
|
129
130
|
template <typename T, typename NAN_T, class V8_T>
|
|
130
|
-
Rect<T, NAN_T, V8_T>::Rect() :
|
|
131
|
+
Rect<T, NAN_T, V8_T>::Rect() : _rect() {}
|
|
131
132
|
|
|
132
133
|
template <typename T, typename NAN_T, class V8_T>
|
|
133
134
|
Rect<T, NAN_T, V8_T>::Rect(T rect_left, T rect_top, T rect_width, T rect_height)
|
|
134
|
-
:
|
|
135
|
+
: _rect(rect_left, rect_top, rect_width, rect_height) {}
|
|
135
136
|
|
|
136
137
|
template <typename T, typename NAN_T, class V8_T>
|
|
137
138
|
Rect<T, NAN_T, V8_T>::Rect(const vector2::Vector2<T, NAN_T, V8_T>& pos,
|
|
138
139
|
const vector2::Vector2<T, NAN_T, V8_T>& size)
|
|
139
|
-
:
|
|
140
|
+
: _rect(pos.vector2(), size.vector2()) {}
|
|
140
141
|
|
|
141
142
|
template <typename T, typename NAN_T, class V8_T>
|
|
142
143
|
Rect<T, NAN_T, V8_T>::~Rect() {}
|
package/src/rect.h
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#define SRC_RECT_H_
|
|
3
3
|
|
|
4
4
|
#include <nan.h>
|
|
5
|
+
|
|
5
6
|
#include <SFML/Graphics.hpp>
|
|
6
7
|
|
|
7
8
|
#include "vector2.h"
|
|
@@ -16,11 +17,14 @@ namespace rect {
|
|
|
16
17
|
V(Height, height)
|
|
17
18
|
|
|
18
19
|
template <typename T, typename NAN_T, class V8_T>
|
|
19
|
-
class Rect : public Nan::ObjectWrap
|
|
20
|
+
class Rect : public Nan::ObjectWrap {
|
|
20
21
|
public:
|
|
21
22
|
static Nan::Persistent<v8::Function> constructor;
|
|
22
23
|
static Nan::Persistent<v8::Function> real_constructor;
|
|
23
24
|
|
|
25
|
+
inline const sf::Rect<T>& rect() const { return _rect; }
|
|
26
|
+
inline sf::Rect<T>& rect() { return _rect; }
|
|
27
|
+
|
|
24
28
|
template <const char* class_name>
|
|
25
29
|
static NAN_MODULE_INIT(Init) {
|
|
26
30
|
v8::Local<v8::String> name = Nan::New(class_name).ToLocalChecked();
|
|
@@ -46,12 +50,7 @@ class Rect : public Nan::ObjectWrap, public sf::Rect<T> {
|
|
|
46
50
|
constructor.Reset(func);
|
|
47
51
|
|
|
48
52
|
Nan::Set(target, name, func);
|
|
49
|
-
|
|
50
|
-
Nan::Set(
|
|
51
|
-
func,
|
|
52
|
-
Nan::New("setRealConstructor").ToLocalChecked(),
|
|
53
|
-
Nan::GetFunction(Nan::New<v8::FunctionTemplate>(SetRealConstructor))
|
|
54
|
-
.ToLocalChecked());
|
|
53
|
+
Nan::SetMethod(func, "setRealConstructor", SetRealConstructor);
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
static v8::MaybeLocal<v8::Object> NewRealInstance(
|
|
@@ -79,6 +78,9 @@ class Rect : public Nan::ObjectWrap, public sf::Rect<T> {
|
|
|
79
78
|
Rect(const vector2::Vector2<T, NAN_T, V8_T>& pos,
|
|
80
79
|
const vector2::Vector2<T, NAN_T, V8_T>& size);
|
|
81
80
|
virtual ~Rect();
|
|
81
|
+
|
|
82
|
+
protected:
|
|
83
|
+
sf::Rect<T> _rect;
|
|
82
84
|
};
|
|
83
85
|
|
|
84
86
|
class IntRect : public Rect<int, int, v8::Int32> {
|
package/src/render_window.cc
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
#include "render_window.h"
|
|
2
2
|
#include "color.h"
|
|
3
3
|
#include "drawable/drawable.h"
|
|
4
|
+
#include "image.h"
|
|
4
5
|
#include "poll_event.h"
|
|
6
|
+
#include "vector2-inl.h"
|
|
5
7
|
#include "video_mode.h"
|
|
6
8
|
|
|
7
9
|
namespace node_sfml {
|
|
@@ -22,12 +24,21 @@ NAN_MODULE_INIT(RenderWindow::Init) {
|
|
|
22
24
|
|
|
23
25
|
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
|
|
24
26
|
|
|
27
|
+
Nan::SetPrototypeMethod(tpl, "capture", Capture);
|
|
25
28
|
Nan::SetPrototypeMethod(tpl, "clear", Clear);
|
|
26
29
|
Nan::SetPrototypeMethod(tpl, "close", Close);
|
|
27
30
|
Nan::SetPrototypeMethod(tpl, "display", Display);
|
|
28
31
|
Nan::SetPrototypeMethod(tpl, "drawDrawable", DrawDrawable);
|
|
29
32
|
Nan::SetPrototypeMethod(tpl, "isOpen", IsOpen);
|
|
30
33
|
Nan::SetPrototypeMethod(tpl, "pollEvent", PollEvent);
|
|
34
|
+
Nan::SetPrototypeMethod(tpl, "getSize", GetSize);
|
|
35
|
+
|
|
36
|
+
#define PRIMITIVE_VALUE_PROTOTYPE_METHOD(name, _) \
|
|
37
|
+
Nan::SetPrototypeMethod(tpl, "set" #name, Set##name);
|
|
38
|
+
|
|
39
|
+
PRIMITIVE_VALUES(PRIMITIVE_VALUE_PROTOTYPE_METHOD);
|
|
40
|
+
|
|
41
|
+
#undef PRIMITIVE_VALUE_PROTOTYPE_METHOD
|
|
31
42
|
|
|
32
43
|
tpl->SetClassName(name);
|
|
33
44
|
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
|
@@ -98,10 +109,10 @@ NAN_METHOD(RenderWindow::New) {
|
|
|
98
109
|
|
|
99
110
|
if (window == nullptr) {
|
|
100
111
|
if (style.IsEmpty()) {
|
|
101
|
-
window = new RenderWindow(
|
|
112
|
+
window = new RenderWindow(mode->mode(), title);
|
|
102
113
|
} else {
|
|
103
|
-
window =
|
|
104
|
-
|
|
114
|
+
window = new RenderWindow(
|
|
115
|
+
mode->mode(), title, Nan::To<sf::Uint32>(style).FromJust());
|
|
105
116
|
}
|
|
106
117
|
}
|
|
107
118
|
|
|
@@ -109,11 +120,30 @@ NAN_METHOD(RenderWindow::New) {
|
|
|
109
120
|
info.GetReturnValue().Set(info.This());
|
|
110
121
|
}
|
|
111
122
|
|
|
123
|
+
NAN_METHOD(RenderWindow::Capture) {
|
|
124
|
+
RenderWindow* window = Nan::ObjectWrap::Unwrap<RenderWindow>(info.Holder());
|
|
125
|
+
sf::Image img = window->_window->capture();
|
|
126
|
+
|
|
127
|
+
Nan::TryCatch try_catch;
|
|
128
|
+
MaybeLocal<Object> maybe_img =
|
|
129
|
+
image::Image::NewRealInstance(info.GetIsolate());
|
|
130
|
+
if (maybe_img.IsEmpty()) {
|
|
131
|
+
try_catch.ReThrow();
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
Local<Object> img_obj = maybe_img.ToLocalChecked();
|
|
136
|
+
image::Image* node_sfml_img = Nan::ObjectWrap::Unwrap<image::Image>(img_obj);
|
|
137
|
+
node_sfml_img->SetInnerImage(img);
|
|
138
|
+
|
|
139
|
+
info.GetReturnValue().Set(img_obj);
|
|
140
|
+
}
|
|
141
|
+
|
|
112
142
|
NAN_METHOD(RenderWindow::Clear) {
|
|
113
143
|
RenderWindow* window = Nan::ObjectWrap::Unwrap<RenderWindow>(info.Holder());
|
|
114
144
|
color::Color* color =
|
|
115
145
|
Nan::ObjectWrap::Unwrap<color::Color>(info[0].As<v8::Object>());
|
|
116
|
-
window->_window->clear(
|
|
146
|
+
window->_window->clear(color->color());
|
|
117
147
|
}
|
|
118
148
|
|
|
119
149
|
NAN_METHOD(RenderWindow::Close) {
|
|
@@ -128,8 +158,8 @@ NAN_METHOD(RenderWindow::Display) {
|
|
|
128
158
|
|
|
129
159
|
NAN_METHOD(RenderWindow::DrawDrawable) {
|
|
130
160
|
RenderWindow* window = Nan::ObjectWrap::Unwrap<RenderWindow>(info.Holder());
|
|
131
|
-
drawable::
|
|
132
|
-
Nan::ObjectWrap::Unwrap<drawable::
|
|
161
|
+
drawable::Drawable* drawable =
|
|
162
|
+
Nan::ObjectWrap::Unwrap<drawable::Drawable>(info[0].As<Object>());
|
|
133
163
|
window->_window->draw(drawable->raw<sf::Drawable>());
|
|
134
164
|
}
|
|
135
165
|
|
|
@@ -154,10 +184,39 @@ NAN_METHOD(RenderWindow::PollEvent) {
|
|
|
154
184
|
info.GetReturnValue().Set(v8_event.ToLocalChecked());
|
|
155
185
|
}
|
|
156
186
|
|
|
187
|
+
NAN_METHOD(RenderWindow::GetSize) {
|
|
188
|
+
RenderWindow* window = Nan::ObjectWrap::Unwrap<RenderWindow>(info.Holder());
|
|
189
|
+
sf::Vector2u vec = window->_window->getSize();
|
|
190
|
+
|
|
191
|
+
Nan::TryCatch try_catch;
|
|
192
|
+
MaybeLocal<Object> maybe_vec =
|
|
193
|
+
vector2::Vector2U::NewRealInstance(info.GetIsolate(), vec);
|
|
194
|
+
if (maybe_vec.IsEmpty()) {
|
|
195
|
+
try_catch.ReThrow();
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
info.GetReturnValue().Set(maybe_vec.ToLocalChecked());
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
#define SET_PRIMITIVE_VALUE(name, type) \
|
|
203
|
+
NAN_METHOD(RenderWindow::Set##name) { \
|
|
204
|
+
RenderWindow* window = \
|
|
205
|
+
Nan::ObjectWrap::Unwrap<RenderWindow>(info.Holder()); \
|
|
206
|
+
type val = Nan::To<type>(info[0]).FromJust(); \
|
|
207
|
+
window->_window->set##name(val); \
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
PRIMITIVE_VALUES(SET_PRIMITIVE_VALUE);
|
|
211
|
+
|
|
212
|
+
#undef SET_PRIMITIVE_VALUE
|
|
213
|
+
|
|
157
214
|
RenderWindow::RenderWindow() : _window(new sf::RenderWindow()) {}
|
|
215
|
+
|
|
158
216
|
RenderWindow::~RenderWindow() {
|
|
159
217
|
delete _window;
|
|
160
218
|
}
|
|
219
|
+
|
|
161
220
|
RenderWindow::RenderWindow(sf::VideoMode mode,
|
|
162
221
|
v8::Local<v8::String> title,
|
|
163
222
|
sf::Uint32 style) {
|
package/src/render_window.h
CHANGED
|
@@ -2,24 +2,46 @@
|
|
|
2
2
|
#define SRC_RENDER_WINDOW_H_
|
|
3
3
|
|
|
4
4
|
#include <nan.h>
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
#include <SFML/Graphics/RenderWindow.hpp>
|
|
7
|
+
#include <SFML/Window/Event.hpp>
|
|
6
8
|
|
|
7
9
|
namespace node_sfml {
|
|
8
10
|
namespace render_window {
|
|
9
11
|
|
|
10
|
-
class RenderWindow : public Nan::ObjectWrap
|
|
12
|
+
class RenderWindow : public Nan::ObjectWrap {
|
|
11
13
|
public:
|
|
12
14
|
static NAN_MODULE_INIT(Init);
|
|
13
15
|
|
|
16
|
+
inline sf::RenderWindow* window() { return _window; }
|
|
17
|
+
|
|
14
18
|
private:
|
|
15
19
|
static NAN_METHOD(New);
|
|
16
20
|
|
|
21
|
+
static NAN_METHOD(Capture);
|
|
17
22
|
static NAN_METHOD(Clear);
|
|
18
23
|
static NAN_METHOD(Close);
|
|
19
24
|
static NAN_METHOD(Display);
|
|
20
25
|
static NAN_METHOD(DrawDrawable);
|
|
21
26
|
static NAN_METHOD(IsOpen);
|
|
22
27
|
static NAN_METHOD(PollEvent);
|
|
28
|
+
static NAN_METHOD(GetSize);
|
|
29
|
+
|
|
30
|
+
#define PRIMITIVE_VALUES(V) \
|
|
31
|
+
V(Visible, bool) \
|
|
32
|
+
V(VerticalSyncEnabled, bool) \
|
|
33
|
+
V(MouseCursorVisible, bool) \
|
|
34
|
+
V(MouseCursorGrabbed, bool) \
|
|
35
|
+
V(KeyRepeatEnabled, bool) \
|
|
36
|
+
V(FramerateLimit, sf::Uint32) \
|
|
37
|
+
V(Active, bool)
|
|
38
|
+
|
|
39
|
+
#define DECLARE_PRIMITIVE_VALUE_NAN_METHOD(name, _) \
|
|
40
|
+
static NAN_METHOD(Set##name);
|
|
41
|
+
|
|
42
|
+
PRIMITIVE_VALUES(DECLARE_PRIMITIVE_VALUE_NAN_METHOD);
|
|
43
|
+
|
|
44
|
+
#undef DECLARE_PRIMITIVE_VALUE_NAN_METHOD
|
|
23
45
|
|
|
24
46
|
private:
|
|
25
47
|
RenderWindow();
|