Converted applicable enumerations to strongly typed enumerations.

This commit is contained in:
binary1248 2017-04-04 01:13:07 +02:00
parent b3b094fc91
commit 24db1dba1a
74 changed files with 1242 additions and 1251 deletions

View file

@ -161,10 +161,10 @@ struct SFMLmainWindow
// Scaling
/* /!\ we do this at 60fps so choose low scaling factor! /!\ */
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Up))
self.mainWindow->sprite.scale(1.01f, 1.01f);
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Down))
self.mainWindow->sprite.scale(0.99f, 0.99f);
// Clear the window, display some stuff and display it into our view.

View file

@ -13,7 +13,7 @@
////////////////////////////////////////////////////////////
std::ostream& operator <<(std::ostream& stream, const sf::Ftp::Response& response)
{
return stream << response.getStatus() << response.getMessage();
return stream << static_cast<unsigned short>(response.getStatus()) << response.getMessage();
}

View file

@ -161,21 +161,21 @@ int main()
while (window.pollEvent(event))
{
// Close window: exit
if (event.type == sf::Event::Closed)
if (event.type == sf::Event::Type::Closed)
{
exit = true;
window.close();
}
// Escape key: exit
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
if ((event.type == sf::Event::Type::KeyPressed) && (event.key.code == sf::Keyboard::Key::Escape))
{
exit = true;
window.close();
}
// Return key: toggle mipmapping
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Return))
if ((event.type == sf::Event::Type::KeyPressed) && (event.key.code == sf::Keyboard::Key::Return))
{
if (mipmapEnabled)
{
@ -194,14 +194,14 @@ int main()
}
// Space key: toggle sRGB conversion
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Space))
if ((event.type == sf::Event::Type::KeyPressed) && (event.key.code == sf::Keyboard::Key::Space))
{
sRgb = !sRgb;
window.close();
}
// Adjust the viewport when the window is resized
if (event.type == sf::Event::Resized)
if (event.type == sf::Event::Type::Resized)
{
// Make the window the active window for OpenGL calls
window.setActive(true);

View file

@ -91,15 +91,15 @@ int main()
while (window.pollEvent(event))
{
// Window closed or escape key pressed: exit
if ((event.type == sf::Event::Closed) ||
((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)))
if ((event.type == sf::Event::Type::Closed) ||
((event.type == sf::Event::Type::KeyPressed) && (event.key.code == sf::Keyboard::Key::Escape)))
{
window.close();
break;
}
// Space key pressed: play
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Space))
if ((event.type == sf::Event::Type::KeyPressed) && (event.key.code == sf::Keyboard::Key::Space))
{
if (!isPlaying)
{
@ -128,12 +128,12 @@ int main()
float deltaTime = clock.restart().asSeconds();
// Move the player's paddle
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up) &&
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Up) &&
(leftPaddle.getPosition().y - paddleSize.y / 2 > 5.f))
{
leftPaddle.move(0.f, -paddleSpeed * deltaTime);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down) &&
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Down) &&
(leftPaddle.getPosition().y + paddleSize.y / 2 < gameHeight - 5.f))
{
leftPaddle.move(0.f, paddleSpeed * deltaTime);

View file

@ -30,7 +30,7 @@ public:
m_sprite.setTexture(m_texture);
// Load the shader
if (!m_shader.loadFromFile("resources/pixelate.frag", sf::Shader::Fragment))
if (!m_shader.loadFromFile("resources/pixelate.frag", sf::Shader::Type::Fragment))
return false;
m_shader.setUniform("texture", sf::Shader::CurrentTexture);
@ -135,7 +135,7 @@ public:
bool onLoad()
{
// Create the points
m_points.setPrimitiveType(sf::Points);
m_points.setPrimitiveType(sf::PrimitiveType::Points);
for (int i = 0; i < 40000; ++i)
{
float x = static_cast<float>(std::rand() % 800);
@ -214,7 +214,7 @@ public:
}
// Load the shader
if (!m_shader.loadFromFile("resources/edge.frag", sf::Shader::Fragment))
if (!m_shader.loadFromFile("resources/edge.frag", sf::Shader::Type::Fragment))
return false;
m_shader.setUniform("texture", sf::Shader::CurrentTexture);
@ -268,7 +268,7 @@ public:
Geometry() :
Effect("geometry shader billboards"),
m_pointCloud(sf::Points, 10000)
m_pointCloud(sf::PrimitiveType::Points, 10000)
{
}
@ -397,20 +397,20 @@ int main()
while (window.pollEvent(event))
{
// Close window: exit
if (event.type == sf::Event::Closed)
if (event.type == sf::Event::Type::Closed)
window.close();
if (event.type == sf::Event::KeyPressed)
if (event.type == sf::Event::Type::KeyPressed)
{
switch (event.key.code)
{
// Escape key: exit
case sf::Keyboard::Escape:
case sf::Keyboard::Key::Escape:
window.close();
break;
// Left arrow key: previous shader
case sf::Keyboard::Left:
case sf::Keyboard::Key::Left:
if (current == 0)
current = effects.size() - 1;
else
@ -419,7 +419,7 @@ int main()
break;
// Right arrow key: next shader
case sf::Keyboard::Right:
case sf::Keyboard::Key::Right:
if (current == effects.size() - 1)
current = 0;
else

View file

@ -17,26 +17,26 @@ void runTcpServer(unsigned short port)
sf::TcpListener listener;
// Listen to the given port for incoming connections
if (listener.listen(port) != sf::Socket::Done)
if (listener.listen(port) != sf::Socket::Status::Done)
return;
std::cout << "Server is listening to port " << port << ", waiting for connections... " << std::endl;
// Wait for a connection
sf::TcpSocket socket;
if (listener.accept(socket) != sf::Socket::Done)
if (listener.accept(socket) != sf::Socket::Status::Done)
return;
std::cout << "Client connected: " << socket.getRemoteAddress() << std::endl;
// Send a message to the connected client
const char out[] = "Hi, I'm the server";
if (socket.send(out, sizeof(out)) != sf::Socket::Done)
if (socket.send(out, sizeof(out)) != sf::Socket::Status::Done)
return;
std::cout << "Message sent to the client: \"" << out << "\"" << std::endl;
// Receive a message back from the client
char in[128];
std::size_t received;
if (socket.receive(in, sizeof(in), received) != sf::Socket::Done)
if (socket.receive(in, sizeof(in), received) != sf::Socket::Status::Done)
return;
std::cout << "Answer received from the client: \"" << in << "\"" << std::endl;
}
@ -62,20 +62,20 @@ void runTcpClient(unsigned short port)
sf::TcpSocket socket;
// Connect to the server
if (socket.connect(server, port) != sf::Socket::Done)
if (socket.connect(server, port) != sf::Socket::Status::Done)
return;
std::cout << "Connected to server " << server << std::endl;
// Receive a message from the server
char in[128];
std::size_t received;
if (socket.receive(in, sizeof(in), received) != sf::Socket::Done)
if (socket.receive(in, sizeof(in), received) != sf::Socket::Status::Done)
return;
std::cout << "Message received from the server: \"" << in << "\"" << std::endl;
// Send an answer to the server
const char out[] = "Hi, I'm a client";
if (socket.send(out, sizeof(out)) != sf::Socket::Done)
if (socket.send(out, sizeof(out)) != sf::Socket::Status::Done)
return;
std::cout << "Message sent to the server: \"" << out << "\"" << std::endl;
}

View file

@ -16,7 +16,7 @@ void runUdpServer(unsigned short port)
sf::UdpSocket socket;
// Listen to messages on the specified port
if (socket.bind(port) != sf::Socket::Done)
if (socket.bind(port) != sf::Socket::Status::Done)
return;
std::cout << "Server is listening to port " << port << ", waiting for a message... " << std::endl;
@ -25,13 +25,13 @@ void runUdpServer(unsigned short port)
std::size_t received;
sf::IpAddress sender;
unsigned short senderPort;
if (socket.receive(in, sizeof(in), received, sender, senderPort) != sf::Socket::Done)
if (socket.receive(in, sizeof(in), received, sender, senderPort) != sf::Socket::Status::Done)
return;
std::cout << "Message received from client " << sender << ": \"" << in << "\"" << std::endl;
// Send an answer to the client
const char out[] = "Hi, I'm the server";
if (socket.send(out, sizeof(out), sender, senderPort) != sf::Socket::Done)
if (socket.send(out, sizeof(out), sender, senderPort) != sf::Socket::Status::Done)
return;
std::cout << "Message sent to the client: \"" << out << "\"" << std::endl;
}
@ -57,7 +57,7 @@ void runUdpClient(unsigned short port)
// Send a message to the server
const char out[] = "Hi, I'm a client";
if (socket.send(out, sizeof(out), server, port) != sf::Socket::Done)
if (socket.send(out, sizeof(out), server, port) != sf::Socket::Status::Done)
return;
std::cout << "Message sent to the server: \"" << out << "\"" << std::endl;
@ -66,7 +66,7 @@ void runUdpClient(unsigned short port)
std::size_t received;
sf::IpAddress sender;
unsigned short senderPort;
if (socket.receive(in, sizeof(in), received, sender, senderPort) != sf::Socket::Done)
if (socket.receive(in, sizeof(in), received, sender, senderPort) != sf::Socket::Status::Done)
return;
std::cout << "Message received from " << sender << ": \"" << in << "\"" << std::endl;
}

View file

@ -29,7 +29,7 @@ void playSound()
sound.play();
// Loop while the sound is playing
while (sound.getStatus() == sf::Sound::Playing)
while (sound.getStatus() == sf::Sound::Status::Playing)
{
// Leave some CPU time for other processes
sf::sleep(sf::milliseconds(100));
@ -63,7 +63,7 @@ void playMusic(const std::string& filename)
music.play();
// Loop while the music is playing
while (music.getStatus() == sf::Music::Playing)
while (music.getStatus() == sf::Music::Status::Playing)
{
// Leave some CPU time for other processes
sf::sleep(sf::milliseconds(100));

View file

@ -72,7 +72,7 @@ int main()
sound.play();
// Wait until finished
while (sound.getStatus() == sf::Sound::Playing)
while (sound.getStatus() == sf::Sound::Status::Playing)
{
// Display the playing position
std::cout << "\rPlaying... " << sound.getPlayingOffset().asSeconds() << " sec ";

View file

@ -52,7 +52,7 @@ private:
////////////////////////////////////////////////////////////
virtual bool onStart()
{
if (m_socket.connect(m_host, m_port) == sf::Socket::Done)
if (m_socket.connect(m_host, m_port) == sf::Socket::Status::Done)
{
std::cout << "Connected to server " << m_host << std::endl;
return true;
@ -75,7 +75,7 @@ private:
packet.append(samples, sampleCount * sizeof(sf::Int16));
// Send the audio packet to the server
return m_socket.send(packet) == sf::Socket::Done;
return m_socket.send(packet) == sf::Socket::Status::Done;
}
////////////////////////////////////////////////////////////

View file

@ -43,12 +43,12 @@ public:
if (!m_hasFinished)
{
// Listen to the given port for incoming connections
if (m_listener.listen(port) != sf::Socket::Done)
if (m_listener.listen(port) != sf::Socket::Status::Done)
return;
std::cout << "Server is listening to port " << port << ", waiting for connections... " << std::endl;
// Wait for a connection
if (m_listener.accept(m_client) != sf::Socket::Done)
if (m_listener.accept(m_client) != sf::Socket::Status::Done)
return;
std::cout << "Client connected: " << m_client.getRemoteAddress() << std::endl;
@ -117,7 +117,7 @@ private:
{
// Get waiting audio data from the network
sf::Packet packet;
if (m_client.receive(packet) != sf::Socket::Done)
if (m_client.receive(packet) != sf::Socket::Status::Done)
break;
// Extract the message ID
@ -177,7 +177,7 @@ void doServer(unsigned short port)
audioStream.start(port);
// Loop until the sound playback is finished
while (audioStream.getStatus() != sf::SoundStream::Stopped)
while (audioStream.getStatus() != sf::SoundStream::Status::Stopped)
{
// Leave some CPU time for other threads
sf::sleep(sf::milliseconds(100));
@ -193,7 +193,7 @@ void doServer(unsigned short port)
audioStream.play();
// Loop until the sound playback is finished
while (audioStream.getStatus() != sf::SoundStream::Stopped)
while (audioStream.getStatus() != sf::SoundStream::Status::Stopped)
{
// Leave some CPU time for other threads
sf::sleep(sf::milliseconds(100));

View file

@ -112,15 +112,15 @@ int main()
while (window.pollEvent(event))
{
// Close window: exit
if (event.type == sf::Event::Closed)
if (event.type == sf::Event::Type::Closed)
window.close();
// Escape key: exit
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
if ((event.type == sf::Event::Type::KeyPressed) && (event.key.code == sf::Keyboard::Key::Escape))
window.close();
// Resize event: adjust the viewport
if (event.type == sf::Event::Resized)
if (event.type == sf::Event::Type::Resized)
glViewport(0, 0, event.size.width, event.size.height);
}