Compare commits
10 Commits
a71d6bc078
...
910514871e
Author | SHA1 | Date | |
---|---|---|---|
|
910514871e | ||
|
1b257c8ea8 | ||
|
6b503a726d | ||
|
9dc2e541e8 | ||
|
434effd6a1 | ||
|
f9e6f673dd | ||
|
d56e1838a0 | ||
|
f6f95b03a5 | ||
|
d6079ce526 | ||
|
5cfbf912c7 |
@ -29,7 +29,6 @@ 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,9 +214,6 @@ 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 sf::Color(static_cast<std::uint8_t>(r), static_cast<std::uint8_t>(g), static_cast<std::uint8_t>(b));
|
return {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 sf::Vector2f(crossProduct.x, crossProduct.y);
|
return {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 Color(clampedAdd(left.r, right.r),
|
return {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 Color(clampedSub(left.r, right.r),
|
return {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,10 +109,7 @@ 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 Color(scaledMul(left.r, right.r),
|
return {scaledMul(left.r, right.r), scaledMul(left.g, right.g), scaledMul(left.b, right.b), scaledMul(left.a, right.a)};
|
||||||
scaledMul(left.g, right.g),
|
|
||||||
scaledMul(left.b, right.b),
|
|
||||||
scaledMul(left.a, right.a));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -265,7 +265,10 @@ private:
|
|||||||
/// \code
|
/// \code
|
||||||
/// // Declare and load a texture
|
/// // Declare and load a texture
|
||||||
/// sf::Texture texture;
|
/// sf::Texture texture;
|
||||||
/// texture.loadFromFile("texture.png");
|
/// if (!texture.loadFromFile("texture.png"))
|
||||||
|
/// {
|
||||||
|
/// // Handle error...
|
||||||
|
/// }
|
||||||
///
|
///
|
||||||
/// // Create a sprite
|
/// // Create a sprite
|
||||||
/// sf::Sprite sprite(texture);
|
/// sf::Sprite sprite(texture);
|
||||||
|
@ -464,7 +464,10 @@ private:
|
|||||||
/// \code
|
/// \code
|
||||||
/// // Declare and load a font
|
/// // Declare and load a font
|
||||||
/// sf::Font font;
|
/// sf::Font font;
|
||||||
/// font.loadFromFile("arial.ttf");
|
/// if (!font.loadFromFile("arial.ttf"))
|
||||||
|
/// {
|
||||||
|
/// // Handle error...
|
||||||
|
/// }
|
||||||
///
|
///
|
||||||
/// // Create a text
|
/// // Create a text
|
||||||
/// sf::Text text(font, "hello");
|
/// sf::Text text(font, "hello");
|
||||||
|
@ -120,8 +120,10 @@ 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;
|
||||||
/// image.loadFromFile(filename);
|
/// if (!image.loadFromFile(filename))
|
||||||
/// texture.loadFromImage(image, area);
|
/// return false;
|
||||||
|
/// 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
|
||||||
@ -151,8 +153,10 @@ 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;
|
||||||
/// image.loadFromMemory(data, size);
|
/// if (!image.loadFromMemory(data, size))
|
||||||
/// texture.loadFromImage(image, area);
|
/// return false;
|
||||||
|
/// 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
|
||||||
@ -183,8 +187,10 @@ 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;
|
||||||
/// image.loadFromStream(stream);
|
/// if (!image.loadFromStream(stream))
|
||||||
/// texture.loadFromImage(image, area);
|
/// return false;
|
||||||
|
/// 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 Transform( (m_matrix[15] * m_matrix[5] - m_matrix[7] * m_matrix[13]) / det,
|
return {(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 Vector2f(m_matrix[0] * point.x + m_matrix[4] * point.y + m_matrix[12],
|
return {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 FloatRect({left, top}, {right - left, bottom - top});
|
return {{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 Time(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::duration<float>(amount)));
|
return 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 Time(std::chrono::milliseconds(amount));
|
return std::chrono::milliseconds(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
constexpr Time microseconds(std::int64_t amount)
|
constexpr Time microseconds(std::int64_t amount)
|
||||||
{
|
{
|
||||||
return Time(std::chrono::microseconds(amount));
|
return 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::Window::setMouseCursor,
|
/// This is primarily designed for sf::WindowBase::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::Window::setMouseCursor().
|
/// cursor can be changed with sf::WindowBase::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::Window::setMouseCursor
|
/// \see sf::WindowBase::setMouseCursor
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -79,7 +79,7 @@ Vector2f CircleShape::getPoint(std::size_t index) const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector2f CircleShape::getGeometricCenter() const
|
Vector2f CircleShape::getGeometricCenter() const
|
||||||
{
|
{
|
||||||
return Vector2f(m_radius, m_radius);
|
return {m_radius, m_radius};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sf
|
} // namespace sf
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/ConvexShape.hpp>
|
#include <SFML/Graphics/ConvexShape.hpp>
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
{
|
{
|
||||||
@ -55,6 +57,7 @@ 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();
|
||||||
}
|
}
|
||||||
@ -63,6 +66,7 @@ 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 IntRect({0, 0}, {2, 2});
|
return {{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 IntRect({0, 0}, {2, 2});
|
return {{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 Color(pixel[0], pixel[1], pixel[2], pixel[3]);
|
return {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 Vector2f(0, 0);
|
return {0, 0};
|
||||||
case 1:
|
case 1:
|
||||||
return Vector2f(m_size.x, 0);
|
return {m_size.x, 0};
|
||||||
case 2:
|
case 2:
|
||||||
return Vector2f(m_size.x, m_size.y);
|
return {m_size.x, m_size.y};
|
||||||
case 3:
|
case 3:
|
||||||
return Vector2f(0, m_size.y);
|
return {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 FloatRect({0.f, 0.f}, {width, height});
|
return {{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 Image();
|
return {};
|
||||||
|
|
||||||
const TransientContextLock lock;
|
const TransientContextLock lock;
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#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
|
||||||
{
|
{
|
||||||
@ -51,6 +53,7 @@ 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];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,6 +61,7 @@ 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];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,12 +128,12 @@ FloatRect VertexArray::getBounds() const
|
|||||||
bottom = position.y;
|
bottom = position.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FloatRect({left, top}, {right - left, bottom - top});
|
return {{left, top}, {right - left, bottom - top}};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Array is empty
|
// Array is empty
|
||||||
return FloatRect();
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ Ftp::Response Ftp::keepAlive()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Ftp::DirectoryResponse Ftp::getWorkingDirectory()
|
Ftp::DirectoryResponse Ftp::getWorkingDirectory()
|
||||||
{
|
{
|
||||||
return DirectoryResponse(sendCommand("PWD"));
|
return {sendCommand("PWD")};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ Ftp::ListingResponse Ftp::getDirectoryListing(const std::string& directory)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ListingResponse(response, directoryData.str());
|
return {response, directoryData.str()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
|
||||||
@ -213,6 +214,7 @@ 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];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,6 +222,7 @@ 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 String();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ void JoystickImpl::close()
|
|||||||
JoystickCaps JoystickImpl::getCapabilities() const
|
JoystickCaps JoystickImpl::getCapabilities() const
|
||||||
{
|
{
|
||||||
// To implement
|
// To implement
|
||||||
return JoystickCaps();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ Joystick::Identification JoystickImpl::getIdentification() const
|
|||||||
JoystickState JoystickImpl::update()
|
JoystickState JoystickImpl::update()
|
||||||
{
|
{
|
||||||
// To implement
|
// To implement
|
||||||
return JoystickState();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // 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 Vector2i(0, 0);
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -682,7 +682,7 @@ Vector2i InputImpl::getTouchPosition(unsigned int finger)
|
|||||||
return slot.pos;
|
return slot.pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Vector2i();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ WindowHandle WindowImplDRM::getNativeHandle() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector2i WindowImplDRM::getPosition() const
|
Vector2i WindowImplDRM::getPosition() const
|
||||||
{
|
{
|
||||||
return Vector2i(0, 0);
|
return {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 XVisualInfo();
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 Vector2i(gx, gy);
|
return {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 Vector2i(x, y);
|
return {x, y};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return Vector2i();
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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 Vector2i();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -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 Vector2i();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // 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 std::string(name);
|
return 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 std::string(product);
|
return {product};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::err() << "Unable to get name for joystick " << devnode << std::endl;
|
sf::err() << "Unable to get name for joystick " << devnode << std::endl;
|
||||||
|
|
||||||
return std::string("Unknown Joystick");
|
return "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 String(unicode);
|
return {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 Vector3f(0, 0, 0);
|
return {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 WindowsImplX11Impl
|
namespace WindowImplX11Impl
|
||||||
{
|
{
|
||||||
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 WindowsImplX11Impl
|
} // namespace WindowImplX11Impl
|
||||||
} // 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 WindowsImplX11Impl;
|
using namespace WindowImplX11Impl;
|
||||||
|
|
||||||
// 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 WindowsImplX11Impl;
|
using namespace WindowImplX11Impl;
|
||||||
|
|
||||||
// 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 WindowsImplX11Impl;
|
using namespace WindowImplX11Impl;
|
||||||
|
|
||||||
// Cleanup graphical resources
|
// Cleanup graphical resources
|
||||||
cleanup();
|
cleanup();
|
||||||
@ -729,7 +729,7 @@ WindowHandle WindowImplX11::getNativeHandle() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::processEvents()
|
void WindowImplX11::processEvents()
|
||||||
{
|
{
|
||||||
using namespace WindowsImplX11Impl;
|
using namespace WindowImplX11Impl;
|
||||||
|
|
||||||
XEvent event;
|
XEvent event;
|
||||||
|
|
||||||
@ -800,7 +800,7 @@ void WindowImplX11::processEvents()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector2i WindowImplX11::getPosition() const
|
Vector2i WindowImplX11::getPosition() const
|
||||||
{
|
{
|
||||||
using namespace WindowsImplX11Impl;
|
using namespace WindowImplX11Impl;
|
||||||
|
|
||||||
// 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 Vector2i(xAbsRelToRoot, yAbsRelToRoot);
|
return {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 Vector2i((xAbsRelToRoot - static_cast<int>(xFrameExtent)), (yAbsRelToRoot - static_cast<int>(yFrameExtent)));
|
return {(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 Vector2i(xRelToRoot, yRelToRoot);
|
return {xRelToRoot, yRelToRoot};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -928,8 +928,7 @@ 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.
|
||||||
std::basic_string<std::uint8_t> utf8Title;
|
const std::basic_string<std::uint8_t> utf8Title = title.toUtf8();
|
||||||
Utf32::toUtf8(title.begin(), title.end(), std::back_inserter(utf8Title));
|
|
||||||
|
|
||||||
const Atom useUtf8 = getAtom("UTF8_STRING", false);
|
const Atom useUtf8 = getAtom("UTF8_STRING", false);
|
||||||
|
|
||||||
@ -1126,7 +1125,7 @@ void WindowImplX11::setMouseCursor(const CursorImpl& cursor)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::setMouseCursorGrabbed(bool grabbed)
|
void WindowImplX11::setMouseCursorGrabbed(bool grabbed)
|
||||||
{
|
{
|
||||||
using namespace WindowsImplX11Impl;
|
using namespace WindowImplX11Impl;
|
||||||
|
|
||||||
// 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))
|
||||||
@ -1171,7 +1170,7 @@ void WindowImplX11::setKeyRepeatEnabled(bool enabled)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::requestFocus()
|
void WindowImplX11::requestFocus()
|
||||||
{
|
{
|
||||||
using namespace WindowsImplX11Impl;
|
using namespace WindowImplX11Impl;
|
||||||
|
|
||||||
// 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
|
||||||
@ -1236,7 +1235,7 @@ bool WindowImplX11::hasFocus() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::grabFocus()
|
void WindowImplX11::grabFocus()
|
||||||
{
|
{
|
||||||
using namespace WindowsImplX11Impl;
|
using namespace WindowImplX11Impl;
|
||||||
|
|
||||||
Atom netActiveWindow = None;
|
Atom netActiveWindow = None;
|
||||||
|
|
||||||
@ -1285,7 +1284,7 @@ void WindowImplX11::grabFocus()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::setVideoMode(const VideoMode& mode)
|
void WindowImplX11::setVideoMode(const VideoMode& mode)
|
||||||
{
|
{
|
||||||
using namespace WindowsImplX11Impl;
|
using namespace WindowImplX11Impl;
|
||||||
|
|
||||||
// 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())
|
||||||
@ -1377,7 +1376,7 @@ void WindowImplX11::setVideoMode(const VideoMode& mode)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::resetVideoMode()
|
void WindowImplX11::resetVideoMode()
|
||||||
{
|
{
|
||||||
using namespace WindowsImplX11Impl;
|
using namespace WindowImplX11Impl;
|
||||||
|
|
||||||
if (fullscreenWindow == this)
|
if (fullscreenWindow == this)
|
||||||
{
|
{
|
||||||
@ -1439,7 +1438,7 @@ void WindowImplX11::resetVideoMode()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::switchToFullscreen()
|
void WindowImplX11::switchToFullscreen()
|
||||||
{
|
{
|
||||||
using namespace WindowsImplX11Impl;
|
using namespace WindowImplX11Impl;
|
||||||
|
|
||||||
grabFocus();
|
grabFocus();
|
||||||
|
|
||||||
@ -1495,7 +1494,7 @@ void WindowImplX11::switchToFullscreen()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::setProtocols()
|
void WindowImplX11::setProtocols()
|
||||||
{
|
{
|
||||||
using namespace WindowsImplX11Impl;
|
using namespace WindowImplX11Impl;
|
||||||
|
|
||||||
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");
|
||||||
@ -1563,7 +1562,7 @@ void WindowImplX11::setProtocols()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::initialize()
|
void WindowImplX11::initialize()
|
||||||
{
|
{
|
||||||
using namespace WindowsImplX11Impl;
|
using namespace WindowImplX11Impl;
|
||||||
|
|
||||||
// Create the input context
|
// Create the input context
|
||||||
m_inputMethod = openXim();
|
m_inputMethod = openXim();
|
||||||
@ -1679,7 +1678,7 @@ void WindowImplX11::cleanup()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool WindowImplX11::processEvent(XEvent& windowEvent)
|
bool WindowImplX11::processEvent(XEvent& windowEvent)
|
||||||
{
|
{
|
||||||
using namespace WindowsImplX11Impl;
|
using namespace WindowImplX11Impl;
|
||||||
|
|
||||||
// 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 Vector2i(point.x, point.y);
|
return {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 Vector2i(point.x, point.y);
|
return {point.x, point.y};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return Vector2i();
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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 Vector2i();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -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 Vector2i();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // 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 Vector3f(0, 0, 0);
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ String getErrorString(DWORD errorCode)
|
|||||||
|
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << "Error " << errorCode;
|
ss << "Error " << errorCode;
|
||||||
return String(ss.str());
|
return {ss.str()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ Vector2i WindowImplWin32::getPosition() const
|
|||||||
RECT rect;
|
RECT rect;
|
||||||
GetWindowRect(m_handle, &rect);
|
GetWindowRect(m_handle, &rect);
|
||||||
|
|
||||||
return Vector2i(rect.left, rect.top);
|
return {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(static_cast<unsigned int>(rect.right - rect.left), static_cast<unsigned int>(rect.bottom - rect.top));
|
return Vector2u(Vector2<LONG>(rect.right - rect.left, rect.bottom - rect.top));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ String ClipboardImpl::getString()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return String();
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ bool InputImpl::isMouseButtonPressed(Mouse::Button /* button */)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector2i InputImpl::getMousePosition()
|
Vector2i InputImpl::getMousePosition()
|
||||||
{
|
{
|
||||||
return Vector2i(0, 0);
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ void JoystickImpl::close()
|
|||||||
JoystickCaps JoystickImpl::getCapabilities() const
|
JoystickCaps JoystickImpl::getCapabilities() const
|
||||||
{
|
{
|
||||||
// Not implemented
|
// Not implemented
|
||||||
return JoystickCaps();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ JoystickCaps JoystickImpl::getCapabilities() const
|
|||||||
Joystick::Identification JoystickImpl::getIdentification() const
|
Joystick::Identification JoystickImpl::getIdentification() const
|
||||||
{
|
{
|
||||||
// Not implemented
|
// Not implemented
|
||||||
return Joystick::Identification();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ Joystick::Identification JoystickImpl::getIdentification() const
|
|||||||
JoystickState JoystickImpl::update()
|
JoystickState JoystickImpl::update()
|
||||||
{
|
{
|
||||||
// Not implemented
|
// Not implemented
|
||||||
return JoystickState();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // 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 Vector2i(static_cast<int>(origin.x * static_cast<double>(m_backingScale)),
|
return {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 Vector2u(static_cast<unsigned int>(physicalFrame.size.width * static_cast<double>(m_backingScale)),
|
return {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 String(static_cast<char32_t>(unicode));
|
return {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() << "We got a keyboard without any keys." << std::endl;
|
err() << "Detected 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 Vector2i();
|
return {};
|
||||||
|
|
||||||
// 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 Vector2i();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -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 Vector2i();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // 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 Vector3f(0, 0, 0);
|
return {0, 0, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@ 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 sf::Vector2f(m_size.x / 2, 0);
|
return {m_size.x / 2, 0};
|
||||||
case 1:
|
case 1:
|
||||||
return sf::Vector2f(0, m_size.y);
|
return {0, m_size.y};
|
||||||
case 2:
|
case 2:
|
||||||
return sf::Vector2f(m_size.x, m_size.y);
|
return {m_size.x, m_size.y};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,7 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
// Skip these tests with [.display] because they fail when using DRM which hasn't implemented sf::Cursor
|
TEST_CASE("[Window] sf::Cursor", runDisplayTests())
|
||||||
TEST_CASE("[Window] sf::Cursor", "[.display]")
|
|
||||||
{
|
{
|
||||||
SECTION("Type traits")
|
SECTION("Type traits")
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user