Compare commits
No commits in common. "910514871e905d3c014a03cfb6bfdef77d609f7f" and "a71d6bc078d653c719e7ad96b3812028a81749b2" have entirely different histories.
910514871e
...
a71d6bc078
@ -29,6 +29,7 @@ Checks: >
|
|||||||
-misc-non-private-member-variables-in-classes,
|
-misc-non-private-member-variables-in-classes,
|
||||||
-modernize-avoid-c-arrays,
|
-modernize-avoid-c-arrays,
|
||||||
-modernize-macro-to-enum,
|
-modernize-macro-to-enum,
|
||||||
|
-modernize-return-braced-init-list,
|
||||||
-modernize-use-nodiscard,
|
-modernize-use-nodiscard,
|
||||||
-modernize-use-trailing-return-type,
|
-modernize-use-trailing-return-type,
|
||||||
-performance-inefficient-string-concatenation,
|
-performance-inefficient-string-concatenation,
|
||||||
|
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@ -214,6 +214,9 @@ jobs:
|
|||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: sudo apt-get install clang-format-14
|
||||||
|
|
||||||
- name: Format Code
|
- name: Format Code
|
||||||
run: cmake -DCLANG_FORMAT_EXECUTABLE=clang-format-14 -P cmake/Format.cmake
|
run: cmake -DCLANG_FORMAT_EXECUTABLE=clang-format-14 -P cmake/Format.cmake
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ float getMoisture(unsigned int x, unsigned int y)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
sf::Color colorFromFloats(float r, float g, float b)
|
sf::Color colorFromFloats(float r, float g, float b)
|
||||||
{
|
{
|
||||||
return {static_cast<std::uint8_t>(r), static_cast<std::uint8_t>(g), static_cast<std::uint8_t>(b)};
|
return sf::Color(static_cast<std::uint8_t>(r), static_cast<std::uint8_t>(g), static_cast<std::uint8_t>(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::Color getLowlandsTerrainColor(float moisture)
|
sf::Color getLowlandsTerrainColor(float moisture)
|
||||||
@ -451,7 +451,7 @@ sf::Vector2f computeNormal(float left, float right, float bottom, float top)
|
|||||||
crossProduct /= crossProduct.z;
|
crossProduct /= crossProduct.z;
|
||||||
|
|
||||||
// Return "compressed" normal
|
// Return "compressed" normal
|
||||||
return {crossProduct.x, crossProduct.y};
|
return sf::Vector2f(crossProduct.x, crossProduct.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,10 +77,10 @@ constexpr Color operator+(const Color& left, const Color& right)
|
|||||||
return static_cast<std::uint8_t>(intResult < 255 ? intResult : 255);
|
return static_cast<std::uint8_t>(intResult < 255 ? intResult : 255);
|
||||||
};
|
};
|
||||||
|
|
||||||
return {clampedAdd(left.r, right.r),
|
return Color(clampedAdd(left.r, right.r),
|
||||||
clampedAdd(left.g, right.g),
|
clampedAdd(left.g, right.g),
|
||||||
clampedAdd(left.b, right.b),
|
clampedAdd(left.b, right.b),
|
||||||
clampedAdd(left.a, right.a)};
|
clampedAdd(left.a, right.a));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -93,10 +93,10 @@ constexpr Color operator-(const Color& left, const Color& right)
|
|||||||
return static_cast<std::uint8_t>(intResult > 0 ? intResult : 0);
|
return static_cast<std::uint8_t>(intResult > 0 ? intResult : 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
return {clampedSub(left.r, right.r),
|
return Color(clampedSub(left.r, right.r),
|
||||||
clampedSub(left.g, right.g),
|
clampedSub(left.g, right.g),
|
||||||
clampedSub(left.b, right.b),
|
clampedSub(left.b, right.b),
|
||||||
clampedSub(left.a, right.a)};
|
clampedSub(left.a, right.a));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -109,7 +109,10 @@ constexpr Color operator*(const Color& left, const Color& right)
|
|||||||
return static_cast<std::uint8_t>(uint16Result / 255u);
|
return static_cast<std::uint8_t>(uint16Result / 255u);
|
||||||
};
|
};
|
||||||
|
|
||||||
return {scaledMul(left.r, right.r), scaledMul(left.g, right.g), scaledMul(left.b, right.b), scaledMul(left.a, right.a)};
|
return Color(scaledMul(left.r, right.r),
|
||||||
|
scaledMul(left.g, right.g),
|
||||||
|
scaledMul(left.b, right.b),
|
||||||
|
scaledMul(left.a, right.a));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -265,10 +265,7 @@ private:
|
|||||||
/// \code
|
/// \code
|
||||||
/// // Declare and load a texture
|
/// // Declare and load a texture
|
||||||
/// sf::Texture texture;
|
/// sf::Texture texture;
|
||||||
/// if (!texture.loadFromFile("texture.png"))
|
/// texture.loadFromFile("texture.png");
|
||||||
/// {
|
|
||||||
/// // Handle error...
|
|
||||||
/// }
|
|
||||||
///
|
///
|
||||||
/// // Create a sprite
|
/// // Create a sprite
|
||||||
/// sf::Sprite sprite(texture);
|
/// sf::Sprite sprite(texture);
|
||||||
|
@ -464,10 +464,7 @@ private:
|
|||||||
/// \code
|
/// \code
|
||||||
/// // Declare and load a font
|
/// // Declare and load a font
|
||||||
/// sf::Font font;
|
/// sf::Font font;
|
||||||
/// if (!font.loadFromFile("arial.ttf"))
|
/// font.loadFromFile("arial.ttf");
|
||||||
/// {
|
|
||||||
/// // Handle error...
|
|
||||||
/// }
|
|
||||||
///
|
///
|
||||||
/// // Create a text
|
/// // Create a text
|
||||||
/// sf::Text text(font, "hello");
|
/// sf::Text text(font, "hello");
|
||||||
|
@ -120,10 +120,8 @@ public:
|
|||||||
/// This function is a shortcut for the following code:
|
/// This function is a shortcut for the following code:
|
||||||
/// \code
|
/// \code
|
||||||
/// sf::Image image;
|
/// sf::Image image;
|
||||||
/// if (!image.loadFromFile(filename))
|
/// image.loadFromFile(filename);
|
||||||
/// return false;
|
/// texture.loadFromImage(image, area);
|
||||||
/// if (!texture.loadFromImage(image, area))
|
|
||||||
/// return false;
|
|
||||||
/// \endcode
|
/// \endcode
|
||||||
///
|
///
|
||||||
/// The \a area argument can be used to load only a sub-rectangle
|
/// The \a area argument can be used to load only a sub-rectangle
|
||||||
@ -153,10 +151,8 @@ public:
|
|||||||
/// This function is a shortcut for the following code:
|
/// This function is a shortcut for the following code:
|
||||||
/// \code
|
/// \code
|
||||||
/// sf::Image image;
|
/// sf::Image image;
|
||||||
/// if (!image.loadFromMemory(data, size))
|
/// image.loadFromMemory(data, size);
|
||||||
/// return false;
|
/// texture.loadFromImage(image, area);
|
||||||
/// if (!texture.loadFromImage(image, area))
|
|
||||||
/// return false;
|
|
||||||
/// \endcode
|
/// \endcode
|
||||||
///
|
///
|
||||||
/// The \a area argument can be used to load only a sub-rectangle
|
/// The \a area argument can be used to load only a sub-rectangle
|
||||||
@ -187,10 +183,8 @@ public:
|
|||||||
/// This function is a shortcut for the following code:
|
/// This function is a shortcut for the following code:
|
||||||
/// \code
|
/// \code
|
||||||
/// sf::Image image;
|
/// sf::Image image;
|
||||||
/// if (!image.loadFromStream(stream))
|
/// image.loadFromStream(stream);
|
||||||
/// return false;
|
/// texture.loadFromImage(image, area);
|
||||||
/// if (!texture.loadFromImage(image, area))
|
|
||||||
/// return false;
|
|
||||||
/// \endcode
|
/// \endcode
|
||||||
///
|
///
|
||||||
/// The \a area argument can be used to load only a sub-rectangle
|
/// The \a area argument can be used to load only a sub-rectangle
|
||||||
|
@ -63,7 +63,7 @@ constexpr Transform Transform::getInverse() const
|
|||||||
if (det != 0.f)
|
if (det != 0.f)
|
||||||
{
|
{
|
||||||
// clang-format off
|
// clang-format off
|
||||||
return {(m_matrix[15] * m_matrix[5] - m_matrix[7] * m_matrix[13]) / det,
|
return Transform( (m_matrix[15] * m_matrix[5] - m_matrix[7] * m_matrix[13]) / det,
|
||||||
-(m_matrix[15] * m_matrix[4] - m_matrix[7] * m_matrix[12]) / det,
|
-(m_matrix[15] * m_matrix[4] - m_matrix[7] * m_matrix[12]) / det,
|
||||||
(m_matrix[13] * m_matrix[4] - m_matrix[5] * m_matrix[12]) / det,
|
(m_matrix[13] * m_matrix[4] - m_matrix[5] * m_matrix[12]) / det,
|
||||||
-(m_matrix[15] * m_matrix[1] - m_matrix[3] * m_matrix[13]) / det,
|
-(m_matrix[15] * m_matrix[1] - m_matrix[3] * m_matrix[13]) / det,
|
||||||
@ -71,7 +71,7 @@ constexpr Transform Transform::getInverse() const
|
|||||||
-(m_matrix[13] * m_matrix[0] - m_matrix[1] * m_matrix[12]) / det,
|
-(m_matrix[13] * m_matrix[0] - m_matrix[1] * m_matrix[12]) / det,
|
||||||
(m_matrix[7] * m_matrix[1] - m_matrix[3] * m_matrix[5]) / det,
|
(m_matrix[7] * m_matrix[1] - m_matrix[3] * m_matrix[5]) / det,
|
||||||
-(m_matrix[7] * m_matrix[0] - m_matrix[3] * m_matrix[4]) / det,
|
-(m_matrix[7] * m_matrix[0] - m_matrix[3] * m_matrix[4]) / det,
|
||||||
(m_matrix[5] * m_matrix[0] - m_matrix[1] * m_matrix[4]) / det};
|
(m_matrix[5] * m_matrix[0] - m_matrix[1] * m_matrix[4]) / det);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -84,8 +84,8 @@ constexpr Transform Transform::getInverse() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
constexpr Vector2f Transform::transformPoint(const Vector2f& point) const
|
constexpr Vector2f Transform::transformPoint(const Vector2f& point) const
|
||||||
{
|
{
|
||||||
return {m_matrix[0] * point.x + m_matrix[4] * point.y + m_matrix[12],
|
return Vector2f(m_matrix[0] * point.x + m_matrix[4] * point.y + m_matrix[12],
|
||||||
m_matrix[1] * point.x + m_matrix[5] * point.y + m_matrix[13]};
|
m_matrix[1] * point.x + m_matrix[5] * point.y + m_matrix[13]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ constexpr FloatRect Transform::transformRect(const FloatRect& rectangle) const
|
|||||||
// clang-format on
|
// clang-format on
|
||||||
}
|
}
|
||||||
|
|
||||||
return {{left, top}, {right - left, bottom - top}};
|
return FloatRect({left, top}, {right - left, bottom - top});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,21 +73,21 @@ constexpr Time::operator std::chrono::duration<Rep, Period>() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
constexpr Time seconds(float amount)
|
constexpr Time seconds(float amount)
|
||||||
{
|
{
|
||||||
return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::duration<float>(amount));
|
return Time(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::duration<float>(amount)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
constexpr Time milliseconds(std::int32_t amount)
|
constexpr Time milliseconds(std::int32_t amount)
|
||||||
{
|
{
|
||||||
return std::chrono::milliseconds(amount);
|
return Time(std::chrono::milliseconds(amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
constexpr Time microseconds(std::int64_t amount)
|
constexpr Time microseconds(std::int64_t amount)
|
||||||
{
|
{
|
||||||
return std::chrono::microseconds(amount);
|
return Time(std::chrono::microseconds(amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ private:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get access to the underlying implementation
|
/// \brief Get access to the underlying implementation
|
||||||
///
|
///
|
||||||
/// This is primarily designed for sf::WindowBase::setMouseCursor,
|
/// This is primarily designed for sf::Window::setMouseCursor,
|
||||||
/// hence the friendship.
|
/// hence the friendship.
|
||||||
///
|
///
|
||||||
/// \return a reference to the OS-specific implementation
|
/// \return a reference to the OS-specific implementation
|
||||||
@ -238,7 +238,7 @@ private:
|
|||||||
///
|
///
|
||||||
/// After loading the cursor the graphical appearance
|
/// After loading the cursor the graphical appearance
|
||||||
/// with either loadFromPixels() or loadFromSystem(), the
|
/// with either loadFromPixels() or loadFromSystem(), the
|
||||||
/// cursor can be changed with sf::WindowBase::setMouseCursor().
|
/// cursor can be changed with sf::Window::setMouseCursor().
|
||||||
///
|
///
|
||||||
/// The behaviour is undefined if the cursor is destroyed while
|
/// The behaviour is undefined if the cursor is destroyed while
|
||||||
/// in use by the window.
|
/// in use by the window.
|
||||||
@ -254,6 +254,6 @@ private:
|
|||||||
/// window.setMouseCursor(cursor);
|
/// window.setMouseCursor(cursor);
|
||||||
/// \endcode
|
/// \endcode
|
||||||
///
|
///
|
||||||
/// \see sf::WindowBase::setMouseCursor
|
/// \see sf::Window::setMouseCursor
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -79,7 +79,7 @@ Vector2f CircleShape::getPoint(std::size_t index) const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector2f CircleShape::getGeometricCenter() const
|
Vector2f CircleShape::getGeometricCenter() const
|
||||||
{
|
{
|
||||||
return {m_radius, m_radius};
|
return Vector2f(m_radius, m_radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sf
|
} // namespace sf
|
||||||
|
@ -27,8 +27,6 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/ConvexShape.hpp>
|
#include <SFML/Graphics/ConvexShape.hpp>
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
{
|
{
|
||||||
@ -57,7 +55,6 @@ std::size_t ConvexShape::getPointCount() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void ConvexShape::setPoint(std::size_t index, const Vector2f& point)
|
void ConvexShape::setPoint(std::size_t index, const Vector2f& point)
|
||||||
{
|
{
|
||||||
assert(index < m_points.size() && "Index is out of bounds");
|
|
||||||
m_points[index] = point;
|
m_points[index] = point;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@ -66,7 +63,6 @@ void ConvexShape::setPoint(std::size_t index, const Vector2f& point)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector2f ConvexShape::getPoint(std::size_t index) const
|
Vector2f ConvexShape::getPoint(std::size_t index) const
|
||||||
{
|
{
|
||||||
assert(index < m_points.size() && "Index is out of bounds");
|
|
||||||
return m_points[index];
|
return m_points[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -755,7 +755,7 @@ IntRect Font::findGlyphRect(Page& page, const Vector2u& size) const
|
|||||||
if (!newTexture.create(textureSize * 2u))
|
if (!newTexture.create(textureSize * 2u))
|
||||||
{
|
{
|
||||||
err() << "Failed to create new page texture" << std::endl;
|
err() << "Failed to create new page texture" << std::endl;
|
||||||
return {{0, 0}, {2, 2}};
|
return IntRect({0, 0}, {2, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
newTexture.setSmooth(m_isSmooth);
|
newTexture.setSmooth(m_isSmooth);
|
||||||
@ -767,7 +767,7 @@ IntRect Font::findGlyphRect(Page& page, const Vector2u& size) const
|
|||||||
// Oops, we've reached the maximum texture size...
|
// Oops, we've reached the maximum texture size...
|
||||||
err() << "Failed to add a new character to the font: the maximum texture size has been reached"
|
err() << "Failed to add a new character to the font: the maximum texture size has been reached"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return {{0, 0}, {2, 2}};
|
return IntRect({0, 0}, {2, 2});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ void Image::setPixel(const Vector2u& coords, const Color& color)
|
|||||||
Color Image::getPixel(const Vector2u& coords) const
|
Color Image::getPixel(const Vector2u& coords) const
|
||||||
{
|
{
|
||||||
const std::uint8_t* pixel = &m_pixels[(coords.x + coords.y * m_size.x) * 4];
|
const std::uint8_t* pixel = &m_pixels[(coords.x + coords.y * m_size.x) * 4];
|
||||||
return {pixel[0], pixel[1], pixel[2], pixel[3]};
|
return Color(pixel[0], pixel[1], pixel[2], pixel[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,13 +68,13 @@ Vector2f RectangleShape::getPoint(std::size_t index) const
|
|||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case 0:
|
case 0:
|
||||||
return {0, 0};
|
return Vector2f(0, 0);
|
||||||
case 1:
|
case 1:
|
||||||
return {m_size.x, 0};
|
return Vector2f(m_size.x, 0);
|
||||||
case 2:
|
case 2:
|
||||||
return {m_size.x, m_size.y};
|
return Vector2f(m_size.x, m_size.y);
|
||||||
case 3:
|
case 3:
|
||||||
return {0, m_size.y};
|
return Vector2f(0, m_size.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ FloatRect Sprite::getLocalBounds() const
|
|||||||
const auto width = static_cast<float>(std::abs(m_textureRect.width));
|
const auto width = static_cast<float>(std::abs(m_textureRect.width));
|
||||||
const auto height = static_cast<float>(std::abs(m_textureRect.height));
|
const auto height = static_cast<float>(std::abs(m_textureRect.height));
|
||||||
|
|
||||||
return {{0.f, 0.f}, {width, height}};
|
return FloatRect({0.f, 0.f}, {width, height});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -365,7 +365,7 @@ Image Texture::copyToImage() const
|
|||||||
{
|
{
|
||||||
// Easy case: empty texture
|
// Easy case: empty texture
|
||||||
if (!m_texture)
|
if (!m_texture)
|
||||||
return {};
|
return Image();
|
||||||
|
|
||||||
const TransientContextLock lock;
|
const TransientContextLock lock;
|
||||||
|
|
||||||
|
@ -28,8 +28,6 @@
|
|||||||
#include <SFML/Graphics/RenderTarget.hpp>
|
#include <SFML/Graphics/RenderTarget.hpp>
|
||||||
#include <SFML/Graphics/VertexArray.hpp>
|
#include <SFML/Graphics/VertexArray.hpp>
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
{
|
{
|
||||||
@ -53,7 +51,6 @@ std::size_t VertexArray::getVertexCount() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vertex& VertexArray::operator[](std::size_t index)
|
Vertex& VertexArray::operator[](std::size_t index)
|
||||||
{
|
{
|
||||||
assert(index < m_vertices.size() && "Index is out of bounds");
|
|
||||||
return m_vertices[index];
|
return m_vertices[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +58,6 @@ Vertex& VertexArray::operator[](std::size_t index)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
const Vertex& VertexArray::operator[](std::size_t index) const
|
const Vertex& VertexArray::operator[](std::size_t index) const
|
||||||
{
|
{
|
||||||
assert(index < m_vertices.size() && "Index is out of bounds");
|
|
||||||
return m_vertices[index];
|
return m_vertices[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,12 +124,12 @@ FloatRect VertexArray::getBounds() const
|
|||||||
bottom = position.y;
|
bottom = position.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {{left, top}, {right - left, bottom - top}};
|
return FloatRect({left, top}, {right - left, bottom - top});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Array is empty
|
// Array is empty
|
||||||
return {};
|
return FloatRect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ Ftp::Response Ftp::keepAlive()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Ftp::DirectoryResponse Ftp::getWorkingDirectory()
|
Ftp::DirectoryResponse Ftp::getWorkingDirectory()
|
||||||
{
|
{
|
||||||
return {sendCommand("PWD")};
|
return DirectoryResponse(sendCommand("PWD"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ Ftp::ListingResponse Ftp::getDirectoryListing(const std::string& directory)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {response, directoryData.str()};
|
return ListingResponse(response, directoryData.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
|
||||||
@ -214,7 +213,6 @@ String& String::operator+=(const String& right)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
char32_t String::operator[](std::size_t index) const
|
char32_t String::operator[](std::size_t index) const
|
||||||
{
|
{
|
||||||
assert(index < m_string.size() && "Index is out of bounds");
|
|
||||||
return m_string[index];
|
return m_string[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +220,6 @@ char32_t String::operator[](std::size_t index) const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
char32_t& String::operator[](std::size_t index)
|
char32_t& String::operator[](std::size_t index)
|
||||||
{
|
{
|
||||||
assert(index < m_string.size() && "Index is out of bounds");
|
|
||||||
return m_string[index];
|
return m_string[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ namespace sf::priv
|
|||||||
String ClipboardImpl::getString()
|
String ClipboardImpl::getString()
|
||||||
{
|
{
|
||||||
sf::err() << "Clipboard API not implemented for Android.\n";
|
sf::err() << "Clipboard API not implemented for Android.\n";
|
||||||
return {};
|
return String();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ void JoystickImpl::close()
|
|||||||
JoystickCaps JoystickImpl::getCapabilities() const
|
JoystickCaps JoystickImpl::getCapabilities() const
|
||||||
{
|
{
|
||||||
// To implement
|
// To implement
|
||||||
return {};
|
return JoystickCaps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ Joystick::Identification JoystickImpl::getIdentification() const
|
|||||||
JoystickState JoystickImpl::update()
|
JoystickState JoystickImpl::update()
|
||||||
{
|
{
|
||||||
// To implement
|
// To implement
|
||||||
return {};
|
return JoystickState();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sf::priv
|
} // namespace sf::priv
|
||||||
|
@ -125,7 +125,7 @@ void WindowImplAndroid::processEvents()
|
|||||||
Vector2i WindowImplAndroid::getPosition() const
|
Vector2i WindowImplAndroid::getPosition() const
|
||||||
{
|
{
|
||||||
// Not applicable
|
// Not applicable
|
||||||
return {};
|
return Vector2i(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -682,7 +682,7 @@ Vector2i InputImpl::getTouchPosition(unsigned int finger)
|
|||||||
return slot.pos;
|
return slot.pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return Vector2i();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ WindowHandle WindowImplDRM::getNativeHandle() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector2i WindowImplDRM::getPosition() const
|
Vector2i WindowImplDRM::getPosition() const
|
||||||
{
|
{
|
||||||
return {0, 0};
|
return Vector2i(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ XVisualInfo GlxContext::selectBestVisual(::Display* display, unsigned int bitsPe
|
|||||||
// Should never happen...
|
// Should never happen...
|
||||||
err() << "No GLX visual found. You should check your graphics driver" << std::endl;
|
err() << "No GLX visual found. You should check your graphics driver" << std::endl;
|
||||||
|
|
||||||
return {};
|
return XVisualInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ Vector2i InputImpl::getMousePosition()
|
|||||||
// Close the connection with the X server
|
// Close the connection with the X server
|
||||||
closeDisplay(display);
|
closeDisplay(display);
|
||||||
|
|
||||||
return {gx, gy};
|
return Vector2i(gx, gy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -165,11 +165,11 @@ Vector2i InputImpl::getMousePosition(const WindowBase& relativeTo)
|
|||||||
// Close the connection with the X server
|
// Close the connection with the X server
|
||||||
closeDisplay(display);
|
closeDisplay(display);
|
||||||
|
|
||||||
return {x, y};
|
return Vector2i(x, y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return {};
|
return Vector2i();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ bool InputImpl::isTouchDown(unsigned int /*finger*/)
|
|||||||
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/)
|
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/)
|
||||||
{
|
{
|
||||||
// Not applicable
|
// Not applicable
|
||||||
return {};
|
return Vector2i();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/)
|
|||||||
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/, const WindowBase& /*relativeTo*/)
|
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/, const WindowBase& /*relativeTo*/)
|
||||||
{
|
{
|
||||||
// Not applicable
|
// Not applicable
|
||||||
return {};
|
return Vector2i();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sf::priv
|
} // namespace sf::priv
|
||||||
|
@ -407,7 +407,7 @@ std::string getJoystickName(unsigned int index)
|
|||||||
::close(fd);
|
::close(fd);
|
||||||
|
|
||||||
if (result >= 0)
|
if (result >= 0)
|
||||||
return name;
|
return std::string(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fall back to manual USB chain walk via udev
|
// Fall back to manual USB chain walk via udev
|
||||||
@ -421,13 +421,13 @@ std::string getJoystickName(unsigned int index)
|
|||||||
udev_device_unref(udevDevice);
|
udev_device_unref(udevDevice);
|
||||||
|
|
||||||
if (product)
|
if (product)
|
||||||
return {product};
|
return std::string(product);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::err() << "Unable to get name for joystick " << devnode << std::endl;
|
sf::err() << "Unable to get name for joystick " << devnode << std::endl;
|
||||||
|
|
||||||
return "Unknown Joystick";
|
return std::string("Unknown Joystick");
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -677,7 +677,7 @@ String KeyboardImpl::getDescription(Keyboard::Scancode code)
|
|||||||
const char32_t unicode = keysymToUnicode(keysym);
|
const char32_t unicode = keysymToUnicode(keysym);
|
||||||
|
|
||||||
if (unicode != 0)
|
if (unicode != 0)
|
||||||
return {unicode};
|
return String(unicode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to our best guess for the keys that are known to be independent of the layout.
|
// Fallback to our best guess for the keys that are known to be independent of the layout.
|
||||||
|
@ -71,7 +71,7 @@ void SensorImpl::close()
|
|||||||
Vector3f SensorImpl::update()
|
Vector3f SensorImpl::update()
|
||||||
{
|
{
|
||||||
// To be implemented
|
// To be implemented
|
||||||
return {0, 0, 0};
|
return Vector3f(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ using ContextType = sf::priv::GlxContext;
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
// A nested named namespace is used here to allow unity builds of SFML.
|
// A nested named namespace is used here to allow unity builds of SFML.
|
||||||
namespace WindowImplX11Impl
|
namespace WindowsImplX11Impl
|
||||||
{
|
{
|
||||||
sf::priv::WindowImplX11* fullscreenWindow = nullptr;
|
sf::priv::WindowImplX11* fullscreenWindow = nullptr;
|
||||||
std::vector<sf::priv::WindowImplX11*> allWindows;
|
std::vector<sf::priv::WindowImplX11*> allWindows;
|
||||||
@ -381,7 +381,7 @@ bool isWMAbsolutePositionGood()
|
|||||||
std::end(wmAbsPosGood),
|
std::end(wmAbsPosGood),
|
||||||
[&](const sf::String& name) { return name == windowManagerName; });
|
[&](const sf::String& name) { return name == windowManagerName; });
|
||||||
}
|
}
|
||||||
} // namespace WindowImplX11Impl
|
} // namespace WindowsImplX11Impl
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
@ -434,7 +434,7 @@ struct XDeleter<XRRCrtcInfo>
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
WindowImplX11::WindowImplX11(WindowHandle handle) : m_isExternal(true)
|
WindowImplX11::WindowImplX11(WindowHandle handle) : m_isExternal(true)
|
||||||
{
|
{
|
||||||
using namespace WindowImplX11Impl;
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
// Open a connection with the X server
|
// Open a connection with the X server
|
||||||
m_display = openDisplay();
|
m_display = openDisplay();
|
||||||
@ -470,7 +470,7 @@ m_isExternal(false),
|
|||||||
m_fullscreen((style & Style::Fullscreen) != 0),
|
m_fullscreen((style & Style::Fullscreen) != 0),
|
||||||
m_cursorGrabbed(m_fullscreen)
|
m_cursorGrabbed(m_fullscreen)
|
||||||
{
|
{
|
||||||
using namespace WindowImplX11Impl;
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
// Open a connection with the X server
|
// Open a connection with the X server
|
||||||
m_display = openDisplay();
|
m_display = openDisplay();
|
||||||
@ -678,7 +678,7 @@ m_cursorGrabbed(m_fullscreen)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
WindowImplX11::~WindowImplX11()
|
WindowImplX11::~WindowImplX11()
|
||||||
{
|
{
|
||||||
using namespace WindowImplX11Impl;
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
// Cleanup graphical resources
|
// Cleanup graphical resources
|
||||||
cleanup();
|
cleanup();
|
||||||
@ -729,7 +729,7 @@ WindowHandle WindowImplX11::getNativeHandle() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::processEvents()
|
void WindowImplX11::processEvents()
|
||||||
{
|
{
|
||||||
using namespace WindowImplX11Impl;
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
XEvent event;
|
XEvent event;
|
||||||
|
|
||||||
@ -800,7 +800,7 @@ void WindowImplX11::processEvents()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector2i WindowImplX11::getPosition() const
|
Vector2i WindowImplX11::getPosition() const
|
||||||
{
|
{
|
||||||
using namespace WindowImplX11Impl;
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
// Get absolute position of our window relative to root window. This
|
// Get absolute position of our window relative to root window. This
|
||||||
// takes into account all information that X11 has, including X11
|
// takes into account all information that X11 has, including X11
|
||||||
@ -818,7 +818,7 @@ Vector2i WindowImplX11::getPosition() const
|
|||||||
// it to, even with decorations and such, which get shifted back.
|
// it to, even with decorations and such, which get shifted back.
|
||||||
// In these rare cases, we can use the absolute value directly.
|
// In these rare cases, we can use the absolute value directly.
|
||||||
if (isWMAbsolutePositionGood())
|
if (isWMAbsolutePositionGood())
|
||||||
return {xAbsRelToRoot, yAbsRelToRoot};
|
return Vector2i(xAbsRelToRoot, yAbsRelToRoot);
|
||||||
|
|
||||||
// CASE 2: most modern WMs support EWMH and can define _NET_FRAME_EXTENTS
|
// CASE 2: most modern WMs support EWMH and can define _NET_FRAME_EXTENTS
|
||||||
// with the exact frame size to subtract, so if present, we prefer it and
|
// with the exact frame size to subtract, so if present, we prefer it and
|
||||||
@ -830,7 +830,7 @@ Vector2i WindowImplX11::getPosition() const
|
|||||||
{
|
{
|
||||||
// Get final X/Y coordinates: subtract EWMH frame extents from
|
// Get final X/Y coordinates: subtract EWMH frame extents from
|
||||||
// absolute window position.
|
// absolute window position.
|
||||||
return {(xAbsRelToRoot - static_cast<int>(xFrameExtent)), (yAbsRelToRoot - static_cast<int>(yFrameExtent))};
|
return Vector2i((xAbsRelToRoot - static_cast<int>(xFrameExtent)), (yAbsRelToRoot - static_cast<int>(yFrameExtent)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// CASE 3: EWMH frame extents were not available, use geometry.
|
// CASE 3: EWMH frame extents were not available, use geometry.
|
||||||
@ -866,7 +866,7 @@ Vector2i WindowImplX11::getPosition() const
|
|||||||
|
|
||||||
XGetGeometry(m_display, ancestor, &root, &xRelToRoot, &yRelToRoot, &width, &height, &borderWidth, &depth);
|
XGetGeometry(m_display, ancestor, &root, &xRelToRoot, &yRelToRoot, &width, &height, &borderWidth, &depth);
|
||||||
|
|
||||||
return {xRelToRoot, yRelToRoot};
|
return Vector2i(xRelToRoot, yRelToRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -928,7 +928,8 @@ void WindowImplX11::setTitle(const String& title)
|
|||||||
// There is however an option to tell the window manager your Unicode title via hints.
|
// There is however an option to tell the window manager your Unicode title via hints.
|
||||||
|
|
||||||
// Convert to UTF-8 encoding.
|
// Convert to UTF-8 encoding.
|
||||||
const std::basic_string<std::uint8_t> utf8Title = title.toUtf8();
|
std::basic_string<std::uint8_t> utf8Title;
|
||||||
|
Utf32::toUtf8(title.begin(), title.end(), std::back_inserter(utf8Title));
|
||||||
|
|
||||||
const Atom useUtf8 = getAtom("UTF8_STRING", false);
|
const Atom useUtf8 = getAtom("UTF8_STRING", false);
|
||||||
|
|
||||||
@ -1125,7 +1126,7 @@ void WindowImplX11::setMouseCursor(const CursorImpl& cursor)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::setMouseCursorGrabbed(bool grabbed)
|
void WindowImplX11::setMouseCursorGrabbed(bool grabbed)
|
||||||
{
|
{
|
||||||
using namespace WindowImplX11Impl;
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
// This has no effect in fullscreen mode
|
// This has no effect in fullscreen mode
|
||||||
if (m_fullscreen || (m_cursorGrabbed == grabbed))
|
if (m_fullscreen || (m_cursorGrabbed == grabbed))
|
||||||
@ -1170,7 +1171,7 @@ void WindowImplX11::setKeyRepeatEnabled(bool enabled)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::requestFocus()
|
void WindowImplX11::requestFocus()
|
||||||
{
|
{
|
||||||
using namespace WindowImplX11Impl;
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
// Focus is only stolen among SFML windows, not between applications
|
// Focus is only stolen among SFML windows, not between applications
|
||||||
// Check the global list of windows to find out whether an SFML window has the focus
|
// Check the global list of windows to find out whether an SFML window has the focus
|
||||||
@ -1235,7 +1236,7 @@ bool WindowImplX11::hasFocus() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::grabFocus()
|
void WindowImplX11::grabFocus()
|
||||||
{
|
{
|
||||||
using namespace WindowImplX11Impl;
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
Atom netActiveWindow = None;
|
Atom netActiveWindow = None;
|
||||||
|
|
||||||
@ -1284,7 +1285,7 @@ void WindowImplX11::grabFocus()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::setVideoMode(const VideoMode& mode)
|
void WindowImplX11::setVideoMode(const VideoMode& mode)
|
||||||
{
|
{
|
||||||
using namespace WindowImplX11Impl;
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
// Skip mode switching if the new mode is equal to the desktop mode
|
// Skip mode switching if the new mode is equal to the desktop mode
|
||||||
if (mode == VideoMode::getDesktopMode())
|
if (mode == VideoMode::getDesktopMode())
|
||||||
@ -1376,7 +1377,7 @@ void WindowImplX11::setVideoMode(const VideoMode& mode)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::resetVideoMode()
|
void WindowImplX11::resetVideoMode()
|
||||||
{
|
{
|
||||||
using namespace WindowImplX11Impl;
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
if (fullscreenWindow == this)
|
if (fullscreenWindow == this)
|
||||||
{
|
{
|
||||||
@ -1438,7 +1439,7 @@ void WindowImplX11::resetVideoMode()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::switchToFullscreen()
|
void WindowImplX11::switchToFullscreen()
|
||||||
{
|
{
|
||||||
using namespace WindowImplX11Impl;
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
grabFocus();
|
grabFocus();
|
||||||
|
|
||||||
@ -1494,7 +1495,7 @@ void WindowImplX11::switchToFullscreen()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::setProtocols()
|
void WindowImplX11::setProtocols()
|
||||||
{
|
{
|
||||||
using namespace WindowImplX11Impl;
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
const Atom wmProtocols = getAtom("WM_PROTOCOLS");
|
const Atom wmProtocols = getAtom("WM_PROTOCOLS");
|
||||||
const Atom wmDeleteWindow = getAtom("WM_DELETE_WINDOW");
|
const Atom wmDeleteWindow = getAtom("WM_DELETE_WINDOW");
|
||||||
@ -1562,7 +1563,7 @@ void WindowImplX11::setProtocols()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::initialize()
|
void WindowImplX11::initialize()
|
||||||
{
|
{
|
||||||
using namespace WindowImplX11Impl;
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
// Create the input context
|
// Create the input context
|
||||||
m_inputMethod = openXim();
|
m_inputMethod = openXim();
|
||||||
@ -1678,7 +1679,7 @@ void WindowImplX11::cleanup()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool WindowImplX11::processEvent(XEvent& windowEvent)
|
bool WindowImplX11::processEvent(XEvent& windowEvent)
|
||||||
{
|
{
|
||||||
using namespace WindowImplX11Impl;
|
using namespace WindowsImplX11Impl;
|
||||||
|
|
||||||
// Convert the X11 event to a sf::Event
|
// Convert the X11 event to a sf::Event
|
||||||
switch (windowEvent.type)
|
switch (windowEvent.type)
|
||||||
|
@ -647,7 +647,7 @@ Vector2i InputImpl::getMousePosition()
|
|||||||
{
|
{
|
||||||
POINT point;
|
POINT point;
|
||||||
GetCursorPos(&point);
|
GetCursorPos(&point);
|
||||||
return {point.x, point.y};
|
return Vector2i(point.x, point.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -660,11 +660,11 @@ Vector2i InputImpl::getMousePosition(const WindowBase& relativeTo)
|
|||||||
POINT point;
|
POINT point;
|
||||||
GetCursorPos(&point);
|
GetCursorPos(&point);
|
||||||
ScreenToClient(handle, &point);
|
ScreenToClient(handle, &point);
|
||||||
return {point.x, point.y};
|
return Vector2i(point.x, point.y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return {};
|
return Vector2i();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -701,7 +701,7 @@ bool InputImpl::isTouchDown(unsigned int /*finger*/)
|
|||||||
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/)
|
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/)
|
||||||
{
|
{
|
||||||
// Not applicable
|
// Not applicable
|
||||||
return {};
|
return Vector2i();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -709,7 +709,7 @@ Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/)
|
|||||||
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/, const WindowBase& /*relativeTo*/)
|
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/, const WindowBase& /*relativeTo*/)
|
||||||
{
|
{
|
||||||
// Not applicable
|
// Not applicable
|
||||||
return {};
|
return Vector2i();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sf::priv
|
} // namespace sf::priv
|
||||||
|
@ -71,7 +71,7 @@ void SensorImpl::close()
|
|||||||
Vector3f SensorImpl::update()
|
Vector3f SensorImpl::update()
|
||||||
{
|
{
|
||||||
// To be implemented
|
// To be implemented
|
||||||
return {};
|
return Vector3f(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ String getErrorString(DWORD errorCode)
|
|||||||
|
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << "Error " << errorCode;
|
ss << "Error " << errorCode;
|
||||||
return {ss.str()};
|
return String(ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ Vector2i WindowImplWin32::getPosition() const
|
|||||||
RECT rect;
|
RECT rect;
|
||||||
GetWindowRect(m_handle, &rect);
|
GetWindowRect(m_handle, &rect);
|
||||||
|
|
||||||
return {rect.left, rect.top};
|
return Vector2i(rect.left, rect.top);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ Vector2u WindowImplWin32::getSize() const
|
|||||||
RECT rect;
|
RECT rect;
|
||||||
GetClientRect(m_handle, &rect);
|
GetClientRect(m_handle, &rect);
|
||||||
|
|
||||||
return Vector2u(Vector2<LONG>(rect.right - rect.left, rect.bottom - rect.top));
|
return Vector2u(static_cast<unsigned int>(rect.right - rect.left), static_cast<unsigned int>(rect.bottom - rect.top));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ String ClipboardImpl::getString()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return {};
|
return String();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ bool InputImpl::isMouseButtonPressed(Mouse::Button /* button */)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector2i InputImpl::getMousePosition()
|
Vector2i InputImpl::getMousePosition()
|
||||||
{
|
{
|
||||||
return {};
|
return Vector2i(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ void JoystickImpl::close()
|
|||||||
JoystickCaps JoystickImpl::getCapabilities() const
|
JoystickCaps JoystickImpl::getCapabilities() const
|
||||||
{
|
{
|
||||||
// Not implemented
|
// Not implemented
|
||||||
return {};
|
return JoystickCaps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ JoystickCaps JoystickImpl::getCapabilities() const
|
|||||||
Joystick::Identification JoystickImpl::getIdentification() const
|
Joystick::Identification JoystickImpl::getIdentification() const
|
||||||
{
|
{
|
||||||
// Not implemented
|
// Not implemented
|
||||||
return {};
|
return Joystick::Identification();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ Joystick::Identification JoystickImpl::getIdentification() const
|
|||||||
JoystickState JoystickImpl::update()
|
JoystickState JoystickImpl::update()
|
||||||
{
|
{
|
||||||
// Not implemented
|
// Not implemented
|
||||||
return {};
|
return JoystickState();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sf::priv
|
} // namespace sf::priv
|
||||||
|
@ -109,8 +109,8 @@ WindowHandle WindowImplUIKit::getNativeHandle() const
|
|||||||
Vector2i WindowImplUIKit::getPosition() const
|
Vector2i WindowImplUIKit::getPosition() const
|
||||||
{
|
{
|
||||||
const CGPoint origin = m_window.frame.origin;
|
const CGPoint origin = m_window.frame.origin;
|
||||||
return {static_cast<int>(origin.x * static_cast<double>(m_backingScale)),
|
return Vector2i(static_cast<int>(origin.x * static_cast<double>(m_backingScale)),
|
||||||
static_cast<int>(origin.y * static_cast<double>(m_backingScale))};
|
static_cast<int>(origin.y * static_cast<double>(m_backingScale)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -124,8 +124,8 @@ void WindowImplUIKit::setPosition(const Vector2i& /* position */)
|
|||||||
Vector2u WindowImplUIKit::getSize() const
|
Vector2u WindowImplUIKit::getSize() const
|
||||||
{
|
{
|
||||||
const CGRect physicalFrame = m_window.frame;
|
const CGRect physicalFrame = m_window.frame;
|
||||||
return {static_cast<unsigned int>(physicalFrame.size.width * static_cast<double>(m_backingScale)),
|
return Vector2u(static_cast<unsigned int>(physicalFrame.size.width * static_cast<double>(m_backingScale)),
|
||||||
static_cast<unsigned int>(physicalFrame.size.height * static_cast<double>(m_backingScale))};
|
static_cast<unsigned int>(physicalFrame.size.height * static_cast<double>(m_backingScale)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -691,7 +691,7 @@ String HIDInputManager::getDescription(Keyboard::Scancode code)
|
|||||||
// Phase 2: Try to convert the key to unicode
|
// Phase 2: Try to convert the key to unicode
|
||||||
const UniChar unicode = toUnicode(localize(code));
|
const UniChar unicode = toUnicode(localize(code));
|
||||||
if (unicode != 0x00)
|
if (unicode != 0x00)
|
||||||
return {static_cast<char32_t>(unicode)};
|
return String(static_cast<char32_t>(unicode));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Phase 3: Return final fallback
|
// Phase 3: Return final fallback
|
||||||
@ -771,7 +771,7 @@ void HIDInputManager::loadKeyboard(IOHIDDeviceRef keyboard)
|
|||||||
CFArrayRef underlying = IOHIDDeviceCopyMatchingElements(keyboard, nullptr, kIOHIDOptionsTypeNone);
|
CFArrayRef underlying = IOHIDDeviceCopyMatchingElements(keyboard, nullptr, kIOHIDOptionsTypeNone);
|
||||||
if ((underlying == nullptr) || (CFArrayGetCount(underlying) == 0))
|
if ((underlying == nullptr) || (CFArrayGetCount(underlying) == 0))
|
||||||
{
|
{
|
||||||
err() << "Detected a keyboard without any keys." << std::endl;
|
err() << "We got a keyboard without any keys." << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ Vector2i InputImpl::getMousePosition(const WindowBase& relativeTo)
|
|||||||
|
|
||||||
// No view ?
|
// No view ?
|
||||||
if (view == nil)
|
if (view == nil)
|
||||||
return {};
|
return Vector2i();
|
||||||
|
|
||||||
// Use -cursorPositionFromEvent: with nil.
|
// Use -cursorPositionFromEvent: with nil.
|
||||||
const NSPoint pos = [view cursorPositionFromEvent:nil];
|
const NSPoint pos = [view cursorPositionFromEvent:nil];
|
||||||
@ -250,7 +250,7 @@ bool InputImpl::isTouchDown(unsigned int /*finger*/)
|
|||||||
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/)
|
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/)
|
||||||
{
|
{
|
||||||
// Not applicable
|
// Not applicable
|
||||||
return {};
|
return Vector2i();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -258,7 +258,7 @@ Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/)
|
|||||||
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/, const WindowBase& /*relativeTo*/)
|
Vector2i InputImpl::getTouchPosition(unsigned int /*finger*/, const WindowBase& /*relativeTo*/)
|
||||||
{
|
{
|
||||||
// Not applicable
|
// Not applicable
|
||||||
return {};
|
return Vector2i();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sf::priv
|
} // namespace sf::priv
|
||||||
|
@ -71,7 +71,7 @@ void SensorImpl::close()
|
|||||||
Vector3f SensorImpl::update()
|
Vector3f SensorImpl::update()
|
||||||
{
|
{
|
||||||
// To be implemented
|
// To be implemented
|
||||||
return {0, 0, 0};
|
return Vector3f(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,8 +7,7 @@ set(CATCH_CONFIG_FAST_COMPILE ON CACHE BOOL "")
|
|||||||
set(CATCH_CONFIG_NO_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT ON CACHE BOOL "")
|
set(CATCH_CONFIG_NO_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT ON CACHE BOOL "")
|
||||||
FetchContent_Declare(Catch2
|
FetchContent_Declare(Catch2
|
||||||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||||
GIT_TAG v3.4.0
|
GIT_TAG v3.4.0)
|
||||||
GIT_SHALLOW ON)
|
|
||||||
FetchContent_MakeAvailable(Catch2)
|
FetchContent_MakeAvailable(Catch2)
|
||||||
include(Catch)
|
include(Catch)
|
||||||
|
|
||||||
|
@ -24,11 +24,11 @@ public:
|
|||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case 0:
|
case 0:
|
||||||
return {m_size.x / 2, 0};
|
return sf::Vector2f(m_size.x / 2, 0);
|
||||||
case 1:
|
case 1:
|
||||||
return {0, m_size.y};
|
return sf::Vector2f(0, m_size.y);
|
||||||
case 2:
|
case 2:
|
||||||
return {m_size.x, m_size.y};
|
return sf::Vector2f(m_size.x, m_size.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
TEST_CASE("[Window] sf::Cursor", runDisplayTests())
|
// Skip these tests with [.display] because they fail when using DRM which hasn't implemented sf::Cursor
|
||||||
|
TEST_CASE("[Window] sf::Cursor", "[.display]")
|
||||||
{
|
{
|
||||||
SECTION("Type traits")
|
SECTION("Type traits")
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user