Hi, OrderNexus. I bought the Mastering SFML book. Big fan of your work. I want to dive deeper into openGL. Looks promising. Btw, I just thought you might like this small change on the codebase (that is, if you didn't do this yet in this specific part of the code). Anyways, on the StateManager.cpp file, consider using reverse_iterators, they are good for what you wanted to accomplish in the update and draw methods, but with less hastle.
Here is what I did. It has less lines of code and does the exact same thing and also uses the STL facilities "rbegin" and "rend". Thanks!!
void StateManager::update(const sf::Time& time) {
if (statesContainer.empty()) { return; }
if (statesContainer.back().second->isTranscendent() && statesContainer.size() > 1) {
for (auto statesItr = statesContainer.rbegin(); statesItr != statesContainer.rend(); ++statesItr) {
if (!statesItr->second->isTranscendent()) { break; }
}
for (auto statesItr = statesContainer.begin(); statesItr != statesContainer.end(); ++statesItr) {
statesItr->second->update(time);
}
}
else { statesContainer.back().second->update(time); }
}
void StateManager::draw() {
if (statesContainer.empty()) { return; }
if (statesContainer.back().second->isTransparent() && statesContainer.size() > 1) {
for (auto statesItr = statesContainer.rbegin(); statesItr != statesContainer.rend(); ++statesItr) {
if (!statesItr->second->isTransparent()) { break; }
}
for (auto statesItr = statesContainer.begin(); statesItr != statesContainer.end(); ++statesItr) {
locator->window->getRenderWindow()->setView(statesItr->second->getView());
statesItr->second->draw();
}
}
else {
locator->window->getRenderWindow()->setView(statesContainer.back().second->getView());
statesContainer.back().second->getView();
}
}