Hello! I'm currently working on a personal project in Visual Studio 2019. I've created some 'buttons' for a menu and I decided that I want to put them in a container, such as a vector. My issue is that whenever I use this vector to display the buttons, I get this warning: "The enum type 'sf::PrimitiveType' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).". It is not a big issue, but I'd like to get rid of this warning and know the meaning...
Also, I am working with classes... so I don't have everything in one file, I'll put here just the definitions of the main methods.
Interface::Interface()
{
// A constructor where I am creating the buttons and then append them to a vector of type Button
if (!font.loadFromFile("/AlgorithmSimulator/design/quicksandBold.otf"))
std::cerr << "There's no such file" << std::endl;
Button sortingAlgsB("Sorting Algorithms", sf::Color::Black, 15, sf::Color(224, 251, 252), { 200, 50 });
sortingAlgsB.SetFont(font);
sortingAlgsB.Positionate({ 100, 100 });
Button pathAlgsB("Pathfinding Algorithms", sf::Color::Black, 15, sf::Color(224, 251, 252), { 200, 50 });
pathAlgsB.SetFont(font);
pathAlgsB.Positionate({ 100, 50 });
buttons.push_back(sortingAlgsB);
buttons.push_back(pathAlgsB);
Init();
}
void Interface::Init()
{
// Here's the method with the main loop
sf::RenderWindow window(sf::VideoMode(1280, 800), "AlgorithmSimulator");
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
for (std::vector<Button>::iterator it = buttons.begin(); it != buttons.end(); it = std::next(it))
{
switch (event.type)
{
case sf::Event::Closed:
window.close();
case sf::Event::MouseMoved:
if ((*it).DetectMouse(window) == true)
{
(*it).SetTextColor(sf::Color(154, 3, 30));
}
else
{
(*it).SetTextColor(sf::Color::Black);
}
break;
case sf::Event::MouseButtonPressed:
if ((*it).DetectMouse(window) == true)
{
(*it).SetTextColor(sf::Color::White);
(*it).SetShapeColor(sf::Color(154, 3, 30));
}
break;
case sf::Event::MouseButtonReleased:
if ((*it).DetectMouse(window) == true || (*it).DetectMouse(window) == false)
{
(*it).SetTextColor(sf::Color::Black);
(*it).SetShapeColor(sf::Color(224, 251, 252));
}
break;
}
}
}
window.clear(sf::Color(224, 251, 252));
for (std::vector<Button>::iterator it = buttons.begin(); it != buttons.end(); it = std::next(it))
{
(*it).Draw(window);
}
//pathAlgsB.Draw(window);
window.display();
}
}