void StateManager::update(const sf::Time& time) {
if (statesContainer.empty()) { return; }
if (statesContainer.back().second->isTranscendent() && statesContainer.size() > 1) {
bool reversing = true;
for (auto statesItr = statesContainer.end() - 1; statesItr != statesContainer.end(); (reversing ? --statesItr : ++statesItr)) {
if (!statesItr->second->isTranscendent() || statesItr == statesContainer.begin()) {
reversing = false;
if (!statesItr->second->isTranscendent()) { continue; }
}
if (!reversing) {
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) {
bool reversing = true;
for (auto statesItr = statesContainer.end() - 1; statesItr != statesContainer.end(); (reversing ? --statesItr : ++statesItr)) {
if (!statesItr->second->isTransparent() || statesItr == statesContainer.begin()) {
reversing = false;
if (!statesItr->second->isTransparent()) { continue; }
}
if (!reversing) {
locator->window->getRenderWindow()->setView(statesItr->second->getView());
statesItr->second->draw();
} }
}
else {
locator->window->getRenderWindow()->setView(statesContainer.back().second->getView());
statesContainer.back().second->draw();
}
}
Yes OrderNexus, you are right. The previous approach wasn't doing any work inside the first loop. Sorry for the delay to reply. I wasn't able to dive into the engine code for a couple days, too busy. Anyway, after returning to it, I took my time to understand what needed to be accomplished there and I believe I got it right this time. Actually it uses only one for loop now.